Commit 6b956286 authored by John Ballance's avatar John Ballance
Browse files

Rounded up a couple of 'zero pains'

Detail:
  Some list checkers produce a null at the end. A couple of routines
  needed to be more robust...
Admin:


Version 0.10. Tagged as 'PartMan-0_10'
parent c71f7a61
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.08"
Module_Version SETA 8
Module_MajorVersion SETS "0.10"
Module_Version SETA 10
Module_MinorVersion SETS ""
Module_Date SETS "17 Mar 2016"
Module_ApplicationDate SETS "17-Mar-16"
Module_ComponentName SETS "SPIDriver"
Module_ComponentPath SETS "private/RiscOS/Sources/HWSupport/SPIDriver"
Module_FullVersion SETS "0.08"
Module_HelpVersion SETS "0.08 (17 Mar 2016)"
Module_Date SETS "01 Dec 2016"
Module_ApplicationDate SETS "01-Dec-16"
Module_ComponentName SETS "PartMan"
Module_ComponentPath SETS "castle/RiscOS/Sources/FileSys/SCSIFS/PartMan"
Module_FullVersion SETS "0.10"
Module_HelpVersion SETS "0.10 (01 Dec 2016)"
END
/* (0.09)
/* (0.10)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.09
#define Module_MajorVersion_CMHG 0.10
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Nov 2016
#define Module_Date_CMHG 01 Dec 2016
#define Module_MajorVersion "0.09"
#define Module_Version 9
#define Module_MajorVersion "0.10"
#define Module_Version 10
#define Module_MinorVersion ""
#define Module_Date "28 Nov 2016"
#define Module_Date "01 Dec 2016"
#define Module_ApplicationDate "28-Nov-16"
#define Module_ApplicationDate "01-Dec-16"
#define Module_ComponentName "PartMan"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/SCSIFS/PartMan"
#define Module_FullVersion "0.09"
#define Module_HelpVersion "0.09 (28 Nov 2016)"
#define Module_LibraryVersionInfo "0:9"
#define Module_FullVersion "0.10"
#define Module_HelpVersion "0.10 (01 Dec 2016)"
#define Module_LibraryVersionInfo "0:10"
......@@ -32,6 +32,7 @@ static _kernel_oserror our_error;
#define MaxZonesNormalDir 0x7f // max number of zones to permit in a format without big dirs
#define MaxZonesBigDir 0x7fff // max number of zones to permit in a format with big dirs
#define CHSRound(c,h,s,secs) {h=16;do{h++;c=secs/h;s=63;while(c%s)s--;c/=s;}while((c>65535)&&(h>255));secs=c*h*s;}
// write a fragment into a zone
// Assume FragmentID and FragmentLen are legitimate
......@@ -73,25 +74,25 @@ int MakeAcornFormat(int ID,
fa.bigdir = (char)bigdir;
// suggest a head/cylinder/lfau setup
int discsize = SecCount;
int heads=16, secs=63,cyls=0; // initialise
do
{
heads++;
cyls=discsize/heads;
secs=63;
while(cyls%secs) secs--;
cyls=cyls/secs;
} while((cyls>65535)&&(heads>255));
testprint3(" suggested heads %d, cyls %d, secs %d\n",heads,cyls,secs);
CHSRound(fa.cyls,fa.heads,fa.spt,fa.SecCount);
// do
// {
// heads++;
// cyls=discsize/heads;
// secs=63;
// while(cyls%secs) secs--;
// cyls=cyls/secs;
//
// } while((cyls>65535)&&(heads>255));
testprint4(" suggested heads %d, cyls %d, secs %d giving disk size %x\n",fa.heads,fa.cyls,fa.spt,fa.SecCount);
#if Debug
map = calloc(1024,1);
sprintf(map,"AFmt id %x key %x size %x BaseOff %x SC %x bigdir %d\n",ID,AccessKey,SecSize,BaseOffset,SecCount,bigdir);
sprintf(map,"AFmt id %x key %x size %x BaseOff %x SC %x bigdir %d\n",ID,AccessKey,fa.SecSize,BaseOffset,fa.SecCount,bigdir);
testprint(map);
free(map);
#endif
......@@ -116,19 +117,19 @@ int MakeAcornFormat(int ID,
*(j+i) = 0; // clear to null
}
k=0;
//while((*(defect+k)>0)&&(*(defect+k)<(0x1fffffff>>fa.log2secsize)))
//{
// boot->defects[k] = *(defect+k)<<fa.log2secsize;
// k++;
//}
while(defect&&(*(defect+k)>0)&&(*(defect+k)<(0x1fffffff>>fa.log2secsize)))
{
boot->defects[k] = *(defect+k)<<fa.log2secsize;
k++;
}
boot->defects[k]=0x20000000;
if(fa.bigdisc == 1)
{
// while(*(defect+k)>0)
// {
// boot->defects[k+1] = *(defect+k);
// k++;
// }
while(defect&&*(defect+k)>0)
{
boot->defects[k+1] = *(defect+k);
k++;
}
boot->defects[k+1]=0x40000000;
}
DefectChecksum((int*)&boot->defects[0],fa.bigdisc);
......@@ -201,7 +202,7 @@ int MakeAcornFormat(int ID,
// compute zonestart & zoneend disc addresses (sectors)
zonestart = zoneend;
zoneend = zonestart + ((((60*8)-fa.zonespare)<<fa.log2bpmb)>>fa.log2secsize);
while((*defect>0)&&(*defect>=zonestart)&&(*defect<zoneend))
while(defect&&(*defect>0)&&(*defect>=zonestart)&&(*defect<zoneend))
{
// compute bit offset & skew of frag start to map out defect sector
i = skew = (((*(defect++)-zonestart)<<fa.log2bpmb)>>fa.log2secsize)+0x18;
......@@ -755,17 +756,18 @@ void ComputeAcornLayout(FormatArray* fmt)
}
// compute plausible heads & spt
// suggest a head/cylinder/spt setup
fmt->heads=16; // initialise
do
{
fmt->heads++;
fmt->cyls=fmt->SecCount/fmt->heads;
fmt->spt=63;
while(fmt->cyls%fmt->spt) fmt->spt--;
fmt->cyls=fmt->cyls/fmt->spt;
} while((fmt->cyls>65535)&&(fmt->heads>255));
// suggest a head/cylinder/spt setup
CHSRound(fmt->cyls,fmt->heads,fmt->spt,fmt->SecCount);
// fmt->heads=16; // initialise
// do
// {
// fmt->heads++;
// fmt->cyls=fmt->SecCount/fmt->heads;
// fmt->spt=63;
// while(fmt->cyls%fmt->spt) fmt->spt--;
// fmt->cyls=fmt->cyls/fmt->spt;
//
// } while((fmt->cyls>65535)&&(fmt->heads>255));
// testprint3("heads %d, cyls %d, secs %d\n",fmt->heads,fmt->cyls,fmt->spt);
}
......@@ -28,23 +28,25 @@ _kernel_oserror * FormatPartition( int ID, FormatParamsp FP, int sectorsize)
testprint3("FormatPartition ID:%x partn:%d name:%s\n",ID,FP->partition,(int)FP->discname);
// first read the partition spec
GUIDPartn* myGP = ReturnGPTPartionInfo ( ID, FP->partition);
printGUIDpart(myGP);
switch(FP->type)
if(myGP)
{
case GUIDWinNorm:
MakeDosFormat(ID,OverrideKey,sectorsize,myGP->StartLBA[0],myGP->EndLBA[0]-myGP->StartLBA[0]-1,myGP->EndLBA[0]-myGP->StartLBA[0]-1,FP->discname, NULL,-1,1);
break;
case GUIDFilecore:
MakeAcornFormat(ID,OverrideKey,sectorsize,myGP->StartLBA[0],myGP->EndLBA[0]-myGP->StartLBA[0]-1,FP->discname, NULL,2,1);
printGUIDpart(myGP);
switch(FP->type)
{
case GUIDWinNorm:
MakeDosFormat(ID,OverrideKey,sectorsize,myGP->StartLBA[0],myGP->EndLBA[0]-myGP->StartLBA[0]-1,myGP->EndLBA[0]-myGP->StartLBA[0]-1,FP->discname, NULL,-1,1);
break;
default:
err.errnum=0;
strncpy(err.errmess,"no known format",250);
wimp_error(&(err));
return &(err);
case GUIDFilecore:
MakeAcornFormat(ID,OverrideKey,sectorsize,myGP->StartLBA[0],myGP->EndLBA[0]-myGP->StartLBA[0]-1,FP->discname, NULL,2,1);
break;
default:
err.errnum=0;
strncpy(err.errmess,"no known format",250);
wimp_error(&(err));
return &(err);
}
}
return NULL;
}
......
......@@ -256,27 +256,31 @@ partitionArray * registerDrive(int id, int LBA)
}
return NULL;
}
//forgetDrive(
// unlink and free a drive array
void freeDriveArray(driveArray* array)
{
driveArray *temp = array;
if((array)->last)
if(array)
{
if(array == Drives)
if((array)->last)
{
Drives=(array)->next;
if((array)->next)(array)->next->last=Drives;
if(array == Drives)
{
Drives=(array)->next;
if((array)->next)(array)->next->last=Drives;
}
else
{
(array)->last->next=(array)->next;
if((array)->next)(array)->next->last=(array)->last;
}
}
else
{
(array)->last->next=(array)->next;
if((array)->next)(array)->next->last=(array)->last;
Drives = NULL;
}
}
else
{
Drives = NULL;
}
// testprint2("free %x Drives = %x\n",(int)temp,(int)Drives);
if(temp)free(temp);
}
......@@ -339,8 +343,9 @@ void module_service_handler(int service_number, _kernel_swi_regs *r, void *pw)
// testprint3("detach drive %x %x %x\n",r->r[2],r->r[2],r->r[0]&r->r[2]);
// we need to forget the partition info for this drive
driveArray* dr = Drive2Array(r->r[0]&r->r[2]);
testprint1("abt to free %x\n",(int)dr);
freeDriveArray(dr);
if (dr) freeDriveArray(dr);
}
break;
case Service_SCSIMounting:
......@@ -376,17 +381,20 @@ void module_service_handler(int service_number, _kernel_swi_regs *r, void *pw)
// }
// }
// }
// now report next unused partition
for (int i=0;i<MaxPartitions;i++)
// now report next unused partition
if(pabase)
{
if(pabase->used&&!pabase->mounted)
for (int i=0;i<MaxPartitions;i++)
{
pabase->mounted=1;
testprint3("give partition offset for drive %d, ID %x as %x\n",r->r[2],r->r[3],pabase->partitionLBA);
_swix(SCSIFS_Partitions,_INR(0,2),0,r->r[2],pabase->partitionLBA);
i = MaxPartitions;
if(pabase->used&&!pabase->mounted)
{
pabase->mounted=1;
testprint3("give partition offset for drive %d, ID %x as %x\n",r->r[2],r->r[3],pabase->partitionLBA);
_swix(SCSIFS_Partitions,_INR(0,2),0,r->r[2],pabase->partitionLBA);
i = MaxPartitions;
}
pabase++;
}
pabase++;
}
driveArray * dr;
if(dr = Drive2Array(r->r[3]), dr) dr->initialised = 1;
......@@ -424,23 +432,25 @@ _kernel_oserror *PM_MorePartitions(_kernel_swi_regs *r, void *pw)
testprint("PMM ");
dr = ReadDrivePartitions (r->r[1]);
partitionArray* pap=&dr->partition[0];
// if(!dr->initialised)
// {
// }
for (int i=0;i<MaxPartitions;i++)
if(dr)
{
if(pap->used&&!pap->reported)
partitionArray* pap=&dr->partition[0];
// if(!dr->initialised)
// {
// }
for (int i=0;i<MaxPartitions;i++)
{
pap->reported=1;
if((i<MaxPartitions-1)&&(++pap)&& (pap->used))r->r[2]=0;
testprint2(":%02x pap %x \n",r->r[1],(int)pap);
return NULL;
if(pap->used&&!pap->reported)
{
pap->reported=1;
if((i<MaxPartitions-1)&&(++pap)&& (pap->used))r->r[2]=0;
testprint2(":%02x pap %x \n",r->r[1],(int)pap);
return NULL;
}
pap++;
}
pap++;
testprint("Q\n");
}
testprint("Q\n");
}
return (NULL);
}
......
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