Skip to contentSkip to conversation

m68k: merge mmu and non-mmu versions of processor.h

PATCH New Greg Ungerer 1 participant 1 message Jun 17, 2009

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

PATCH 1/1 m68k: merge mmu and non-mmu versions of processor.h

[PATCH] m68k: merge mmu and non-mmu versions of processor.h

The mmu and non-mmu versions of processor.h have a lot of common code. This is a strait forward merge. start_thread() could be improved, but that is not quite as strait forward, leaving for a follow on change.

---
 .../include/asm/{processor_mm.h => processor.h}    |   42 ++++++-
 arch/m68k/include/asm/processor_no.h               |  143 --------------------
 2 files changed, 41 insertions(+), 144 deletions(-)
 rename arch/m68k/include/asm/{processor_mm.h => processor.h} (75%)
 delete mode 100644 arch/m68k/include/asm/processor_no.h
arch/m68k/include/asm/processor.h renamed from arch/m68k/include/asm/processor_mm.h +41 -1
similarity index 75%
rename from arch/m68k/include/asm/processor_mm.h
rename to arch/m68k/include/asm/processor.h
index 1f61ef5..74fd674 100644
@@ -20,15 +20,24 @@
 
 static inline unsigned long rdusp(void)
 {
+#ifdef CONFIG_COLDFIRE
+	extern unsigned int sw_usp;
+	return sw_usp;
+#else
 	unsigned long usp;
-
 	__asm__ __volatile__("move %/usp,%0" : "=a" (usp));
 	return usp;
+#endif
 }
 
 static inline void wrusp(unsigned long usp)
 {
+#ifdef CONFIG_COLDFIRE
+	extern unsigned int sw_usp;
+	sw_usp = usp;
+#else
 	__asm__ __volatile__("move %0,%/usp" : : "a" (usp));
+#endif
 }
 
 /*
@@ -49,12 +58,16 @@ static inline void wrusp(unsigned long usp)
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
  */
+#ifdef CONFIG_MMU
 #ifndef CONFIG_SUN3
 #define TASK_UNMAPPED_BASE	0xC0000000UL
 #else
 #define TASK_UNMAPPED_BASE	0x0A000000UL
 #endif
 #define TASK_UNMAPPED_ALIGN(addr, off)	PAGE_ALIGN(addr)
+#else
+#define TASK_UNMAPPED_BASE	0
+#endif
 
 struct thread_struct {
 	unsigned long  ksp;		/* kernel stack pointer */
@@ -78,6 +91,7 @@ struct thread_struct {
 	.info	= INIT_THREAD_INFO(init_task),				\
 }
 
+#ifdef CONFIG_MMU
 /*
  * Do necessary setup to start up a newly executed thread.
  */
@@ -92,6 +106,32 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,
 	wrusp(usp);
 }
 
+#else
+
+/*
+ * Coldfire stacks need to be re-aligned on trap exit, conventional
+ * 68k can handle this case cleanly.
+ */
+#ifdef CONFIG_COLDFIRE
+#define reformat(_regs)		do { (_regs)->format = 0x4; } while(0)
+#else
+#define reformat(_regs)		do { } while (0)
+#endif
+
+#define start_thread(_regs, _pc, _usp)                  \
+do {                                                    \
+	set_fs(USER_DS); /* reads from user space */    \
+	(_regs)->pc = (_pc);                            \
+	((struct switch_stack *)(_regs))[-1].a6 = 0;    \
+	reformat(_regs);                                \
+	if (current->mm)                                \
+		(_regs)->d5 = current->mm->start_data;  \
+	(_regs)->sr &= ~0x2000;                         \
+	wrusp(_usp);                                    \
+} while(0)
+
+#endif
+
 /* Forward declaration, a strange C thing */
 struct task_struct;
 
arch/m68k/include/asm/processor_no.h deleted +0 -143

143 lines not on this page · raw message