patch-2.2.8 linux/include/asm-arm/proc-armv/mm-init.h

Next file: linux/include/asm-arm/proc-armv/pgtable.h
Previous file: linux/include/asm-arm/proc-armv/io.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.7/linux/include/asm-arm/proc-armv/mm-init.h linux/include/asm-arm/proc-armv/mm-init.h
@@ -37,7 +37,7 @@
  */
 #include <asm/pgtable.h>
  
-#define PTE_SIZE (PTRS_PER_PTE * 4)
+#define PTE_SIZE (PTRS_PER_PTE * BYTES_PER_PTR)
 
 extern unsigned long setup_io_pagetables(unsigned long start_mem);
 
@@ -79,7 +79,7 @@
 alloc_init_page(unsigned long *mem, unsigned long virt, unsigned long phys, int domain, int prot)
 {
 	pgd_t *pgdp;
-	pmd_t *pmdp, pmd;
+	pmd_t *pmdp;
 	pte_t *ptep;
 
 	pgdp = pgd_offset_k(virt);
@@ -92,46 +92,41 @@
 
 		ptep = (pte_t *)memory;
 		memzero(ptep, PTE_SIZE);
+		memory += PTE_SIZE;
 
-		pmd_val(pmd) = __virt_to_phys(memory) | PMD_TYPE_TABLE | PMD_DOMAIN(domain);
-		set_pmd(pmdp, pmd);
+		ptep = (pte_t *)memory;
+		memzero(ptep, PTE_SIZE);
+
+		set_pmd(pmdp, __mk_pmd(ptep, PMD_TYPE_TABLE | PMD_DOMAIN(domain)));
 
 		*mem = memory + PTE_SIZE;
 	}
 
 	ptep = pte_offset(pmdp, virt);
 
-	pte_val(*ptep) = phys | prot | PTE_TYPE_SMALL;
+	set_pte(ptep, mk_pte_phys(phys, __pgprot(prot)));
 }
 
 static inline unsigned long
 setup_pagetables(unsigned long start_mem, unsigned long end_mem)
 {
-	unsigned long address;
+	unsigned long address = 0;
 
-	/*
-	 * map in zero page
-	 */
-	alloc_init_page(&start_mem, 0, __virt_to_phys(PAGE_OFFSET), DOMAIN_USER, PTE_CACHEABLE);
-
-	/*
-	 * ensure no mappings in user space
-	 */
-	for (address = PGDIR_SIZE; address < PAGE_OFFSET; address += PGDIR_SIZE)
-		free_init_section(address);
-
-	/*
-	 * map in physical ram & kernel
-	 */
-	for (address = PAGE_OFFSET; address < end_mem; address += PGDIR_SIZE)
-		alloc_init_section(&start_mem, address, __virt_to_phys(address), DOMAIN_KERNEL,
-				   PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE | PMD_SECT_AP_WRITE);
+	do {
+		if (address >= PAGE_OFFSET && address < end_mem)
+			/*
+			 * map in physical ram & kernel
+			 */
+			alloc_init_section(&start_mem, address, __virt_to_phys(address), DOMAIN_KERNEL,
+					   PMD_SECT_CACHEABLE | PMD_SECT_BUFFERABLE | PMD_SECT_AP_WRITE);
+		else
+			/*
+			 * unmap everything else
+			 */
+			free_init_section(address);
 
-	/*
-	 * unmap everything else
-	 */
-	for (address = end_mem; address; address += PGDIR_SIZE)
-		free_init_section(address);
+		address += PGDIR_SIZE;
+	} while (address != 0);
 
 	/*
 	 * An area to invalidate the cache
@@ -144,6 +139,12 @@
 	 */
 	start_mem = setup_io_pagetables(start_mem);
 
+	/*
+	 * map in zero page
+	 */
+	alloc_init_page(&start_mem, 0, __virt_to_phys(PAGE_OFFSET),
+			DOMAIN_USER, L_PTE_CACHEABLE | L_PTE_YOUNG | L_PTE_PRESENT);
+
 	flush_cache_all();
 
 	return start_mem;
@@ -156,9 +157,21 @@
 
 	*start_mem = smem = PAGE_ALIGN(*start_mem);
 
+	/*
+	 * Mark all of memory from the end of kernel to end of memory
+	 */
 	while (smem < end_mem) {
-	    	clear_bit(PG_reserved, &mem_map[MAP_NR(smem)].flags);
-    		smem += PAGE_SIZE;
+		clear_bit(PG_reserved, &mem_map[MAP_NR(smem)].flags);
+		smem += PAGE_SIZE;
+	}
+
+	/*
+	 * Mark memory from page 1 to start of the swapper page directory
+	 */
+	smem = PAGE_OFFSET + PAGE_SIZE;
+	while (smem < (unsigned long)&swapper_pg_dir) {
+		clear_bit(PG_reserved, &mem_map[MAP_NR(smem)].flags);
+		smem += PAGE_SIZE;
 	}
 }	
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)