Skip to contentSkip to conversation

unicore32 core architecture: mm related: generic code

PATCH In review Guan Xuetao 1 participant 1 message Dec 25, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/12 unicore32 core architecture: mm related: generic code

From: Guan Xuetao <[email protected]>

Patch 6 includes generic codes of memory management.

---
 arch/unicore32/include/asm/cache.h       |   27 ++
 arch/unicore32/include/asm/mach/map.h    |   20 ++
 arch/unicore32/include/asm/mach/memory.h |   53 +++
 arch/unicore32/include/asm/memblock.h    |   20 ++
 arch/unicore32/include/asm/memory.h      |  123 +++++++
 arch/unicore32/include/asm/page.h        |   80 +++++
 arch/unicore32/include/asm/tlb.h         |   98 ++++++
 arch/unicore32/mm/Kconfig                |   52 +++
 arch/unicore32/mm/Makefile               |   15 +
 arch/unicore32/mm/init.c                 |  517 ++++++++++++++++++++++++++++++
 arch/unicore32/mm/iomap.c                |   56 ++++
 arch/unicore32/mm/ioremap.c              |  261 +++++++++++++++
 arch/unicore32/mm/mm.h                   |   39 +++
 arch/unicore32/mm/proc-syms.c            |   28 ++
 14 files changed, 1389 insertions(+), 0 deletions(-)
arch/unicore32/include/asm/cache.h new file +27 -0
new file mode 100644
index 0000000..ad8f795
@@ -0,0 +1,27 @@
+/*
+ * linux/arch/unicore32/include/asm/cache.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __UNICORE_CACHE_H__
+#define __UNICORE_CACHE_H__
+
+#define L1_CACHE_SHIFT		(5)
+#define L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
+
+/*
+ * Memory returned by kmalloc() may be used for DMA, so we must make
+ * sure that all such allocations are cache aligned. Otherwise,
+ * unrelated code may cause parts of the buffer to be read into the
+ * cache before the transfer is done, causing old data to be seen by
+ * the CPU.
+ */
+#define ARCH_DMA_MINALIGN	L1_CACHE_BYTES
+
+#endif
arch/unicore32/include/asm/mach/map.h new file +20 -0
new file mode 100644
index 0000000..a2f4bfc
@@ -0,0 +1,20 @@
+/*
+ * linux/arch/unicore32/include/asm/mach/map.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Page table mapping constructs and function prototypes
+ */
+#define MT_DEVICE		0
+#define MT_DEVICE_CACHED	2
+#define MT_KUSER		7
+#define MT_HIGH_VECTORS		8
+#define MT_MEMORY		9
+#define MT_ROM			10
+
arch/unicore32/include/asm/mach/memory.h new file +53 -0

53 lines not on this page · raw message

arch/unicore32/include/asm/memblock.h new file +20 -0
new file mode 100644
index 0000000..76f51a6
@@ -0,0 +1,20 @@
+/*
+ * linux/arch/unicore32/include/asm/memblock.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __UNICORE_MEMBLOCK_H__
+#define __UNICORE_MEMBLOCK_H__
+
+struct meminfo;
+
+extern void uc32_memblock_init(struct meminfo *);
+
+#endif
arch/unicore32/include/asm/memory.h new file +123 -0

123 lines not on this page · raw message

arch/unicore32/include/asm/page.h new file +80 -0

80 lines not on this page · raw message

arch/unicore32/include/asm/tlb.h new file +98 -0

98 lines not on this page · raw message

arch/unicore32/mm/Kconfig new file +52 -0

52 lines not on this page · raw message

arch/unicore32/mm/Makefile new file +15 -0
new file mode 100644
index 0000000..bfc36ff
@@ -0,0 +1,15 @@
+#
+# Makefile for the linux unicore-specific parts of the memory manager.
+#
+
+obj-y		:= extable.o fault.o init.o pgd.o mmu.o		\
+		   iomap.o fault-unicore.o flush.o ioremap.o
+
+obj-$(CONFIG_SWIOTLB)		+= dma-swiotlb.o
+
+obj-$(CONFIG_MODULES)		+= proc-syms.o
+
+obj-$(CONFIG_ALIGNMENT_TRAP)	+= alignment.o
+
+obj-$(CONFIG_CPU_UCV2)		+= cache-ucv2.o tlb-ucv2.o proc-ucv2.o
+
arch/unicore32/mm/init.c new file +517 -0

517 lines not on this page · raw message

arch/unicore32/mm/iomap.c new file +56 -0

56 lines not on this page · raw message

arch/unicore32/mm/ioremap.c new file +261 -0

261 lines not on this page · raw message

arch/unicore32/mm/mm.h new file +39 -0
new file mode 100644
index 0000000..3296bca
@@ -0,0 +1,39 @@
+/*
+ * linux/arch/unicore32/mm/mm.h
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+/* the upper-most page table pointer */
+extern pmd_t *top_pmd;
+extern int sysctl_overcommit_memory;
+
+#define TOP_PTE(x)	pte_offset_kernel(top_pmd, x)
+
+static inline pmd_t *pmd_off(pgd_t *pgd, unsigned long virt)
+{
+	return pmd_offset((pud_t *)pgd, virt);
+}
+
+static inline pmd_t *pmd_off_k(unsigned long virt)
+{
+	return pmd_off(pgd_offset_k(virt), virt);
+}
+
+struct mem_type {
+	unsigned int prot_pte;
+	unsigned int prot_l1;
+	unsigned int prot_sect;
+};
+
+const struct mem_type *get_mem_type(unsigned int type);
+
+extern void __flush_dcache_page(struct address_space *, struct page *);
+
+void __init bootmem_init(void);
+void uc32_mm_memblock_reserve(void);
arch/unicore32/mm/proc-syms.c new file +28 -0
new file mode 100644
index 0000000..3f257a0
@@ -0,0 +1,28 @@
+/*
+ * linux/arch/unicore32/mm/proc-syms.c
+ *
+ * Code specific to PKUnity SoC and UniCore ISA
+ *
+ * Copyright (C) 2001-2010 GUAN Xue-tao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include <asm/cacheflush.h>
+#include <asm/proc-fns.h>
+#include <asm/tlbflush.h>
+#include <asm/page.h>
+
+EXPORT_SYMBOL(cpu_dcache_clean_area);
+EXPORT_SYMBOL(cpu_set_pte);
+
+EXPORT_SYMBOL(__cpuc_flush_kern_all);
+EXPORT_SYMBOL(__cpuc_flush_user_all);
+EXPORT_SYMBOL(__cpuc_flush_user_range);
+EXPORT_SYMBOL(__cpuc_coherent_kern_range);
+EXPORT_SYMBOL(__cpuc_flush_dcache_area);
+