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

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



New version of this patch, the #ifdef statements are removed and only
instructions compatible with 68000, 020-60 and ColdFire are used.
I've tested it with Aranym.

Commit message:

Make USB mass storage driver compilable for ColdFire and 68000 architectures.

2014-01-27 9:55 GMT+01:00 David Gálvez <dgalvez75@gmail.com>:
> 2014-01-26 Alan Hourihane <alanh@fairlite.co.uk>:
>> On 01/26/14 19:31, David Gálvez wrote:
>>>
>>> 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.
>>
>>
>> Mmm, o.k. so I guess the code hasn't been tested on the FireBee ?
>>
>
> No, not yet because the EHCI udd module isn't finished. I'm working on
> it right now but it depends in other code outside MiNT. BaS doesn't
> have a complete PCI-BIOS yet, and FireTOS doesn't like when we unhook
> its USB interrupt handle and we hook ours, mouse (ATARI not USB) stops
> working and other weird things happens.
Index: bios.S
===================================================================
RCS file: /mint/freemint/sys/usb/src.km/udd/storage/bios.S,v
retrieving revision 1.8
diff -u -8 -r1.8 bios.S
--- bios.S	15 Feb 2014 21:07:06 -0000	1.8
+++ bios.S	15 Feb 2014 22:00:19 -0000
@@ -167,47 +167,66 @@
 	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
+	move.l D4,D2
+	add.l D2,D2
+	move.l D0,(A0,D2.l)		// B15:swap, B7:change, B0:bootable
 	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
-	move.l D2,pinfo_ptype(A3,D4.l*4)
+	lea pinfo_ptype(A3),A2
+	move.l D4,D3
+	add.l D3,D3
+	add.l D3,D3
+	move.l D2,(A2,D3.l)
 	jmp .end_ptype
 .dos_partition:
 	clr.l D3
 	move.b D2,D3
-	move.w #0x0044,pinfo_ptype(A3,D4.l*4)          		// NULL+ 'D'
-	move.b D3,pinfo_ptype+2(A3,D4.l*4)
+	lea pinfo_ptype(A3),A2
+	move.l D4,D1
+	add.l D1,D1
+	add.l D1,D1
+	move #0x044,D0	// NULL+ 'D'
+	move.w D0,(A2,D1)
+	lea pinfo_ptype+2(A3),A2
+	move.l D4,D1
+	add.l D1,D1
+	add.l D1,D1
+	move.b D3,(A2,D1)
 .end_ptype:
 	move.l 48(SP),D3         // part_size
 	move.l 44(SP),D1         // part_offset
 	move.l 36(SP),D0         // dev_num
-	move.b D0,pinfo_devnum(A3,D4.l)
+	lea pinfo_devnum(A3),A2
+	move.b D0,(A2,D4.l)
 	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)	
+	move.l D4,D2
+	add.l D2,D2
+	add.l D2,D2
+	move.l D3,(A0,D2.l)	// size
+	move.l D1,pinfo_pstart(A3,D2.l)
 	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
@@ -288,17 +307,20 @@
 	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 
+	move D4,D3
+	add.l D3,D3
+	add.l D3,D3
+	move.l (A2,D3.l),D2	// partition size in sectors
 	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
@@ -312,17 +334,20 @@
 	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
-	move.l A3,(A0,D4.l*4)
+	move.l D4,D3
+	add.l D3,D3
+	add.l D3,D3
+	move.l A3,(A0,D3.l)
 	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
@@ -404,17 +429,17 @@
 .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
-	subq.w #1,D0
+	subq.l #1,D0
 	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
@@ -441,17 +466,26 @@
 	bpl.s .dhbu1
 .dhbu2:
 	move.l (SP)+,A0
 	moveq #0,D0
 	move.l old_hdv_bpb_usb,-(SP)
 	rts
 .dhbu1:
 	move.l D1,-(SP)
-	move.l pinfo_ptype(A0,D0.l*4),D1
+	move.l A0,-(SP)
+	add.l pinfo_ptype,A0
+	move.l D2,-(SP)
+	move.l D0,D2
+	add.l D2,D2
+	add.l D2,D2
+	move.l (A0,D2.l),D1
+	move (SP)+,D2
+	move.l (SP)+,A0
+
 	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:
@@ -567,34 +601,43 @@
 	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
-	move.l pinfo_pstart(A0,D0.l*4),D3
-	move.l pinfo_devnum(A0,D0.l),D4	 // devnum in the USB bus
+	move.l D0,D4
+	add.l D4,D4
+	add.l D4,D4
+	move.l pinfo_pstart(A0,D4.l),D3
+	move.l A0,-(SP)
+	add.l pinfo_devnum,A0
+	move.l (A0,D0.l),D4	// devnum in the USB bus
 	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
-	mulu.l D0,D2
+	move.l D0,-(SP)
+	move.l D2,-(SP)
+	jsr ___mulsi3
+	addq.l #8,(SP)
+	move D0,D2
 	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: 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
--- debug2.S	17 Apr 2012 16:53:34 -0000	1.2
+++ debug2.S	15 Feb 2014 22:00:19 -0000
@@ -14,59 +14,62 @@
  * 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          
+	lsr.l #8,D0          
 	bsr.s hex_byte     
 	move.w (SP)+,D0
 hex_byte:
 	move.w D0,-(SP)
-	lsr.b #4,D0        
+	lsr.l #4,D0        
 	bsr.s hex_char      
 	move.w (SP)+,D0      
 hex_char:
-	and.b #0xF,D0      
-	or.b #0x30,D0      
+	and.l #0xF,D0      
+	or.l #0x30,D0      
 	cmp.b #0x3A,D0     
 	bcs.s display_char  
-	addq.b #7,D0   
+	addq.l #7,D0   
 	    
 display_char:
-	and.w #0xFF,D0  
-	movem.l D0-D2/A0-A2,-(SP)
+	and.l #0xFF,D0  
+	lea -24(SP),SP
+	movem.l D0-D2/A0-A2,(SP)
 	move.w D0,-(sp)
 	jsr _bconout_from_S       // Bconout
 	addq.l #2,SP
-	movem.l (SP)+,D0-D2/A0-A2
+	movem.l (SP),D0-D2/A0-A2
+	lea 24(SP),SP
 	rts
 	
 display_string:
-	movem.l D0/A0,-(SP)
+	lea -8(SP),SP
+	movem.l D0/A0,(SP)
 .os2:
 	move.b (A0)+,D0
 	beq.s .os1
 	bsr display_char
 	bra.s .os2
 .os1:
-	movem.l (SP)+,D0/A0
+	movem.l (SP),D0/A0
+	lea 8(SP),SP
 	rts