m68k: ColdFire MMU support
Subsystems (4)
cover m68k: ColdFire MMU support
Hi All,
The following patch set adds support for running the V4e ColdFire cores with their MMU enabled. This is very much a request for comments. I expect a lot more cleanup is required here. But this is a start.
This patch set is based on 3.1 with all the recent patches I have sent here applied first. It is available as a git tree for easier testing, just pull this tree, with the cfmmu branch:
[email protected]:gregungerer/m68knommu.git cfmmu
Some of the code in this set is taken from Freescales 2.6.25 kernel support of MMU ColdFire.
I have pretty much ignored FPU support in this code. I would like to handle it later in a follow up patch set. But it does mean some ugly ifdefery in a couple of files. I expect a couple of the patches in here can be dropped once Geert has merged his IRQ changes.
Currently shared libraries are not working, only statically compiled apps. For reference I am using a gcc-4.5.1 based toolchain.
Specifically I am testing this on a ColdFire 5475 (on a FireBee board). I have test compiled and run this patch set on ARAnyM as well, I didn't have any problems there. Also test compiled and run on MMU-less ColdFire.
Regards
Greg
PATCH 1/36 m68k: add machine and CPU definitions for ColdFire cores
From: Greg Ungerer <[email protected]>
Create machine and CPU definitions to support the ColdFire CPU family members that have a virtual memory management unit.
The ColdFire V4e core contains an MMU, and it is quite different to any other 68k family members.
--- arch/m68k/include/asm/setup.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
arch/m68k/include/asm/setup.h +14 -0
@@ -40,6 +40,7 @@#define MACH_HP300 9#define MACH_Q40 10#define MACH_SUN3X 11 +#define MACH_M54XX 12#define COMMAND_LINE_SIZE 256
@@ -211,23 +212,27 @@ extern unsigned long m68k_machtype;#define CPUB_68030 1#define CPUB_68040 2#define CPUB_68060 3 +#define CPUB_COLDFIRE 4#define CPU_68020 (1<<CPUB_68020)#define CPU_68030 (1<<CPUB_68030)#define CPU_68040 (1<<CPUB_68040)#define CPU_68060 (1<<CPUB_68060) +#define CPU_COLDFIRE (1<<CPUB_COLDFIRE)#define FPUB_68881 0#define FPUB_68882 1#define FPUB_68040 2/* Internal FPU */ #define FPUB_68060 3/* Internal FPU */ #define FPUB_SUNFPA 4/* Sun-3 FPA */ +#define FPUB_COLDFIRE 5/* ColdFire FPU */ #define FPU_68881 (1<<FPUB_68881)#define FPU_68882 (1<<FPUB_68882)#define FPU_68040 (1<<FPUB_68040)#define FPU_68060 (1<<FPUB_68060)#define FPU_SUNFPA (1<<FPUB_SUNFPA) +#define FPU_COLDFIRE (1<<FPUB_COLDFIRE)#define MMUB_68851 0#define MMUB_68030 1/* Internal MMU */
@@ -235,6 +240,7 @@ extern unsigned long m68k_machtype;#define MMUB_68060 3/* Internal MMU */ #define MMUB_APOLLO 4/* Custom Apollo */ #define MMUB_SUN3 5/* Custom Sun-3 */ +#define MMUB_COLDFIRE 6/* Internal MMU */ #define MMU_68851 (1<<MMUB_68851)#define MMU_68030 (1<<MMUB_68030)
@@ -242,6 +248,7 @@ extern unsigned long m68k_machtype;#define MMU_68060 (1<<MMUB_68060)#define MMU_SUN3 (1<<MMUB_SUN3)#define MMU_APOLLO (1<<MMUB_APOLLO) +#define MMU_COLDFIRE (1<<MMUB_COLDFIRE)#ifdef __KERNEL__
@@ -341,6 +348,13 @@ extern int m68k_is040or060;# endif #endif +#if !defined(CONFIG_COLDFIRE ) +# define CPU_IS_COLDFIRE (0) +#else +# define CPU_IS_COLDFIRE (1) +# define MMU_IS_COLDFIRE (1) +#endif +#define CPU_TYPE (m68k_cputype)#ifdef CONFIG_M68KFPU_EMU
Signature · 1 line
1.7.0.4
PATCH 2/36 m68k: show ColdFire CPU/FPU/MMU type
In reply to [email protected]From: Greg Ungerer <[email protected]>
Update the show_cpuinfo() code to display info about ColdFire cores.
--- arch/m68k/kernel/setup_mm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/m68k/kernel/setup_mm.c +8 -0
@@ -388,6 +388,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)#define LOOP_CYCLES_68030 (8)#define LOOP_CYCLES_68040 (3)#define LOOP_CYCLES_68060 (1) +#define LOOP_CYCLES_COLDFIRE (2)if (CPU_IS_020 ) { cpu ="68020" ;
@@ -401,6 +402,9 @@ static int show_cpuinfo(struct seq_file *m, void *v) }else if (CPU_IS_060 ) { cpu ="68060" ; clockfactor =LOOP_CYCLES_68060 ; + }else if (CPU_IS_COLDFIRE ) { + cpu ="ColdFire" ; + clockfactor =LOOP_CYCLES_COLDFIRE ; }else { cpu ="680x0" ; clockfactor =0 ;
@@ -419,6 +423,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) fpu ="68060" ; else if (m68k_fputype & FPU_SUNFPA) fpu ="Sun FPA" ; + else if (m68k_fputype & FPU_COLDFIRE) + fpu ="ColdFire" ; else fpu ="none" ;#endif
@@ -435,6 +441,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) mmu ="Sun-3" ; else if (m68k_mmutype & MMU_APOLLO) mmu ="Apollo" ; + else if (m68k_mmutype & MMU_COLDFIRE) + mmu ="ColdFire" ; else mmu ="unknown" ;
Signature · 1 line
1.7.0.4
PATCH 3/36 m68k: definitions for the ColdFire V4e MMU hardware
In reply to [email protected]From: Greg Ungerer <[email protected]>
Basic register level definitions to support the internal MMU of the V4e ColdFire cores.
--- arch/m68k/include/asm/mcfmmu.h | 117 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 117 insertions(+), 0 deletions(-) create mode 100644 arch/m68k/include/asm/mcfmmu.h
arch/m68k/include/asm/mcfmmu.h new file +117 -0
@@ -0,0 +1,117 @@ +/****************************************************************************/ + +/* +* mcfmmu.h -- definitions for the ColdFire v4e MMU +* +* (C) Copyright 2011, Greg Ungerer <[email protected]> +* +* 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. +*/ + +/****************************************************************************/ +#ifndef MCFMMU_H +#define MCFMMU_H +/****************************************************************************/ + +/* +* The MMU support registers are mapped into the address space using +* the processor MMUBASE register. We used a fixed address for mapping, +* there doesn't seem any need to make this configurable yet. +*/ +#define MMUBASE 0xfe000000 + +/* +* The support registers of the MMU. Names are the sames as those +* used in the Freescale v4e documentation. +*/ +#define MMUCR (MMUBASE + 0x00)/* Control register */ +#define MMUOR (MMUBASE + 0x04)/* Operation register */ +#define MMUSR (MMUBASE + 0x08)/* Status register */ +#define MMUAR (MMUBASE + 0x10)/* TLB Address register */ +#define MMUTR (MMUBASE + 0x14)/* TLB Tag register */ +#define MMUDR (MMUBASE + 0x18)/* TLB Data register */ + +/* +* MMU Control register bit flags +*/ +#define MMUCR_EN 0x00000001/* Virtual mode enable */ +#define MMUCR_ASM 0x00000002/* Address space mode */ + +/* +* MMU Operation register. +*/ +#define MMUOR_UAA 0x00000001/* Update allocatiom address */ +#define MMUOR_ACC 0x00000002/* TLB access */ +#define MMUOR_RD 0x00000004/* TLB access read */ +#define MMUOR_WR 0x00000000/* TLB access write */ +#define MMUOR_ADR 0x00000008/* TLB address select */ +#define MMUOR_ITLB 0x00000010/* ITLB operation */ +#define MMUOR_CAS 0x00000020/* Clear non-locked ASID TLBs */ +#define MMUOR_CNL 0x00000040/* Clear non-locked TLBs */ +#define MMUOR_CA 0x00000080/* Clear all TLBs */ +#define MMUOR_STLB 0x00000100/* Search TLBs */ +#define MMUOR_AAN 16/* TLB allocation address */ +#define MMUOR_AAMASK 0xffff0000/* AA mask */ + +/* +* MMU Status register. +*/ +#define MMUSR_HIT 0x00000002/* Search TLB hit */ +#define MMUSR_WF 0x00000008/* Write access fault */ +#define MMUSR_RF 0x00000010/* Read access fault */ +#define MMUSR_SPF 0x00000020/* Supervisor protect fault */ + +/* +* MMU Read/Write Tag register. +*/ +#define MMUTR_V 0x00000001/* Valid */ +#define MMUTR_SG 0x00000002/* Shared global */ +#define MMUTR_IDN 2/* Address Space ID */ +#define MMUTR_IDMASK 0x000003fc/* ASID mask */ +#define MMUTR_VAN 10/* Virtual Address */ +#define MMUTR_VAMASK 0xfffffc00/* VA mask */ + +/* +* MMU Read/Write Data register. +*/ +#define MMUDR_LK 0x00000002/* Lock entry */ +#define MMUDR_X 0x00000004/* Execute access enable */ +#define MMUDR_W 0x00000008/* Write access enable */ +#define MMUDR_R 0x00000010/* Read access enable */ +#define MMUDR_SP 0x00000020/* Supervisor access enable */ +#define MMUDR_CM_CWT 0x00000000/* Cachable write thru */ +#define MMUDR_CM_CCB 0x00000040/* Cachable copy back */ +#define MMUDR_CM_NCP 0x00000080/* Non-cachable precise */ +#define MMUDR_CM_NCI 0x000000c0/* Non-cachable imprecise */ +#define MMUDR_SZ_1MB 0x00000000/* 1MB page size */ +#define MMUDR_SZ_4KB 0x00000100/* 4kB page size */ +#define MMUDR_SZ_8KB 0x00000200/* 8kB page size */ +#define MMUDR_SZ_1KB 0x00000300/* 1kB page size */ +#define MMUDR_PAN 10/* Physical address */ +#define MMUDR_PAMASK 0xfffffc00/* PA mask */ + +/* +* Simple access functions for the MMU registers. Nothing fancy +* currently required, just simple 32bit access. +*/ +#ifndef __ASSEMBLY__ + +#define CF_PAGE_PGNUM_MASK (PAGE_MASK) + +static inline u32 mmu_read (u32 a) +{ +return *((volatile u32 *) a); +} + +static inline void mmu_write (u32 a,u32 v) +{ + *((volatile u32 *) a) = v; + __asm__ __volatile__ ("nop" ); +} + +#endif + +/****************************************************************************/ +#endif /* MCFMMU_H */
Signature · 1 line
1.7.0.4
PATCH 4/36 m68k: make old interrupt code conditional on correct CPU types
In reply to [email protected]From: Greg Ungerer <[email protected]>
The older interrupt handling support code is not so much conditional on an MMU being present (CONFIG_MMU), as it is on which type of CPU we are building for. So make the code conditional on the CPU types instead.
--- arch/m68k/include/asm/irq.h | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
arch/m68k/include/asm/irq.h +3 -2
@@ -25,7 +25,8 @@#define NR_IRQS 0#endif -#ifdef CONFIG_MMU +#if defined(CONFIG_M68020 ) || defined(CONFIG_M68030 ) || \ + defined(CONFIG_M68040 ) || defined(CONFIG_M68060 )#include <linux/linkage.h> #include <linux/hardirq.h>
@@ -120,7 +121,7 @@ asmlinkage void __m68k_handle_int(unsigned int, struct pt_regs *);#else #define irq_canonicalize (irq) (irq) -#endif /* CONFIG_MMU */ +#endif /* !(CONFIG_M68020 || CONFIG_M68030 || CONFIG_M68040 || CONFIG_M68060) */ asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
Signature · 1 line
1.7.0.4
PATCH 5/36 m68k: add TASK definitions for ColdFires running with MMU
In reply to [email protected]From: Greg Ungerer <[email protected]>
Add appropriate TASK_SIZE and TASK_UNMAPPED_BASE definitions for running on ColdFire V4e cores with MMU enabled.
--- arch/m68k/include/asm/processor.h | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
arch/m68k/include/asm/processor.h +10 -6
@@ -48,10 +48,12 @@ static inline void wrusp(unsigned long usp)* so don't change it unless you know what you are doing. */ #ifdef CONFIG_MMU -#ifndef CONFIG_SUN3 -#define TASK_SIZE (0xF0000000UL) -#else +#if defined(CONFIG_COLDFIRE ) +#define TASK_SIZE (0xC0000000UL) +#elif defined(CONFIG_SUN3 )#define TASK_SIZE (0x0E000000UL) +#else +#define TASK_SIZE (0xF0000000UL)#endif #else #define TASK_SIZE (0xFFFFFFFFUL)
@@ -66,10 +68,12 @@ static inline void wrusp(unsigned long usp)* space during mmap's. */ #ifdef CONFIG_MMU -#ifndef CONFIG_SUN3 -#define TASK_UNMAPPED_BASE 0xC0000000UL -#else +#if defined(CONFIG_COLDFIRE ) +#define TASK_UNMAPPED_BASE 0x80000000UL +#elif defined(CONFIG_SUN3 )#define TASK_UNMAPPED_BASE 0x0A000000UL +#else +#define TASK_UNMAPPED_BASE 0xC0000000UL#endif #define TASK_UNMAPPED_ALIGN (addr, off) PAGE_ALIGN(addr)#else
Signature · 1 line
1.7.0.4
PATCH 6/36 m68k: modify user space access functions to support ColdFire CPUs
In reply to [email protected]From: Greg Ungerer <[email protected]>
Modify the user space access functions to support the ColdFire V4e cores running with MMU enabled.
The ColdFire processors do not support the "moves" instruction used by the traditional 680x0 processors for moving data into and out of another address space. They only support the notion of a single address space, and you use the usual "move" instruction to access that.
I am interrested in what others think if this approach. It is a little ugly, but it does mean that the same code is used, not a complete duplicate that is almost the same except for the "moves" instructions. It does also mean in this form that it is an either/or compile. It can't support both ColdFire and 680x0 in the same binary as it is.
--- arch/m68k/include/asm/uaccess_mm.h | 42 ++++++++++++++++++++++++----------- arch/m68k/lib/uaccess.c | 22 +++++++++--------- 2 files changed, 40 insertions(+), 24 deletions(-)
arch/m68k/include/asm/uaccess_mm.h +29 -13
@@ -20,6 +20,22 @@ static inline int access_ok(int type, const void __user *addr,return 1 ; } +#ifdef CONFIG_COLDFIRE +/* +* The ColdFire processors do not support the moves instruction used by +* the traditional 680x0 processors for moving data into and out of +* another address space. They only support the notion of a single address +* space, and you use the usual move instruction to access that. +* +* All the user space access functions are otherwise the same on ColdFire +* as the other 680x0 processors. So lets keep the code simple and just +* define in what we need to use. +*/ +#define MOVES "move" +#else +#define MOVES "moves" +#endif /* CONFIG_COLDFIRE */ +/* * The exception table consists of pairs of addresses: the first is the * address of an instruction that is allowed to fault, and the second is
@@ -43,7 +59,7 @@ extern int __get_user_bad(void);#define __put_user_asm (res, x, ptr, bwl, reg, err) \ asm volatile ("\n" \ - "1: moves."#bwl" %2,%1\n" \ + "1: "MOVES"."#bwl" %2,%1\n" \ "2:\n" \ " .section .fixup,\"ax\"\n" \ " .even\n" \
@@ -83,8 +99,8 @@ asm volatile ("\n" \ { \ const void __user *__pu_ptr = (ptr); \ asmvolatile ("\n" \ -"1: moves.l %2,(%1)+\n" \ -"2: moves.l %R2,(%1)\n" \ +"1: " MOVES ".l %2,(%1)+\n" \ +"2: " MOVES ".l %R2,(%1)\n" \"3:\n" \" .section .fixup,\"ax\"\n" \ " .even\n" \
@@ -115,12 +131,12 @@ asm volatile ("\n" \#define __get_user_asm (res, x, ptr, type, bwl, reg, err) ({ \ type __gu_val; \ asm volatile ("\n" \ - "1: moves."#bwl" %2,%1\n" \ + "1: "MOVES"."#bwl" %2,%1\n" \ "2:\n" \ " .section .fixup,\"ax\"\n" \ " .even\n" \ "10: move.l %3,%0\n" \ - " sub."#bwl" %1,%1\n" \ + " sub.l %1,%1\n" \ " jra 2b\n" \ " .previous\n" \ "\n" \
@@ -152,8 +168,8 @@ asm volatile ("\n" \const void *__gu_ptr = (ptr); \u64 __gu_val; \ asmvolatile ("\n" \ -"1: moves.l (%2)+,%1\n" \ -"2: moves.l (%2),%R1\n" \ +"1: " MOVES ".l (%2)+,%1\n" \ +"2: " MOVES ".l (%2),%R1\n" \"3:\n" \" .section .fixup,\"ax\"\n" \ " .even\n" \
@@ -188,12 +204,12 @@ unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned#define __constant_copy_from_user_asm (res, to, from, tmp, n, s1, s2, s3)\ asm volatile ("\n" \ - "1: moves."#s1" (%2)+,%3\n" \ + "1: "MOVES"."#s1" (%2)+,%3\n" \ " move."#s1" %3,(%1)+\n" \ - "2: moves."#s2" (%2)+,%3\n" \ + "2: "MOVES"."#s2" (%2)+,%3\n" \ " move."#s2" %3,(%1)+\n" \ " .ifnc \""#s3"\",\"\"\n" \ - "3: moves."#s3" (%2)+,%3\n" \ + "3: "MOVES"."#s3" (%2)+,%3\n" \ " move."#s3" %3,(%1)+\n" \ " .endif\n" \ "4:\n" \
@@ -269,13 +285,13 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n)#define __constant_copy_to_user_asm (res, to, from, tmp, n, s1, s2, s3) \ asm volatile ("\n" \ " move."#s1" (%2)+,%3\n" \ - "11: moves."#s1" %3,(%1)+\n" \ + "11: "MOVES"."#s1" %3,(%1)+\n" \ "12: move."#s2" (%2)+,%3\n" \ - "21: moves."#s2" %3,(%1)+\n" \ + "21: "MOVES"."#s2" %3,(%1)+\n" \ "22:\n" \ " .ifnc \""#s3"\",\"\"\n" \ " move."#s3" (%2)+,%3\n" \ - "31: moves."#s3" %3,(%1)+\n" \ + "31: "MOVES"."#s3" %3,(%1)+\n" \ "32:\n" \ " .endif\n" \ "4:\n" \
arch/m68k/lib/uaccess.c +11 -11
@@ -15,17 +15,17 @@ unsigned long __generic_copy_from_user(void *to, const void __user *from, asmvolatile ("\n" " tst.l %0\n" " jeq 2f\n" -"1: moves.l (%1)+,%3\n" +"1: " MOVES ".l (%1)+,%3\n" " move.l %3,(%2)+\n" " subq.l #1,%0\n" " jne 1b\n" "2: btst #1,%5\n" " jeq 4f\n" -"3: moves.w (%1)+,%3\n" +"3: " MOVES ".w (%1)+,%3\n" " move.w %3,(%2)+\n" "4: btst #0,%5\n" " jeq 6f\n" -"5: moves.b (%1)+,%3\n" +"5: " MOVES ".b (%1)+,%3\n" " move.b %3,(%2)+\n" "6:\n" " .section .fixup,\"ax\"\n"
@@ -68,17 +68,17 @@ unsigned long __generic_copy_to_user(void __user *to, const void *from," tst.l %0\n" " jeq 4f\n" "1: move.l (%1)+,%3\n" -"2: moves.l %3,(%2)+\n" +"2: " MOVES ".l %3,(%2)+\n" "3: subq.l #1,%0\n" " jne 1b\n" "4: btst #1,%5\n" " jeq 6f\n" " move.w (%1)+,%3\n" -"5: moves.w %3,(%2)+\n" +"5: " MOVES ".w %3,(%2)+\n" "6: btst #0,%5\n" " jeq 8f\n" " move.b (%1)+,%3\n" -"7: moves.b %3,(%2)+\n" +"7: " MOVES ".b %3,(%2)+\n" "8:\n" " .section .fixup,\"ax\"\n" " .even\n"
@@ -115,7 +115,7 @@ long strncpy_from_user(char *dst, const char __user *src, long count)return count; asmvolatile ("\n" -"1: moves.b (%2)+,%4\n" +"1: " MOVES ".b (%2)+,%4\n" " move.b %4,(%1)+\n" " jeq 2f\n" " subq.l #1,%3\n"
@@ -152,7 +152,7 @@ long strnlen_user(const char __user *src, long n) asmvolatile ("\n" "1: subq.l #1,%1\n" " jmi 3f\n" -"2: moves.b (%0)+,%2\n" +"2: " MOVES ".b (%0)+,%2\n" " tst.b %2\n" " jne 1b\n" " jra 4f\n"
@@ -188,15 +188,15 @@ unsigned long __clear_user(void __user *to, unsigned long n) asmvolatile ("\n" " tst.l %0\n" " jeq 3f\n" -"1: moves.l %2,(%1)+\n" +"1: " MOVES ".l %2,(%1)+\n" "2: subq.l #1,%0\n" " jne 1b\n" "3: btst #1,%4\n" " jeq 5f\n" -"4: moves.w %2,(%1)+\n" +"4: " MOVES ".w %2,(%1)+\n" "5: btst #0,%4\n" " jeq 7f\n" -"6: moves.b %2,(%1)\n" +"6: " MOVES ".b %2,(%1)\n" "7:\n" " .section .fixup,\"ax\"\n" " .even\n"
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 06/36] m68k: modify user space access functions to support ColdFire CPUs
Quoted 23 lines · On Tue, Oct 25, 2011 at 09:18, <[email protected]> wrote:
From: Greg Ungerer <[email protected]>
Modify the user space access functions to support the ColdFire V4e cores running with MMU enabled.
The ColdFire processors do not support the "moves" instruction used by the traditional 680x0 processors for moving data into and out of another address space. They only support the notion of a single address space, and you use the usual "move" instruction to access that.
I am interrested in what others think if this approach. It is a little ugly, but it does mean that the same code is used, not a complete duplicate that is almost the same except for the "moves" instructions. It does also mean in this form that it is an either/or compile. It can't support both ColdFire and 680x0 in the same binary as it is.
Signed-off-by Greg Ungerer <[email protected]>arch/m68k/include/asm/uaccess_mm.h +5
-0+#ifdef CONFIG_COLDFIRE +/* +* The ColdFire processors do not support the moves instruction used by +* the traditional 680x0 processors for moving data into and out of +* another address space. They only support the notion of a single address
arch/m68k/include/asm/uaccess_mm.h static inline int access_ok(int type, const void __user *addr, · line 37
Quoted 10 lines
arch/m68k/include/asm/uaccess_mm.h +10
-0+* space, and you use the usual move instruction to access that. +* +* All the user space access functions are otherwise the same on ColdFire +* as the other 680x0 processors. So lets keep the code simple and just +* define in what we need to use. +*/ +#define MOVES "move" +#else +#define MOVES "moves" +#endif /* CONFIG_COLDFIRE */
I did the same thing originally when trying to get uClinux running on MMU-less Amigas, so it's fine for me.
If I'm not mistaken, this will also make it easier to merge uaccess.h again in the long run, as the version with "move" should work on all MMU-less platforms, right?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 06/36] m68k: modify user space access functions to support ColdFire CPUs
Hi Geert,
Quoted 38 lines · Geert Uytterhoeven
Quoted 23 lines · On Tue, Oct 25, 2011 at 09:18,<[email protected]> wrote:
From: Greg Ungerer<[email protected]>
Modify the user space access functions to support the ColdFire V4e cores running with MMU enabled.
The ColdFire processors do not support the "moves" instruction used by the traditional 680x0 processors for moving data into and out of another address space. They only support the notion of a single address space, and you use the usual "move" instruction to access that.
I am interrested in what others think if this approach. It is a little ugly, but it does mean that the same code is used, not a complete duplicate that is almost the same except for the "moves" instructions. It does also mean in this form that it is an either/or compile. It can't support both ColdFire and 680x0 in the same binary as it is.
Signed-off-by Greg Ungerer<[email protected]>arch/m68k/include/asm/uaccess_mm.h +5
-0+#ifdef CONFIG_COLDFIRE +/* +* The ColdFire processors do not support the moves instruction used by +* the traditional 680x0 processors for moving data into and out of +* another address space. They only support the notion of a single address arch/m68k/include/asm/uaccess_mm.h static inline int access_ok(int type, const void __user *addr, · line 37
Quoted 10 lines
arch/m68k/include/asm/uaccess_mm.h +10
-0+* space, and you use the usual move instruction to access that. +* +* All the user space access functions are otherwise the same on ColdFire +* as the other 680x0 processors. So lets keep the code simple and just +* define in what we need to use. +*/ +#define MOVES "move" +#else +#define MOVES "moves" +#endif /* CONFIG_COLDFIRE */ I did the same thing originally when trying to get uClinux running on MMU-less Amigas, so it's fine for me.
Quoted 3 lines
If I'm not mistaken, this will also make it easier to merge
uaccess.hagain in the long run, as the version with "move" should work on all MMU-less platforms, right?
Yes, very good point. I hadn't even considered then when I was trying to make this work. Another good reason to go with it :-)
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
PATCH 7/36 m68k: add ColdFire 54xx CPU MMU memory init code
In reply to [email protected]From: Greg Ungerer <[email protected]>
Add code to the 54xx ColdFire CPU init to setup memory ready for the m68k paged memory start up.
--- arch/m68k/platform/54xx/config.c | 52 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-)
arch/m68k/platform/54xx/config.c +52 -0
@@ -13,11 +13,17 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/mm.h> +#include <linux/bootmem.h> +#include <asm/pgalloc.h> #include <asm/machdep.h> #include <asm/coldfire.h> #include <asm/m54xxsim.h> #include <asm/mcfuart.h> #include <asm/m54xxgpt.h> +#ifdef CONFIG_MMU +#include <asm/mmu_context.h> +#endif /***************************************************************************/
@@ -95,8 +101,54 @@ static void mcf54xx_reset(void)/***************************************************************************/ +#ifdef CONFIG_MMU + +unsigned long num_pages; + +static void __init mcf54xx_bootmem_alloc (void ) +{ +extern unsigned int _rambase, _ramstart, _ramend; +unsigned long start_pfn; +unsigned long memstart; + +/* _rambase and _ramend will be natureally page aligned */ + m68k_memory[0 ].addr = _rambase; + m68k_memory[0 ].size = _ramend - _rambase; + +/* compute total pages in system */ + num_pages = (_ramend - _rambase) >>PAGE_SHIFT ; + +/* page numbers */ + memstart =PAGE_ALIGN (_ramstart); + min_low_pfn = _rambase >>PAGE_SHIFT ; + start_pfn = memstart >>PAGE_SHIFT ; + max_low_pfn = _ramend >>PAGE_SHIFT ; + high_memory = (void *)_ramend; + + m68k_virt_to_node_shift =fls (_ramend - _rambase -1 ) -6 ; +module_fixup (NULL , __start_fixup, __stop_fixup); + +/* setup bootmem data */ +m68k_setup_node (0 ); + memstart +=init_bootmem_node (NODE_DATA (0 ), start_pfn, + min_low_pfn, max_low_pfn); +free_bootmem_node (NODE_DATA (0 ), memstart, _ramend - memstart); +} + +#endif /* CONFIG_MMU */ + +/***************************************************************************/ +void __init config_BSP (char *commandp,int size) { +#ifdef CONFIG_MMU + m68k_cputype =CPU_COLDFIRE ; + m68k_fputype =FPU_COLDFIRE ; + m68k_mmutype =MMU_COLDFIRE ; + m68k_machtype =MACH_M54XX ; +mcf54xx_bootmem_alloc (); +mmu_context_init (); +#endif mach_reset = mcf54xx_reset;m54xx_uarts_init (); }
Signature · 1 line
1.7.0.4
PATCH 8/36 m68k: init the MMU hardware for the 54xx ColdFire
In reply to [email protected]From: Greg Ungerer <[email protected]>
If we want to run with the MMU enabled on the 54xx ColdFire CPUs then we need to initialize it at startup. We also need to reserve some space for the kernel's page table directory.
--- arch/m68k/platform/coldfire/head.S | 38 +++++++++++++++++++++++++++++++++++- 1 files changed, 37 insertions(+), 1 deletions(-)
arch/m68k/platform/coldfire/head.S +37 -1
@@ -3,7 +3,7 @@ /* * head.S -- common startup code for ColdFire CPUs. * - * (C) Copyright 1999-2010, Greg Ungerer <[email protected]>. + * (C) Copyright 1999-2011, Greg Ungerer <[email protected]>. */ /*****************************************************************************/
@@ -13,6 +13,7 @@ #include <asm/asm-offsets.h> #include <asm/coldfire.h> #include <asm/mcfsim.h> +#include <asm/mcfmmu.h> #include <asm/thread_info.h> /*****************************************************************************/
@@ -135,6 +136,14 @@ _init_sp: __HEAD +#ifdef CONFIG_MMU +_start0: + jmp _start +.global kernel_pg_dir +.equ kernel_pg_dir,_start0 +.equ .,_start0+0x1000 +#endif + /* * This is the codes first entry point. This is where it all * begins...
@@ -193,6 +202,26 @@ _start: movec %d0,%CACR nop +#ifdef CONFIG_MMU + /* + * Identity mapping for the kernel region. + */ + movel #(MMUBASE+1),%d0 /* enable MMUBAR registers */ + movec %d0,%MMUBAR + movel #MMUOR_CA,%d0 /* clear TLB entries */ + movel %d0,MMUOR + movel #0,%d0 /* set ASID to 0 */ + movec %d0,%asid + + movel #MMUCR_EN,%d0 /* Enable the identity map */ + movel %d0,MMUCR + nop /* sync i-pipeline */ + + movel #_vstart,%a0 /* jump to "virtual" space */ + jmp %a0@ +_vstart: +#endif /* CONFIG_MMU */ + #ifdef CONFIG_ROMFS_FS /* * Move ROM filesystem above bss :-)
@@ -238,6 +267,13 @@ _clear_bss: lea init_thread_union,%a0 lea THREAD_SIZE(%a0),%sp +#ifdef CONFIG_MMU +.global m68k_machtype + movel #MACH_M54XX,%d0 + movel %d0,m68k_machtype /* Mark us as a ColdFire */ + lea init_task,%a2 /* Set "current" init task */ +#endif + /* * Assember start up done, start code proper. */
Signature · 1 line
1.7.0.4
PATCH 9/36 m68k: set register a2 to current if MMU enabled on ColdFire
In reply to [email protected]From: Greg Ungerer <[email protected]>
Virtual memory m68k systems build with register a2 dedicated to being the current proc pointer. Add code to the ColdFire interrupt and exception processing to set this on entry, and also at context switch time.
--- arch/m68k/kernel/entry_no.S | 24 ++++++++++++++++++------ arch/m68k/platform/coldfire/entry.S | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 7 deletions(-)
arch/m68k/kernel/entry_no.S +18 -6
@@ -44,8 +44,12 @@ ENTRY(buserr) SAVE_ALL_INT - moveq #-1,%d0 - movel %d0,%sp@(PT_OFF_ORIG_D0) +#ifdef CONFIG_MMU + movel %sp,%d0 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d0 /* at start of kernel stack */ + movel %d0,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif movel %sp,%sp@- /* stack frame pointer argument */ jsr buserr_c addql #4,%sp
@@ -53,8 +57,12 @@ ENTRY(buserr) ENTRY(trap) SAVE_ALL_INT - moveq #-1,%d0 - movel %d0,%sp@(PT_OFF_ORIG_D0) +#ifdef CONFIG_MMU + movel %sp,%d0 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d0 /* at start of kernel stack */ + movel %d0,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif movel %sp,%sp@- /* stack frame pointer argument */ jsr trap_c addql #4,%sp
@@ -65,8 +73,12 @@ ENTRY(trap) .globl dbginterrupt ENTRY(dbginterrupt) SAVE_ALL_INT - moveq #-1,%d0 - movel %d0,%sp@(PT_OFF_ORIG_D0) +#ifdef CONFIG_MMU + movel %sp,%d0 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d0 /* at start of kernel stack */ + movel %d0,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif movel %sp,%sp@- /* stack frame pointer argument */ jsr dbginterrupt_c addql #4,%sp
arch/m68k/platform/coldfire/entry.S +17 -1
@@ -63,6 +63,13 @@ ENTRY(system_call) SAVE_ALL_SYS move #0x2000,%sr /* enable intrs again */ +#ifdef CONFIG_MMU + movel %sp,%d2 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d2 /* at start of kernel stack */ + movel %d2,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif + cmpl #NR_syscalls,%d0 jcc enosys lea sys_call_table,%a0
@@ -166,6 +173,13 @@ Lsignal_return: ENTRY(inthandler) SAVE_ALL_INT +#ifdef CONFIG_MMU + movel %sp,%d2 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d2 /* at start of kernel stack */ + movel %d2,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif + movew %sp@(PT_OFF_FORMATVEC),%d0 /* put exception # in d0 */ andl #0x03fc,%d0 /* mask out vector only */
@@ -190,7 +204,9 @@ ENTRY(resume) movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack pointer */ RDUSP /* movel %usp,%a3 */ movel %a3,%a0@(TASK_THREAD+THREAD_USP) /* save thread user stack */ - +#ifdef CONFIG_MMU + movel %a1,%a2 /* set new current */ +#endif movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore thread user stack */ WRUSP /* movel %a3,%usp */ movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new kernel stack */
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 09/36] m68k: set register a2 to current if MMU enabled on ColdFire
Quoted 19 lines · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
From: Greg Ungerer <[email protected]>
Virtual memory m68k systems build with register a2 dedicated to being the current proc pointer. Add code to the ColdFire interrupt and exception processing to set this on entry, and also at context switch time.
Signed-off-by Greg Ungerer <[email protected]>---
arch/m68k/kernel/entry_no.S | 24 ++++++++++++++++++------arch/m68k/platform/coldfire/entry.S| 18 +++++++++++++++++-2 files changed, 35 insertions(+), 7 deletions(-)arch/m68k/kernel/entry_no.S +0
-0@@ -44,8 +44,12 @@ ENTRY(buserr)
Quoted 3 lines
SAVE_ALL_INT
- moveq #-1,%d0
- movel %d0,%sp@(PT_OFF_ORIG_D0)
Don't you need the above anymore, at least on nommu?
Quoted 12 lines
arch/m68k/kernel/entry_no.S +6
-0+#ifdef CONFIG_MMU + movel %sp,%d0 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d0 /* at start of kernel stack */ + movel %d0,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endifmovel %sp,%sp@- /* stack frame pointer argument */ jsr
buserr_c
addql #4,%sparch/m68k/kernel/entry_no.S +0
-0@@ -53,8 +57,12 @@ ENTRY(buserr) ENTRY(trap)
Quoted 3 lines
SAVE_ALL_INT
- moveq #-1,%d0
- movel %d0,%sp@(PT_OFF_ORIG_D0)
Same here.
Quoted 64 lines
arch/m68k/kernel/entry_no.S +6
-0+#ifdef CONFIG_MMU + movel %sp,%d0 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d0 /* at start of kernel stack */ + movel %d0,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endifmovel %sp,%sp@- /* stack frame pointer argument */ jsr
trap_c
addql #4,%sparch/m68k/kernel/entry_no.S +0
-0@@ -65,8 +73,12 @@ ENTRY(trap).globl dbginterrupt
ENTRY(dbginterrupt)
SAVE_ALL_INT
- moveq #-1,%d0
- movel %d0,%sp@(PT_OFF_ORIG_D0)arch/m68k/kernel/entry_no.S +6
-0+#ifdef CONFIG_MMU + movel %sp,%d0 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d0 /* at start of kernel stack */ + movel %d0,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endifmovel %sp,%sp@- /* stack frame pointer argument */ jsr
dbginterrupt_c
addql #4,%sparch/m68k/platform/coldfire/entry.S +0
-0@@ -63,6 +63,13 @@ ENTRY(system_call)SAVE_ALL_SYS
move #0x2000,%sr /* enable intrs again */arch/m68k/platform/coldfire/entry.S +7
-0+#ifdef CONFIG_MMU + movel %sp,%d2 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d2 /* at start of kernel stack */ + movel %d2,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif +cmpl #NR_syscalls,%d0
jcc enosys
lea sys_call_table,%a0arch/m68k/platform/coldfire/entry.S +0
-0@@ -166,6 +173,13 @@ Lsignal_return: ENTRY(inthandler)SAVE_ALL_INT
arch/m68k/platform/coldfire/entry.S +7
-0+#ifdef CONFIG_MMU + movel %sp,%d2 /* get thread_info pointer */ + andl #-THREAD_SIZE,%d2 /* at start of kernel stack */ + movel %d2,%a2 + movel %a2@,%a2 /* current pointer into a2 */ +#endif +movew %sp@(PT_OFF_FORMATVEC),%d0 /* put exception # in d0 */ andl #0x03fc,%d0 /* mask out vector only */
arch/m68k/platform/coldfire/entry.S +0
-0@@ -190,7 +204,9 @@ ENTRY(resume)movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack pointer */ RDUSP /* movel %usp,%a3 */ movel %a3,%a0@(TASK_THREAD+THREAD_USP) /* save thread user stack */
arch/m68k/platform/coldfire/entry.S +3
-1- +#ifdef CONFIG_MMU + movel %a1,%a2 /* set new current */ +#endif
Quoted 3 lines
movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore thread user stack */ WRUSP /* movel %a3,%usp */ movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new kernel stack */
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 09/36] m68k: set register a2 to current if MMU enabled on ColdFire
Hi Geert,
Quoted 19 lines · Geert Uytterhoeven
Quoted 18 lines · On Tue, Oct 25, 2011 at 09:19,<[email protected]> wrote:
From: Greg Ungerer<[email protected]>
Virtual memory m68k systems build with register a2 dedicated to being the current proc pointer. Add code to the ColdFire interrupt and exception processing to set this on entry, and also at context switch time.
Signed-off-by Greg Ungerer<[email protected]>---
arch/m68k/kernel/entry_no.S24 ++++++++++++++++++------arch/m68k/platform/coldfire/entry.S| 18 +++++++++++++++++-2 files changed, 35 insertions(+), 7 deletions(-)arch/m68k/kernel/entry_no.S +0
-0@@ -44,8 +44,12 @@
Quoted 6 lines
arch/m68k/kernel/entry_no.S line 48
Quoted 4 lines
arch/m68k/kernel/entry_no.S +0
-2ENTRY(buserr) SAVE_ALL_INT - moveq #-1,%d0 - movel %d0,%sp@(PT_OFF_ORIG_D0)Don't you need the above anymore, at least on nommu?
Yes it is needed, but it is done in the SAVE_ALL_INT macro now. That was done in commit 61619b12078dc8b85a3d4cbfa16f650daa341bd1 ("m68k: merge mmu and non-mmu include/asm/entry.h files").
It sure has nothing to do with the a2 work that the patch description says above :) I'll move this change into a separate patch with appropriate comments.
Regards
Greg
Quoted 99 lines
Quoted 12 lines
arch/m68k/kernel/entry_no.S +6
-0+#ifdef CONFIG_MMU + á á á movel á %sp,%d0 á á á á á á á á /* get thread_info pointer */ + á á á andl á á#-THREAD_SIZE,%d0 á á á /* at start of kernel stack */ + á á á movel á %d0,%a2 + á á á movel á %a2@,%a2 á á á á á á á á/* current pointer into a2 */ +#endifá á á ámovel á %sp,%sp@- á á á á á á á /* stack frame pointer argument */ á á á ájsr á á
buserr_c
á á á áaddql á #4,%sparch/m68k/kernel/entry_no.S +0
-0@@ -53,8 +57,12 @@ ENTRY(buserr) áENTRY(trap)Quoted 3 lines
á á á áSAVE_ALL_INT
- á á á moveq á #-1,%d0
- á á á movel á %d0,%sp@(PT_OFF_ORIG_D0)Same here.
Quoted 64 lines
arch/m68k/kernel/entry_no.S +6
-0+#ifdef CONFIG_MMU + á á á movel á %sp,%d0 á á á á á á á á /* get thread_info pointer */ + á á á andl á á#-THREAD_SIZE,%d0 á á á /* at start of kernel stack */ + á á á movel á %d0,%a2 + á á á movel á %a2@,%a2 á á á á á á á á/* current pointer into a2 */ +#endifá á á ámovel á %sp,%sp@- á á á á á á á /* stack frame pointer argument */ á á á ájsr á á
trap_c
á á á áaddql á #4,%sparch/m68k/kernel/entry_no.S +0
-0@@ -65,8 +73,12 @@ ENTRY(trap)á.globl dbginterrupt
áENTRY(dbginterrupt)
á á á áSAVE_ALL_INT
- á á á moveq á #-1,%d0
- á á á movel á %d0,%sp@(PT_OFF_ORIG_D0)arch/m68k/kernel/entry_no.S +6
-0+#ifdef CONFIG_MMU + á á á movel á %sp,%d0 á á á á á á á á /* get thread_info pointer */ + á á á andl á á#-THREAD_SIZE,%d0 á á á /* at start of kernel stack */ + á á á movel á %d0,%a2 + á á á movel á %a2@,%a2 á á á á á á á á/* current pointer into a2 */ +#endifá á á ámovel á %sp,%sp@- á á á á á á á /* stack frame pointer argument */ á á á ájsr á á
dbginterrupt_c
á á á áaddql á #4,%sparch/m68k/platform/coldfire/entry.S +0
-0@@ -63,6 +63,13 @@ ENTRY(system_call)á á á áSAVE_ALL_SYS
á á á ámove á á#0x2000,%sr á á á á á á /* enable intrs again */arch/m68k/platform/coldfire/entry.S +7
-0+#ifdef CONFIG_MMU + á á á movel á %sp,%d2 á á á á á á á á /* get thread_info pointer */ + á á á andl á á#-THREAD_SIZE,%d2 á á á /* at start of kernel stack */ + á á á movel á %d2,%a2 + á á á movel á %a2@,%a2 á á á á á á á á/* current pointer into a2 */ +#endif +á á á ácmpl á á#NR_syscalls,%d0
á á á ájcc á á enosys
á á á álea á á sys_call_table,%a0arch/m68k/platform/coldfire/entry.S +0
-0@@ -166,6 +173,13 @@ Lsignal_return: áENTRY(inthandler)á á á áSAVE_ALL_INT
arch/m68k/platform/coldfire/entry.S +7
-0+#ifdef CONFIG_MMU + á á á movel á %sp,%d2 á á á á á á á á /* get thread_info pointer */ + á á á andl á á#-THREAD_SIZE,%d2 á á á /* at start of kernel stack */ + á á á movel á %d2,%a2 + á á á movel á %a2@,%a2 á á á á á á á á/* current pointer into a2 */ +#endif +á á á ámovew á %sp@(PT_OFF_FORMATVEC),%d0 /* put exception # in d0 */ á á á áandl á á#0x03fc,%d0 á á á á á á /* mask out vector only */
arch/m68k/platform/coldfire/entry.S +0
-0@@ -190,7 +204,9 @@ ENTRY(resume)á á á ámovel á %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack pointer */ á á á áRDUSP á á á á á á á á á á á á á á á á á á/* movel %usp,%a3 */ á á á ámovel á %a3,%a0@(TASK_THREAD+THREAD_USP) /* save thread user stack */
arch/m68k/platform/coldfire/entry.S +3
-1- +#ifdef CONFIG_MMU + á á á movel á %a1,%a2 á á á á á á á á á á á á á/* set new current */ +#endifQuoted 3 lines
á á á ámovel á %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore thread user stack */ á á á áWRUSP á á á á á á á á á á á á á á á á á á/* movel %a3,%usp */ á á á ámovel á %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new kernel stack */
Gr{oetje,eeting}s,
á á á á á á á á á á á á Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. á á á á á á á á á á á á á áá áá -- Linus Torvalds
Signature · 5 lines
------------------------------------------------------------------------ Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
PATCH 10/36 m68k: page table support definitions and code for ColdFire MMU
In reply to [email protected]From: Greg Ungerer <[email protected]>
The ColdFire V4e MMU is nothing line any of the other m68k MMU's. So we need to create a set of definitions and support routines for kernel's paging functions.
This is largely taken from Freescales BSP code for this (though it was a 2.6.25 kernel). I have done some cleanups, and it probably needs a little more.
--- arch/m68k/include/asm/mcf_pgtable.h | 380 +++++++++++++++++++++++++++++++++++ 1 files changed, 380 insertions(+), 0 deletions(-) create mode 100644 arch/m68k/include/asm/mcf_pgtable.h
arch/m68k/include/asm/mcf_pgtable.h new file +380 -0
@@ -0,0 +1,380 @@ +#ifndef CF_PGTABLE_H +#define CF_PGTABLE_H + +#include <asm/mcfmmu.h> +#include <asm/page.h> + +#ifndef __ASSEMBLY__ +#include <linux/linkage.h> +#include <asm/virtconvert.h> + +/* +* For virtual address to physical address conversion. +*/ +#define VTOP (addr) __pa(addr) +#define PTOV (addr) __va(addr) + +#endif /* !__ASSEMBLY__ */ + +/* +* Page protection values within PTE. +*/ + +/* +* MMUDR bits, in proper place. +*/ +#define CF_PAGE_LOCKED 0x00000002 +#define CF_PAGE_EXEC 0x00000004 +#define CF_PAGE_WRITABLE 0x00000008 +#define CF_PAGE_READABLE 0x00000010 +#define CF_PAGE_SYSTEM 0x00000020 +#define CF_PAGE_COPYBACK 0x00000040 +#define CF_PAGE_NOCACHE 0x00000080 + +#define CF_CACHEMASK (~0x00000040) +#define CF_PAGE_MMUDR_MASK 0x000000fe + +#define _PAGE_NOCACHE030 CF_PAGE_NOCACHE + +/* +* MMUTR bits, need shifting down. +*/ +#define CF_PAGE_VALID 0x00000400 +#define CF_PAGE_SHARED 0x00000800 + +#define CF_PAGE_MMUTR_MASK 0x00000c00 +#define CF_PAGE_MMUTR_SHIFT 10 +#define CF_ASID_MMU_SHIFT 2 + +/* +* Fake bits, not implemented in CF, will get masked out before +* hitting hardware, and might go away altogether once this port is +* complete. +*/ +#if PAGE_SHIFT <13 +#error COLDFIRE Error: Pages must be at least 8k in size +#endif +#define CF_PAGE_ACCESSED 0x00001000 +#define CF_PAGE_FILE 0x00000200 +#define CF_PAGE_DIRTY 0x00000001 + +#define _PAGE_CACHE040 0x020/* 68040 cache mode, cachable, copyback */ +#define _PAGE_NOCACHE_S 0x040/* 68040 no-cache mode, serialized */ +#define _PAGE_NOCACHE 0x060/* 68040 cache mode, non-serialized */ +#define _PAGE_CACHE040W 0x000/* 68040 cache mode, cachable, write-through */ +#define _DESCTYPE_MASK 0x003 +#define _CACHEMASK040 (~0x060) +#define _PAGE_GLOBAL040 0x400/* 68040 global bit, used for kva descs */ + +/* +* Externally used page protection values. +*/ +#define _PAGE_PRESENT (CF_PAGE_VALID) +#define _PAGE_ACCESSED (CF_PAGE_ACCESSED) +#define _PAGE_DIRTY (CF_PAGE_DIRTY) +#define _PAGE_READWRITE (CF_PAGE_WRITABLE \ + | CF_PAGE_READABLE \ + | CF_PAGE_SYSTEM \ + | CF_PAGE_SHARED) + +/* Compound page protection values. */ +#define PAGE_NONE __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED) + +#define PAGE_SHARED __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED) + +#define PAGE_INIT __pgprot(CF_PAGE_VALID \ + | CF_PAGE_WRITABLE \ + | CF_PAGE_READABLE \ + | CF_PAGE_EXEC \ + | CF_PAGE_SYSTEM \ + | CF_PAGE_SHARED) + +#define PAGE_KERNEL __pgprot(CF_PAGE_VALID \ + | CF_PAGE_WRITABLE \ + | CF_PAGE_READABLE \ + | CF_PAGE_EXEC \ + | CF_PAGE_SYSTEM \ + | CF_PAGE_SHARED \ + | CF_PAGE_ACCESSED) + +#define PAGE_COPY __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_READABLE \ + | CF_PAGE_DIRTY) + +/* +* Page protections for initialising protection_map. See mm/mmap.c +* for use. In general, the bit positions are xwr, and P-items are +* private, the S-items are shared. +*/ + +#define __P000 PAGE_NONE +#define __P100 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_EXEC) +#define __P010 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_WRITABLE \ + | CF_PAGE_ACCESSED) +#define __P110 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_WRITABLE \ + | CF_PAGE_EXEC) +#define __P001 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_READABLE) +#define __P101 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_READABLE \ + | CF_PAGE_EXEC) +#define __P011 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_READABLE \ + | CF_PAGE_WRITABLE \ + | CF_PAGE_ACCESSED) +#define __P111 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_WRITABLE \ + | CF_PAGE_READABLE \ + | CF_PAGE_EXEC) + +#define __S000 PAGE_NONE +#define __S100 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED \ + | CF_PAGE_EXEC) +#define __S010 PAGE_SHARED +#define __S110 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED \ + | CF_PAGE_EXEC) +#define __S001 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED \ + | CF_PAGE_READABLE) +#define __S101 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED \ + | CF_PAGE_READABLE \ + | CF_PAGE_EXEC) +#define __S011 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED \ + | CF_PAGE_READABLE) +#define __S111 __pgprot(CF_PAGE_VALID \ + | CF_PAGE_ACCESSED \ + | CF_PAGE_SHARED \ + | CF_PAGE_READABLE \ + | CF_PAGE_EXEC) + +#define PTE_MASK PAGE_MASK +#define CF_PAGE_CHG_MASK (PTE_MASK | CF_PAGE_ACCESSED | CF_PAGE_DIRTY) + +#ifndef __ASSEMBLY__ + +/* +* Conversion functions: convert a page and protection to a page entry, +* and a page entry and page directory to the page they refer to. +*/ +#define mk_pte (page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) + +static inline pte_t pte_modify (pte_t pte,pgprot_t newprot) +{ +pte_val (pte) = (pte_val (pte) &CF_PAGE_CHG_MASK ) |pgprot_val (newprot); +return pte; +} + +#define pmd_set (pmdp, ptep) do {} while (0) + +static inline void pgd_set (pgd_t *pgdp,pmd_t *pmdp) +{ +pgd_val (*pgdp) =virt_to_phys (pmdp); +} + +#define __pte_page (pte) \ + ((unsigned long) ((pte_val(pte) & CF_PAGE_PGNUM_MASK) + PAGE_OFFSET)) +#define __pmd_page (pmd) ((unsigned long) (pmd_val(pmd))) + +static inline int pte_none (pte_t pte) +{ +return !pte_val (pte); +} +static inline int pte_present (pte_t pte) +{ +return pte_val (pte) &CF_PAGE_VALID ; +} +static inline void pte_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep) +{ +pte_val (*ptep) =0 ; +} + +#define pte_pagenr (pte) ((__pte_page(pte) - PAGE_OFFSET) >> PAGE_SHIFT) +#define pte_page (pte) virt_to_page(__pte_page(pte)) + +static inline int pmd_none2 (pmd_t *pmd) {return !pmd_val (*pmd); } +#define pmd_none (pmd) pmd_none2(&(pmd)) +static inline int pmd_bad2 (pmd_t *pmd) {return 0 ; } +#define pmd_bad (pmd) pmd_bad2(&(pmd)) +#define pmd_present (pmd) (!pmd_none2(&(pmd))) +static inline void pmd_clear (pmd_t *pmdp) {pmd_val (*pmdp) =0 ; } + +static inline int pgd_none (pgd_t pgd) {return 0 ; } +static inline int pgd_bad (pgd_t pgd) {return 0 ; } +static inline int pgd_present (pgd_t pgd) {return 1 ; } +static inline void pgd_clear (pgd_t *pgdp) {} + +#define pte_ERROR (e) \ + printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \ + __FILE__, __LINE__, pte_val(e)) +#define pmd_ERROR (e) \ + printk(KERN_ERR "%s:%d: bad pmd %08lx.\n", \ + __FILE__, __LINE__, pmd_val(e)) +#define pgd_ERROR (e) \ + printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \ + __FILE__, __LINE__, pgd_val(e)) + +/* +* The following only work if pte_present() is true. +* Undefined behaviour if not... +* [we have the full set here even if they don't change from m68k] +*/ +static inline int pte_read (pte_t pte) \ + {return pte_val (pte) &CF_PAGE_READABLE ; } +static inline int pte_write (pte_t pte) \ + {return pte_val (pte) &CF_PAGE_WRITABLE ; } +static inline int pte_exec (pte_t pte) \ + {return pte_val (pte) &CF_PAGE_EXEC ; } +static inline int pte_dirty (pte_t pte) \ + {return pte_val (pte) &CF_PAGE_DIRTY ; } +static inline int pte_young (pte_t pte) \ + {return pte_val (pte) &CF_PAGE_ACCESSED ; } +static inline int pte_file (pte_t pte) \ + {return pte_val (pte) &CF_PAGE_FILE ; } +static inline int pte_special (pte_t pte) \ + {return 0 ; } + +static inline pte_t pte_wrprotect (pte_t pte) \ + {pte_val (pte) &= ~CF_PAGE_WRITABLE ;return pte; } +static inline pte_t pte_rdprotect (pte_t pte) \ + {pte_val (pte) &= ~CF_PAGE_READABLE ;return pte; } +static inline pte_t pte_exprotect (pte_t pte) \ + {pte_val (pte) &= ~CF_PAGE_EXEC ;return pte; } +static inline pte_t pte_mkclean (pte_t pte) \ + {pte_val (pte) &= ~CF_PAGE_DIRTY ;return pte; } +static inline pte_t pte_mkold (pte_t pte) \ + {pte_val (pte) &= ~CF_PAGE_ACCESSED ;return pte; } +static inline pte_t pte_mkwrite (pte_t pte) \ + {pte_val (pte) |=CF_PAGE_WRITABLE ;return pte; } +static inline pte_t pte_mkread (pte_t pte) \ + {pte_val (pte) |=CF_PAGE_READABLE ;return pte; } +static inline pte_t pte_mkexec (pte_t pte) \ + {pte_val (pte) |=CF_PAGE_EXEC ;return pte; } +static inline pte_t pte_mkdirty (pte_t pte) \ + {pte_val (pte) |=CF_PAGE_DIRTY ;return pte; } +static inline pte_t pte_mkyoung (pte_t pte) \ + {pte_val (pte) |=CF_PAGE_ACCESSED ;return pte; } +static inline pte_t pte_mknocache (pte_t pte) \ + {pte_val (pte) |=0x80 | (pte_val (pte) & ~0x40 );return pte; } +static inline pte_t pte_mkcache (pte_t pte) \ + {pte_val (pte) &= ~CF_PAGE_NOCACHE ;return pte; } +static inline pte_t pte_mkspecial (pte_t pte) \ + {return pte; } + +#define swapper_pg_dir kernel_pg_dir +extern pgd_t kernel_pg_dir[PTRS_PER_PGD ]; + +/* +* Find an entry in a pagetable directory. +*/ +#define pgd_index (address) ((address) >> PGDIR_SHIFT) + +#define pgd_offset (mm, address) ((mm)->pgd + pgd_index(address)) + +/* +* Find an entry in a kernel pagetable directory. +*/ +#define pgd_offset_k (address) pgd_offset(&init_mm, address) + +/* +* Find an entry in the second-level pagetable. +*/ +static inline pmd_t *pmd_offset (pgd_t *pgd,unsigned long address) +{ +return (pmd_t *) pgd; +} + +/* +* Find an entry in the third-level pagetable. +*/ +#define __pte_offset (address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) +#define pte_offset_kernel (dir, address) ((pte_t *) __pmd_page(*(dir)) + \ + __pte_offset(address)) + +/* +* Disable caching for page at given kernel virtual address. +*/ +static inline void nocache_page (void *vaddr) +{ +pgd_t *dir; +pmd_t *pmdp; +pte_t *ptep; +unsigned long addr = (unsigned long ) vaddr; + + dir =pgd_offset_k (addr); + pmdp =pmd_offset (dir, addr); + ptep =pte_offset_kernel (pmdp, addr); + *ptep =pte_mknocache (*ptep); +} + +/* +* Enable caching for page at given kernel virtual address. +*/ +static inline void cache_page (void *vaddr) +{ +pgd_t *dir; +pmd_t *pmdp; +pte_t *ptep; +unsigned long addr = (unsigned long ) vaddr; + + dir =pgd_offset_k (addr); + pmdp =pmd_offset (dir, addr); + ptep =pte_offset_kernel (pmdp, addr); + *ptep =pte_mkcache (*ptep); +} + +#define PTE_FILE_MAX_BITS 21 +#define PTE_FILE_SHIFT 11 + +static inline unsigned long pte_to_pgoff (pte_t pte) +{ +return pte_val (pte) >>PTE_FILE_SHIFT ; +} + +static inline pte_t pgoff_to_pte (unsigned pgoff) +{ +return __pte ((pgoff <<PTE_FILE_SHIFT ) +CF_PAGE_FILE ); +} + +/* +* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) +*/ +#define __swp_entry (type, offset) ((swp_entry_t) { (type) | \ + (offset << PTE_FILE_SHIFT) }) +#define __swp_type (x) ((x).val & 0xFF) +#define __swp_offset (x) ((x).val >> PTE_FILE_SHIFT) +#define __pte_to_swp_entry (pte) ((swp_entry_t) { pte_val(pte) }) +#define __swp_entry_to_pte (x) (__pte((x).val)) + +#define pmd_page (pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) + +#define pte_offset_map (pmdp, address) ((pte_t *)__pmd_page(*pmdp) + \ + __pte_offset(address)) +#define pte_unmap (pte) ((void)0) + +#define pfn_pte (pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) +#define pte_pfn (pte) (pte_val(pte) >> PAGE_SHIFT) + +#endif /* !__ASSEMBLY__ */ +#endif /* CF_PGTABLE_H */
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 10/36] m68k: page table support definitions and code for ColdFire MMU
Quoted 1 line · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
The ColdFire V4e MMU is nothing line any of the other m68k MMU's.
s/line/like/
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 11/36 m68k: add page table size definitions for ColdFire V4e MMU
In reply to [email protected]From: Greg Ungerer <[email protected]>
Define the page table size and attributes for the ColdFire V4e MMU. Also setup the vmalloc and kmap regions we will use.
--- arch/m68k/include/asm/pgtable_mm.h | 30 ++++++++++++++++++++++++------ 1 files changed, 24 insertions(+), 6 deletions(-)
arch/m68k/include/asm/pgtable_mm.h +24 -6
@@ -40,6 +40,8 @@/* PGDIR_SHIFT determines what a third-level page table entry can map */ #ifdef CONFIG_SUN3 #define PGDIR_SHIFT 17 +#elif defined(CONFIG_COLDFIRE ) +#define PGDIR_SHIFT 22#else #define PGDIR_SHIFT 25#endif
@@ -54,6 +56,10 @@#define PTRS_PER_PTE 16#define PTRS_PER_PMD 1#define PTRS_PER_PGD 2048 +#elif defined(CONFIG_COLDFIRE ) +#define PTRS_PER_PTE 512 +#define PTRS_PER_PMD 1 +#define PTRS_PER_PGD 1024#else #define PTRS_PER_PTE 1024#define PTRS_PER_PMD 8
@@ -66,12 +72,22 @@#ifdef CONFIG_SUN3 #define KMAP_START 0x0DC00000#define KMAP_END 0x0E000000 +#elif defined(CONFIG_COLDFIRE ) +#define KMAP_START 0xd0000000 +#define KMAP_END 0xe0000000#else #define KMAP_START 0xd0000000#define KMAP_END 0xf0000000#endif -#ifndef CONFIG_SUN3 +#ifdef CONFIG_SUN3 +extern unsigned long m68k_vmalloc_end; +#define VMALLOC_START 0x0f800000 +#define VMALLOC_END m68k_vmalloc_end +#elif defined(CONFIG_COLDFIRE ) +#define VMALLOC_START 0xc0000000 +#define VMALLOC_END 0xcfffffff +#else /* Just any arbitrary offset to the start of the vmalloc VM area: the * current 8MB value just means that there will be a 8MB "hole" after the * physical memory until the kernel virtual memory starts. That means that
@@ -82,11 +98,7 @@#define VMALLOC_OFFSET (8*1024*1024)#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))#define VMALLOC_END KMAP_START -#else -extern unsigned long m68k_vmalloc_end; -#define VMALLOC_START 0x0f800000 -#define VMALLOC_END m68k_vmalloc_end -#endif /* CONFIG_SUN3 */ +#endif /* zero page used for uninitialized stuff */ extern void *empty_zero_page;
@@ -130,6 +142,8 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,#ifdef CONFIG_SUN3 #include <asm/sun3_pgtable.h> +#elif defined(CONFIG_COLDFIRE ) +#include <asm/mcf_pgtable.h> #else #include <asm/motorola_pgtable.h> #endif
@@ -138,6 +152,9 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,/* * Macro to mark a page protection value as "uncacheable". */ +#ifdef CONFIG_COLDFIRE +# define pgprot_noncached (prot) (__pgprot(pgprot_val(prot) | CF_PAGE_NOCACHE)) +#else #ifdef SUN3_PAGE_NOCACHE # define __SUN3_PAGE_NOCACHE SUN3_PAGE_NOCACHE#else
@@ -152,6 +169,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma, ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \ : (prot))) +#endif /* CONFIG_COLDFIRE */ #include <asm-generic/pgtable.h> #endif /* !__ASSEMBLY__ */
Signature · 1 line
1.7.0.4
PATCH 12/36 m68k: add ColdFire paging exception handling code
In reply to [email protected]From: Greg Ungerer <[email protected]>
Add code to traps.c to handle MMU exceptions for the ColdFire. Most of this code is from the 2.6.25 kernel BSP code released by Freescale.
--- arch/m68k/kernel/traps.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 104 insertions(+), 0 deletions(-)
arch/m68k/kernel/traps.c +104 -0
@@ -706,8 +706,94 @@ create_atc_entry:#endif /* CPU_M68020_OR_M68030 */ #endif /* !CONFIG_SUN3 */ +#if defined(CONFIG_COLDFIRE ) && defined(CONFIG_MMU ) +#include <asm/mcfmmu.h> + +/* +* The following table converts the FS encoding of a ColdFire +* exception stack frame into the error_code value needed by +* do_fault. +*/ +static const unsigned char fs_err_code[] = { +0 ,/* 0000 */ +0 ,/* 0001 */ +0 ,/* 0010 */ +0 ,/* 0011 */ +1 ,/* 0100 */ +0 ,/* 0101 */ +0 ,/* 0110 */ +0 ,/* 0111 */ +2 ,/* 1000 */ +3 ,/* 1001 */ +2 ,/* 1010 */ +0 ,/* 1011 */ +1 ,/* 1100 */ +1 ,/* 1101 */ +0 ,/* 1110 */ +0 /* 1111 */ +}; + +static inline void access_errorcf (unsigned int fs,struct frame *fp) +{ +unsigned long int mmusr, complainingAddress; +unsigned int err_code; +int need_page_fault; + + mmusr =mmu_read (MMUSR ); + complainingAddress =mmu_read (MMUAR ); + +/* +* error_code: +* bit 0 == 0 means no page found, 1 means protection fault +* bit 1 == 0 means read, 1 means write +*/ +switch (fs) { +case 5 :/* 0101 TLB opword X miss */ + need_page_fault =cf_tlb_miss (&fp->ptregs,0 ,0 ,0 ); + complainingAddress = fp->ptregs.pc; +break ; +case 6 :/* 0110 TLB extension word X miss */ + need_page_fault =cf_tlb_miss (&fp->ptregs,0 ,0 ,1 ); + complainingAddress = fp->ptregs.pc +sizeof (long ); +break ; +case 10 :/* 1010 TLB W miss */ + need_page_fault =cf_tlb_miss (&fp->ptregs,1 ,1 ,0 ); +break ; +case 14 :/* 1110 TLB R miss */ + need_page_fault =cf_tlb_miss (&fp->ptregs,0 ,1 ,0 ); +break ; +default : +/* 0000 Normal */ +/* 0001 Reserved */ +/* 0010 Interrupt during debug service routine */ +/* 0011 Reserved */ +/* 0100 X Protection */ +/* 0111 IFP in emulator mode */ +/* 1000 W Protection*/ +/* 1001 Write error*/ +/* 1011 Reserved*/ +/* 1100 R Protection*/ +/* 1101 R Protection*/ +/* 1111 OEP in emulator mode*/ + need_page_fault =1 ; +break ; + } + +if (need_page_fault) { + err_code = fs_err_code[fs]; +if ((fs ==13 ) && (mmusr &MMUSR_WF ))/* rd-mod-wr access */ + err_code |=2 ;/* bit1 - write, bit0 - protection */ +do_page_fault (&fp->ptregs, complainingAddress, err_code); + } +} +#endif /* CONFIG_COLDFIRE CONFIG_MMU */ + asmlinkage void buserr_c(struct frame *fp) { +#if defined(CONFIG_COLDFIRE ) && defined(CONFIG_MMU ) +unsigned int fs; +#endif +/* Only set esp0 if coming from user mode */ if (user_mode (&fp->ptregs)) current->thread.esp0 = (unsigned long ) fp;
@@ -716,6 +802,24 @@ asmlinkage void buserr_c(struct frame *fp)printk ("*** Bus Error *** Format is %x\n" , fp->ptregs.format);#endif +#if defined(CONFIG_COLDFIRE ) && defined(CONFIG_MMU ) + fs = (fp->ptregs.vector &0x3 ) | ((fp->ptregs.vector &0xc00 ) >>8 ); +switch (fs) { +case 0x5 : +case 0x6 : +case 0x7 : +case 0x9 : +case 0xa : +case 0xd : +case 0xe : +case 0xf : +access_errorcf (fs, fp); +return ; +default : +break ; + } +#endif /* CONFIG_COLDFIRE CONFIG_MMU */ +switch (fp->ptregs.format) {#if defined (CONFIG_M68060 )case 4 :/* 68060 access error */
Signature · 1 line
1.7.0.4
PATCH 13/36 m68k: add cache support for V4e ColdFire cores running with MMU enabled
In reply to [email protected]From: Greg Ungerer <[email protected]>
Add code to deal with instruction, data and branch caches of the V4e ColdFire cores when they are running with the MMU enabled.
--- arch/m68k/include/asm/cacheflush_mm.h | 88 +++++++++++++++++++++++++++++++-- arch/m68k/mm/cache.c | 57 +++++++++++++--------- 2 files changed, 117 insertions(+), 28 deletions(-)
arch/m68k/include/asm/cacheflush_mm.h +83 -5
@@ -2,23 +2,89 @@#define _M68K_CACHEFLUSH_H#include <linux/mm.h> +#ifdef CONFIG_COLDFIRE +#include <asm/mcfsim.h> +#endif /* cache code */ #define FLUSH_I_AND_D (0x00000808)#define FLUSH_I (0x00000008) +#ifndef ICACHE_MAX_ADDR +#define ICACHE_MAX_ADDR 0 +#define ICACHE_SET_MASK 0 +#define DCACHE_MAX_ADDR 0 +#define DCACHE_SETMASK 0 +#endif + +static inline void flush_cf_icache (unsigned long start,unsigned long end) +{ +unsigned long set; + +for (set = start; set <= end; set += (0x10 -3 )) { + __asm__ __volatile__ ( +"cpushl %%ic,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%ic,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%ic,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%ic,(%0)" + :"=a" (set) + :"a" (set)); + } +} + +static inline void flush_cf_dcache (unsigned long start,unsigned long end) +{ +unsigned long set; + +for (set = start; set <= end; set += (0x10 -3 )) { + __asm__ __volatile__ ( +"cpushl %%dc,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%dc,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%dc,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%dc,(%0)" + :"=a" (set) + :"a" (set)); + } +} + +static inline void flush_cf_bcache (unsigned long start,unsigned long end) +{ +unsigned long set; + +for (set = start; set <= end; set += (0x10 -3 )) { + __asm__ __volatile__ ( +"cpushl %%bc,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%bc,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%bc,(%0)\n\t" +"addq%.l #1,%0\n\t" +"cpushl %%bc,(%0)" + :"=a" (set) + :"a" (set)); + } +} +/* * Cache handling functions */ static inline void flush_icache (void ) { -if (CPU_IS_040_OR_060 ) +if (CPU_IS_COLDFIRE ) { +flush_cf_icache (0 ,ICACHE_MAX_ADDR ); + }else if (CPU_IS_040_OR_060 ) { asmvolatile ("nop\n" " .chip 68040\n" " cpusha %bc\n" " .chip 68k" ); -else { + }else {unsigned long tmp; asmvolatile ("movec %%cacr,%0\n" " or.w %1,%0\n"
@@ -51,12 +117,14 @@ extern void cache_push_v(unsigned long vaddr, int len);process changes. */ #define __flush_cache_all () \ ({ \ - if (CPU_IS_040_OR_060) \ + if (CPU_IS_COLDFIRE) { \ + flush_cf_dcache(0, DCACHE_MAX_ADDR); \ + } else if (CPU_IS_040_OR_060) { \ __asm__ __volatile__("nop\n\t" \ ".chip 68040\n\t" \ "cpusha %dc\n\t" \ ".chip 68k"); \ - else { \ + } else { \ unsigned long _tmp; \ __asm__ __volatile__("movec %%cacr,%0\n\t" \ "orw %1,%0\n\t" \
@@ -112,7 +180,17 @@ static inline void flush_cache_page(struct vm_area_struct *vma, unsigned long vm/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */ static inline void __flush_page_to_ram (void *vaddr) { -if (CPU_IS_040_OR_060 ) { +if (CPU_IS_COLDFIRE ) { +unsigned long addr, start, end; + addr = ((unsigned long ) vaddr) & ~(PAGE_SIZE -1 ); + start = addr &ICACHE_SET_MASK ; + end = (addr +PAGE_SIZE -1 ) &ICACHE_SET_MASK ; +if (start > end) { +flush_cf_bcache (0 , end); + end =ICACHE_MAX_ADDR ; + } +flush_cf_bcache (start, end); + }else if (CPU_IS_040_OR_060 ) { __asm__ __volatile__("nop\n\t" ".chip 68040\n\t" "cpushp %%bc,(%0)\n\t"
arch/m68k/mm/cache.c +34 -23
78 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 14/36 m68k: modify ColdFire 54xx cache support for MMU enabled
In reply to [email protected]From: Greg Ungerer <[email protected]>
Modify the cache setup for the ColdFire 54xx parts when running with the MMU enabled.
--- arch/m68k/include/asm/m54xxacr.h | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-)
arch/m68k/include/asm/m54xxacr.h +25 -1
@@ -39,6 +39,7 @@#define ACR_CM_OFF_PRE 0x00000040/* No cache, precise */ #define ACR_CM_OFF_IMP 0x00000060/* No cache, imprecise */ #define ACR_CM 0x00000060/* Cache mode mask */ +#define ACR_SP 0x00000008/* Supervisor protect */ #define ACR_WPROTECT 0x00000004/* Write protect */ #if defined(CONFIG_M5407 )
@@ -56,6 +57,11 @@#define CACHE_LINE_SIZE 0x0010/* 16 bytes */ #define CACHE_WAYS 4/* 4 ways */ +#define ICACHE_SET_MASK ((ICACHE_SIZE / 64 - 1) << CACHE_WAYS) +#define DCACHE_SET_MASK ((DCACHE_SIZE / 64 - 1) << CACHE_WAYS) +#define ICACHE_MAX_ADDR ICACHE_SET_MASK +#define DCACHE_MAX_ADDR DCACHE_SET_MASK +/* * Version 4 cores have a true harvard style separate instruction * and data cache. Enable data and instruction caches, also enable write
@@ -73,6 +79,24 @@#else #define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC+CACR_EUSP)#endif +#define CACHE_INIT (CACR_DCINVA+CACR_BCINVA+CACR_ICINVA) + +#if defined(CONFIG_MMU ) +/* +* If running with the MMU enabled then we need to map the internal +* register region as non-cacheable. And then we map all or RAM as +* cacheable and supervisor access only. +*/ +#define ACR0_MODE (0xf00f0000+ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP) +#define ACR1_MODE (0x000f0000+ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP) +#define ACR2_MODE 0 +#define ACR3_MODE (0x000f0000+ACR_ENABLE+ACR_SUPER+ACR_SP) + +#else + +/* +* For the non-MMU enabled case we map all of RAM as cacheable. +*/ #if defined(CONFIG_CACHE_COPYBACK )#define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_CP)#else
@@ -80,7 +104,6 @@#endif #define INSN_CACHE_MODE (ACR_ENABLE+ACR_ANY) -#define CACHE_INIT (CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)#define CACHE_INVALIDATE (CACHE_MODE+CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)#define CACHE_INVALIDATEI (CACHE_MODE+CACR_BCINVA+CACR_ICINVA)#define CACHE_INVALIDATED (CACHE_MODE+CACR_DCINVA)
@@ -94,4 +117,5 @@#define CACHE_PUSH #endif +#endif /* CONFIG_MMU */ #endif /* m54xxacr_h */
Signature · 1 line
1.7.0.4
PATCH 15/36 m68k: add TLB flush support for the ColdFire V4e MMU hardware
In reply to [email protected]From: Greg Ungerer <[email protected]>
The ColdFire V4e MMU is unlike any of the other m68k MMU hardware. It needs is own TLB flush support code.
--- arch/m68k/include/asm/tlbflush.h | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-)
arch/m68k/include/asm/tlbflush.h +17 -6
@@ -5,10 +5,13 @@#ifndef CONFIG_SUN3 #include <asm/current.h> +#include <asm/mcfmmu.h> static inline void flush_tlb_kernel_page (void *addr) { -if (CPU_IS_040_OR_060 ) { +if (CPU_IS_COLDFIRE ) { +mmu_write (MMUOR ,MMUOR_CNL ); + }else if (CPU_IS_040_OR_060 ) {mm_segment_t old_fs =get_fs ();set_fs (KERNEL_DS ); __asm__ __volatile__(".chip 68040\n\t"
@@ -25,12 +28,15 @@ static inline void flush_tlb_kernel_page(void *addr)*/ static inline void __flush_tlb (void ) { -if (CPU_IS_040_OR_060 ) +if (CPU_IS_COLDFIRE ) { +mmu_write (MMUOR ,MMUOR_CNL ); + }else if (CPU_IS_040_OR_060 ) { __asm__ __volatile__(".chip 68040\n\t" "pflushan\n\t" ".chip 68k" ); -else if (CPU_IS_020_OR_030 ) + }else if (CPU_IS_020_OR_030 ) { __asm__ __volatile__("pflush #0,#4" ); + } }static inline void __flush_tlb040_one (unsigned long addr)
@@ -43,7 +49,9 @@ static inline void __flush_tlb040_one(unsigned long addr)static inline void __flush_tlb_one (unsigned long addr) { -if (CPU_IS_040_OR_060 ) +if (CPU_IS_COLDFIRE ) +mmu_write (MMUOR ,MMUOR_CNL ); +else if (CPU_IS_040_OR_060 )__flush_tlb040_one (addr);else if (CPU_IS_020_OR_030 ) __asm__ __volatile__("pflush #0,#4,(%0)" : :"a" (addr));
@@ -56,12 +64,15 @@ static inline void __flush_tlb_one(unsigned long addr)*/ static inline void flush_tlb_all (void ) { -if (CPU_IS_040_OR_060 ) +if (CPU_IS_COLDFIRE ) { +mmu_write (MMUOR ,MMUOR_CNL ); + }else if (CPU_IS_040_OR_060 ) { __asm__ __volatile__(".chip 68040\n\t" "pflusha\n\t" ".chip 68k" ); -else if (CPU_IS_020_OR_030 ) + }else if (CPU_IS_020_OR_030 ) { __asm__ __volatile__("pflusha" ); + } }static inline void flush_tlb_mm (struct mm_struct *mm)
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 15/36] m68k: add TLB flush support for the ColdFire V4e MMU hardware
Quoted 1 line · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
It needs is own TLB flush support code.
s/is/its/
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 16/36 m68k: set ColdFire MMU page size
In reply to [email protected]From: Greg Ungerer <[email protected]>
We use the ColdFire V4e MMU page size of 8kb. Define PAGE_SHIFT appropriately.
--- arch/m68k/include/asm/page.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/m68k/include/asm/page.h +3 -3
@@ -6,10 +6,10 @@#include <asm/page_offset.h> /* PAGE_SHIFT determines the page size */ -#ifndef CONFIG_SUN3 -#define PAGE_SHIFT (12) +#if defined(CONFIG_SUN3 ) || defined(CONFIG_COLDFIRE ) +#define PAGE_SHIFT 13#else -#define PAGE_SHIFT (13) +#define PAGE_SHIFT 12#endif #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)#define PAGE_MASK (~(PAGE_SIZE-1))
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 16/36] m68k: set ColdFire MMU page size
Quoted 2 lines · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
We use the ColdFire V4e MMU page size of 8kb. Define
PAGE_SHIFTappropriately.
8kb = 0.9765625 KiB ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 16/36] m68k: set ColdFire MMU page size
Hi Geert,
Quoted 5 lines · Geert Uytterhoeven
Quoted 2 lines · On Tue, Oct 25, 2011 at 09:19,<[email protected]> wrote:
We use the ColdFire V4e MMU page size of 8kb. Define
PAGE_SHIFTappropriately.8kb = 0.9765625 KiB ;-)
Indeed :-)
Fixed up. And all the other little spelling mistakes and typos :-)
Thanks
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
PATCH 17/36 m68k: ColdFire with MMU does not support separate address spaces
In reply to [email protected]From: Greg Ungerer <[email protected]>
The ColdFire V4e implementation with an MMU does not support separate addresses spaces, or the instructions that are used to access them. Use the same code for segment get/set as the non-MMU mode.
--- arch/m68k/include/asm/segment.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/m68k/include/asm/segment.h +2 -2
@@ -31,7 +31,7 @@ typedef struct {static inline mm_segment_t get_fs (void ) { -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU ) && !defined(CONFIG_COLDFIRE )mm_segment_t _v; __asm__ ("movec %/dfc,%0" :"=r" (_v.seg):);
@@ -49,7 +49,7 @@ static inline mm_segment_t get_ds(void)static inline void set_fs (mm_segment_t val) { -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU ) && !defined(CONFIG_COLDFIRE ) __asm__ __volatile__ ("movec %0,%/sfc\n\t" "movec %0,%/dfc\n\t" :/* no outputs */ :"r" (val.seg) :"memory" );
Signature · 1 line
1.7.0.4
PATCH 18/36 m68k: ColdFire V4e MMU context support code
In reply to [email protected]From: Greg Ungerer <[email protected]>
Add code to manage the context's of the ColdFire V4e MMU.
--- arch/m68k/include/asm/atomic.h | 10 ++ arch/m68k/include/asm/mmu_context.h | 250 ++++++++++++++++++++++++++++------- 2 files changed, 211 insertions(+), 49 deletions(-)
arch/m68k/include/asm/atomic.h +10 -0
@@ -55,6 +55,16 @@ static inline int atomic_dec_and_test(atomic_t *v)return c !=0 ; } +static inline int atomic_dec_and_test_lt (atomic_t *v) +{ +char c; + __asm__ __volatile__( +"subql #1,%1; slt %0" + :"=d" (c),"=m" (*v) + :"m" (*v)); +return c !=0 ; +} +static inline int atomic_inc_and_test (atomic_t *v) {char c;
arch/m68k/include/asm/mmu_context.h +201 -49
263 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 19/36 m68k: use tracehook_report_syscall_entry/exit for ColdFire MMU ptrace path
In reply to [email protected]From: Greg Ungerer <[email protected]>
The existing ColdFire code (which is all non-mmu) for system call entry and exit uses the more modern tracehook_report_syscall_entry()/exit() into the ptrace code. Now that we are supporting ColdFire with MMU we need the same hooks for these.
--- arch/m68k/kernel/ptrace_mm.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
arch/m68k/kernel/ptrace_mm.c +18 -0
@@ -18,6 +18,7 @@#include <linux/ptrace.h> #include <linux/user.h> #include <linux/signal.h> +#include <linux/tracehook.h> #include <asm/uaccess.h> #include <asm/page.h>
@@ -275,3 +276,20 @@ asmlinkage void syscall_trace(void) current->exit_code =0 ; } } + +#ifdef CONFIG_COLDFIRE +asmlinkage int syscall_trace_enter(void) +{ +int ret =0 ; + +if (test_thread_flag (TIF_SYSCALL_TRACE )) + ret =tracehook_report_syscall_entry (task_pt_regs (current)); +return ret; +} + +asmlinkage void syscall_trace_leave(void) +{ +if (test_thread_flag (TIF_SYSCALL_TRACE )) +tracehook_report_syscall_exit (task_pt_regs (current),0 ); +} +#endif /* CONFIG_COLDFIRE */
Signature · 1 line
1.7.0.4
PATCH 20/36 m68k: ColdFire with MMU needs simpler lib checksum code
In reply to [email protected]From: Greg Ungerer <[email protected]>
We have 2 implementations of the IP checksuming code for m68k. One uses the more advanced instructions available in 68020 and above processors, the other uses the simpler instructions available on the original 68000 processors and the modern ColdFire processors.
The code choice shouldn't be made based on whether we have an MMU enabled or not. It is a processor specific choice. The newer advanced ColdFire CPU family members with MMU still only support the simpler instructions.
So choose the checksumming code based on CONFIG_CPU_HAS_NO_BITFIELDS.
--- arch/m68k/lib/Makefile | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
arch/m68k/lib/Makefile +8 -2
@@ -7,8 +7,14 @@ lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ memcpy.o memset.o memmove.o ifdef CONFIG_MMU -lib-y += string.o uaccess.o checksum_mm.o +lib-y += string.o uaccess.o else -lib-y += mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o checksum_no.o +lib-y += mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o +endif + +ifdef CONFIG_CPU_HAS_NO_BITFIELDS +lib-y += checksum_no.o +else +lib-y += checksum_mm.o endif
Signature · 1 line
1.7.0.4
PATCH 21/36 m68k: modify cache push and clear code for ColdFire with MMU enable
In reply to [email protected]From: Greg Ungerer <[email protected]>
The cache push and clear code only need to flush the branch cache on the write-through cache setup of the ColdFire V4e with MMU enabled.
--- arch/m68k/mm/memory.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/m68k/mm/memory.c +8 -0
@@ -203,6 +203,9 @@ static inline void pushcl040(unsigned long paddr)void cache_clear (unsigned long paddr,int len) { +#ifdef CONFIG_COLDFIRE +flush_cf_bcache (0 ,DCACHE_MAX_ADDR ); +#else if (CPU_IS_040_OR_060 ) {int tmp;
@@ -237,6 +240,7 @@ void cache_clear (unsigned long paddr, int len)if (mach_l2_flush)mach_l2_flush (0 );#endif +#endif /* CONFIG_COLDFIRE */ }EXPORT_SYMBOL (cache_clear);
@@ -250,6 +254,9 @@ EXPORT_SYMBOL(cache_clear);void cache_push (unsigned long paddr,int len) { +#ifdef CONFIG_COLDFIRE +flush_cf_bcache (0 ,DCACHE_MAX_ADDR ); +#else if (CPU_IS_040_OR_060 ) {int tmp =PAGE_SIZE ;
@@ -290,6 +297,7 @@ void cache_push (unsigned long paddr, int len)if (mach_l2_flush)mach_l2_flush (1 );#endif +#endif /* CONFIG_COLDFIRE */ }EXPORT_SYMBOL (cache_push);
Signature · 1 line
1.7.0.4
PATCH 22/36 m68k: use ColdFire V4e MMU flags when ioremapping()
In reply to [email protected]From: Greg Ungerer <[email protected]>
Different flags needed when mapping pages for the ColdFire V4e MMU case.
--- arch/m68k/mm/kmap.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
arch/m68k/mm/kmap.c +9 -0
@@ -50,7 +50,11 @@ static inline void free_io_area(void *addr)#else +#ifdef CONFIG_COLDFIRE +#define IO_SIZE PAGE_SIZE +#else #define IO_SIZE (256*1024) +#endif static struct vm_struct *iolist;
@@ -171,7 +175,12 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cacheflabreak ; } }else { +#ifdef CONFIG_COLDFIRE + physaddr |= (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY | + _PAGE_READWRITE); +#else physaddr |= (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY); +#endif switch (cacheflag) {case IOMAP_NOCACHE_SER :case IOMAP_NOCACHE_NONSER :
Signature · 1 line
1.7.0.4
PATCH 23/36 m68k: ColdFire V4e MMU paginit init code and miss handler
In reply to [email protected]From: Greg Ungerer <[email protected]>
The quite different ColdFire V4e MMU requires its own dedicated pageing init code, and a TLB miss handler for its software driven TLB.
--- arch/m68k/include/asm/mcfmmu.h | 10 +- arch/m68k/mm/mcfmmu.c | 240 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 arch/m68k/mm/mcfmmu.c
arch/m68k/include/asm/mcfmmu.h +6 -4
@@ -92,14 +92,14 @@#define MMUDR_PAN 10/* Physical address */ #define MMUDR_PAMASK 0xfffffc00/* PA mask */ -/* -* Simple access functions for the MMU registers. Nothing fancy -* currently required, just simple 32bit access. -*/ #ifndef __ASSEMBLY__#define CF_PAGE_PGNUM_MASK (PAGE_MASK) +/* +* Simple access functions for the MMU registers. Nothing fancy +* currently required, just simple 32bit access. +*/ static inline u32 mmu_read (u32 a) {return *((volatile u32 *) a);
@@ -111,6 +111,8 @@ static inline void mmu_write(u32 a, u32 v) __asm__ __volatile__ ("nop"); } +int cf_tlb_miss (struct pt_regs *regs,int write,int dtlb,int extension_word); +#endif /****************************************************************************/
arch/m68k/mm/mcfmmu.c new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Re: [PATCH 23/36] m68k: ColdFire V4e MMU paginit init code and miss handler
Quoted 3 lines · On Tue, 25 Oct 2011, [email protected] wrote:
From: Greg Ungerer <[email protected]>
The quite different ColdFire V4e MMU requires its own dedicated pageing
s/pageing/paging/
Finn
Quoted 1 line
init code, and a TLB miss handler for its software driven TLB.
Re: [PATCH 23/36] m68k: ColdFire V4e MMU paginit init code and miss handler
Hi Finn,
Quoted 8 lines · Finn Thain
Quoted 3 lines · On Tue, 25 Oct 2011, [email protected] wrote:
From: Greg Ungerer<[email protected]>
The quite different ColdFire V4e MMU requires its own dedicated pageing
s/pageing/paging/
Thanks. Fixed this and the wirh/with one too.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
PATCH 24/36 m68k: compile appropriate mm arch files for ColdFire V4e MMU support
In reply to [email protected]From: Greg Ungerer <[email protected]>
Compile the mcfmmu.c code when the ColdFire V4e MMU is enabled. And don't compile the unnecessary hwtest.c code for it.
--- arch/m68k/mm/Makefile | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
arch/m68k/mm/Makefile +7 -1
@@ -4,6 +4,12 @@ obj-y := init.o -obj-$(CONFIG_MMU) += cache.o fault.o hwtest.o +obj-$(CONFIG_MMU) += cache.o fault.o obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o obj-$(CONFIG_MMU_SUN3) += sun3kmap.o sun3mmu.o + +ifdef CONFIG_COLDFIRE +obj-$(CONFIG_MMU) += kmap.o memory.o mcfmmu.o +else +obj-$(CONFIG_MMU) += hwtest.o +endif
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 24/36] m68k: compile appropriate mm arch files for ColdFire V4e MMU support
Quoted 22 lines · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
From: Greg Ungerer <[email protected]>
Compile the
mcfmmu.ccode when the ColdFire V4e MMU is enabled. And don't compile the unnecessaryhwtest.ccode for it.Signed-off-by Greg Ungerer <[email protected]>---
arch/m68k/mm/Makefile | 8 +++++++-1 files changed, 7 insertions(+), 1 deletions(-)arch/m68k/mm/Makefile +0
-0@@ -4,6 +4,12 @@obj-y := init.o
arch/m68k/mm/Makefile +1
-1-obj-$(CONFIG_MMU) += cache.o fault.o hwtest.o +obj-$(CONFIG_MMU) += cache.o fault.oobj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o obj-$(CONFIG_MMU_SUN3) += sun3kmap.o sun3mmu.o
arch/m68k/mm/Makefile line 12
Quoted 3 lines
arch/m68k/mm/Makefile +3
-0+ +ifdef CONFIG_COLDFIRE +obj-$(CONFIG_MMU) += kmap.o memory.o mcfmmu.o
What about introducing CONFIG_MMU_COLDFIRE and writing
obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o mcfmmu.o
instead?
It could turn out to be useful in other places too, especially when considering merging more mm/no sources files.
arch/m68k/mm/Makefile line 15
Quoted 3 lines
arch/m68k/mm/Makefile +3
-0+else +obj-$(CONFIG_MMU) += hwtest.o +endif
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 24/36] m68k: compile appropriate mm arch files for ColdFire V4e MMU support
Hi Geert,
Quoted 29 lines · Geert Uytterhoeven
Quoted 15 lines · On Tue, Oct 25, 2011 at 09:19,<[email protected]> wrote:
From: Greg Ungerer<[email protected]>
Compile the
mcfmmu.ccode when the ColdFire V4e MMU is enabled. And don't compile the unnecessaryhwtest.ccode for it.Signed-off-by Greg Ungerer<[email protected]>---
arch/m68k/mm/Makefile| 8 +++++++-1 files changed, 7 insertions(+), 1 deletions(-)arch/m68k/mm/Makefile +0
-0arch/m68k/mm/Makefile line 12
Quoted 10 lines
arch/m68k/mm/Makefile +4
-1@@ -4,6 +4,12 @@ obj-y := init.o -obj-$(CONFIG_MMU) += cache.o fault.o hwtest.o +obj-$(CONFIG_MMU) += cache.o fault.o obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o obj-$(CONFIG_MMU_SUN3) += sun3kmap.o sun3mmu.o + +ifdef CONFIG_COLDFIRE +obj-$(CONFIG_MMU) += kmap.o memory.o mcfmmu.oWhat about introducing
CONFIG_MMU_COLDFIREand writing
Quoted 6 lines
obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o mcfmmu.o
instead?
It could turn out to be useful in other places too, especially when considering merging more mm/no sources files.
Yep, that is much nice. I'll change it.
Thanks
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
PATCH 25/36 m68k: create ColdFire MMU pgalloc code
In reply to [email protected]From: Greg Ungerer <[email protected]>
Add code to support the ColdFire V4e MMU pgalloc functions.
--- arch/m68k/include/asm/mcf_pgalloc.h | 103 +++++++++++++++++++++++++++++++++++ arch/m68k/include/asm/pgalloc.h | 4 +- 2 files changed, 106 insertions(+), 1 deletions(-) create mode 100644 arch/m68k/include/asm/mcf_pgalloc.h
arch/m68k/include/asm/mcf_pgalloc.h new file +103 -0
@@ -0,0 +1,103 @@ +#ifndef M68K_MCF_PGALLOC_H +#define M68K_MCF_PGALLOC_H + +#include <asm/coldfire.h> +#include <asm/page.h> +#include <asm/tlbflush.h> + +extern inline void pte_free_kernel (struct mm_struct *mm,pte_t *pte) +{ +free_page ((unsigned long ) pte); +} + +extern const char bad_pmd_string[]; + +extern inline pte_t *pte_alloc_one_kernel (struct mm_struct *mm, +unsigned long address) +{ +unsigned long page =__get_free_page (GFP_DMA |__GFP_REPEAT); + +if (!page) +return NULL ; + +memset ((void *)page,0 ,PAGE_SIZE ); +return (pte_t *) (page); +} + +extern inline pmd_t *pmd_alloc_kernel (pgd_t *pgd,unsigned long address) +{ +return (pmd_t *) pgd; +} + +#define pmd_alloc_one_fast (mm, address) ({ BUG(); ((pmd_t *)1); }) +#define pmd_alloc_one (mm, address) ({ BUG(); ((pmd_t *)2); }) + +#define pte_alloc_one_fast (mm, addr) pte_alloc_one(mm, addr) + +#define pmd_populate (mm, pmd, page) (pmd_val(*pmd) = \ + (unsigned long)(page_address(page))) + +#define pmd_populate_kernel (mm, pmd, pte) (pmd_val(*pmd) = (unsigned long)(pte)) + +#define pmd_pgtable (pmd) pmd_page(pmd) + +static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t page, +unsigned long address) +{ +__free_page (page); +} + +#define __pmd_free_tlb (tlb, pmd, address) do { } while (0) + +static inline struct page *pte_alloc_one (struct mm_struct *mm, +unsigned long address) +{ +struct page *page =alloc_pages (GFP_DMA |__GFP_REPEAT,0 ); +pte_t *pte; + +if (!page) +return NULL ; + + pte =kmap (page); +if (pte) { +clear_page (pte); +__flush_page_to_ram (pte); +flush_tlb_kernel_page (pte); +nocache_page (pte); + } +kunmap (page); + +return page; +} + +extern inline void pte_free (struct mm_struct *mm,struct page *page) +{ +__free_page (page); +} + +/* +* In our implementation, each pgd entry contains 1 pmd that is never allocated +* or freed. pgd_present is always 1, so this should never be called. -NL +*/ +#define pmd_free (mm, pmd) BUG() + +static inline void pgd_free (struct mm_struct *mm,pgd_t *pgd) +{ +free_page ((unsigned long ) pgd); +} + +static inline pgd_t *pgd_alloc (struct mm_struct *mm) +{ +pgd_t *new_pgd; + + new_pgd = (pgd_t *)__get_free_page (GFP_DMA | __GFP_NOWARN); +if (!new_pgd) +return NULL ; +memcpy (new_pgd, swapper_pg_dir,PAGE_SIZE ); +memset (new_pgd,0 ,PAGE_OFFSET >>PGDIR_SHIFT ); +return new_pgd; +} + +#define pgd_populate (mm, pmd, pte) BUG() + +#endif /* M68K_MCF_PGALLOC_H */
arch/m68k/include/asm/pgalloc.h +3 -1
@@ -7,7 +7,9 @@#ifdef CONFIG_MMU #include <asm/virtconvert.h> -#ifdef CONFIG_SUN3 +#if defined(CONFIG_COLDFIRE ) +#include <asm/mcf_pgalloc.h> +#elif defined(CONFIG_SUN3 )#include <asm/sun3_pgalloc.h> #else #include <asm/motorola_pgalloc.h>
Signature · 1 line
1.7.0.4
PATCH 26/36 m68k: use non-MMU entry.S code when compiling for ColdFire CPU
In reply to [email protected]From: Greg Ungerer <[email protected]>
No matter whether we are configured for non-MMU or MMU enabled if we are compiling for ColdFire CPU we always use the entry_no.S code.
--- arch/m68k/kernel/entry.S | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/m68k/kernel/entry.S +1 -1
@@ -1,4 +1,4 @@ -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) #include "entry_mm.S" #else #include "entry_no.S"
Signature · 1 line
1.7.0.4
PATCH 27/36 m68k: add code to setup a ColdFire 54xx platform when MMU enabled
In reply to [email protected]From: Greg Ungerer <[email protected]>
We use the same setup code for ColdFire MMU enabled platforms as standard m68k. So add support for it to setup our 54xx ColdFire platforms. They do not support the same bootinfo parsing as other m68k platforms.
--- arch/m68k/kernel/setup_mm.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
arch/m68k/kernel/setup_mm.c +7 -1
@@ -221,7 +221,8 @@ void __init setup_arch(char **cmdline_p)#endif /* The bootinfo is located right after the kernel bss */ -m68k_parse_bootinfo ((const struct bi_record *)_end); +if (!CPU_IS_COLDFIRE ) +m68k_parse_bootinfo ((const struct bi_record *)_end);if (CPU_IS_040 ) m68k_is040or060 =4 ;
@@ -327,6 +328,11 @@ void __init setup_arch(char **cmdline_p)config_sun3x ();break ;#endif +#ifdef CONFIG_COLDFIRE +case MACH_M54XX : +config_BSP (NULL ,0 ); +break ; +#endif default :panic ("No configuration setup" ); }
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 27/36] m68k: add code to setup a ColdFire 54xx platform when MMU enabled
Quoted 27 lines · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
From: Greg Ungerer <[email protected]>
We use the same setup code for ColdFire MMU enabled platforms as standard m68k. So add support for it to setup our 54xx ColdFire platforms. They do not support the same bootinfo parsing as other m68k platforms.
Signed-off-by Greg Ungerer <[email protected]>---
arch/m68k/kernel/setup_mm.c | 8 +++++++-1 files changed, 7 insertions(+), 1 deletions(-)arch/m68k/kernel/setup_mm.c +2
-1@@ -221,7 +221,8 @@ void __init setup_arch(char **cmdline_p) #endif /* The bootinfo is located right after the kernel bss */ - m68k_parse_bootinfo((const struct bi_record *)_end); + if (!CPU_IS_COLDFIRE) + m68k_parse_bootinfo((const struct bi_record *)_end); if (CPU_IS_040) m68k_is040or060 = 4;
arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 333
Quoted 6 lines
arch/m68k/kernel/setup_mm.c +3
-0@@ -327,6 +328,11 @@ void __init setup_arch(char **cmdline_p) config_sun3x(); break; #endif +#ifdef CONFIG_COLDFIRE + case MACH_M54XX: + config_BSP(NULL, 0);
config_M54xx?
Quoted 5 lines
arch/m68k/kernel/setup_mm.c +2
-0+ break; +#endif default:
panic("No configuration setup");
}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 27/36] m68k: add code to setup a ColdFire 54xx platform when MMU enabled
Hi Geert,
Quoted 25 lines · Geert Uytterhoeven
Quoted 24 lines · On Tue, Oct 25, 2011 at 09:19,<[email protected]> wrote:
From: Greg Ungerer<[email protected]>
We use the same setup code for ColdFire MMU enabled platforms as standard m68k. So add support for it to setup our 54xx ColdFire platforms. They do not support the same bootinfo parsing as other m68k platforms.
Signed-off-by Greg Ungerer<[email protected]>---
arch/m68k/kernel/setup_mm.c8 +++++++-1 files changed, 7 insertions(+), 1 deletions(-)arch/m68k/kernel/setup_mm.c +2
-1@@ -221,7 +221,8 @@ void __init setup_arch(char **cmdline_p)#endif /* The bootinfo is located right after the kernel bss */ -m68k_parse_bootinfo ((const struct bi_record *)_end); +if (!CPU_IS_COLDFIRE ) +m68k_parse_bootinfo ((const struct bi_record *)_end);
Quoted 11 lines
arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 333
Quoted 9 lines
arch/m68k/kernel/setup_mm.c +3
-0if (CPU_IS_040 ) m68k_is040or060 =4 ;@@ -327,6 +328,11 @@ void __init setup_arch(char **cmdline_p)config_sun3x ();break ;#endif +#ifdef CONFIG_COLDFIRE +case MACH_M54XX : +config_BSP (NULL ,0 );
config_M54xx?
config_BSP is the name of the existing function as it used for non-MMU, so I just left it unchanged. The non-mmu code is built for a specific processor type (no multi-cpu image support), and all those functions for each CPU type are just called config_BSP.
So I was trying to minimize the changed needed here. Although the name is not too descriptive. In the furture I want to merge all the separate config_BSP() functions into a single one for ColdFire. They are almost all the same. I plan on renaming it then.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
PATCH 28/36 m68k: ColdFire with MMU enabled uses same clocking code as non-MMU
In reply to [email protected]From: Greg Ungerer <[email protected]>
We want to use the same timer support code for ColdFire CPU's when running with MMU enabled or not. So use the same time_no.c code even when the MMU is enabled for ColdFire.
--- arch/m68k/kernel/time.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/m68k/kernel/time.c +1 -1
@@ -1,4 +1,4 @@ -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU ) && !defined(CONFIG_COLDFIRE )#include "time_mm.c" #else #include "time_no.c"
Signature · 1 line
1.7.0.4
PATCH 29/36 m68k: use non-MMU linker script for ColdFire MMU builds
In reply to [email protected]From: Greg Ungerer <[email protected]>
Use the non-MMU linker script for ColdFire builds when we are building for MMU enabled. The image layout is correct for loading on existing ColdFire dev boards. The only addition required to the current non-MMU linker script is to add support for the fixup section.
--- arch/m68k/kernel/vmlinux.lds.S | 2 +- arch/m68k/kernel/vmlinux.lds_no.S | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletions(-)
arch/m68k/kernel/vmlinux.lds.S +1 -1
@@ -1,4 +1,4 @@ -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) #include "vmlinux.lds_mm.S" #else #include "vmlinux.lds_no.S"
arch/m68k/kernel/vmlinux.lds_no.S +8 -0
@@ -69,6 +69,7 @@ SECTIONS { SCHED_TEXT LOCK_TEXT *(.text..lock) + *(.fixup) . = ALIGN(16); /* Exception table */ __start___ex_table = .;
@@ -162,6 +163,13 @@ SECTIONS { _edata = . ; } > DATA + .m68k_fixup : { + __start_fixup = .; + *(.m68k_fixup) + __stop_fixup = .; + } > DATA + NOTES > DATA + .init.text : { . = ALIGN(PAGE_SIZE); __init_begin = .;
Signature · 1 line
1.7.0.4
PATCH 30/36 m68k: adjustments to stack frame for ColdFire with MMU enabled
In reply to [email protected]From: Greg Ungerer <[email protected]>
The exception return stack adjustment required by ColdFire when running with the MMU enabled is not completely identical to 680x0 processors. Specifically the format type 4 stack frame doesn't need any stack adjustment on exception return. And the ColdFire always must return with a frame type of 4, not 0.
--- arch/m68k/kernel/signal_mm.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-)
arch/m68k/kernel/signal_mm.c +15 -2
@@ -56,7 +56,11 @@ static const int frame_extra_sizes[16] = { [1] = -1, /* sizeof(((struct frame *)0)->un.fmt1), */ [2] = sizeof(((struct frame *)0)->un.fmt2), [3] = sizeof(((struct frame *)0)->un.fmt3), +#ifdef CONFIG_COLDFIRE + [4] = 0, +#else [4] = sizeof(((struct frame *)0)->un.fmt4), +#endif [5] = -1, /* sizeof(((struct frame *)0)->un.fmt5), */ [6] = -1, /* sizeof(((struct frame *)0)->un.fmt6), */ [7] = sizeof(((struct frame *)0)->un.fmt7),
@@ -84,7 +88,11 @@ int handle_kernel_fault(struct pt_regs *regs) regs->stkadj = frame_extra_sizes[regs->format]; tregs = (struct pt_regs *)((long )regs + regs->stkadj); tregs->vector = regs->vector; +#ifdef CONFIG_COLDFIRE + tregs->format =4 ; +#else tregs->format =0 ; +#endif tregs->pc = fixup->fixup; tregs->sr = regs->sr;
@@ -336,8 +344,12 @@ static int mangle_kernel_stack(struct pt_regs *regs, int formatvec, regs->format = formatvec >>12 ; regs->vector = formatvec &0xfff ;#define frame_offset (sizeof(struct pt_regs)+sizeof(struct switch_stack)) - __asm__ __volatile__ - (" movel %0,%/a0\n\t" + __asm__ __volatile__ ( +#ifdef CONFIG_COLDFIRE + " movel %0,%/sp\n\t" + " bra ret_from_signal\n" +#else +" movel %0,%/a0\n\t" " subl %1,%/a0\n\t" /* make room on stack */ " movel %/a0,%/sp\n\t" /* set stack pointer */ /* move switch_stack and pt_regs */
@@ -350,6 +362,7 @@ static int mangle_kernel_stack(struct pt_regs *regs, int formatvec, "2: movel %4@+,%/a0@+\n\t" " dbra %1,2b\n\t" " bral ret_from_signal\n" +#endif : /* no outputs, it doesn't ever return */ : "a" (sw), "d" (fsize), "d" (frame_offset/4-1),"n" (frame_offset),"a" (buf + fsize/4 )
Signature · 1 line
1.7.0.4
PATCH 31/36 m68k: completely disable FPU support for ColdFire
In reply to [email protected]From: Greg Ungerer <[email protected]>
Disable all FPU support for the ColdFire CPU's running wirh MMU enabled.
--- arch/m68k/kernel/process_mm.c | 15 ++++++++++++--- arch/m68k/kernel/signal_mm.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-)
arch/m68k/kernel/process_mm.c +12 -3
@@ -168,13 +168,16 @@ EXPORT_SYMBOL(kernel_thread);void flush_thread (void ) { -unsigned long zero =0 ; - +set_fs (USER_DS ); current->thread.fs = __USER_DS; -if (!FPU_IS_EMU ) +#ifndef CONFIG_COLDFIRE +if (!FPU_IS_EMU ) { +unsigned long zero =0 ; asmvolatile (".chip 68k/68881\n\t" "frestore %0@\n\t" ".chip 68k" : :"a" (&zero)); + } +#endif }/*
@@ -244,6 +247,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,*/ p->thread.fs =get_fs ().seg; +#ifndef CONFIG_COLDFIRE if (!FPU_IS_EMU ) {/* Copy the current fpu state */ asmvolatile ("fsave %0" : :"m" (p->thread.fpstate[0 ]) :"memory" );
@@ -256,6 +260,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,/* Restore the state in case the fpu was busy */ asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0])); } +#endif return 0 ; }
@@ -264,7 +269,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,int dump_fpu (struct pt_regs *regs,struct user_m68kfp_struct *fpu) { +#ifndef CONFIG_COLDFIRE char fpustate[216 ]; +#endif if (FPU_IS_EMU ) {int i;
@@ -280,6 +287,7 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)return 1 ; } +#ifndef CONFIG_COLDFIRE /* First dump the fpu context to avoid protocol violation. */ asmvolatile ("fsave %0" ::"m" (fpustate[0 ]) :"memory" );if (!CPU_IS_060 ? !fpustate[0 ] : !fpustate[2 ])
@@ -291,6 +299,7 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu) asmvolatile ("fmovemx %/fp0-%/fp7,%0" ::"m" (fpu->fpregs[0 ]) :"memory" ); +#endif return 1 ; }EXPORT_SYMBOL (dump_fpu);
arch/m68k/kernel/signal_mm.c +16 -0
@@ -225,16 +225,20 @@ static inline int restore_fpu_state(struct sigcontext *sc) }else goto out; +#ifndef CONFIG_COLDFIRE __asm__volatile (".chip 68k/68881\n\t" "fmovemx %0,%%fp0-%%fp1\n\t" "fmoveml %1,%%fpcr/%%fpsr/%%fpiar\n\t" ".chip 68k" :/* no outputs */ :"m" (*sc->sc_fpregs),"m" (*sc->sc_fpcntl)); +#endif } +#ifndef CONFIG_COLDFIRE __asm__volatile (".chip 68k/68881\n\t" "frestore %0\n\t" ".chip 68k" : :"m" (*sc->sc_fpstate)); +#endif err =0 ; out:
@@ -295,6 +299,7 @@ static inline int rt_restore_fpu_state(struct ucontext __user *uc)if (__copy_from_user (&fpregs, &uc->uc_mcontext.fpregs,sizeof (fpregs))) goto out; +#ifndef CONFIG_COLDFIRE __asm__volatile (".chip 68k/68881\n\t" "fmovemx %0,%%fp0-%%fp7\n\t" "fmoveml %1,%%fpcr/%%fpsr/%%fpiar\n\t"
@@ -302,14 +307,17 @@ static inline int rt_restore_fpu_state(struct ucontext __user *uc) : /* no outputs */ : "m" (*fpregs.f_fpregs), "m" (*fpregs.f_fpcntl)); +#endif }if (context_size &&__copy_from_user (fpstate +4 , (long __user *)&uc->uc_fpstate +1 , context_size)) goto out; +#ifndef CONFIG_COLDFIRE __asm__volatile (".chip 68k/68881\n\t" "frestore %0\n\t" ".chip 68k" : :"m" (*fpstate)); +#endif err =0 ; out:
@@ -529,6 +537,7 @@ static inline void save_fpu_state(struct sigcontext *sc, struct pt_regs *regs)return ; } +#ifndef CONFIG_COLDFIRE __asm__volatile (".chip 68k/68881\n\t" "fsave %0\n\t" ".chip 68k"
@@ -552,12 +561,15 @@ static inline void save_fpu_state(struct sigcontext *sc, struct pt_regs *regs) : /* no inputs */ : "memory"); } +#endif }static inline int rt_save_fpu_state (struct ucontext __user *uc,struct pt_regs *regs) { +#ifndef CONFIG_COLDFIRE unsigned char fpstate[FPCONTEXT_SIZE ];int context_size =CPU_IS_060 ?8 :0 ; +#endif int err =0 ;if (FPU_IS_EMU ) {
@@ -570,6 +582,7 @@ static inline int rt_save_fpu_state(struct ucontext __user *uc, struct pt_regs *return err; } +#ifndef CONFIG_COLDFIRE __asm__volatile (".chip 68k/68881\n\t" "fsave %0\n\t" ".chip 68k"
@@ -602,6 +615,7 @@ static inline int rt_save_fpu_state(struct ucontext __user *uc, struct pt_regs *if (context_size) err |=copy_to_user ((long __user *)&uc->uc_fpstate +1 , fpstate +4 , context_size); +#endif return err; }
@@ -661,6 +675,7 @@ static inline void push_cache (unsigned long vaddr)* cache_push_v(). * Jes */ +#ifndef CONFIG_COLDFIRE if (CPU_IS_040 ) {unsigned long temp;
@@ -709,6 +724,7 @@ static inline void push_cache (unsigned long vaddr) "movec %1,%%cacr" : : "r" (vaddr + 4), "r" (temp)); } +#endif } static inline void __user *
Signature · 1 line
1.7.0.4
Re: [PATCH 31/36] m68k: completely disable FPU support for ColdFire
Quoted 3 lines · On Tue, 25 Oct 2011, [email protected] wrote:
From: Greg Ungerer <[email protected]>
Disable all FPU support for the ColdFire CPU's running wirh MMU enabled.
s/wirh/with/
FWIW
Finn
PATCH 32/36 m68k: use new style interrupt handling for ColdFire with MMU enabled
In reply to [email protected]From: Greg Ungerer <[email protected]>
We want to use the same interrupt processing code for all ColdFire CPU types, even when the MMU is enabled. The current m68k MMU interrupt processing still uses old style code, not generic interrupts. Choose to compile the generic interrupt support used by the non-MMU ColdFire for all ColdFire configurations.
--- arch/m68k/kernel/Makefile | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
arch/m68k/kernel/Makefile +12 -5
@@ -2,20 +2,27 @@ # Makefile for the linux kernel. # +ifndef CONFIG_COLDFIRE extra-$(CONFIG_MMU) := head.o extra-$(CONFIG_SUN3) := sun3-head.o +endif extra-y += vmlinux.lds obj-y := entry.o init_task.o m68k_ksyms.o module.o process.o ptrace.o obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o -obj-$(CONFIG_MMU) += ints.o devres.o vectors.o -devres-$(CONFIG_MMU) = ../../../kernel/irq/devres.o +ifdef CONFIG_COLDFIRE +obj-y += irq.o +else +ifdef CONFIG_MMU +obj-y += ints.o devres.o vectors.o +devres-y = ../../../kernel/irq/devres.o +else +obj-y += irq.o +endif +endif ifndef CONFIG_MMU_SUN3 obj-y += dma.o endif -ifndef CONFIG_MMU -obj-y += irq.o -endif
Signature · 1 line
1.7.0.4
PATCH 33/36 m68k: define a ack_bad_irq() function for ColdFire with MMU
In reply to [email protected]From: Greg Ungerer <[email protected]>
With the generic interrupt code we need an ack_bad_irq() function. Otherwise you get:
CC kernel/irq/handle.okernel/irq/handle.c: In function ‘handle_bad_irq’:kernel/irq/handle.c:34:2: error: implicit declaration of function ‘ack_bad_irq’ make[3]: *** [kernel/irq/handle.o] Error 1
The standard m68k MMU targets don't use generic interrupts yet, so didn't need this.
--- arch/m68k/include/asm/hardirq.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
arch/m68k/include/asm/hardirq.h +7 -0
@@ -25,6 +25,13 @@ typedef struct {#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ +#ifndef ack_bad_irq +static inline void ack_bad_irq (unsigned int irq) +{ +printk (KERN_CRIT "unexpected IRQ trap at vector %02x\n" , irq); +} +#endif +#else #include <asm-generic/hardirq.h>
Signature · 1 line
1.7.0.4
PATCH 34/36 m68k: add ColdFire with MMU enabled support to the m68k mem init code
In reply to [email protected]From: Greg Ungerer <[email protected]>
The ColdFire has similar setup requirements to the SUN3 code, so we use that.
--- arch/m68k/mm/init_mm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/m68k/mm/init_mm.c +1 -1
@@ -139,7 +139,7 @@ void __init mem_init(void) } } -#ifndef CONFIG_SUN3 +#if !defined(CONFIG_SUN3 ) && !defined(CONFIG_COLDFIRE )/* insert pointer tables allocated so far into the tablelist */ init_pointer_table ((unsigned long )kernel_pg_dir);for (i =0 ; i <PTRS_PER_PGD ; i++) {
Signature · 1 line
1.7.0.4
PATCH 35/36 m68k: config option adjustments for configuring ColdFire with MMU
In reply to [email protected]From: Greg Ungerer <[email protected]>
We want to reuse as much of the exitsing ColdFire code as we can for running it with the MMU enabled. So we need to disable CONFIG_GENERIC_IOMAP and CONFIG_ARCH_USES_GETTIMEOFFSET for the case where we are building for ColdFire CPU with MMU enabled.
--- arch/m68k/Kconfig | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/m68k/Kconfig +2 -2
@@ -36,14 +36,14 @@ config GENERIC_CALIBRATE_DELAY default y config GENERIC_IOMAP - def_bool MMU + def_bool MMU && !COLDFIRE config TIME_LOW_RES bool default y config ARCH_USES_GETTIMEOFFSET - def_bool MMU + def_bool MMU && !COLDFIRE config NO_IOPORT def_bool y
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerRe: [PATCH 35/36] m68k: config option adjustments for configuring ColdFire with MMU
Quoted 1 line · On Tue, Oct 25, 2011 at 09:19, <[email protected]> wrote:
We want to reuse as much of the exitsing ColdFire code as we can for
s/exitsing/existing/
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 36/36 m68k: allow ColdFire 547x and 548x CPUs to be built with MMU enabled
In reply to [email protected]From: Greg Ungerer <[email protected]>
The ColdFire 547x and 548x CPUs have internal MMU hardware. All code to support this is now in, so we can build kernels with it enabled.
--- arch/m68k/Kconfig.cpu | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
arch/m68k/Kconfig.cpu +0 -2
@@ -224,7 +224,6 @@ config M54xx config M547x bool "MCF547x" - depends on !MMU select COLDFIRE select M54xx select HAVE_CACHE_CB
@@ -234,7 +233,6 @@ config M547x config M548x bool "MCF548x" - depends on !MMU select COLDFIRE select M54xx select HAVE_CACHE_CB
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerHi Greg,
Quoted 3 lines · On Tue, Oct 25, 2011 at 09:18, <[email protected]> wrote:
The following patch set adds support for running the V4e ColdFire cores with their MMU enabled. This is very much a request for comments. I expect a lot more cleanup is required here. But this is a start.
I replied a few comments to the individual patches, but in general it looks OK, so you can add my Acked-by.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Geert,
Quoted 7 lines · Geert Uytterhoeven
Quoted 3 lines · On Tue, Oct 25, 2011 at 09:18,<[email protected]> wrote:
The following patch set adds support for running the V4e ColdFire cores with their MMU enabled. This is very much a request for comments. I expect a lot more cleanup is required here. But this is a start.
I replied a few comments to the individual patches, but in general it looks OK, so you can add my Acked-by.
Thats great, thanks, I really appreciate the review.
I will probably send a v2 after you have pushed the IRQ changes. No doubt a couple of changes can be dropped from this patch set then.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected] SnapGear Group, McAfee PHONE: +61 7 3435 2888 8 Gardner Close FAX: +61 7 3217 5323 Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com