From: David Gibson <david@gibson•dropbear.id.au>
To: <linuxppc-dev@ozlabs•org>
Subject: [PATCH 6/16] Port 44x MMU definitions to ARCH=powerpc
Date: Tue, 13 Feb 2007 17:10:24 +1100 (EST) [thread overview]
Message-ID: <20070213061024.B4A8CDDD0D@ozlabs.org> (raw)
In-Reply-To: <20070213060904.GA6214@localhost.localdomain>
This patch moves the mmu.h definitions which are still relevant for
ARCH=powerpc from include/asm-ppc/mmu.h to their own file,
include/asm-powerpc/mmu_44x.h. The new file is included from
asm-powerpc/mmu.h, and a couple of other tweaks to correct mmu
definitions for 44x are made.
Signed-off-by: David Gibson <dwg@au1•ibm.com>
---
arch/powerpc/kernel/head_44x.S | 4 +-
arch/powerpc/mm/44x_mmu.c | 81 ++++++++---------------------------------
arch/powerpc/mm/mmu_decl.h | 2 +
include/asm-powerpc/mmu.h | 4 +-
include/asm-powerpc/mmu_44x.h | 74 +++++++++++++++++++++++++++++++++++++
5 files changed, 98 insertions(+), 67 deletions(-)
Index: working-2.6/include/asm-powerpc/mmu.h
===================================================================
--- working-2.6.orig/include/asm-powerpc/mmu.h 2007-01-24 12:01:20.000000000 +1100
+++ working-2.6/include/asm-powerpc/mmu.h 2007-02-05 14:24:52.000000000 +1100
@@ -2,7 +2,9 @@
#define _ASM_POWERPC_MMU_H_
#ifdef __KERNEL__
-#ifndef CONFIG_PPC64
+#ifdef CONFIG_44x
+#include <asm/mmu_44x.h>
+#elif !defined(CONFIG_PPC64)
#include <asm-ppc/mmu.h>
#else
Index: working-2.6/include/asm-powerpc/mmu_44x.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/include/asm-powerpc/mmu_44x.h 2007-02-05 15:25:11.000000000 +1100
@@ -0,0 +1,74 @@
+#ifndef _ASM_POWERPC_MMU_44X_H_
+#define _ASM_POWERPC_MMU_44X_H_
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned long long phys_addr_t;
+extern phys_addr_t fixup_bigphys_addr(phys_addr_t, phys_addr_t);
+#define PHYS_FMT "%16Lx"
+
+typedef struct {
+ unsigned long id;
+ unsigned long vdso_base;
+} mm_context_t;
+
+#endif /* !__ASSEMBLY__ */
+
+/*
+ * PPC440 support
+ */
+#define PPC44x_MMUCR_TID 0x000000ff
+#define PPC44x_MMUCR_STS 0x00010000
+
+#define PPC44x_TLB_PAGEID 0
+#define PPC44x_TLB_XLAT 1
+#define PPC44x_TLB_ATTRIB 2
+
+/* Page identification fields */
+#define PPC44x_TLB_EPN_MASK 0xfffffc00 /* Effective Page Number */
+#define PPC44x_TLB_VALID 0x00000200 /* Valid flag */
+#define PPC44x_TLB_TS 0x00000100 /* Translation address space */
+#define PPC44x_TLB_1K 0x00000000 /* Page sizes */
+#define PPC44x_TLB_4K 0x00000010
+#define PPC44x_TLB_16K 0x00000020
+#define PPC44x_TLB_64K 0x00000030
+#define PPC44x_TLB_256K 0x00000040
+#define PPC44x_TLB_1M 0x00000050
+#define PPC44x_TLB_16M 0x00000070
+#define PPC44x_TLB_256M 0x00000090
+
+/* Translation fields */
+#define PPC44x_TLB_RPN_MASK 0xfffffc00 /* Real Page Number */
+#define PPC44x_TLB_ERPN_MASK 0x0000000f
+
+/* Storage attribute and access control fields */
+#define PPC44x_TLB_ATTR_MASK 0x0000ff80
+#define PPC44x_TLB_U0 0x00008000 /* User 0 */
+#define PPC44x_TLB_U1 0x00004000 /* User 1 */
+#define PPC44x_TLB_U2 0x00002000 /* User 2 */
+#define PPC44x_TLB_U3 0x00001000 /* User 3 */
+#define PPC44x_TLB_W 0x00000800 /* Caching is write-through */
+#define PPC44x_TLB_I 0x00000400 /* Caching is inhibited */
+#define PPC44x_TLB_M 0x00000200 /* Memory is coherent */
+#define PPC44x_TLB_G 0x00000100 /* Memory is guarded */
+#define PPC44x_TLB_E 0x00000080 /* Memory is guarded */
+
+#define PPC44x_TLB_PERM_MASK 0x0000003f
+#define PPC44x_TLB_UX 0x00000020 /* User execution */
+#define PPC44x_TLB_UW 0x00000010 /* User write */
+#define PPC44x_TLB_UR 0x00000008 /* User read */
+#define PPC44x_TLB_SX 0x00000004 /* Super execution */
+#define PPC44x_TLB_SW 0x00000002 /* Super write */
+#define PPC44x_TLB_SR 0x00000001 /* Super read */
+
+/* Number of TLB entries */
+#define PPC44x_TLB_SIZE 64
+
+/* TLB entry offset/size used for pinning kernel lowmem */
+#define PPC44x_PIN_SHIFT 28
+#define PPC_PIN_SIZE (1 << PPC44x_PIN_SHIFT)
+
+#define PPC44x_EARLY_TLBS 1
+
+#endif /* _ASM_POWERPC_MMU_44X_H_ */
+
Index: working-2.6/arch/powerpc/mm/44x_mmu.c
===================================================================
--- working-2.6.orig/arch/powerpc/mm/44x_mmu.c 2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/mm/44x_mmu.c 2007-02-05 15:25:19.000000000 +1100
@@ -24,73 +24,35 @@
*
*/
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/swap.h>
-#include <linux/stddef.h>
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/highmem.h>
-
-#include <asm/pgalloc.h>
-#include <asm/prom.h>
-#include <asm/io.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
#include <asm/mmu.h>
-#include <asm/uaccess.h>
-#include <asm/smp.h>
-#include <asm/bootx.h>
-#include <asm/machdep.h>
-#include <asm/setup.h>
#include "mmu_decl.h"
-extern char etext[], _stext[];
-
/* Used by the 44x TLB replacement exception handler.
* Just needed it declared someplace.
*/
-unsigned int tlb_44x_index = 0;
-unsigned int tlb_44x_hwater = 62;
+unsigned int tlb_44x_index; /* = 0 */
+unsigned int tlb_44x_hwater = PPC44x_TLB_SIZE - 1 - PPC44x_EARLY_TLBS;
/*
* "Pins" a 256MB TLB entry in AS0 for kernel lowmem
*/
-static void __init
-ppc44x_pin_tlb(int slot, unsigned int virt, unsigned int phys)
+static void __init ppc44x_pin_tlb(unsigned int virt, unsigned int phys)
{
- unsigned long attrib = 0;
-
- __asm__ __volatile__("\
- clrrwi %2,%2,10\n\
- ori %2,%2,%4\n\
- clrrwi %1,%1,10\n\
- li %0,0\n\
- ori %0,%0,%5\n\
- tlbwe %2,%3,%6\n\
- tlbwe %1,%3,%7\n\
- tlbwe %0,%3,%8"
+ __asm__ __volatile__(
+ "tlbwe %2,%3,%4\n"
+ "tlbwe %1,%3,%5\n"
+ "tlbwe %0,%3,%6\n"
:
- : "r" (attrib), "r" (phys), "r" (virt), "r" (slot),
- "i" (PPC44x_TLB_VALID | PPC44x_TLB_256M),
- "i" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G),
+ : "r" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G),
+ "r" (phys),
+ "r" (virt | PPC44x_TLB_VALID | PPC44x_TLB_256M),
+ "r" (tlb_44x_hwater--), /* slot for this TLB entry */
"i" (PPC44x_TLB_PAGEID),
"i" (PPC44x_TLB_XLAT),
"i" (PPC44x_TLB_ATTRIB));
}
-/*
- * MMU_init_hw does the chip-specific initialization of the MMU hardware.
- */
void __init MMU_init_hw(void)
{
flush_instruction_cache();
@@ -98,22 +60,13 @@ void __init MMU_init_hw(void)
unsigned long __init mmu_mapin_ram(void)
{
- unsigned int pinned_tlbs = 1;
- int i;
+ unsigned long addr;
- /* Determine number of entries necessary to cover lowmem */
- pinned_tlbs = (unsigned int)
- (_ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT);
-
- /* Write upper watermark to save location */
- tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
-
- /* If necessary, set additional pinned TLBs */
- if (pinned_tlbs > 1)
- for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) {
- unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC_PIN_SIZE;
- ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr);
- }
+ /* Pin in enough TLBs to cover any lowmem not covered by the
+ * initial 256M mapping established in head_44x.S */
+ for (addr = PPC_PIN_SIZE; addr < total_lowmem;
+ addr += PPC_PIN_SIZE)
+ ppc44x_pin_tlb(addr + PAGE_OFFSET, addr);
return total_lowmem;
}
Index: working-2.6/arch/powerpc/mm/mmu_decl.h
===================================================================
--- working-2.6.orig/arch/powerpc/mm/mmu_decl.h 2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/mm/mmu_decl.h 2007-02-05 14:24:52.000000000 +1100
@@ -35,8 +35,10 @@ extern int __map_without_bats;
extern unsigned long ioremap_base;
extern unsigned int rtas_data, rtas_size;
+#ifdef CONFIG_CLASSIC32
extern PTE *Hash, *Hash_end;
extern unsigned long Hash_size, Hash_mask;
+#endif /* CONFIG_CLASSIC32 */
extern unsigned int num_tlbcam_entries;
#endif
Index: working-2.6/arch/powerpc/kernel/head_44x.S
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/head_44x.S 2007-02-05 14:24:52.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/head_44x.S 2007-02-05 15:25:11.000000000 +1100
@@ -120,8 +120,8 @@ skpinv: addi r4,r4,1 /* Increment */
* Configure and load pinned entry into TLB slot 63.
*/
- lis r3,KERNELBASE@h /* Load the kernel virtual address */
- ori r3,r3,KERNELBASE@l
+ lis r3,PAGE_OFFSET@h
+ ori r3,r3,PAGE_OFFSET@l
/* Kernel is at the base of RAM */
li r4, 0 /* Load the kernel physical address */
next prev parent reply other threads:[~2007-02-13 6:10 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-13 6:09 [0/16] Preliminary Ebony (440GP) support for arch/powerpc David Gibson
2007-02-13 6:10 ` [PATCH 7/16] Early serial debug support for PPC44x David Gibson
2007-02-13 15:04 ` Josh Boyer
2007-02-14 0:16 ` David Gibson
2007-02-14 1:02 ` Josh Boyer
2007-02-14 1:00 ` David Gibson
2007-02-14 2:00 ` Alan Modra
2007-02-14 2:02 ` David Gibson
2007-02-14 2:38 ` Alan Modra
2007-02-14 15:41 ` Josh Boyer
2007-02-14 23:05 ` David Gibson
2007-02-13 6:10 ` [PATCH 3/16] [powerpc] Use udbg_early_init() on ppc32 David Gibson
2007-02-13 6:22 ` Benjamin Herrenschmidt
2007-02-13 6:10 ` [PATCH 1/16] Remove ibm4{xx,4x}.h from arch/powerpc David Gibson
2007-02-13 14:19 ` Josh Boyer
2007-02-13 6:10 ` [PATCH 5/16] powerpc: Add zImage platform hook for kernel address David Gibson
2007-02-13 6:10 ` [PATCH 4/16] powerpc: Allow duplicate lmb_reserve() calls David Gibson
2007-02-13 7:05 ` Michael Neuling
2007-02-13 8:48 ` Michael Ellerman
2007-02-13 20:44 ` Benjamin Herrenschmidt
2007-02-13 6:10 ` [PATCH 8/16] Define FIXED_PORT flag for serial_core David Gibson
2007-02-13 6:10 ` David Gibson [this message]
2007-02-13 6:24 ` [PATCH 6/16] Port 44x MMU definitions to ARCH=powerpc Benjamin Herrenschmidt
2007-02-13 17:13 ` Roland Dreier
2007-02-13 17:45 ` Josh Boyer
2007-02-13 21:36 ` Benjamin Herrenschmidt
2007-02-13 6:10 ` [PATCH 2/16] More DCR native fixups David Gibson
2007-02-13 6:22 ` Benjamin Herrenschmidt
2007-02-13 6:10 ` [PATCH 12/16] Automatically lmb_reserve() initrd David Gibson
2007-02-13 7:14 ` Michael Neuling
2007-02-13 6:10 ` [PATCH 10/16] Add support for BSS stack for zImage wrapper David Gibson
2007-02-13 6:10 ` [PATCH 14/16] Add arch/powerpc driver for UIC, PPC4xx interrupt controller David Gibson
2007-02-13 6:10 ` [PATCH 11/16] zImage wrapper for Ebony David Gibson
2007-02-13 17:05 ` Geoff Levand
2007-02-14 0:17 ` David Gibson
2007-02-13 6:10 ` [PATCH 9/16] Use resource_size_t for serial port IO addresses David Gibson
2007-02-13 6:10 ` [PATCH 13/16] Add initrd properties to device tree from zImage David Gibson
2007-02-13 6:10 ` [PATCH 16/16] Support for Ebony in arch/powerpc David Gibson
2007-02-13 17:18 ` Roland Dreier
2007-02-14 0:20 ` David Gibson
2007-02-13 6:10 ` [PATCH 15/16] Add device tree for Ebony David Gibson
2007-02-13 20:08 ` Segher Boessenkool
2007-02-14 0:22 ` David Gibson
2007-02-14 1:51 ` Benjamin Herrenschmidt
2007-02-14 4:46 ` David Gibson
2007-02-14 17:54 ` Segher Boessenkool
2007-02-14 23:18 ` David Gibson
2007-02-15 0:25 ` Segher Boessenkool
2007-02-14 17:51 ` Segher Boessenkool
2007-02-14 17:48 ` Segher Boessenkool
2007-02-14 21:30 ` Benjamin Herrenschmidt
2007-02-15 0:03 ` Segher Boessenkool
2007-02-15 0:53 ` Benjamin Herrenschmidt
2007-02-15 1:00 ` Segher Boessenkool
2007-02-15 2:22 ` Benjamin Herrenschmidt
2007-02-15 2:51 ` Segher Boessenkool
2007-02-14 23:17 ` David Gibson
2007-02-15 0:27 ` Segher Boessenkool
2007-02-15 14:02 ` Jon Loeliger
2007-02-15 14:56 ` Segher Boessenkool
2007-02-15 17:02 ` Yoder Stuart-B08248
2007-02-15 17:10 ` Scott Wood
2007-02-16 9:20 ` Segher Boessenkool
2007-02-14 16:14 ` Yoder Stuart-B08248
2007-02-14 16:32 ` Josh Boyer
2007-02-14 17:58 ` Segher Boessenkool
2007-02-14 20:08 ` Yoder Stuart-B08248
2007-02-14 21:12 ` Segher Boessenkool
2007-02-14 21:35 ` Yoder Stuart-B08248
2007-02-14 21:42 ` Benjamin Herrenschmidt
2007-02-14 21:59 ` Scott Wood
2007-02-15 0:20 ` Segher Boessenkool
2007-02-14 22:50 ` Yoder Stuart-B08248
2007-02-14 22:57 ` Benjamin Herrenschmidt
2007-02-15 0:17 ` Segher Boessenkool
2007-02-15 2:12 ` Paul Mackerras
2007-02-15 2:43 ` Segher Boessenkool
2007-02-15 3:15 ` Paul Mackerras
2007-02-15 14:40 ` Segher Boessenkool
2007-02-16 1:17 ` Paul Mackerras
2007-02-16 9:41 ` Segher Boessenkool
2007-02-15 0:10 ` Segher Boessenkool
2007-02-14 23:32 ` David Gibson
2007-02-14 23:27 ` David Gibson
2007-02-14 23:22 ` David Gibson
2007-02-14 23:51 ` Benjamin Herrenschmidt
2007-02-15 0:36 ` Segher Boessenkool
2007-02-15 0:31 ` Segher Boessenkool
2007-02-15 1:53 ` David Gibson
2007-02-15 3:09 ` Segher Boessenkool
2007-02-15 3:33 ` David Gibson
2007-02-15 14:47 ` Segher Boessenkool
2007-02-15 10:52 ` Benjamin Herrenschmidt
2007-02-15 14:52 ` Segher Boessenkool
2007-02-15 20:43 ` Benjamin Herrenschmidt
2007-02-16 9:23 ` Segher Boessenkool
2007-02-15 16:37 ` Yoder Stuart-B08248
2007-02-15 21:41 ` Benjamin Herrenschmidt
2007-02-16 9:25 ` Segher Boessenkool
2007-02-16 15:32 ` Hartmut Penner
2007-02-16 16:47 ` Yoder Stuart-B08248
2007-02-19 12:02 ` Hartmut Penner
2007-02-14 21:29 ` Benjamin Herrenschmidt
2007-02-13 14:37 ` [0/16] Preliminary Ebony (440GP) support for arch/powerpc Josh Boyer
2007-02-13 20:21 ` Josh Boyer
2007-02-13 15:46 ` Josh Boyer
2007-02-14 16:06 ` Josh Boyer
2007-02-14 23:12 ` David Gibson
2007-02-16 2:19 ` Josh Boyer
2007-02-16 2:53 ` David Gibson
2007-02-16 4:33 ` Josh Boyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070213061024.B4A8CDDD0D@ozlabs.org \
--to=david@gibson$(echo .)dropbear.id.au \
--cc=linuxppc-dev@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox