--- Begin Message ---diff -ruNp old/kernel/initdisk.c new/kernel/initdisk.c --- old/kernel/initdisk.c 2004-04-14 01:46:24.000000000 +0000 +++ new/kernel/initdisk.c 2004-04-24 10:02:44.000000000 +0000 @@ -647,17 +647,12 @@ void DosDefinePartition(struct DrivePara } /* 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; - struct _bios_LBA_disk_parameterS lba_bios_parameters; - if (driveParam->driveno) - return driveParam->driveno; - - driveParam->descflags = 0; - + memset(driveParam, 0, sizeof *driveParam); drive |= 0x80; /* for tests - disable LBA support, @@ -814,11 +809,18 @@ BOOL ConvPartTableEntryToIntern(struct P BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs) { - return !((chs->Cylinder & 0x3ff) == pEntry_chs->Cylinder || - 1023 == pEntry_chs->Cylinder || - (chs->Cylinder == pEntry_chs->Cylinder && - chs->Head == pEntry_chs->Head && - chs->Sector == pEntry_chs->Sector)); + /* Valid entry: + entry == chs || // partition entry equal to computed values + (chs->Cylinder > 1023 && // or LBA partition + (entry->Cylinder == 1023 || + 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, @@ -894,9 +896,8 @@ BOOL ScanForPrimaryPartitions(struct Dri &pEntry->End); } - if (chs.Cylinder > 1023 || end.Cylinder > 1023) + if ((chs.Cylinder | end.Cylinder) > 1023) { - if (!(driveParam->descflags & DF_LBA)) { printf @@ -1042,8 +1043,6 @@ int ProcessDisk(int scanType, unsigned d /* Get the hard drive parameters and ensure that the drive exists. */ /* If there was an error accessing the drive, skip that drive. */ - memset(&driveParam, 0, sizeof(driveParam)); - if (!LBA_Get_Drive_Parameters(drive, &driveParam)) { printf("can't get drive parameters for drive %02x\n", drive); @@ -1247,19 +1246,31 @@ I don't know, if I did it right, but I t ***********************************************************************/ +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) { UBYTE foundPartitions[MAX_HARD_DRIVE]; - int HardDrive; - int nHardDisk = BIOS_nrdrives(); - int Unit; + int nHardDisk; ddt nddt; - ddt *pddt = &nddt; static iregs regs; /* quick adjustment of diskette parameter table */ - fmemcpy(int1e_table, *(char FAR * FAR *)MK_FP(0, 0x1e*4), sizeof(int1e_table)); + fmemcpy(int1e_table, *(const char FAR* const FAR*)MK_FP(0, 0x1e*4), sizeof int1e_table); /* enforce min. 9 sectors per track */ if (int1e_table[4] < 9) int1e_table[4] = 9; @@ -1267,59 +1278,44 @@ void ReadAllPartitionTables(void) setvec(0x1e, (intvec)int1e_table); /* Setup media info and BPBs arrays for floppies */ - for (Unit = 0; Unit < 2; Unit++) - { - 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; + make_ddt(&nddt, 0, 0, 0); /* this is a quick patch - see if B: exists test for A: also, need not exist */ init_call_intr(0x11, ®s); /* 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 */ -/*if ((r.a.x & 1)==0) *//* no floppy drives installed */ + make_ddt(&nddt, 1, 1, 0); } 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); - nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); + /* Initial number of disk units */ + nUnits = 2; - memset(foundPartitions, 0, sizeof(foundPartitions)); + nHardDisk = BIOS_nrdrives(); + if (nHardDisk > sizeof foundPartitions / sizeof foundPartitions [0]) + nHardDisk = sizeof foundPartitions / sizeof foundPartitions [0]; DebugPrintf(("DSK init: found %d disk drives\n", nHardDisk)); /* Reset the drives */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { BIOS_drive_reset(HardDrive); + foundPartitions[HardDrive] = 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 */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) @@ -1346,37 +1342,33 @@ void ReadAllPartitionTables(void) } else { - UBYTE bootdrv; - struct DriveParamS driveParam; - /* printf("Drive Letter Assignment - sorted by drive\n"); */ /* Process primary partition table 1 partition only */ - bootdrv = *(UBYTE FAR *)MK_FP(0,0x5e0); for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - memset(&driveParam, 0, sizeof(driveParam)); - ExtLBAForce = FALSE; - if (LBA_Get_Drive_Parameters(HardDrive, &driveParam)) + struct DriveParamS driveParam; + ExtLBAForce = FALSE; /* ??? - avb */ + if (LBA_Get_Drive_Parameters(HardDrive, &driveParam) && + driveParam.driveno == *(const UBYTE FAR*)MK_FP(0,0x5e0)) { - if (driveParam.driveno == bootdrv) - { foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); break; - } } } for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { if (foundPartitions[HardDrive] == 0) + { foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); - if (foundPartitions[HardDrive] == 0) - foundPartitions[HardDrive] = + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + } /* Process extended partition table */ ProcessDisk(SCAN_EXTENDED, HardDrive, 0); diff -ruNp old/kernel/ioctl.c new/kernel/ioctl.c --- old/kernel/ioctl.c 2004-04-13 22:37:30.000000000 +0000 +++ new/kernel/ioctl.c 2004-04-24 07:59:16.000000000 +0000 @@ -280,12 +280,10 @@ COUNT DosDevIOctl(lregs * r) r->AX = 0; /* (lock/unlock logical/physical volume) */ break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ } - if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x11) - && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0d) - && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + if ((UBYTE)(~1 & r->AL) == 0x04 /* AL==4 or 5 */ + && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL) || + r->AL == 0x11 && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL) || + r->AL == 0x0d && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) { return DE_INVLDFUNC; } @@ -302,12 +300,11 @@ COUNT DosDevIOctl(lregs * r) { r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; } - - else if (r->AL == 0x04 || r->AL == 0x05) + else if ((UBYTE)(~1 & r->AL) == 0x04) /* AL==4 or 5 */ { r->AX = CharReqHdr.r_count; } - else if (r->AL == 0x0d || r->AL == 0x11) + else /*if (r->AL == 0x0d || r->AL == 0x11)*/ { r->AX = CharReqHdr.r_status; } @@ -346,10 +343,9 @@ COUNT DosDevIOctl(lregs * r) break; case 0x0b: - /* skip, it's a special case. */ - NetDelay = r->CX; - if (!r->DX) + if (r->DX) /* skip, it's a special case */ NetRetry = r->DX; + NetDelay = r->CX; break; default: @@ -357,4 +353,3 @@ COUNT DosDevIOctl(lregs * r) } return SUCCESS; } -------------------------------------------------------- This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th! http://www.thinkgeek.com/freeshipping/?cpg=12297 _______________________________________________ Freedos-kernel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freedos-kernel
--- End Message ---
