Applied most of Arkady's initdisk optimizations (65 bytes) and is_suspect fix.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@963 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-05-25 19:24:55 +00:00
parent e71f6448ab
commit 57bac85ae3

View File

@ -650,17 +650,14 @@ void DosDefinePartition(struct DriveParamS *driveParam,
} }
/* Get the parameters of the hard disk */ /* Get the parameters of the hard disk */
int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam)
{ {
iregs regs; iregs regs;
struct _bios_LBA_disk_parameterS lba_bios_parameters; struct _bios_LBA_disk_parameterS lba_bios_parameters;
if (driveParam->driveno) ExtLBAForce = FALSE;
return driveParam->driveno;
driveParam->descflags = 0;
memset(driveParam, 0, sizeof *driveParam);
drive |= 0x80; drive |= 0x80;
/* for tests - disable LBA support, /* for tests - disable LBA support,
@ -817,11 +814,18 @@ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry,
BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs) BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs)
{ {
return !((chs->Cylinder & 0x3ff) == pEntry_chs->Cylinder || /* Valid entry:
1023 == pEntry_chs->Cylinder || entry == chs || // partition entry equal to computed values
(chs->Cylinder == pEntry_chs->Cylinder && (chs->Cylinder > 1023 && // or LBA partition
chs->Head == pEntry_chs->Head && (entry->Cylinder == 1023 ||
chs->Sector == pEntry_chs->Sector)); entry->Cylinder == (0x3FF & chs->Cylinder)))
*/
return !((pEntry_chs->Cylinder == chs->Cylinder &&
pEntry_chs->Head == chs->Head &&
pEntry_chs->Sector == chs->Sector) ||
chs->Cylinder > 1023u &&
(pEntry_chs->Cylinder == 1023 ||
pEntry_chs->Cylinder == (0x3ff & chs->Cylinder)));
} }
void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs, void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs,
@ -1040,13 +1044,9 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore)
struct DriveParamS driveParam; struct DriveParamS driveParam;
ExtLBAForce = FALSE;
/* Get the hard drive parameters and ensure that the drive exists. */ /* Get the hard drive parameters and ensure that the drive exists. */
/* If there was an error accessing the drive, skip that drive. */ /* If there was an error accessing the drive, skip that drive. */
memset(&driveParam, 0, sizeof(driveParam));
if (!LBA_Get_Drive_Parameters(drive, &driveParam)) if (!LBA_Get_Drive_Parameters(drive, &driveParam))
{ {
printf("can't get drive parameters for drive %02x\n", drive); printf("can't get drive parameters for drive %02x\n", drive);
@ -1250,15 +1250,28 @@ I don't know, if I did it right, but I tried to do it that way. TE
***********************************************************************/ ***********************************************************************/
STATIC void make_ddt (ddt *pddt, int Unit, int driveno, int flags)
{
pddt->ddt_next = MK_FP(0, 0xffff);
pddt->ddt_logdriveno = Unit;
pddt->ddt_driveno = driveno;
pddt->ddt_type = init_getdriveparm(driveno, &pddt->ddt_defbpb);
pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40;
pddt->ddt_descflags = init_readdasd(driveno) | flags;
pddt->ddt_offset = 0;
pddt->ddt_serialno = 0x12345678l;
memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb));
push_ddt(pddt);
}
void ReadAllPartitionTables(void) void ReadAllPartitionTables(void)
{ {
UBYTE foundPartitions[MAX_HARD_DRIVE]; UBYTE foundPartitions[MAX_HARD_DRIVE];
int HardDrive; int HardDrive;
int nHardDisk = BIOS_nrdrives(); int nHardDisk;
int Unit;
ddt nddt; ddt nddt;
ddt *pddt = &nddt;
static iregs regs; static iregs regs;
/* quick adjustment of diskette parameter table */ /* quick adjustment of diskette parameter table */
@ -1270,59 +1283,44 @@ void ReadAllPartitionTables(void)
setvec(0x1e, (intvec)int1e_table); setvec(0x1e, (intvec)int1e_table);
/* Setup media info and BPBs arrays for floppies */ /* Setup media info and BPBs arrays for floppies */
for (Unit = 0; Unit < 2; Unit++) make_ddt(&nddt, 0, 0, 0);
{
pddt->ddt_next = MK_FP(0, 0xffff);
pddt->ddt_driveno = 0;
pddt->ddt_logdriveno = Unit;
pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb);
pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40;
pddt->ddt_descflags = init_readdasd(0);
pddt->ddt_offset = 0l;
pddt->ddt_serialno = 0x12345678l;
memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb));
if (Unit == 0)
push_ddt(pddt);
}
/* Initial number of disk units */
nUnits = 2;
/* /*
this is a quick patch - see if B: exists this is a quick patch - see if B: exists
test for A: also, need not exist test for A: also, need not exist
*/ */
init_call_intr(0x11, &regs); /* get equipment list */ init_call_intr(0x11, &regs); /* get equipment list */
if ((regs.a.x & 1) && (regs.a.x & 0xc0)) /*if ((regs.AL & 1)==0)*//* no floppy drives installed */
if ((regs.AL & 1) && (regs.AL & 0xc0))
{ {
pddt->ddt_driveno = 1;
pddt->ddt_type = init_getdriveparm(1, &pddt->ddt_defbpb);
pddt->ddt_descflags = init_readdasd(1);
pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40;
/* floppy drives installed and a B: drive */ /* floppy drives installed and a B: drive */
/*if ((r.a.x & 1)==0) *//* no floppy drives installed */ make_ddt(&nddt, 1, 1, 0);
} }
else else
{ /* set up the DJ method : multiple logical drives */ {
pddt->ddt_descflags |= DF_MULTLOG; /* set up the DJ method : multiple logical drives */
make_ddt(&nddt, 1, 0, DF_MULTLOG);
} }
push_ddt(pddt); /* Initial number of disk units */
nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); nUnits = 2;
memset(foundPartitions, 0, sizeof(foundPartitions)); nHardDisk = BIOS_nrdrives();
if (nHardDisk > LENGTH(foundPartitions))
nHardDisk = LENGTH(foundPartitions);
DebugPrintf(("DSK init: found %d disk drives\n", nHardDisk)); DebugPrintf(("DSK init: found %d disk drives\n", nHardDisk));
/* Reset the drives */ /* Reset the drives */
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
{
BIOS_drive_reset(HardDrive); BIOS_drive_reset(HardDrive);
foundPartitions[HardDrive] = 0;
}
if (InitKernelConfig.DLASortByDriveNo == 0) if (InitKernelConfig.DLASortByDriveNo == 0)
{ {
/* printf("Drive Letter Assignment - DOS order \n"); */ /* printf("Drive Letter Assignment - DOS order\n"); */
/* Process primary partition table 1 partition only */ /* Process primary partition table 1 partition only */
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
@ -1349,37 +1347,34 @@ void ReadAllPartitionTables(void)
} }
else else
{ {
UBYTE bootdrv; UBYTE bootdrv = peekb(0,0x5e0);
struct DriveParamS driveParam;
/* printf("Drive Letter Assignment - sorted by drive\n"); */ /* printf("Drive Letter Assignment - sorted by drive\n"); */
/* Process primary partition table 1 partition only */ /* Process primary partition table 1 partition only */
bootdrv = *(UBYTE FAR *)MK_FP(0,0x5e0);
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
{ {
memset(&driveParam, 0, sizeof(driveParam)); struct DriveParamS driveParam;
ExtLBAForce = FALSE; if (LBA_Get_Drive_Parameters(HardDrive, &driveParam) &&
if (LBA_Get_Drive_Parameters(HardDrive, &driveParam)) driveParam.driveno == bootdrv)
{ {
if (driveParam.driveno == bootdrv) foundPartitions[HardDrive] =
{ ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0);
foundPartitions[HardDrive] = break;
ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0);
break;
}
} }
} }
for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++)
{ {
if (foundPartitions[HardDrive] == 0) if (foundPartitions[HardDrive] == 0)
{
foundPartitions[HardDrive] = foundPartitions[HardDrive] =
ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0);
if (foundPartitions[HardDrive] == 0) if (foundPartitions[HardDrive] == 0)
foundPartitions[HardDrive] = foundPartitions[HardDrive] =
ProcessDisk(SCAN_PRIMARY, HardDrive, 0); ProcessDisk(SCAN_PRIMARY, HardDrive, 0);
}
/* Process extended partition table */ /* Process extended partition table */
ProcessDisk(SCAN_EXTENDED, HardDrive, 0); ProcessDisk(SCAN_EXTENDED, HardDrive, 0);