Skip to content

Commit 4831c94

Browse files
committed
[fat-handler 42.06] - Support for non-partitioned SD
1 parent c79be06 commit 4831c94

11 files changed

Lines changed: 104 additions & 99 deletions

File tree

arch/m68k-amiga/boot/romlog.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Idx Name Size VMA LMA File off Algn
2-
0 .rom 00078d44 00f80000 00f80000 0007c000 2**2
3-
1 .ext 00078452 00e00000 00e00000 00002000 2**2
2+
0 .rom 00078cd4 00f80000 00f80000 0007c000 2**2
3+
1 .ext 0007845e 00e00000 00e00000 00002000 2**2

arch/m68k-amiga/devs/sagasd/sagasd_device.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ static LONG SAGASD_PerformSCSI(struct IORequest *io)
236236
default:
237237
if (i >= 8 && i < 36)
238238
{
239-
if (sdu->sdu_SDCmd.unitnumber == 0) val = "Apollo SD-Card Slot #1 "[i - 8];
240-
if (sdu->sdu_SDCmd.unitnumber == 1) val = "Apollo SD-Card Slot #2 "[i - 8];
241-
if (sdu->sdu_SDCmd.unitnumber == 2) val = "Apollo SD-Card Slot #3 "[i - 8];
239+
if (sdu->sdu_SDCmd.unitnumber == 0) val = "Apollo SD-Card Slot #0 "[i - 8];
240+
if (sdu->sdu_SDCmd.unitnumber == 1) val = "Apollo SD-Card Slot #1 "[i - 8];
241+
if (sdu->sdu_SDCmd.unitnumber == 2) val = "Apollo SD-Card Slot #2 "[i - 8];
242242
} else {
243243
if (i >= 36 && i < 44)
244244
{
@@ -749,7 +749,7 @@ static void SAGASD_IOTask(struct Library *SysBase)
749749
BOOL sdpin = FALSE;
750750
ULONG detectcounter = 0;
751751

752-
//if (sdu->sdu_SDCmd.unitnumber > 0) sdpin = TRUE; //hardware pin enable for SD-Cards Slots #1 and higher
752+
if (sdu->sdu_SDCmd.unitnumber > 0) sdpin = TRUE; //hardware pin enable for SD-Cards Slots #1 and higher
753753

754754
debug("Starting SAGASD_IOTask");
755755

@@ -1076,28 +1076,21 @@ static void SAGASD_InitUnit(struct SAGASDBase * SAGASDBase, int id)
10761076

10771077
switch (id)
10781078
{
1079-
case 0: // SPI#1 | CS=0 | Micro-SD-Card slot (backside)
1079+
case 0: // SPI#1 | CS=0 | Micro-SD-Card slot #0 (Backside)
10801080
sdu->sdu_SDCmd.iobase = SAGA_SD_BASE_SPI1;
10811081
sdu->sdu_SDCmd.cs = SAGA_SD_CTL_NCS;
10821082
sdu->sdu_SDCmd.unitnumber = id;
10831083
sdu->sdu_Enabled = TRUE;
10841084
break;
10851085

1086-
case 1: // SPI#2 | CS=0 | SD-Card slot 1 (Expansion Port)
1086+
case 1: // SPI#2 | CS=0 | SD-Card Slot #1 (Expansion Port)
10871087
sdu->sdu_SDCmd.iobase = SAGA_SD_BASE_SPI2;
10881088
sdu->sdu_SDCmd.cs = SAGA_CS_DRIVE0;
10891089
sdu->sdu_SDCmd.unitnumber = id;
10901090
sdu->sdu_Enabled = TRUE;
10911091
break;
1092-
1093-
//case 2: // SPI#2 | CS=1 | SD-Card slot 1 (Expansion Port)
1094-
//sdu->sdu_SDCmd.iobase = SAGA_SD_BASE_SPI2;
1095-
//sdu->sdu_SDCmd.cs = SAGA_CS_DRIVE1;
1096-
//sdu->sdu_SDCmd.unitnumber = id+1;
1097-
//sdu->sdu_Enabled = TRUE;
1098-
//break;
10991092

1100-
default:
1093+
default:
11011094
sdu->sdu_Enabled = FALSE;
11021095
}
11031096

arch/m68k-amiga/devs/sagasd/sdcmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define SDSIZ_BLOCK 512 /* Block size in bytes */
3333

34-
#define SDCMD_TIMEOUT 100000 /* Times to read for new status */
34+
#define SDCMD_TIMEOUT 1000000 /* Times to read for new status */
3535
#define SDCMD_IDLE_RETRY 100000
3636

3737
#define SDERRF_TIMEOUT (1 << 7)

rom/dosboot/bootscan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ static VOID CheckPartitions(struct ExpansionBase *ExpansionBase, struct Library
317317

318318
//* Cleanup Device Node and if no partitions were found for the DeviceNode or device is SDx: then we put it back
319319
Remove(&bn->bn_Node);
320-
if (!res || (AROS_BSTR_ADDR(dn->dn_Name)[0] == 'S' && AROS_BSTR_ADDR(dn->dn_Name)[1] == 'D'
321-
&& AROS_BSTR_ADDR(dn->dn_Name)[2] == 'R' && AROS_BSTR_ADDR(dn->dn_Name)[3] == 'O' && AROS_BSTR_ADDR(dn->dn_Name)[4] == 'M') )
320+
if (!res)
321+
// || (AROS_BSTR_ADDR(dn->dn_Name)[0] == 'S' && AROS_BSTR_ADDR(dn->dn_Name)[1] == 'D'
322+
// && AROS_BSTR_ADDR(dn->dn_Name)[2] == 'R' && AROS_BSTR_ADDR(dn->dn_Name)[3] == 'O' && AROS_BSTR_ADDR(dn->dn_Name)[4] == 'M') )
322323
{
323324
Enqueue(&ExpansionBase->MountList, &bn->bn_Node);
324325
}

rom/filesys/fat/fat.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##begin config
2-
version 42.05
2+
version 42.06
33
basename fat
44
residentpri -1
55
handler_func handler

rom/filesys/fat/volume.c

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,24 +1014,7 @@ void DoDiskInsert(struct Globals *glob)
10141014
return;
10151015
} else {
10161016
ULONG RDB_ID = ((read_buffer[0]<<24) + (read_buffer[1]<<16) + (read_buffer[2]<<8) + read_buffer[3]);
1017-
D(kprintf("[FAT] [%s] RDB = %4d|%08x\n", __FUNCTION__, 0x200, RDB_ID));
1018-
if(RDB_ID == 0x5244534b)
1019-
{
1020-
glob->diskioreq->iotd_Req.io_Command = 0xffff;
1021-
glob->diskioreq->iotd_Req.io_Length = 1;
1022-
DoIO((struct IORequest *)glob->diskioreq);
1023-
return;
1024-
}
1025-
}
1026-
1027-
err = RawDiskSectorRead(1, geometry.dg_SectorSize, (UBYTE*)&read_buffer[0], glob);
1028-
if (err)
1029-
{
1030-
D(bug("[FAT] [%s] Read Error = %d on BootSector #1 (RDB Check)\n",__FUNCTION__, err ));
1031-
return;
1032-
} else {
1033-
ULONG RDB_ID = ((read_buffer[0]<<24) + (read_buffer[1]<<16) + (read_buffer[2]<<8) + read_buffer[3]);
1034-
D(kprintf("[FAT] [%s] RDB = %4d|%08x\n", __FUNCTION__, 0x200, RDB_ID));
1017+
D(kprintf("[FAT] [%s] RDB = %04x|%08x\n", __FUNCTION__, 0x200, RDB_ID));
10351018
if(RDB_ID == 0x5244534b)
10361019
{
10371020
glob->diskioreq->iotd_Req.io_Command = 0xffff;
@@ -1051,44 +1034,57 @@ void DoDiskInsert(struct Globals *glob)
10511034
}
10521035

10531036
UWORD MBR_ID = (read_buffer[0x1fe]<<8) + read_buffer[0x1ff];
1054-
D(kprintf("[FAT] [%s] MBR = %4d|%08x\n", __FUNCTION__, 0x1fe, MBR_ID));
1037+
D(kprintf("[FAT] [%s] MBR = %04x|%08x\n", __FUNCTION__, 0x1fe, MBR_ID));
10551038
if(MBR_ID != 0x55aa)
10561039
{
10571040
D(bug("[FAT] [%s] No RDB or MBR Boot Record found\n",__FUNCTION__ ));
10581041
return;
10591042
}
10601043

1044+
UBYTE MDB_PART1_STATUS = (read_buffer[0x1be + 0x0]);
10611045
ULONG MDB_PART1_START = (read_buffer[0x1be + 0x8])+(read_buffer[0x1be + 0x9]<<8)+(read_buffer[0x1be + 0xa]<<16)+(read_buffer[0x1be + 0xb]<<24);
10621046
ULONG MDB_PART1_TOTAL = (read_buffer[0x1be + 0xc])+(read_buffer[0x1be + 0xd]<<8)+(read_buffer[0x1be + 0xe]<<16)+(read_buffer[0x1be + 0xf]<<24);
1047+
1048+
UBYTE MDB_PART2_STATUS = (read_buffer[0x1ce + 0x0]);
10631049
ULONG MDB_PART2_START = (read_buffer[0x1ce + 0x8])+(read_buffer[0x1ce + 0x9]<<8)+(read_buffer[0x1ce + 0xa]<<16)+(read_buffer[0x1ce + 0xb]<<24);
10641050
ULONG MDB_PART2_TOTAL = (read_buffer[0x1ce + 0xc])+(read_buffer[0x1ce + 0xd]<<8)+(read_buffer[0x1ce + 0xe]<<16)+(read_buffer[0x1ce + 0xf]<<24);
1051+
1052+
UBYTE MDB_PART3_STATUS = (read_buffer[0x1de + 0x0]);
10651053
ULONG MDB_PART3_START = (read_buffer[0x1de + 0x8])+(read_buffer[0x1de + 0x9]<<8)+(read_buffer[0x1de + 0xa]<<16)+(read_buffer[0x1de + 0xb]<<24);
10661054
ULONG MDB_PART3_TOTAL = (read_buffer[0x1de + 0xc])+(read_buffer[0x1de + 0xd]<<8)+(read_buffer[0x1de + 0xe]<<16)+(read_buffer[0x1de + 0xf]<<24);
1055+
1056+
UBYTE MDB_PART4_STATUS = (read_buffer[0x1ee + 0x0]);
10671057
ULONG MDB_PART4_START = (read_buffer[0x1ee + 0x8])+(read_buffer[0x1ee + 0x9]<<8)+(read_buffer[0x1ee + 0xa]<<16)+(read_buffer[0x1ee + 0xb]<<24);
10681058
ULONG MDB_PART4_TOTAL = (read_buffer[0x1ee + 0xc])+(read_buffer[0x1ee + 0xd]<<8)+(read_buffer[0x1ee + 0xe]<<16)+(read_buffer[0x1ee + 0xf]<<24);
10691059

1070-
D(kprintf("\tPART#1-LBA-Start = %4d|%08x\n", 0x1be + 0x8, MDB_PART1_START));
1071-
D(kprintf("\tPART#1-LBA-Total = %4d|%08x\n", 0x1be + 0xc, MDB_PART1_TOTAL));
1072-
D(kprintf("\tPART#2-LBA-Start = %4d|%08x\n", 0x1ce + 0x8, MDB_PART2_START));
1073-
D(kprintf("\tPART#2-LBA-Total = %4d|%08x\n", 0x1ce + 0xc, MDB_PART2_TOTAL));
1074-
D(kprintf("\tPART#3-LBA-Start = %4d|%08x\n", 0x1de + 0x8, MDB_PART3_START));
1075-
D(kprintf("\tPART#3-LBA-Total = %4d|%08x\n", 0x1de + 0xc, MDB_PART3_TOTAL));
1076-
D(kprintf("\tPART#4-LBA-Start = %4d|%08x\n", 0x1ee + 0x8, MDB_PART4_START));
1077-
D(kprintf("\tPART#4-LBA-Total = %4d|%08x\n\n", 0x1ee + 0xc, MDB_PART4_TOTAL));
1060+
D(bug("\tPART#1 LBA-Start = %04x|%08x | LBA-Total = %04x|%08x | STATUS = %04x|%02x\n", 0x1be + 0x8, MDB_PART1_START, 0x1be + 0xc, MDB_PART1_TOTAL, 0x1be, MDB_PART1_STATUS ));
1061+
D(bug("\tPART#2 LBA-Start = %04x|%08x | LBA-Total = %04x|%08x | STATUS = %04x|%02x\n", 0x1ce + 0x8, MDB_PART2_START, 0x1ce + 0xc, MDB_PART2_TOTAL, 0x1ce, MDB_PART2_STATUS ));
1062+
D(bug("\tPART#3 LBA-Start = %04x|%08x | LBA-Total = %04x|%08x | STATUS = %04x|%02x\n", 0x1de + 0x8, MDB_PART3_START, 0x1de + 0xc, MDB_PART3_TOTAL, 0x1de, MDB_PART3_STATUS ));
1063+
D(bug("\tPART#4 LBA-Start = %04x|%08x | LBA-Total = %04x|%08x | STATUS = %04x|%02x\n", 0x1ee + 0x8, MDB_PART4_START, 0x1ee + 0xc, MDB_PART4_TOTAL, 0x1ee, MDB_PART4_STATUS ));
10781064

10791065
//Final step is to translate MDB_PART1_START LBA addresses to a valid LowCyl and with MDB_PART1_TOTAL also a valid HighCyl
10801066
//LBA = Surfaces * BlocksPerTrack * Cylinders or Cylinders = LBA / Surfaces / BlocksPerTrack
10811067
//In most cases the default values of Surfaces = 16 and BlocksPerTrack = 64 will work, but for smaller SD this may fail because Cylinder must be an integer and >0
10821068

1083-
if ((MDB_PART1_START % de->de_BlocksPerTrack % de->de_Surfaces) == 0)
1069+
if (MDB_PART1_STATUS == 0x00)
10841070
{
1085-
de->de_LowCyl = MDB_PART1_START / de->de_BlocksPerTrack / de->de_Surfaces ; // Read ULONG from MBR-PART1 = 0x1BE + 0x8
1086-
de->de_HighCyl = MDB_PART1_TOTAL / de->de_BlocksPerTrack / de->de_Surfaces + de->de_LowCyl; // Read ULONG from MBR-PART1 = 0x1BE + 0xC
1071+
D(bug("[FAT] Valid First Partition Found\n"));
1072+
if ((MDB_PART1_START % de->de_BlocksPerTrack % de->de_Surfaces) == 0)
1073+
{
1074+
D(bug("[FAT] First Partition Start Block (%d) aligns with Cylinders/Tracks (%d) and Heads/Surfaces (%d)\n", MDB_PART1_START, de->de_BlocksPerTrack, de->de_Surfaces));
1075+
de->de_LowCyl = MDB_PART1_START / de->de_BlocksPerTrack / de->de_Surfaces ;
1076+
de->de_HighCyl = MDB_PART1_TOTAL / de->de_BlocksPerTrack / de->de_Surfaces + de->de_LowCyl;
1077+
} else {
1078+
D(bug("[FAT] First Partition Start Block (%d) does NOT align with Cylinders/Tracks (%d) and Heads/Surfaces (%d)\n", MDB_PART1_START, de->de_BlocksPerTrack, de->de_Surfaces));
1079+
de->de_Surfaces = 1;
1080+
de->de_BlocksPerTrack = 1;
1081+
de->de_LowCyl = MDB_PART1_START;
1082+
de->de_HighCyl = MDB_PART1_TOTAL;
1083+
}
10871084
} else {
1088-
de->de_Surfaces = 1;
1089-
de->de_BlocksPerTrack = 1;
1090-
de->de_LowCyl = MDB_PART1_START;
1091-
de->de_HighCyl = MDB_PART1_TOTAL;
1085+
D(bug("[FAT] NO Valid First Partition Found, default to Full Disk Partition\n"));
1086+
de->de_LowCyl = 0;
1087+
de->de_HighCyl = geometry.dg_Cylinders;
10921088
}
10931089

10941090
D(bug("\n[FAT] [%s] Drive Geometry transfer to glob->fssm->fssm_Environ:\n",__FUNCTION__ ));

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Release 9.5 Final
1+
Release 9.5

workbench/system/BHFormat/cli.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ int rcCliMain(void)
7676
prda = ReadArgs(ARGS_TEMPLATE, (IPTR *)&args, 0 );
7777
if( prda == 0 )
7878
{
79-
PrintFault( IoErr(), 0 );
80-
return RETURN_ERROR;
79+
PrintFault( IoErr(), 0 );
80+
DD(bug("[FORMAT-CLI] Error Reading Args\n"));
81+
return RETURN_ERROR;
8182
}
8283

8384
{
@@ -89,22 +90,22 @@ int rcCliMain(void)
8990
try opening the console, or as a last resort sending errors to
9091
COS instead */
9192
if( bpfhStdErr == 0 )
92-
{
93-
if( (bpfhStdErr = Open( "*", MODE_NEWFILE )) == 0 )
94-
bpfhStdErr = bpfhStdOut;
95-
else
96-
bCloseStdErr = TRUE;
97-
}
93+
{
94+
if( (bpfhStdErr = Open( "*", MODE_NEWFILE )) == 0 )
95+
bpfhStdErr = bpfhStdOut;
96+
else
97+
bCloseStdErr = TRUE;
98+
}
9899
}
99100

100-
if( !bSetSzDosDeviceFromSz(args.pszDevice)
101-
|| !bSetSzVolumeFromSz(args.pszName)
102-
|| (args.pszType && !bSetFstFromSz(args.pszType))
103-
|| (args.pszFlags && !bSetDevfFromSz(args.pszFlags))
104-
|| !bGetDosDevice(NULL, 0) )
101+
102+
103+
if( !bSetSzDosDeviceFromSz(args.pszDevice) || bSetSzVolumeFromSz(args.pszName) || (args.pszType && !bSetFstFromSz(args.pszType)) || (args.pszFlags && !bSetDevfFromSz(args.pszFlags)) || !bGetDosDevice(NULL, 0) )
105104
{
106-
rc = RETURN_ERROR;
107-
goto cleanup;
105+
rc = RETURN_ERROR;
106+
DD(bug("[FORMAT-CLI] %d %d %d %d %d\n", !bSetSzDosDeviceFromSz(args.pszDevice), bSetSzVolumeFromSz(args.pszName), (args.pszType && !bSetFstFromSz(args.pszType)), (args.pszFlags && !bSetDevfFromSz(args.pszFlags)), !bGetDosDevice(NULL, 0) ));
107+
DD(bug("[FORMAT-CLI] Error Interpreting Args\n"));
108+
goto cleanup;
108109
}
109110

110111
/* Get confirmation before we start the process */
@@ -117,7 +118,7 @@ int rcCliMain(void)
117118
LONG cch;
118119
do {
119120
cch = Read( bpfhStdIn, &ch, 1 );
120-
D(Printf("Character code: %lu\n", ch));
121+
DD(bug("Character code: %lu\n", ch));
121122
} while( cch == 1 && ch != 3 && ch != 13 );
122123
}
123124
SetMode( bpfhStdIn, 0 ); /* cooked input */
@@ -149,14 +150,14 @@ int rcCliMain(void)
149150
if(CheckSignal(SIGBREAKF_CTRL_C))
150151
{
151152
PutStr("\033[ p\n");
152-
D(Printf("Cancelled by user\n"));
153+
DD(bug("Cancelled by user\n"));
153154
PrintFault( ERROR_BREAK, 0 );
154155
formatOk = FALSE;
155156
break;
156157
}
157158

158159
Printf( _(MSG_FORMATTING), icyl, HighCyl-icyl );
159-
D(PutStr("\n"));
160+
DD(bug("\n"));
160161
Flush(bpfhStdOut);
161162
if(!bFormatCylinder(icyl))
162163
{
@@ -167,7 +168,7 @@ int rcCliMain(void)
167168
if(!args.bNoVerify)
168169
{
169170
PutStr( _(MSG_VERIFYING) );
170-
D(PutStr("\n"));
171+
DD(bug("\n"));
171172
Flush(bpfhStdOut);
172173
if(!bVerifyCylinder(icyl))
173174
{

workbench/system/BHFormat/format.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,21 @@
3838

3939
#include <stdarg.h>
4040

41-
#ifdef __AROS__
41+
#if APOLLO_DEBUG
42+
#define DEBUG 1
43+
#else
44+
#define DEBUG 0
45+
#endif
46+
47+
#if DEBUG
4248
#include <aros/debug.h>
4349
#define _WBenchMsg WBenchMsg
4450
#define DD(x) x
4551
#define bug kprintf
52+
#else
53+
#define _WBenchMsg WBenchMsg
54+
#define DD(x)
55+
#define bug
4656
#endif
4757

4858

workbench/system/BHFormat/gui.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ int rcGuiMain(void)
550550

551551
if( _WBenchMsg->sm_ArgList[1].wa_Lock == 0 )
552552
{
553-
DD(bug("[FORMAT] Object specified by Device name: %s\n", _WBenchMsg->sm_ArgList[1].wa_Name);)
553+
DD(bug("[FORMAT] Object specified by Device name: %s\n", _WBenchMsg->sm_ArgList[1].wa_Name));
554554
if( !bSetSzDosDeviceFromSz(_WBenchMsg->sm_ArgList[1].wa_Name) )
555555
{
556556
DD(bug("[FORMAT] Bad device name from Workbench: %s\n", _WBenchMsg->sm_ArgList[1].wa_Name));

0 commit comments

Comments
 (0)