Re: [Freedos-kernel] state of kernel 2038

2009-02-12 Thread Eric Auer

Hi Tom,

here is one of two diffs for patches that I have not
commited to SVN because I was waiting for review...

Topic: Handle floppy type 6 and use DF_DISKCHANGE and
DF_NOACCESS as well as InitializeAllBPBs in a way which
should help disk tools to avoid confusion about FAT1x
versus FAT32.

Question: Are there any side effects?

Thanks for commenting :-)

Eric



$ svn diff freedos/
Index: freedos/kernel/initdisk.c
===
--- freedos/kernel/initdisk.c   (Revision 1365)
+++ freedos/kernel/initdisk.c   (Working Copy)
@@ -318,7 +318,7 @@
   type = regs.b.b.l - 1;
   if (regs.flags & 1)
 type = 0;   /* return 320-360 for XTs */
-  else if (type > 6)
+  else if (type >= 6)
 type = 8;   /* any odd ball drives get 8&7=0: the
320-360 table */
   else if (type == 5)
 type = 4;   /* 5 and 4 are both 2.88 MB */
@@ -577,7 +577,7 @@

   if (nUnits >= NDEV)
   {
-printf("more Partitions detected then possible, max = %d\n", NDEV);
+printf("more Partitions detected than possible, max = %d\n", NDEV);
 return; /* we are done */
   }

@@ -719,7 +719,7 @@
   lba_bios_parameters.sectors > 0x ||
   lba_bios_parameters.totalSectHigh != 0)
   {
-printf("Drive is too large to handle, using only 1st 8 GB\n"
+printf("LBA drive properties implausible, using only 1st 8 GB\n"
" drive %02x heads %lu sectors %lu , total=0x%lx-%08lx\n",
drive,
(ULONG) lba_bios_parameters.heads,
@@ -1269,7 +1269,7 @@
   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_descflags = init_readdasd(driveno) | flags | DF_DISKCHANGE
| DF_NOACCESS;

   pddt->ddt_offset = 0;
   pddt->ddt_serialno = 0x12345678l;
Index: freedos/kernel/dsk.c
===
--- freedos/kernel/dsk.c(Revision 1365)
+++ freedos/kernel/dsk.c(Working Copy)
@@ -374,8 +374,8 @@
   unsigned secs_per_cyl;
   WORD ret;

-  /* pddt->ddt_descflags |= DF_NOACCESS;
-   * disabled for now - problems with FORMAT ?? */
+  pddt->ddt_descflags |= DF_NOACCESS;
+  /* was disabled - problems with FORMAT ?? */

   /* set drive to not accessible and changed */
   if (diskchange(pddt) != M_NOT_CHANGED)
Index: freedos/kernel/main.c
===
--- freedos/kernel/main.c   (Revision 1365)
+++ freedos/kernel/main.c   (Working Copy)
@@ -126,14 +126,10 @@
 }

 /*
-InitializeAllBPBs()
-
-or MakeNortonDiskEditorHappy()
-
-it has been determined, that FDOS's BPB tables are initialized,
-only when used (like DIR H:).
-at least one known utility (norton DE) seems to access them directly.
-ok, so we access for all drives, that the stuff gets build
+InitializeAllBPBs() or MakeNortonDiskEditorHappy() - FreeDOS
+does DPB setup on demand (eg DIR H:, via media_check, bpb_to_dpb)
+so we touch all drives to make sure DPB are filled in. For some reason,
+this was described as "init BPB to make Norton Disk Edit happy"...?
 */
 void InitializeAllBPBs(VOID)
 {
@@ -145,6 +141,14 @@
 if ((fileno = open(filename, O_RDONLY)) >= 0)
   close(fileno);
   }
+  /* chdir("A:\\") would need intr.asm/init-mod.h ext. but nicer than
open() */
+#ifdef WITHFAT32  /* mark drive as not FAT32 to allow int25/26 access */
+  /* floppy is DF_NOACCESS until 1st media_check or int 21.440d.0847  */
+  LoL->DPBp->dpb_fatsize = 1;   /* not 0, that would be FAT32 */
+  LoL->DPBp->dpb_next->dpb_fatsize = 1; /* not 0, that would be FAT32 */
+  /* bpb_to_dpb(ddt_defbpb...) would be perfect but is not accessible */
+  /* media_check(get_dpb(0)); / int 21.32 etc would access phys drive */
+#endif
 }

 STATIC void PSPInit(void)



--
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-kernel mailing list
Freedos-kernel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


Re: [Freedos-kernel] state of kernel 2038

2009-02-12 Thread Eric Auer

Here is the IsShareInstalled patch which also does
not seem to be commited to SVN yet?? The goal is
to reduce the share install check call floods that
FreeDOS would normally cause. The side effect is
minimally later detection of share, should be fine.
Thanks for commenting :-)

Eric



diff -bur freedos/kernel/dosfns.c rayer/kernel/dosfns.c
--- freedos/kernel/dosfns.c 2007-07-28 18:40:25.0 +0200
+++ rayer/kernel/dosfns.c   2008-11-30 18:38:06.0 +0100
@@ -289,7 +289,7 @@

   /* a block transfer   */
   /* /// Added for SHARE - Ron Cemer */
-  if (IsShareInstalled() && (s->sft_shroff >= 0))
+  if (IsShareInstalled(FALSE) && (s->sft_shroff >= 0))
   {
 int rc = share_access_check(cu_psp, s->sft_shroff, s->sft_posit,
  (unsigned long)n, 1);
@@ -581,7 +581,7 @@
   }

 /* /// Added for SHARE.  - Ron Cemer */
-  if (IsShareInstalled())
+  if (IsShareInstalled(TRUE))
   {
 if ((sftp->sft_shroff =
  share_open_check(PriPathName, cu_psp,
@@ -625,7 +625,7 @@
   else
   {
 /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***.  - Ron Cemer */
-if (IsShareInstalled())
+if (IsShareInstalled(TRUE))
 {
   share_close_file(sftp->sft_shroff);
   sftp->sft_shroff = -1;
@@ -755,7 +755,7 @@
 return dos_commit(sftp->sft_status);

 /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***.  - Ron Cemer */
-  if (IsShareInstalled())
+  if (IsShareInstalled(TRUE))
   {
 if (sftp->sft_shroff >= 0)
   share_close_file(sftp->sft_shroff);
@@ -1354,7 +1354,7 @@
 return remote_lock_unlock(s, pos, len, unlock);

   /* Invalid function unless SHARE is installed or remote. */
-  if (!IsShareInstalled())
+  if (!IsShareInstalled(FALSE))
 return DE_INVLDFUNC;

   /* Lock violation if this SFT entry does not support locking. */
@@ -1444,10 +1444,13 @@
 }

 /* /// Added for SHARE.  - Ron Cemer */
+/* Eric 8/2008: only re-check (2f.1000) on open/close, not on each
access */

-BOOL IsShareInstalled(void)
+BOOL IsShareInstalled(BOOL recheck)
 {
   extern unsigned char ASMPASCAL share_check(void);
+  if (recheck == FALSE)
+return share_installed;
   if (!share_installed && share_check() == 0xff)
 share_installed = TRUE;
   return share_installed;
diff -bur freedos/kernel/fatfs.c rayer/kernel/fatfs.c
--- freedos/kernel/fatfs.c  2008-04-04 17:36:58.0 +0200
+++ rayer/kernel/fatfs.c2008-11-30 18:34:28.0 +0100
@@ -447,7 +447,7 @@
   f_node_ptr fnp2;
   int i, fd;

-  if (!IsShareInstalled())
+  if (!IsShareInstalled(FALSE))
 return;

   fd = xlt_fnp(fnp);
--- freedos/kernel/proto.h  2008-04-04 17:36:58.0 +0200
+++ rayer/kernel/proto.h2008-11-30 18:34:56.0 +0100
@@ -112,7 +112,7 @@
 COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib);
 COUNT DosMkRmdir(const char FAR * dir, int action);
 struct dhdr FAR *IsDevice(const char FAR * FileName);
-BOOL IsShareInstalled(void);
+BOOL IsShareInstalled(BOOL recheck);
 COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock);
 int idx_to_sft_(int SftIndex);
 sft FAR *idx_to_sft(int SftIndex);


--
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-kernel mailing list
Freedos-kernel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


Re: [Freedos-kernel] state of kernel 2038

2009-02-12 Thread Eric Auer

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.0 +0200
+++ rayer/kernel/initdisk.c 2008-11-30 21:03:48.0 +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