Commit 43d66052 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Change to the policy of loading the FAT inside Service_Identify disc.

Now,for fixed discs,we read uncached as much as possible into as big a
lump of RMA as possible.
Reduced mounting a 128M flash keyring from 21s to 1.5s!

Version 0.77. Tagged as 'DOSFS-0_77'
parent 1f55e15c
/* (0.76)
/* (0.77)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
*
*/
#define Module_MajorVersion_CMHG 0.76
#define Module_MajorVersion_CMHG 0.77
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Jun 2003
#define Module_Date_CMHG 26 Jun 2003
#define Module_MajorVersion "0.76"
#define Module_Version 76
#define Module_MajorVersion "0.77"
#define Module_Version 77
#define Module_MinorVersion ""
#define Module_Date "13 Jun 2003"
#define Module_Date "26 Jun 2003"
#define Module_ApplicationDate "13-Jun-03"
#define Module_ApplicationDate "26-Jun-03"
#define Module_ComponentName "DOSFS"
#define Module_ComponentPath "RiscOS/Sources/FileSys/ImageFS/DOSFS"
#define Module_FullVersion "0.76"
#define Module_HelpVersion "0.76 (13 Jun 2003)"
#define Module_LibraryVersionInfo "0:76"
#define Module_FullVersion "0.77"
#define Module_HelpVersion "0.77 (26 Jun 2003)"
#define Module_LibraryVersionInfo "0:77"
......@@ -387,7 +387,7 @@ static void validatedosformat(ADFS_drecord *dr,_kernel_swi_regs *rset)
_kernel_swi_regs urset ;
_kernel_oserror *rerror = NULL ;
char *sector;
char *sector,*sectorblock;
byte *name;
DOS_bootsector *bblock;
FS_discop64 opblock;
......@@ -399,7 +399,7 @@ static void validatedosformat(ADFS_drecord *dr,_kernel_swi_regs *rset)
int bufsz = 0;
word winioffset = 0;
bool floppy = !((log2secsize(dr) == 0) || (dr->dr_floppy_density == 0) || (secspertrk(dr) == 0) || (heads(dr) == 0));
int loop, index;
int loop, index, step;
tracef1("DOSFS: validatedosformat: treating as a %s disc\n",floppy ? "floppy" : "fixed");
/* If it is a floppy then insist on a few floppyesque parameters */
......@@ -444,8 +444,8 @@ static void validatedosformat(ADFS_drecord *dr,_kernel_swi_regs *rset)
urset.r[8] = rset->r[8] ; /* entry FileCore private word pointer */
if (discopswi==FileCore_DiscOp)
{
urset.r[1] = (9 | (4 << 4) | (((int)dr >> 2) << 8)) ;
urset.r[2] = dr->dr_rootSIN & 0xE0000000 ; /* disc address */
urset.r[1] = (9 | (4 << 4) | (((int)dr >> 2) << 8)) ; /* read cached here */
urset.r[2] = dr->dr_rootSIN & 0xE0000000 ; /* disc address */
}
else
{
......@@ -490,35 +490,47 @@ static void validatedosformat(ADFS_drecord *dr,_kernel_swi_regs *rset)
* also to calculate a disc ID to pass back to FileCore.
*/
tracef0("DOSFS: validatedosformat: reading FAT\n");
for (index = 0; index < FATsize; index += DOSsecsize)
sectorblock = realloc(sector,FATsize);
if (sectorblock == NULL)
{
step = DOSsecsize; /* Low on memory,so FAT is read one sector at a time */
}
else
{
sector = sectorblock;
step = FATsize; /* Enough memory to load the whole FAT at once */
}
for (index = 0; index < FATsize; index += step)
{
urset.r[3] = (word)sector ;
urset.r[4] = DOSsecsize ;
urset.r[4] = step ;
/* sector cache handle and FileCore private word pointer preserved from above call */
if (discopswi==FileCore_DiscOp)
{
urset.r[1] = (9 | (4 << 4) | (((int)dr >> 2) << 8)) ;
urset.r[1] = ((floppy ? 9 : 1) | (4 << 4) | (((int)dr >> 2) << 8)) ;
urset.r[2] = (index + DOSsecsize + winioffset) | (dr->dr_rootSIN & 0xE0000000); /* disc address */
}
else
{
/* rely on r1 and r2 being preserved,and the drive number in the block */
/* rely on r2 being preserved,and the drive number in the block */
opblock.byteaddresslo = index + DOSsecsize + winioffset;
opblock.byteaddresshi = 0;
urset.r[1] = ((floppy ? 9 : 1) | (4 << 4)); /* Read uncached for fixed discs */
urset.r[5] = (int)dr;
}
if ((rerror = _kernel_swi(discopswi,&urset,&urset)) == NULL)
{
/* Check the first byte of the FAT for the 320K or 160K media type. */
if ((*sector == 0xFE) && (magic==0))
if ((*sector == 0xFE) && (magic==0) && (index==0))
{
magic = 0xFE;
ROOTsize = 64 * sizeof(DOS_direntry);
discsize(dr) = 0x28000;
heads(dr) = 1;
}
if ((*sector == 0xFF) && (magic==0))
if ((*sector == 0xFF) && (magic==0) && (index==0))
{
magic = 0xFF;
ROOTsize = 112 * sizeof(DOS_direntry);
......@@ -527,8 +539,8 @@ static void validatedosformat(ADFS_drecord *dr,_kernel_swi_regs *rset)
}
}
/* We're certain it's a DOS disc so calculate a disc ID from the FAT contents */
for (loop = 0; loop < DOSsecsize; loop++)
discID += sector[loop] ;
for (loop = 0; loop < step; loop++)
discID += sector[loop] ;
}
/* In all circumstances we'd have deduced the magic number by now */
......@@ -562,7 +574,7 @@ static void validatedosformat(ADFS_drecord *dr,_kernel_swi_regs *rset)
if (discopswi==FileCore_DiscOp)
{
/* sector cache handle and FileCore private word pointer preserved from above call */
urset.r[1] = (9 | (4 << 4) | (((int)dr >> 2) << 8)) ;
urset.r[1] = ((floppy ? 9 : 1) | (4 << 4) | (((int)dr >> 2) << 8)) ;
urset.r[2] = ((numFATs * FATsize) + loop + DOSsecsize + winioffset) | (dr->dr_rootSIN & 0xE0000000) ; /* disc address */
}
else
......@@ -1589,7 +1601,7 @@ _kernel_oserror *init_fs(const char *cmd_tail,int podule_base,void *privateword)
/* Ignore error here, if setting the variable fails then "fc4" will be used. */
(void)_kernel_swi(OS_SetVarVal, &r, &r);
r.r[1] = (int)"FileCore_DiscOp64\0";
r.r[1] = (int)"FileCore_DiscOp64";
if (_kernel_swi(OS_SWINumberFromString, &r, &r)==NULL) discopswi = r.r[0];
tracef0("DOSFS: init_fs: exiting\n") ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment