Hi Tom :-)

>> - int 21.1c should report invalid drives via AL (keep other regs?)
>>   News here: DR-DOS modifies BX/CX/DX but not DS for inv drives.

Unfortunately I do not know to what value DR DOS sets BX/CX/DX,
only got the information that they looked kind of random...
In any case AL has to be set to -1 to flag invalid drives :-)



>> - CHS calculations are off by 1 and overflowing (thanks Rayer)
>>   If your BIOS has no LBA, this was probably a real pain for you.
> 
> any details about this ? like the original email ('thanks Rayer' is
> not enough of a description)

The discussion is spread over mail and chat, so I had to reverse
engineer the fix by diffing sources with Rugxulo, results below.

I omit parts where only whitespace / empty lines were changed,
where only { } got added or removed or debug messages are only
extended without fixing for example format string bugs.

I also omit the parts of the patch where RayeR disabled LBA to
be able to check CHS problems without having to use SYS CONFIG.

The remaining differences can be separated into not commited
(waiting for comments) patches from me and several patches by
Rayer: cylinder off by 1 in DDT and total_sectors, also have
to cast to ULONG for total_sectors calc.

The IsShareInstalled thing will be in a separate mail.

Same for the DF_NOACCESS, DF_DISKCHANGE, InitializeAllBPBs.

Sorry for not being able to provide a proper diff -u for
initdisk because it contains too many "mixed" patches...

Please also comment on the changed messages in the snippet
below, do any of them fix format string bugs? Which? How?

--- freedos/kernel/initdisk.c   2008-06-02 00:48:47.000000000 +0200
+++ rayer/kernel/initdisk.c     2008-11-30 21:03:48.000000000 +0100
@@ -6,6 +6,8 @@
 /*                      tom ehlert                              */
 /*                      All Rights Reserved                     */
 /*                                                              */
+/* Bugfixes for Compaq EVO T20 compatability by RayeR 30.11.2008*/
+/*                                                              */
 /* This file is part of DOS-C.                                  */
 /*                                                              */
 /* DOS-C is free software; you can redistribute it and/or       */
@@ -33,7 +35,7 @@
 #endif

 UBYTE InitDiskTransferBuffer[SEC_SIZE] BSS_INIT({0});
-COUNT nUnits BSS_INIT(0);
+COUNT nUnits BSS_INIT(0); /* Watcom C 11.x didn't initialized, fixed to
= 0 */

 /*
  *    Rev 1.0   13 May 2001  tom ehlert
@@ -590,7 +592,7 @@
      above cylinder 1023 was found */
   if (!InitKernelConfig.ForceLBA && !ExtLBAForce &&
!IsLBAPartition(pEntry->FileSystem))
     pddt->ddt_descflags &= ~DF_LBA;
-  pddt->ddt_ncyl = driveParam->chs.Cylinder;
+  pddt->ddt_ncyl = driveParam->chs.Cylinder + 1; /* chs.Cylinder
[0-1023] */

 #ifdef DEBUG
   if (pddt->ddt_descflags & DF_LBA)
@@ UNKNOWN UNKNOWN UNKNOWN UNKNOWN @@
-  driveParam->chs.Head = (regs.d.x >> 8) + 1;
-  driveParam->chs.Sector = (regs.c.x & 0x3f);
-  driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) << 2);
+  driveParam->chs.Head = (regs.d.x >> 8) + 1; /* DH = heads -1 [0-255] */
+  driveParam->chs.Sector = (regs.c.x & 0x3F); /* CL5:0 = sectors/track
[0-63] */
+  driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) <<
2); /* CH=cyls7:0, CL7:6=cyls9:8 -1 [0-1023] */

   if (driveParam->chs.Sector == 0) {
     /* happens e.g. with Bochs 1.x if no harddisk defined */
     driveParam->chs.Sector = 63; /* avoid division by zero...! */
     printf("BIOS reported 0 sectors/track, assuming 63!\n");
   }

   if (!(driveParam->descflags & DF_LBA))
   {
-    driveParam->total_sectors =
-        min(driveParam->chs.Cylinder, 1023)
-        * driveParam->chs.Head * driveParam->chs.Sector;
+    driveParam->total_sectors =
+        (ULONG)(driveParam->chs.Cylinder+1)
+        * driveParam->chs.Head * driveParam->chs.Sector;
   }

   driveParam->driveno = drive;

-  DebugPrintf(("drive parameters %02x - %04lu-%u-%u",
-               drive,
-               driveParam->chs.Cylinder,
+  DebugPrintf(("drive %02Xh parameters: C = %u, H = %u, S = %u, ", drive,
+               driveParam->chs.Cylinder+1,
                driveParam->chs.Head, driveParam->chs.Sector));
-  DebugPrintf((" total size %luMB\n\n", driveParam->total_sectors / 2048));
+  DebugPrintf(("total size = %lu MB\n\n", driveParam->total_sectors /
2048));

 ErrorReturn:

@@ -1021,7 +995,7 @@

       if (chs.Cylinder > 1023)
       {
-        printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder);
+        printf("LBA-Transfer error: address = %lu, cylinder %u >
1023\n",LBA_address + 1, chs.Cylinder);
         return 1;
       }

@@ -1075,13 +1047,14 @@
   strangeHardwareLoop = 0;
 strange_restart:

  if (Read1LBASector
      (&driveParam, drive, RelSectorOffset, InitDiskTransferBuffer))
   {
-    printf("Error reading partition table drive %02x sector %lu", drive,
+    printf("Error reading partition table drive %02Xh, sector %lu\n",
drive,
           RelSectorOffset);
     return PartitionsToIgnore;
   }

   if (!ConvPartTableEntryToIntern(PTable, InitDiskTransferBuffer))
   {




>> - the BSS_INIT macro is bogus (thanks Rayer)
> any details about this ? like the original email ('thanks Rayer' is
> not enough of a description)

Here is the relevant part of RayeR's kernel:

diff -bur freedos/kernel/init-mod.h rayer/kernel/init-mod.h
--- freedos/kernel/init-mod.h   2007-09-07 14:32:05.000000000 +0200
+++ rayer/kernel/init-mod.h     2008-11-30 20:55:58.000000000 +0100
@@ -32,8 +32,9 @@

    These guys are marked BSS_INIT to mark that they really should be BSS
    but can't be because of MS
+   Seems to be needed also for Watcom C 11.x
 */
-#ifdef _MSC_VER
+#if ((defined _MSC_VER) || (defined __WATCOMC__))
 #define BSS_INIT(x) = x
 #else
 #define BSS_INIT(x)

I personally would suggest to always have BSS_INIT(x) = x and
not only for certain compilers. After all, the kernel is not
a "normal program" so compiler-specific BSS clearing code is
usually not triggered...

Thanks for commenting :-)

Eric



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to