[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] FreeMiNT for ColdFire



Hello.

Finally, I have reviewed some ColdFire patches for FreeMiNT which have been sleeping on my hard disk for a few months. Here is he first batch (more will come in a few days).

As benefits, we have recovered the keyboard.tbl support and the ramdisk :-)
And also, a workaround for the idle bug on FireTOS.

I have only tested the kernel and MiS on FireTOS, it still works fine.
Since I have patched all the .h files containing inline assembly, all the C files should compile well for ColdFire (including drivers, etc. - but still untested).

To test that kernel on FireTOS on the FireBee, just cd to sys and "make col" as usual (I will make deeper changes to the makefiles later). Or just wait for the next daily snapshot :-)

Alan, please commit those patches in the trunk!
Here are the CVS descriptions:

- makefiles.patch
Changed the obsolete -mcfv4e ColdFire option into -mcpu=5475. Contributed by Vincent Riviere.

- firetos.patch
Workaround for the buggy STOP instruction in FireTOS. Contributed by Vincent Riviere.

- headers.patch
Added ColdFire support. Contributed by Vincent Riviere.

- akp.patch
Added ColdFire support. Contributed by Vincent Riviere.

- features.patch
Enabled AKB keyboard and RAMFS for ColdFire. Contributed by Vincent Riviere.

--
Vincent Rivière
diff -x CVS -aurN freemint.orig/sys/RULES freemint/sys/RULES
--- freemint.orig/sys/RULES	2006-11-30 23:22:31.000000000 +0100
+++ freemint/sys/RULES	2011-03-20 11:31:20.765625000 +0100
@@ -13,7 +13,7 @@
 INCLUDES = -I$(top_srcdir)
 DEFINITIONS = 
 ifeq ($(CPU),v4e)
-MODEL = -mcfv4e
+MODEL = -mcpu=5475
 else
 MODEL = -m68$(CPU)
 endif
diff -x CVS -aurN freemint.orig/xaaes/src.km/RULES freemint/xaaes/src.km/RULES
--- freemint.orig/xaaes/src.km/RULES	2010-09-12 10:20:09.375000000 +0200
+++ freemint/xaaes/src.km/RULES	2011-03-20 11:31:29.234375000 +0100
@@ -14,7 +14,7 @@
 DEFINITIONS =
 
 ifeq ($(CPU),v4e)
-MODEL = -mcfv4e
+MODEL = -mcpu=5475
 else
 MODEL = -m68$(CPU)
 endif
diff -x CVS -aurN freemint.orig/sys/init.c freemint/sys/init.c
--- freemint.orig/sys/init.c	2010-12-14 18:06:58.734375000 +0100
+++ freemint/sys/init.c	2011-03-20 12:46:41.812500000 +0100
@@ -1151,7 +1151,7 @@
 	if (pid > 0)
 	{
 		do {
-# if 1
+# if !defined(COLDFIRE)
 			r = sys_pwaitpid(-1, 1, NULL);
 			if (r == 0)
 			{
diff -x CVS -aurN freemint.orig/sys/mint/arch/asm_misc.h freemint/sys/mint/arch/asm_misc.h
--- freemint.orig/sys/mint/arch/asm_misc.h	2006-11-30 22:43:27.000000000 +0100
+++ freemint/sys/mint/arch/asm_misc.h	2010-07-18 13:57:02.156250000 +0200
@@ -39,6 +39,28 @@
 # define MINT_CLOBBER_LIST
 #endif
 
+/* Macros for ColdFire compatibility. */
+
+#ifdef __mcoldfire__
+
+#define PUSH_SP(regs,size)						\
+	"lea	sp@(-" #size "),sp\n\t"					\
+	"movml	" regs ",sp@\n\t"
+
+#define POP_SP(regs,size)						\
+	"movml	sp@," regs "\n\t"					\
+	"lea	sp@(" #size "),sp\n\t"
+
+#else
+
+#define PUSH_SP(regs,size)						\
+	"movml	" regs ",sp@-\n\t"
+
+#define POP_SP(regs,size)						\
+	"movml	sp@+," regs "\n\t"
+
+#endif
+
 /* On TOS 1.04, when calling Bconout(2,'\a') the VDI jumps directly
    back to the BIOS which expects the register A5 to be set to zero.
    (Specifying the register as clobbered does not work.) */
@@ -50,13 +72,13 @@
 	short _a = (short)(a);			\
 						\
 	__asm__ volatile			\
-	("  moveml d5-d7/a4-a6,sp@-;		\
-	    movew %2,sp@-;			\
-	    movel %1,a0;			\
-	    subal a5,a5;			\
-	    jsr a0@;				\
-	    addqw #2,sp;			\
-	    moveml sp@+,d5-d7/a4-a6 "		\
+	(   PUSH_SP("d5-d7/a4-a6", 24)		\
+	    "movew	%2,sp@-\n\t"		\
+	    "movel	%1,a0\n\t"		\
+	    "subal	a5,a5\n\t"		\
+	    "jsr	a0@\n\t"		\
+	    "addql	#2,sp\n\t"		\
+	    POP_SP("d5-d7/a4-a6", 24)		\
 	: "=r"(retvalue)	/* outputs */	\
 	: "r"(_f), "r"(_a)	/* inputs */	\
 	:  MINT_CLOBBER_LIST /* clobbered regs */ \
@@ -72,14 +94,14 @@
 	short _b = (short)(b);			\
 						\
 	__asm__ volatile			\
-	("  moveml d5-d7/a4-a6,sp@-;		\
-	    movew %3,sp@-;			\
-	    movew %2,sp@-;			\
-	    movel %1,a0;			\
-	    subal a5,a5;			\
-	    jsr a0@;				\
-	    addqw #4,sp;			\
-	    moveml sp@+,d5-d7/a4-a6 "		\
+	(   PUSH_SP("d5-d7/a4-a6", 24)		\
+	    "movew	%3,sp@-\n\t"		\
+	    "movew	%2,sp@-\n\t"		\
+	    "movel	%1,a0\n\t"		\
+	    "subal	a5,a5\n\t"		\
+	    "jsr	a0@\n\t"		\
+	    "addql	#4,sp\n\t"		\
+	    POP_SP("d5-d7/a4-a6", 24)		\
 	: "=r"(retvalue)	/* outputs */	\
 	: "r"(_f), "r"(_a), "r"(_b) /* inputs */ \
 	: MINT_CLOBBER_LIST /* clobbered regs */ \
diff -x CVS -aurN freemint.orig/sys/mint/arch/asm_spl.h freemint/sys/mint/arch/asm_spl.h
--- freemint.orig/sys/mint/arch/asm_spl.h	2003-01-13 18:18:31.000000000 +0100
+++ freemint/sys/mint/arch/asm_spl.h	2010-07-18 13:46:34.906250000 +0200
@@ -59,12 +59,23 @@
 splhigh (void)
 {
 	register __u16 sr;
+#ifdef __mcoldfire__
+	register __u16 tempo;
+#endif
 	
 	__asm__ volatile
 	(
-		"movew sr, %0;"
-		"oriw  #0x0700, sr"
+#ifdef __mcoldfire__
+		"movew   sr,%0\n\t"
+		"movew   %0,%1\n\t"
+		"oril    #0x0700,%1\n\t"
+		"movew   %1,sr"
+		: "=d" (sr), "=d" (tempo)
+#else
+		"movew   sr,%0\n\t"
+		"oriw    #0x0700,sr"
 		: "=d" (sr)
+#endif
 	);
 	
 	return sr; 
@@ -76,7 +87,7 @@
 {
 	__asm__ volatile
 	(
-		"movew %0, sr"
+		"movew   %0,sr"
 		:
 		: "d" (sr)
 	);
diff -x CVS -aurN freemint.orig/sys/mint/arch/bswap.h freemint/sys/mint/arch/bswap.h
--- freemint.orig/sys/mint/arch/bswap.h	2001-10-31 13:08:52.000000000 +0100
+++ freemint/sys/mint/arch/bswap.h	2011-03-20 21:06:16.234375000 +0100
@@ -35,6 +35,8 @@
 # define _mint_m68k_bswap_h
 
 
+#ifndef __mcoldfire__
+
 static inline __u16
 __asm_bswap16 (register __u16 x)
 {
@@ -90,5 +92,7 @@
 # define HAVE_ASM_BSWAP64
 # endif
 
+#endif /* __mcoldfire__ */
+
 
 # endif /* _mint_m68k_bswap_h */
diff -x CVS -aurN freemint.orig/sys/mint/arch/swap.h freemint/sys/mint/arch/swap.h
--- freemint.orig/sys/mint/arch/swap.h	2001-10-31 13:08:52.000000000 +0100
+++ freemint/sys/mint/arch/swap.h	2010-07-18 13:39:50.828125000 +0200
@@ -40,7 +40,7 @@
 {
 	__asm__
 	(
-		"swap %0;"
+		"swap    %0"
 		: "=d" (x)
 		: "0" (x)
 	);
diff -x CVS -aurN freemint.orig/sys/arch/acia.S freemint/sys/arch/acia.S
--- freemint.orig/sys/arch/acia.S	2007-07-13 23:32:49.000000000 +0200
+++ freemint/sys/arch/acia.S	2011-03-20 12:11:51.609375000 +0100
@@ -41,16 +41,33 @@
 	dc.l	0
 
 _new_acia:
+#ifdef __mcoldfire__
+	lea	-32(sp),sp
+	movem.l	d0-d3/a0-a3,(sp)
+#else
 	movem.l	d0-d3/a0-a3,-(sp)
+#endif
 again:	move.l	_syskey,a3
 //	move.l	VMIDISYS(a3),a0
 //	jsr	(a0)
 	move.l	VIKBDSYS(a3),a0
 	jsr	(a0)
+#ifdef __mcoldfire__
+	moveq.l	#04,d0
+	btst	d0,0xfa01.w	//(0xfa01).w
+#else
 	btst	#04,0xfa01.w	//(0xfa01).w
+#endif
 	beq.s	again
+#ifdef __mcoldfire__
+	moveq.l	#6,d0
+	bclr	d0,0xfa11.w	//move.b	#0xbf,(0xfa11).w
+	movem.l	(sp),d0-d3/a0-a3
+	lea	32(sp),sp
+#else
 	movem.l	(sp)+,d0-d3/a0-a3
 	bclr	#6,0xfa11.w	//move.b	#0xbf,(0xfa11).w
+#endif
 #ifdef M68000
 	nop				// see intr.S and syscall.S
 #endif
@@ -98,7 +115,11 @@
 	bne.s	mid_multiple
 	cmp.b	#0xf6,d0		// $f6-$ff are multibyte packets
 	bcc.s	not_keyboard
+#ifdef __mcoldfire__
+	and.l	#0xff,d0
+#else
 	and.w	#0xff,d0
+#endif
 	move.l	_keyrec,-(sp)
 	move.w	d0,-(sp)
 	jsr	_ikbd_scan
@@ -110,16 +131,29 @@
 //	jmp	(a1)
 
 not_keyboard:
+#ifdef __mcoldfire__
+	sub.l	#0xf6,d0
+#else
 	sub.b	#0xf6,d0
+#endif
 
 // unlike some documentation states, syskey->ikbdstate contains
 // the type of the packet, and not the number of bytes transmitted.
 
 	lea	type,a1
+#ifdef __mcoldfire__
+	move.b	(a1,d0.l),IKBDSTATE(a3)	
+#else
 	move.b	(a1,d0.w),IKBDSTATE(a3)	
+#endif
 	lea	todo,a1
+#ifdef __mcoldfire__
+	move.b	(a1,d0.l),IKBDTODO(a3)
+	add.l	#0xf6,d0
+#else
 	move.b	(a1,d0.w),IKBDTODO(a3)
 	add.b	#0xf6,d0
+#endif
 	cmp.b	#0xf8,d0
 	blt.s	joy
 	cmp.b	#0xfb,d0
@@ -133,7 +167,12 @@
 ret:	rts
 
 mid_multiple:
+#ifdef __mcoldfire__
+	moveq.l	#0x06,d1
+	cmp.b	IKBDSTATE(a3),d1
+#else
 	cmp.b	#0x06,IKBDSTATE(a3)
+#endif
 	bcs.s	nostk
 
 	clr.l	d1
@@ -151,6 +190,18 @@
 	clr.l	d2
 	move.b	IKBDSTATE(a3),d2
 
+#ifdef __mcoldfire__
+	subq.l	#1,d2
+
+	move.l	d2,d3
+	lsl.l	#3,d2			// multiply by 8
+	lsl.l	#2,d3			// multiply by 4
+	add.l	d3,d2			// multiply by 12
+
+	move.l	(a2,d2.l),a0		// get buffer address for packet
+	move.l	4(a2,d2.l),a1		// get buffer end for packet
+	move.l	8(a2,d2.l),d3		// routine to call
+#else
 	subq.w	#1,d2
 
 	move.w	d2,d3
@@ -161,13 +212,21 @@
 	move.l	(a2,d2.w),a0		// get buffer address for packet
 	move.l	4(a2,d2.w),a1		// get buffer end for packet
 	move.l	8(a2,d2.w),d3		// routine to call
+#endif
 	move.l	(a3,d3.l),a2
 
 	clr.l	d2
 	move.b	IKBDTODO(a3),d2
 	sub.l	d2,a1
 	move.b	d0,(a1)
+#ifdef __mcoldfire__
+	moveq.l	#0,d0
+	move.b	IKBDTODO(a3),d0
+	subq.l	#1,d0
+	move.b	d0,IKBDTODO(a3)
+#else
 	subq.b	#1,IKBDTODO(a3)
+#endif
 	tst.b	IKBDTODO(a3)
 	bne.s	xret
 
diff -x CVS -aurN freemint.orig/sys/KERNELDEFS freemint/sys/KERNELDEFS
--- freemint.orig/sys/KERNELDEFS	2010-09-12 10:20:06.843750000 +0200
+++ freemint/sys/KERNELDEFS	2011-03-20 11:38:40.687500000 +0100
@@ -95,7 +95,7 @@
 ifeq ($(kernel),col)
 MINT = mintv4e.prg
 CPU  = v4e
-KERNELDEFS = -DDEBUG_INFO -DM68040 -DNO_AKP_KEYBOARD -DNO_RAMFS -DNO_FAKE_SUPER -DCOLDFIRE -DC_ONLY
+KERNELDEFS = -DDEBUG_INFO -DM68040 -DNO_FAKE_SUPER -DCOLDFIRE -DC_ONLY
 endif
 
 ifeq ($(kernel),mil)