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

[MiNT] [PATCH] Make USB mass storage driver compilable for ColdFire and 68000



I couldn't test it because I don't have the hardware for the 68000
version and we still don't have the EHCI and OHCI drivers for the
FireBee.

Note that the patch will break the build process because the M68000
definition used to check that it's being compiled the 68000 version of
the driver is not defined inside the udd module build environment.

Commit message:

Make USB mass storage driver compilable for ColdFire and 68000 architectures.
Index: usb/src.km/udd/storage/bios.S
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/udd/storage/bios.S,v
retrieving revision 1.7
diff -u -8 -r1.7 bios.S
--- usb/src.km/udd/storage/bios.S	18 Feb 2013 23:32:13 -0000	1.7
+++ usb/src.km/udd/storage/bios.S	26 Jan 2014 18:34:42 -0000
@@ -25,18 +25,16 @@
 
 #undef pun_ptr
 #define pun_ptr _pun_ptr_usb
 
 	.global	_max_logical_drive
 
 #define MAX_LOGICAL_DRIVE	_max_logical_drive
 
-//.chip 68040
-
 	.extern _usb_stor_read,_usb_stor_write 
 	.extern _cconws_from_S, _dsetdrive_from_S, _install_xhdi_driver
 	.extern _product_name, _pun_ptr_usb, _pun_usb
 	.extern _my_drvbits, _usb_1st_disk_drive
 
 	.global _install_usb_stor,_uninstall_usb_stor
 
 #if 0		
@@ -160,47 +158,109 @@
 	bra .end_usb_disk
 .drive_not_exist_usb:
 	move.w pinfo_puns(A3),D0
 	addq.l #1,D0
 	move.w D0,pinfo_puns(A3)
 	moveq #0,D0
 	bset #7,D0               // changed
 	lea pinfo_flags(A3),A0
-	move.l D0,(A0,D4.l*4)    // B15:swap, B7:change, B0:bootable
+#ifdef M68000
+	move.l D4,D2
+	add.w D2,D2
+	add.w D2,D2
+	move.l D0,(A0,D2.l)	// B15:swap, B7:change, B0:bootable
+#else
+	move.l D0,(A0,D4.l*4)	// B15:swap, B7:change, B0:bootable
+#endif
 	lea pinfo_psize(A3),A0
 	move.l 40(SP),D2         // part_type
 	cmp.l #0x4,D2            // FAT16 up to 32M
 	beq.s .dos_partition
 	cmp.l #0x6,D2            // FAT16 over 32M
 	beq.s .dos_partition
 	cmp.l #0xE,D2            // WIN95 FAT16
 	beq .dos_partition
 	cmp.l #0xB,D2		// FAT32
 	beq.s .dos_partition
 	cmp.l #0xC,D2		// FAT32
 	beq.s .dos_partition
+#if !(defined(__mcoldfire__) || defined(M68000))
 	move.l D2,pinfo_ptype(A3,D4.l*4)
+#else
+	move.l A3,A2
+	add.l pinfo_ptype,A2
+#ifdef __mcoldfire__
+	move.l D2,(A2,D4.l*4)
+#else /* M68000 */
+	move.l D4,D3
+	add.w D3,D3
+	add.w D3,D3
+	move.l D2,(A2,D3.l)
+#endif
+#endif
 	jmp .end_ptype
 .dos_partition:
 	clr.l D3
 	move.b D2,D3
-	move.w #0x0044,pinfo_ptype(A3,D4.l*4)          		// NULL+ 'D'
+#if !(defined (__mcoldfire__) || defined (M68000))
+	move.w #0x0044,pinfo_ptype(A3,D4.l*4)	// NULL+ 'D'
+#else
+	move.l A3,A2
+	add.l pinfo_ptype,A2
+#ifdef __mcoldfire__
+	move.w #0x0044,D0	// NULL+ 'D'
+	move.w D0,(A2,D4.l*4)
+#else /* M68000 */
+	move.l D4,D1
+	add.w D1,D1
+	add.w D1,D1
+	move.w #0x0044,(A2,D1)
+#endif
+#endif
+#if !(defined (__mcoldfire__) || defined(M68000))
 	move.b D3,pinfo_ptype+2(A3,D4.l*4)
+#else
+	move.l A3,A2
+	add.l pinfo_ptype+2,A2
+#ifdef __mcoldfire__
+	move.b D3,(A2,D4.l*4)
+#else /* M68000 */
+	move.l D4,D1
+	add.w D1,D1
+	add.w D1,D1
+	move.b D3,(A2,D1)
+#endif
+#endif
+
 .end_ptype:
 	move.l 48(SP),D3         // part_size
 	move.l 44(SP),D1         // part_offset
 	move.l 36(SP),D0         // dev_num
+#if !(defined (__mcoldfire__) || defined (M68000))
 	move.b D0,pinfo_devnum(A3,D4.l)
+#else
+	move.l A3,A2
+	add.l pinfo_devnum,A2
+	move.b D0,(A2,D4.l)
+#endif
 	move.l D4,D2
 	or.l #PUN_USB,D2
 	move.b D2,pinfo_pun(A3,D4.l)
 .ahdi_part_num_limit:			
-	move.l D3,(A0,D4.l*4)    // size
-	move.l D1,pinfo_pstart(A3,D4.l*4)	
+#ifdef M68000
+	move.l D4,D2
+	add.w D2,D2
+	add.w D2,D2
+	move.l D3,(A0,D2.l)	// size
+	move.l D1,pinfo_pstart(A3,D2.l)
+#else
+	move.l D3,(A0,D4.l*4)	// size
+	move.l D1,pinfo_pstart(A3,D4.l*4)
+#endif
 	move.l _dskbufp,A0 
 	move.l A0,-(SP)          // buffer
 	move.l #1,-(SP)          // blkcnt	
 	move.l D1,-(SP)          // blknr
 	move.l D0,-(SP)          // devnum
 	jsr _usb_stor_read
 	lea 16(SP),SP
 	tst.l D0
@@ -281,17 +341,28 @@
 	add.l D3,D0
 	move.w D0,12(A1)         // 1st data sector
 	moveq #0,D2
 	move.b 0x14(A0),D2
 	asl.l #8,D2
 	move.b 0x13(A0),D2       // NSECTS
 	bne.s .nsects_ok_usb
 	lea pinfo_psize(A3),A2
-	move.l (A2,D4.w*4),D2    // partition size in sectors 
+#ifdef __mcoldfire__
+	move.l (A2,D4.l*4),D2	// partition size in sectors
+#else
+#ifdef M68000
+	move D4,D3
+	add.w D3,D3
+	add.w D3,D3
+	move.l (A2,D3.w),D2	// partition size in sectors
+#else /* 020-060 */
+	move.l (A2,D4.w*4),D2	// partition size in sectors
+#endif
+#endif
 	sub.l D0,D2              // - 1st data sector 
 .nsects_ok_usb:
 	divu D1,D2
 	move.w D2,14(A1)         // total clusters 
 	moveq #1,D0 
 	move.w D0,16(A1)         // FAT 16 
 	move.l _drvbits,D0
 	bset D4,D0
@@ -305,17 +376,24 @@
 	move.w D0,_bootdev
 	move.w D0,-(SP)
 	jsr _dsetdrv_from_S
 	addq.l #2,SP
 .no_set_drive_usb:
 	move.l 36(SP),D0         // USB devnum
 	movem.l 52(SP),A1/A2/A3  // vendor / revision / product
 	lea _product_name,A0      // save product name pointer for XHDI
+#ifdef M68000
+	move.l D4,D3
+	add.w D3,D3
+	add.w D3,D3
+	move.l A3,(A0,D3.l)
+#else
 	move.l A3,(A0,D4.l*4)
+#endif
 	bsr display_drive_usb
 	pea message2b(PC)
 	jsr _cconws_from_S       // Cconws 
 	addq.l #4,SP
 	moveq #0x41,D0           // A
 	add.l D4,D0
 	move.w D0,-(SP)
 	jsr _bconout_from_S      // Cconout
@@ -397,17 +475,21 @@
 .ahdi_part_num_limit_2:	
 	move.l pun_ptr,D0
 	move.l D0,A3
 	moveq #-1,D0
 	move.b D0, pinfo_pun(A3,D3.l)
 	clr.l D0
 	move.l D0,pinfo_pstart(A3,D3.l)
 	move.w pinfo_puns(A3),D0
+#ifdef __mcoldfire__
+	subq.l #1,D0
+#else
 	subq.w #1,D0
+#endif
 	move.w D0,pinfo_puns(A3)
 	move.l _drvbits,D0
 	bclr D3,D0
 	move.l D0,_drvbits
 	move.l _my_drvbits,D0
 	bclr D3,D0
 	move.l D0,_my_drvbits
 	move.l D3,D0
@@ -434,17 +516,36 @@
 	bpl.s .dhbu1
 .dhbu2:
 	move.l (SP)+,A0
 	moveq #0,D0
 	move.l old_hdv_bpb_usb,-(SP)
 	rts
 .dhbu1:
 	move.l D1,-(SP)
+#if !(defined(__mcoldfire__) || defined(M68000))
 	move.l pinfo_ptype(A0,D0.l*4),D1
+#else
+#ifdef M68000
+	move.l A0,-(SP)
+	add.l pinfo_ptype,A0
+	move.l D2,-(SP)
+	move.l D0,D2
+	add.w D2,D2
+	add.w D2,D2
+	move.l (A0,D2.l),D1
+	move (SP)+,D2
+	move.l (SP)+,A0
+#else /* mcoldfire */
+	move.l A0,-(SP)
+	add.l pinfo_ptype,A0
+	move.l (A0,D0.l*4),D1
+	move.l (SP)+,A0
+#endif
+#endif
 	and.l #0xFFFFFF,D1
 	cmp.l #0x524157,D1       // RAW
 	beq.s .dhbu4
 	cmp.l #0x81,D1       	 // MINIX
 	beq.s .dhbu4
 	cmp.l #0x83,D1       	 // EXT2/LNX
 	bne.s .dhbu3
 .dhbu4:
@@ -560,34 +661,56 @@
 	cmp.w #0xffff,D2         // Galvez: check recno <> -1
 	bne.s .dhru6		
 	move.l 16+28(SP),D2      // logical sector
 .dhru6:
 	tst.l D2
 	bmi .dhru2               // negative logical sector
 	move.l 6+28(SP),D1       // buffer
 	beq .dhru4               // no buffer
+#ifdef M68000
+	move.l D0,D4
+	add.w D4,D4
+	add.w D4,D4
+	move.l pinfo_pstart(A0,D4.l),D3
+#else
 	move.l pinfo_pstart(A0,D0.l*4),D3
-	move.l pinfo_devnum(A0,D0.l),D4	 // devnum in the USB bus
+#endif
+#if defined(__mcoldfire__) || defined(M68000)
+	move.l A0,-(SP)
+	add.l pinfo_devnum,A0
+	move.l (A0,D0.l),D4	// devnum in the USB bus
+	move.l (SP)+,A0
+#else
+	move.l pinfo_devnum(A0,D0.l),D4	// devnum in the USB bus
+#endif
 	lea pinfo_bpb(A0),A0
 	asl.l #5,D0              // * 32
 	add.l D0,A0
 	move.w 14(A0),D0         // total clusters
 	mulu.w 2(A0),D0          // cluster size in sectors
 	cmp.l D0,D2              // logical sector to hight
 	bcc .dhru2
 	moveq #0,D0
 	move.w (A0),D0           // sector size
 	lsr.l #8,D0
 	lsr.l #1,D0              // / 512
 	move.l D1,A0             // buffer
 	move.w 10+28(SP),D1      // num sectors
 	beq .dhru4               // no sectors
 	mulu D0,D1
+#if M68000
+	move.l D0,-(SP)
+	move.l D2,-(SP)
+	jsr ___mulsi3
+	addq.l #8,(SP)
+	move D0,D2
+#else
 	mulu.l D0,D2
+#endif
 	add.l D3,D2              // start sector
 	move.l D1,D3             // count
 	btst #0,5+28(SP)         // rwflag
 	beq.s .dhru7             // read
 	// write
 	tst.l D2                 // logical sector
 	beq.s .dhru2             // root sector
 	move.l A0,-(SP)          // buffer
Index: usb/src.km/udd/storage/debug2.S
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/udd/storage/debug2.S,v
retrieving revision 1.2
diff -u -8 -r1.2 debug2.S
--- usb/src.km/udd/storage/debug2.S	17 Apr 2012 16:53:34 -0000	1.2
+++ usb/src.km/udd/storage/debug2.S	26 Jan 2014 18:34:42 -0000
@@ -14,59 +14,96 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-	.chip 68040
-	
+
 	.global _bconout_from_S
 
 #include "vars.h"
 
 	.global display_string,hex_long,hex_word,hex_byte,display_char,wait_key,_debug
 
 	.text
 	
 hex_long:
 	move.l D0,-(SP)
 	swap D0
 	bsr.s hex_word
 	move.l (SP)+,D0
 hex_word:
 	move.w D0,-(SP)
-	lsr.w #8,D0          
+#ifdef __mcoldfire__
+	lsr.l #8,D0
+#else
+	lsr.w #8,D0
+#endif
 	bsr.s hex_byte     
 	move.w (SP)+,D0
 hex_byte:
 	move.w D0,-(SP)
-	lsr.b #4,D0        
+#ifdef __mcoldfire__
+	lsr.l #4,D0
+#else
+	lsr.b #4,D0
+#endif
 	bsr.s hex_char      
 	move.w (SP)+,D0      
 hex_char:
-	and.b #0xF,D0      
-	or.b #0x30,D0      
+#ifdef __mcoldfire__
+	and.l #0xF,D0
+	or.l #0x30,D0
+#else
+	and.b #0xF,D0
+	or.b #0x30,D0
+#endif
 	cmp.b #0x3A,D0     
 	bcs.s display_char  
-	addq.b #7,D0   
+#ifdef __mcoldfire__
+	addq.l #7,D0
+#else
+	addq.b #7,D0
+#endif
 	    
 display_char:
-	and.w #0xFF,D0  
+#ifdef __mcoldfire__
+	and.l #0xFF,D0
+	lea -24(SP),SP
+	movem.l D0-D2/A0-A2,(SP)
+#else
+	and.w #0xFF,D0
 	movem.l D0-D2/A0-A2,-(SP)
+#endif
 	move.w D0,-(sp)
 	jsr _bconout_from_S       // Bconout
 	addq.l #2,SP
+#ifdef __mcoldfire__
+	movem.l (SP),D0-D2/A0-A2
+	lea 24(SP),SP
+#else
 	movem.l (SP)+,D0-D2/A0-A2
+#endif
 	rts
 	
 display_string:
+#ifdef __mcoldfire__
+	lea -8(SP),SP
+	movem.l D0/A0,(SP)
+#else
 	movem.l D0/A0,-(SP)
+#endif
 .os2:
 	move.b (A0)+,D0
 	beq.s .os1
 	bsr display_char
 	bra.s .os2
 .os1:
+#ifdef __mcoldfire__
+	movem.l (SP),D0/A0
+	lea 8(SP),SP
+#else
 	movem.l (SP)+,D0/A0
+#endif
 	rts