···2323#include <asm/sections.h>2424#include <asm/tlb.h>25252626+#ifndef CONFIG_MMU2627unsigned int __page_offset;2728EXPORT_SYMBOL(__page_offset);2929+3030+#else3131+DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);3232+3333+int mem_init_done;3434+static int init_bootmem_done;3535+#endif /* CONFIG_MMU */28362937char *klimit = _end;3038···4032 * Initialize the bootmem system and give it all the memory we4133 * have available.4234 */4343-unsigned int memory_start;4444-unsigned int memory_end; /* due to mm/nommu.c */4545-unsigned int memory_size;3535+unsigned long memory_start;3636+unsigned long memory_end; /* due to mm/nommu.c */3737+unsigned long memory_size;46384739/*4840 * paging_init() sets up the page tables - in fact we've already done this.···6759{6860 int i;6961 unsigned long map_size;6262+#ifndef CONFIG_MMU7063 u32 kernel_align_start, kernel_align_size;71647265 /* Find main memory where is the kernel */···10091 __func__, kernel_align_start, kernel_align_start10192 + kernel_align_size, kernel_align_size);102939494+#endif10395 /*10496 * Kernel:10597 * start: base phys address of kernel - page align···129119 * for 4GB of memory, using 4kB pages), plus 1 page130120 * (in case the address isn't page-aligned).131121 */122122+#ifndef CONFIG_MMU132123 map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)_end)),133124 min_low_pfn, max_low_pfn);134134-125125+#else126126+ map_size = init_bootmem_node(&contig_page_data,127127+ PFN_UP(TOPHYS((u32)_end)), min_low_pfn, max_low_pfn);128128+#endif135129 lmb_reserve(PFN_UP(TOPHYS((u32)_end)) << PAGE_SHIFT, map_size);136130137131 /* free bootmem is whole main memory */···149135 reserve_bootmem(lmb.reserved.region[i].base,150136 lmb_size_bytes(&lmb.reserved, i) - 1, BOOTMEM_DEFAULT);151137 }138138+#ifdef CONFIG_MMU139139+ init_bootmem_done = 1;140140+#endif152141 paging_init();153142}154143···206189 printk(KERN_INFO "Memory: %luk/%luk available\n",207190 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),208191 num_physpages << (PAGE_SHIFT-10));192192+#ifdef CONFIG_MMU193193+ mem_init_done = 1;194194+#endif209195}210196197197+#ifndef CONFIG_MMU211198/* Check against bounds of physical memory */212199int ___range_ok(unsigned long addr, unsigned long size)213200{···219198 ((addr + size) > memory_end));220199}221200EXPORT_SYMBOL(___range_ok);201201+202202+#else203203+int page_is_ram(unsigned long pfn)204204+{205205+ return pfn < max_low_pfn;206206+}207207+208208+/*209209+ * Check for command-line options that affect what MMU_init will do.210210+ */211211+static void mm_cmdline_setup(void)212212+{213213+ unsigned long maxmem = 0;214214+ char *p = cmd_line;215215+216216+ /* Look for mem= option on command line */217217+ p = strstr(cmd_line, "mem=");218218+ if (p) {219219+ p += 4;220220+ maxmem = memparse(p, &p);221221+ if (maxmem && memory_size > maxmem) {222222+ memory_size = maxmem;223223+ memory_end = memory_start + memory_size;224224+ lmb.memory.region[0].size = memory_size;225225+ }226226+ }227227+}228228+229229+/*230230+ * MMU_init_hw does the chip-specific initialization of the MMU hardware.231231+ */232232+static void __init mmu_init_hw(void)233233+{234234+ /*235235+ * The Zone Protection Register (ZPR) defines how protection will236236+ * be applied to every page which is a member of a given zone. At237237+ * present, we utilize only two of the zones.238238+ * The zone index bits (of ZSEL) in the PTE are used for software239239+ * indicators, except the LSB. For user access, zone 1 is used,240240+ * for kernel access, zone 0 is used. We set all but zone 1241241+ * to zero, allowing only kernel access as indicated in the PTE.242242+ * For zone 1, we set a 01 binary (a value of 10 will not work)243243+ * to allow user access as indicated in the PTE. This also allows244244+ * kernel access as indicated in the PTE.245245+ */246246+ __asm__ __volatile__ ("ori r11, r0, 0x10000000;" \247247+ "mts rzpr, r11;"248248+ : : : "r11");249249+}250250+251251+/*252252+ * MMU_init sets up the basic memory mappings for the kernel,253253+ * including both RAM and possibly some I/O regions,254254+ * and sets up the page tables and the MMU hardware ready to go.255255+ */256256+257257+/* called from head.S */258258+asmlinkage void __init mmu_init(void)259259+{260260+ unsigned int kstart, ksize;261261+262262+ if (!lmb.reserved.cnt) {263263+ printk(KERN_EMERG "Error memory count\n");264264+ machine_restart(NULL);265265+ }266266+267267+ if ((u32) lmb.memory.region[0].size < 0x1000000) {268268+ printk(KERN_EMERG "Memory must be greater than 16MB\n");269269+ machine_restart(NULL);270270+ }271271+ /* Find main memory where the kernel is */272272+ memory_start = (u32) lmb.memory.region[0].base;273273+ memory_end = (u32) lmb.memory.region[0].base +274274+ (u32) lmb.memory.region[0].size;275275+ memory_size = memory_end - memory_start;276276+277277+ mm_cmdline_setup(); /* FIXME parse args from command line - not used */278278+279279+ /*280280+ * Map out the kernel text/data/bss from the available physical281281+ * memory.282282+ */283283+ kstart = __pa(CONFIG_KERNEL_START); /* kernel start */284284+ /* kernel size */285285+ ksize = PAGE_ALIGN(((u32)_end - (u32)CONFIG_KERNEL_START));286286+ lmb_reserve(kstart, ksize);287287+288288+#if defined(CONFIG_BLK_DEV_INITRD)289289+ /* Remove the init RAM disk from the available memory. */290290+/* if (initrd_start) {291291+ mem_pieces_remove(&phys_avail, __pa(initrd_start),292292+ initrd_end - initrd_start, 1);293293+ }*/294294+#endif /* CONFIG_BLK_DEV_INITRD */295295+296296+ /* Initialize the MMU hardware */297297+ mmu_init_hw();298298+299299+ /* Map in all of RAM starting at CONFIG_KERNEL_START */300300+ mapin_ram();301301+302302+#ifdef HIGHMEM_START_BOOL303303+ ioremap_base = HIGHMEM_START;304304+#else305305+ ioremap_base = 0xfe000000UL; /* for now, could be 0xfffff000 */306306+#endif /* CONFIG_HIGHMEM */307307+ ioremap_bot = ioremap_base;308308+309309+ /* Initialize the context management stuff */310310+ mmu_context_init();311311+}312312+313313+/* This is only called until mem_init is done. */314314+void __init *early_get_page(void)315315+{316316+ void *p;317317+ if (init_bootmem_done) {318318+ p = alloc_bootmem_pages(PAGE_SIZE);319319+ } else {320320+ /*321321+ * Mem start + 32MB -> here is limit322322+ * because of mem mapping from head.S323323+ */324324+ p = __va(lmb_alloc_base(PAGE_SIZE, PAGE_SIZE,325325+ memory_start + 0x2000000));326326+ }327327+ return p;328328+}329329+#endif /* CONFIG_MMU */