From: Michal Simek [EMAIL PROTECTED]
Signed-off-by: Michal Simek [EMAIL PROTECTED]
---
arch/microblaze/mm/init.c| 184 ++
include/asm-microblaze/mmu.h | 17 +++
include/asm-microblaze/mmu_context.h | 22
include/asm-microblaze/tlb.h | 16 +++
include/asm-microblaze/tlbflush.h| 20
5 files changed, 259 insertions(+), 0 deletions(-)
create mode 100644 arch/microblaze/mm/init.c
create mode 100644 include/asm-microblaze/mmu.h
create mode 100644 include/asm-microblaze/mmu_context.h
create mode 100644 include/asm-microblaze/tlb.h
create mode 100644 include/asm-microblaze/tlbflush.h
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
new file mode 100644
index 000..5bb3e01
--- /dev/null
+++ b/arch/microblaze/mm/init.c
@@ -0,0 +1,184 @@
+/*
+ * arch/microblaze/mm/init.c
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007-2008 Michal Simek [EMAIL PROTECTED]
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ */
+
+#undef DEBUG
+
+#include linux/autoconf.h
+#include linux/init.h
+#include linux/mm.h
+#include ../../../mm/internal.h
+#include linux/swap.h
+#include linux/bootmem.h
+#include linux/pfn.h
+#include linux/lmb.h
+
+#include asm/sections.h
+#include asm/uaccess.h
+#include asm/system.h
+#include asm/pgtable.h
+
+char *klimit = _end;
+static unsigned int memory_start;
+unsigned int memory_end; /* due to mm/nommu.c */
+
+unsigned int __page_offset;
+/* EXPORT_SYMBOL(__page_offset); */
+
+void __init setup_memory(void)
+{
+ int i;
+ unsigned int start, end;
+ unsigned long map_size;
+ unsigned long start_pfn = 0;
+ unsigned long end_pfn = 0;
+
+ /* Find main memory where is the kernel */
+ for (i = 0; i lmb.memory.cnt; i++) {
+ start_pfn = lmb.memory.region[i].base PAGE_SHIFT;
+ end_pfn = start_pfn + lmb_size_pages(lmb.memory, i);
+ if ((start_pfn = (((int)_text) PAGE_SHIFT))
+ (((int)_text PAGE_SHIFT) = end_pfn)) {
+ memory_end = (end_pfn PAGE_SHIFT) - 1;
+ PAGE_OFFSET = memory_start = start_pfn PAGE_SHIFT;
+ pr_debug(%s: Main mem: 0x%x-0x%x\n, __func__,
+ memory_start, memory_end);
+ break;
+ }
+ }
+ /*
+* start_pfn - start page - starting point
+* end_pfn - first unused page
+* memory_start - base physical address of main memory
+* memory_end - end physical address of main memory
+* PAGE_OFFSET - moving of first page
+*
+* Kernel:
+* start: base phys address of kernel - page align
+* end: base phys address of kernel - page align
+*
+* min_low_pfn - the first page (mm/bootmem.c - node_boot_start)
+* max_low_pfn
+* max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn)
+* num_physpages - number of all pages
+*
+*/
+
+ /* reservation of region where is the kernel */
+ start = PFN_DOWN((int)_text) PAGE_SHIFT;
+ end = PAGE_ALIGN((unsigned long)klimit);
+ lmb_reserve(start, end - start);
+ pr_debug(%s: kernel addr 0x%08x-0x%08x\n, __func__, start, end);
+
+ /* calculate free pages, etc. */
+ min_low_pfn = PFN_UP(start_pfn PAGE_SHIFT);
+ max_mapnr = PFN_DOWN((end_pfn PAGE_SHIFT));
+ max_low_pfn = max_mapnr - min_low_pfn;
+ num_physpages = max_mapnr - min_low_pfn + 1;
+ printk(KERN_INFO %s: max_mapnr: %#lx\n, __func__, max_mapnr);
+ printk(KERN_INFO %s: min_low_pfn: %#lx\n, __func__, min_low_pfn);
+ printk(KERN_INFO %s: max_low_pfn: %#lx\n, __func__, max_low_pfn);
+
+ /* add place for data pages */
+ map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(end),
+ min_low_pfn, max_mapnr);
+ lmb_reserve(PFN_UP(end) PAGE_SHIFT, map_size);
+
+ /* free bootmem is whole main memory */
+ free_bootmem_node(NODE_DATA(0), start_pfn PAGE_SHIFT,
+ ((end_pfn - start_pfn) PAGE_SHIFT) - 1);
+
+ /* reserve allocate blocks */
+ for (i = 0; i lmb.reserved.cnt; i++) {
+ pr_debug(reserved %d - 0x%08x-0x%08x\n, i,
+ (u32) lmb.reserved.region[i].base,
+ (u32) lmb_size_bytes(lmb.reserved, i));
+ reserve_bootmem(lmb.reserved.region[i].base,
+ lmb_size_bytes(lmb.reserved, i) - 1, BOOTMEM_DEFAULT);
+ }
+}
+
+void __init paging_init(void)
+{
+ int i;
+ unsigned long zones_size[MAX_NR_ZONES];
+
+ /* we can DMA to/from any address. put all page into
+* ZONE_DMA. */
+ zones_size[ZONE_NORMAL] = max_low_pfn;
+
+