login
Header Space

 
 

[PATCH 28/56] microblaze_v2: memory inicialization, MMU, TLB

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: <arnd@...>, <linux-arch@...>, <stephen.neuendorffer@...>, <John.Linn@...>, <john.williams@...>, <matthew@...>, <will.newton@...>, <drepper@...>, <microblaze-uclinux@...>, <grant.likely@...>, Michal Simek <monstr@...>
Date: Sunday, May 4, 2008 - 7:41 am

From: Michal Simek <monstr@monstr.eu>


Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/mm/init.c            |  184 ++++++++++++++++++++++++++++++++++
 include/asm-microblaze/mmu.h         |   19 ++++
 include/asm-microblaze/mmu_context.h |   24 +++++
 include/asm-microblaze/tlb.h         |   18 ++++
 include/asm-microblaze/tlbflush.h    |   22 ++++
 5 files changed, 267 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 0000000..d3c042a
--- /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 Michal Simek <monstr@monstr.eu>
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ */
+
+#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 <asm/sections.h>
+
+#include <asm/lmb.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/pgtable.h>
+
+#undef DEBUG
+
+char *klimit = _end;
+static unsigned int memory_start;
+static unsigned int memory_end;
+
+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(start_pfn << PAGE_SHIFT,
+			((end_pfn - start_pfn) << PAGE_SHIFT) - 1);
+
+	/* reserve allocate blocks */
+	for (i = 1; 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;
+
+	/* every other zones are empty */
+	for (i = 1; i < MAX_NR_ZONES; i++)
+		zones_size[i] = 0;
+
+	free_area_init_node(0, NODE_DATA(0), zones_size,
+		NODE_DATA(0)->bdata->node_boot_start >> PAGE_SHIFT, NULL);
+}
+
+void free_init_pages(char *what, unsigned long begin, unsigned long end)
+{
+	unsigned long addr;
+
+	for (addr = begin; addr < end; addr += PAGE_SIZE) {
+		ClearPageReserved(virt_to_page(addr));
+		init_page_count(virt_to_page(addr));
+		memset((void *)addr, 0xcc, PAGE_SIZE);
+		free_page(addr);
+		totalram_pages++;
+	}
+	printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
+}
+
+#ifdef CONFIG_BLK_DEV_INITRD
+void free_initrd_mem(unsigned long start, unsigned long end)
+{
+	int pages = 0;
+	for (; start < end; start += PAGE_SIZE) {
+		ClearPageReserved(virt_to_page(start));
+		set_page_count(virt_to_page(start), 1);
+		free_page(start);
+		totalram_pages++;
+		pages++;
+	}
+	printk(KERN_NOTICE "Freeing initrd memory: %dk freed\n", pages);
+}
+#endif
+
+void free_initmem(void)
+{
+	free_init_pages("unused kernel memory",
+			(unsigned long)(&__init_begin),
+			(unsigned long)(&__init_end));
+}
+
+/* FIXME from arch/powerpc/mm/mem.c*/
+void show_mem(void)
+{
+	printk(KERN_NOTICE "%s\n", __func__);
+}
+
+void __init mem_init(void)
+{
+	high_memory = (void *)(memory_end);
+
+	/* this will put all memory onto the freelists */
+	totalram_pages += free_all_bootmem();
+
+	printk(KERN_INFO "Memory: %luk/%luk available\n",
+	       (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
+	       num_physpages << (PAGE_SHIFT-10));
+}
+
+/* Check against bounds of physical memory */
+int ___range_ok(unsigned long addr, unsigned long size)
+{
+	return ((addr < memory_start) ||
+		((addr + size) >= memory_end));
+}
diff --git a/include/asm-microblaze/mmu.h b/include/asm-microblaze/mmu.h
new file mode 100644
index 0000000..f1e158f
--- /dev/null
+++ b/include/asm-microblaze/mmu.h
@@ -0,0 +1,19 @@
+/*
+ * include/asm-microblaze/mmu.h
+ *
+ * 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) 2006 Atmark Techno, Inc.
+ */
+
+#ifndef _ASM_MICROBLAZE_MMU_H
+#define _ASM_MICROBLAZE_MMU_H
+
+typedef struct {
+	struct vm_list_struct	*vmlist;
+	unsigned long		end_brk;
+} mm_context_t;
+
+#endif /* _ASM_MICROBLAZE_MMU_H */
diff --git a/include/asm-microblaze/mmu_context.h b/include/asm-microblaze/mmu_context.h
new file mode 100644
index 0000000..f5433c7
--- /dev/null
+++ b/include/asm-microblaze/mmu_context.h
@@ -0,0 +1,24 @@
+/*
+ * include/asm-microblaze/mmu_context.h
+ *
+ * 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) 2006 Atmark Techno, Inc.
+ */
+
+#ifndef _ASM_MICROBLAZE_MMU_CONTEXT_H
+#define _ASM_MICROBLAZE_MMU_CONTEXT_H
+
+#define init_new_context(tsk, mm)		({ 0; })
+
+#define enter_lazy_tlb(mm, tsk)			do {} while (0)
+#define change_mm_context(old, ctx, _pml4)	do {} while (0)
+#define destroy_context(mm)			do {} while (0)
+#define deactivate_mm(tsk, mm)			do {} while (0)
+#define switch_mm(prev, next, tsk)		do {} while (0)
+#define activate_mm(prev, next)			do {} while (0)
+
+
+#endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */
diff --git a/include/asm-microblaze/tlb.h b/include/asm-microblaze/tlb.h
new file mode 100644
index 0000000..60c4df6
--- /dev/null
+++ b/include/asm-microblaze/tlb.h
@@ -0,0 +1,18 @@
+/*
+ * include/asm-microblaze/tlb.h
+ *
+ * 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) 2006 Atmark Techno, Inc.
+ */
+
+#ifndef _ASM_MICROBLAZE_TLB_H
+#define _ASM_MICROBLAZE_TLB_H
+
+#define tlb_flush(tlb)	do {} while (0)
+
+#include <asm-generic/tlb.h>
+
+#endif /* _ASM_MICROBLAZE_TLB_H */
diff --git a/include/asm-microblaze/tlbflush.h b/include/asm-microblaze/tlbflush.h
new file mode 100644
index 0000000..e1b4f6b
--- /dev/null
+++ b/include/asm-microblaze/tlbflush.h
@@ -0,0 +1,22 @@
+/*
+ * include/asm-microblaze/tlbflush.h
+ *
+ * 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) 2006 Atmark Techno, Inc.
+ */
+
+#ifndef _ASM_MICROBLAZE_TLBFLUSH_H
+#define _ASM_MICROBLAZE_TLBFLUSH_H
+
+#define flush_tlb()				BUG()
+#define flush_tlb_all()				BUG()
+#define flush_tlb_mm(mm)			BUG()
+#define flush_tlb_page(vma, addr)		BUG()
+#define flush_tlb_range(mm, start, end)		BUG()
+#define flush_tlb_pgtables(mm, start, end)	BUG()
+#define flush_tlb_kernel_range(start, end)	BUG()
+
+#endif /* _ASM_MICROBLAZE_TLBFLUSH_H */
-- 
1.5.4.GIT

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Microblaze patches V2, , (Sun May 4, 7:40 am)
Re: [PATCH 01/56] microblaze_v2: Kconfig patches, Grant Likely, (Sun May 4, 5:24 pm)
Re: [PATCH 01/56] microblaze_v2: Kconfig patches, Michal Simek, (Mon May 5, 2:36 am)
RE: [microblaze-uclinux] [PATCH 04/56] microblaze_v2: Open f..., Stephen Neuendorffer, (Wed May 7, 12:04 pm)
RE: [microblaze-uclinux] [PATCH 04/56] microblaze_v2: Open f..., Stephen Neuendorffer, (Wed May 7, 4:14 pm)
RE: [PATCH 04/56] microblaze_v2: Open firmware files, Stephen Neuendorffer, (Mon May 5, 5:56 pm)
Re: [PATCH 04/56] microblaze_v2: Open firmware files, Michal Simek, (Tue May 6, 3:27 am)
Re: [PATCH 04/56] microblaze_v2: Open firmware files, Grant Likely, (Mon May 5, 10:24 am)
RE: [PATCH 07/56] microblaze_v2: Signal support, Stephen Neuendorffer, (Mon May 5, 5:32 pm)
RE: [PATCH 07/56] microblaze_v2: Signal support, John Williams, (Mon May 5, 7:33 pm)
RE: [PATCH 07/56] microblaze_v2: Signal support, Stephen Neuendorffer, (Mon May 5, 8:13 pm)
RE: [PATCH 07/56] microblaze_v2: Signal support, John Williams, (Mon May 5, 8:25 pm)
RE: [PATCH 07/56] microblaze_v2: Signal support, Stephen Neuendorffer, (Mon May 5, 8:33 pm)
Re: [PATCH 07/56] microblaze_v2: Signal support, Michal Simek, (Tue May 6, 5:41 am)
RE: [PATCH 09/56] microblaze_v2: cache support, Stephen Neuendorffer, (Mon May 5, 6:37 pm)
RE: [microblaze-uclinux] [PATCH 09/56] microblaze_v2: cache ..., Stephen Neuendorffer, (Mon May 5, 1:37 pm)
RE: [PATCH 10/56] microblaze_v2: Generic dts file for platfo..., Stephen Neuendorffer, (Mon May 5, 1:25 pm)
RE: [PATCH 10/56] microblaze_v2: Generic dts file for platfo..., Stephen Neuendorffer, (Mon May 5, 7:32 pm)
RE: [PATCH 10/56] microblaze_v2: Generic dts file for platfo..., Stephen Neuendorffer, (Mon May 5, 8:17 pm)
Re: [PATCH 18/56] microblaze_v2: early_printk support, John Williams, (Mon May 5, 7:22 pm)
Re: [PATCH 18/56] microblaze_v2: early_printk support, Michal Simek, (Tue May 6, 4:14 am)
Re: [PATCH 18/56] microblaze_v2: early_printk support, Grant Likely, (Mon May 5, 10:36 am)
Re: [PATCH 18/56] microblaze_v2: early_printk support, Michal Simek, (Mon May 5, 4:10 pm)
Re: [PATCH 24/56] microblaze_v2: time support, Thomas Gleixner, (Wed May 7, 3:22 am)
[PATCH 28/56] microblaze_v2: memory inicialization, MMU, TLB, , (Sun May 4, 7:41 am)
Re: [PATCH 37/56] microblaze_v2: headers for irq, Thomas Gleixner, (Wed May 7, 3:26 am)
Re: [PATCH 37/56] microblaze_v2: headers for irq, Michal Simek, (Sun May 11, 9:56 am)
Re: [PATCH 46/56] microblaze_v2: headers files entry.h curre..., Geert Uytterhoeven, (Tue May 6, 4:57 pm)
[PATCH 54/56] microblaze_v2: entry.S, , (Sun May 4, 7:41 am)
Re: [PATCH 52/56] microblaze_v2: pci headers, Arnd Bergmann, (Sun May 4, 6:45 pm)
Re: [PATCH 52/56] microblaze_v2: pci headers, Michal Simek, (Mon May 5, 10:08 am)
Re: [PATCH 48/56] microblaze_v2: pool.h socket.h, Arnd Bergmann, (Sun May 4, 6:39 pm)
Re: [PATCH 43/56] microblaze_v2: termbits.h termios.h, Arnd Bergmann, (Mon May 5, 5:50 am)
Re: [PATCH 42/56] microblaze_v2: stats headers, Arnd Bergmann, (Sun May 4, 6:31 pm)
Re: [PATCH 36/56] microblaze_v2: dma support, John Williams, (Sun May 4, 10:25 pm)
Re: [PATCH 36/56] microblaze_v2: dma support, Geert Uytterhoeven, (Mon May 5, 2:45 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Michal Simek, (Tue May 6, 5:16 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Geert Uytterhoeven, (Tue May 6, 5:48 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Michal Simek, (Tue May 6, 5:53 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Geert Uytterhoeven, (Tue May 6, 7:17 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Arnd Bergmann, (Tue May 6, 7:24 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Michal Simek, (Tue May 6, 9:20 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Arnd Bergmann, (Tue May 6, 11:36 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Michal Simek, (Wed May 7, 2:24 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Geert Uytterhoeven, (Wed May 7, 3:17 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Arnd Bergmann, (Wed May 7, 5:21 am)
Re: [PATCH 36/56] microblaze_v2: dma support, Michal Simek, (Wed May 7, 2:43 pm)
Re: [PATCH 33/56] microblaze_v2: ioctl support, Arnd Bergmann, (Sun May 4, 5:34 pm)
Re: [PATCH 33/56] microblaze_v2: ioctl support, Michal Simek, (Mon May 5, 10:06 am)
Re: [PATCH 32/56] microblaze_v2: definitions of types, Arnd Bergmann, (Sun May 4, 5:28 pm)
Re: [PATCH 30/56] microblaze_v2: includes SHM*, msgbuf, Arnd Bergmann, (Sun May 4, 5:10 pm)
Re: [PATCH 24/56] microblaze_v2: time support, John Williams, (Sun May 4, 10:19 pm)
Re: [PATCH 24/56] microblaze_v2: time support, Michal Simek, (Mon May 5, 10:22 am)
Re: [PATCH 24/56] microblaze_v2: time support, John Williams, (Mon May 5, 8:30 pm)
Re: [PATCH 24/56] microblaze_v2: time support, Michal Simek, (Tue May 6, 6:02 am)
Re: [PATCH 24/56] microblaze_v2: time support, Arnd Bergmann, (Tue May 6, 7:38 am)
RE: [PATCH 24/56] microblaze_v2: time support, Stephen Neuendorffer, (Tue May 6, 12:36 pm)
Re: [PATCH 24/56] microblaze_v2: time support, Grant Likely, (Tue May 6, 10:28 am)
Re: [PATCH 24/56] microblaze_v2: time support, Michal Simek, (Tue May 6, 9:26 am)
Re: [PATCH 24/56] microblaze_v2: time support, John Williams, (Tue May 6, 6:50 pm)
Re: [PATCH 24/56] microblaze_v2: time support, Michal Simek, (Tue May 6, 5:56 am)
Re: [PATCH 21/56] microblaze_v2: setup.c - system setting, John Williams, (Sun May 4, 10:15 pm)
Re: [PATCH 17/56] microblaze_v2: checksum support, Arnd Bergmann, (Sun May 4, 3:59 pm)
Re: [PATCH 17/56] microblaze_v2: checksum support, Michal Simek, (Mon May 5, 10:05 am)
Re: [PATCH 12/56] microblaze_v2: lmb support, John Williams, (Sun May 4, 10:11 pm)
Re: [PATCH 12/56] microblaze_v2: lmb support, Segher Boessenkool, (Mon May 5, 5:32 pm)
Re: [PATCH 09/56] microblaze_v2: cache support, John Williams, (Sun May 4, 10:09 pm)
Re: [PATCH 07/56] microblaze_v2: Signal support, Arnd Bergmann, (Sun May 4, 3:52 pm)
Re: [PATCH 03/56] microblaze_v2: Cpuinfo handling, John Williams, (Sun May 4, 9:52 pm)
Re: [PATCH 03/56] microblaze_v2: Cpuinfo handling, Michal Simek, (Mon May 5, 10:19 am)
Re: [PATCH 01/56] microblaze_v2: Kconfig patches, John Williams, (Sun May 4, 9:42 pm)
Re: [PATCH 01/56] microblaze_v2: Kconfig patches, Michal Simek, (Mon May 5, 10:16 am)
Re: [PATCH 01/56] microblaze_v2: Kconfig patches, Michal Simek, (Mon May 5, 2:46 am)
Re: Microblaze patches V2, John Williams, (Sun May 4, 10:30 pm)
Re: Microblaze patches V2, Michal Simek, (Mon May 5, 3:02 am)
speck-geostationary