[Freedos-kernel] bugs?

2004-05-12 Thread Arkady V.Belousov
Hi!

 FreeDOS returns AX=0 on success for INT21/4E, but RBIL silent about
this. Is this bug or feature? Same for INT21/4F.




---
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson  Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] bugs?

2004-05-12 Thread Arkady V.Belousov
Hi!

 FreeDOS currently returns AX=CX in case of success for INT21/4301, but
RBIL says about AX=CX only for INT21/4300 _and_ DR-DOS. Bug or feature?




---
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson  Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
___
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel


[Freedos-kernel] bugs: inthndlr.c

2004-05-12 Thread Arkady V.Belousov
Hi!

Bugfixes:

- INT21/42: DE_INVLDHNDL is already negative, so it should be assigned to
  `rc' as is, without negation.
- INT21/5E02-...: removed AX clearing on exit - RBIL doesn't says that AX
  cleared for any function AL=2,3,...
- INT21/5F07,5F08: reversed condition - now error DE_INVLDDRV returned
  when DL = (not ) lastdrive (and, thus, outside CDS).
- INT21/65: debug printf() includes extra argument.
- INT21/69: now returned error DE_INVLDDRV when get_cds() returns NULL
  (was forgotten goto error_exit;).
---BeginMessage---
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c   2004-05-11 03:33:34.0 +
+++ new/kernel/inthndlr.c   2004-05-13 05:42:04.0 +
@@ -907,17 +907,13 @@ dispatch:
 case 0x42:
   if (lr.AL  2)
 goto error_invalid;
-  lrc = DosSeek(lr.BX, (LONG)ULONG) (lr.CX))  16) | lr.DX), lr.AL);
+  lrc = DosSeek(lr.BX, ((ULONG)lr.CX  16) | lr.DX, lr.AL);
+  rc = DE_INVLDHNDL;
   if (lrc == -1)
-  {
-lrc = -DE_INVLDHNDL;
-  }
-  else
-  {
-lr.DX = (UWORD)(lrc  16);
-lrc = (UWORD) lrc;
-  }
-  goto long_check;
+goto error_exit;
+  lr.DX = (UWORD)(lrc  16);
+  lr.AX = (UWORD) lrc;
+  break;
 
   /* Get/Set File Attributes  */
 case 0x43:
@@ -1260,7 +1256,6 @@ dispatch:
   rc = (int)network_redirector_mx(REM_PRINTSET, lr, (void *)Int21AX);
   if (rc != SUCCESS)
 goto error_exit;
-  lr.AX = SUCCESS;
   break;
   }
   break;
@@ -1269,25 +1264,18 @@ dispatch:
   if (lr.AL == 7 || lr.AL == 8)
   {
 struct cds FAR *cdsp;
-if (lr.DL  lastdrive)
+if (lr.DL = lastdrive)
 {
   rc = DE_INVLDDRV;
   goto error_exit;
 }
-else
-{
-  cdsp = CDSp[lr.DL];
+cdsp = CDSp + lr.DL;
   if (lr.AL == 7)
-  {
 cdsp-cdsFlags |= 0x100;
-  }
   else
-  {
 cdsp-cdsFlags = ~0x100;
-  }
-}
+break;
   }
-  else
   {
 rc = (int)network_redirector_mx(REM_DOREDIRECT, lr, (void *)Int21AX);
 /* the remote function manipulates *r directly !,
@@ -1300,7 +1288,6 @@ dispatch:
 r-AX = -rc;
 goto real_exit;
   }
-  break;
 
 case 0x60: /* TRUENAME */
   rc = DosTruename(MK_FP(lr.DS, lr.SI), adjust_far(FP_ES_DI));
@@ -1377,16 +1364,16 @@ dispatch:
   lr.AX = DosYesNo(lr.DL);
   break;
 default:
+  rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, FP_ES_DI);
 #ifdef NLS_DEBUG
-  if ((rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, FP_ES_DI))  0)
+  if (rc  SUCCESS)
   {
 printf(DosGetData() := %d\n, rc);
 goto error_exit;
   }
-  printf(DosGetData() returned successfully\n, rc);
+  printf(DosGetData() returned successfully\n);
   break;
 #else
-  rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, FP_ES_DI);
   goto short_check;
 #endif
   }
@@ -1423,26 +1410,25 @@ dispatch:
 
   /* Get/Set Serial Number */
 case 0x69:
+{
+  UWORD saveCX;
+  if (lr.AL  1)
+goto error_invalid;
   rc = (lr.BL == 0 ? default_drive : lr.BL - 1);
-  if (lr.AL == 0 || lr.AL == 1)
-  {
-UWORD saveCX = lr.CX;
 if (get_cds(rc) == NULL)
+{
   rc = DE_INVLDDRV;
-else if (get_dpb(rc) == NULL)
+  goto error_exit;
+}
+if (get_dpb(rc) == NULL)
   goto error_invalid;
-else
-{
+saveCX = lr.CX;
   lr.CX = lr.AL == 0 ? 0x0866 : 0x0846;
   lr.AL = 0x0d;
   rc = DosDevIOctl(lr);
   lr.CX = saveCX;
   goto short_check;
-}
-  }
-  else
-goto error_invalid;
-  break;
+}
 /*
 case 0x6a: see case 0x68
 case 0x6b: dummy func: return AL=0
---End Message---


[Freedos-kernel] patch: inthndlr.c

2004-05-12 Thread Arkady V.Belousov
Hi!

Changes:

- rc != SUCCESS after DosDevIOctl() replaced by rc  SUCCESS.

Cleanups:

- some zeros replaced by SUCCESS.
- used -DE_INVLDDRV expression instead 0x0f value.
- instead ((lr.AX  0xff) != 0)) used nicer lr.AL ? 1 : 0.

Optimizations:

- removed extraneous assignments to `rc'.
- removed extraneous if (rc = SUCCESS) checks before assignments to lr.AX.
- reused goto short_check whenever possible instead if (rc  SUCCESS).

TGROUP reduced from 0e131h (01e41h before previous bigfixes) to 0e111h,
HMA_TEXT reduced from 0a614h (0a623h) to 0a5f8h.



t2
Description: Binary data


[Freedos-kernel] patch: inthndlr.c

2004-05-12 Thread Arkady V.Belousov
Hi!

Changes:

- rc != SUCCESS after DosDevIOctl() replaced by rc  SUCCESS.

Cleanups:

- some zeros replaced by SUCCESS.
- used -DE_INVLDDRV expression instead 0x0f value.
- instead ((lr.AX  0xff) != 0)) used nicer lr.AL ? 1 : 0.

Optimizations:

- removed extraneous assignments to `rc'.
- removed extraneous if (rc = SUCCESS) checks before assignments to lr.AX.
- reused goto short_check whenever possible instead if (rc  SUCCESS).

TGROUP reduced from 0e131h (01e41h before previous bigfixes) to 0e111h,
HMA_TEXT reduced from 0a614h (0a623h) to 0a5f8h.

---BeginMessage---
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c   2004-05-13 05:42:04.0 +
+++ new/kernel/inthndlr.c   2004-05-13 06:33:08.0 +
@@ -382,7 +382,7 @@ int int21_fat32(lregs *r)
 
 VOID ASMCFUNC int21_service(iregs FAR * r)
 {
-  COUNT rc = 0;
+  COUNT rc;
   long lrc;
   lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */
 
@@ -765,8 +765,8 @@ dispatch:
 
 if (dpb == NULL)
 {
+  CritErrCode = -DE_INVLDDRV;
   lr.AL = 0xFF;
-  CritErrCode = 0x0f;
   break;
 }
 /* hazard: no error checking! */
@@ -779,8 +779,8 @@ dispatch:
 if (media_check(dpb)  0)
 #endif
 {
+  CritErrCode = -DE_INVLDDRV;
   lr.AL = 0xff;
-  CritErrCode = 0x0f;
   break;
 }
 lr.DS = FP_SEG(dpb);
@@ -839,7 +839,7 @@ dispatch:
 if (0x == lr.DX)
 {
   /* Set Country Code */
-  if ((rc = DosSetCountry(cntry))  0)
+  if (DosSetCountry(cntry)  0)
 goto error_invalid;
 }
 else
@@ -847,7 +847,7 @@ dispatch:
   if (cntry == 0)
 cntry--;
   /* Get Country Information */
-  if ((rc = DosGetCountryInformation(cntry, FP_DS_DX))  0)
+  if (DosGetCountryInformation(cntry, FP_DS_DX)  0)
 goto error_invalid;
   /* HACK FIXME */
   if (cntry == (UWORD) - 1)
@@ -927,7 +927,6 @@ dispatch:
 
 case 0x01:
   rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX);
-  if (rc = SUCCESS)
 lr.AX = lr.CX;
   break;
 
@@ -939,12 +938,11 @@ dispatch:
   /* Device I/O Control   */
 case 0x44:
   rc = DosDevIOctl(lr);  /* can set critical error code! */
-
-  if (rc != SUCCESS)
+  if (rc  SUCCESS)
   {
 lr.AX = -rc;
 if (rc != DE_DEVICE  rc != DE_ACCESS)
-  CritErrCode = -rc;
+  CritErrCode = lr.AX;
 goto error_carry;
   }
   break;
@@ -962,52 +960,40 @@ dispatch:
   /* Get Current Directory*/
 case 0x47:
   rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI));
-  if (rc = SUCCESS)
 lr.AX = 0x0100; /*jpp: from interrupt list */
   goto short_check;
 
   /* Allocate memory */
 case 0x48:
-  if ((rc =
-   DosMemAlloc(lr.BX, mem_access_mode, (lr.AX), (lr.BX)))  0)
+  if ((rc = DosMemAlloc(lr.BX, mem_access_mode, lr.AX, lr.BX))  SUCCESS)
   {
-DosMemLargest((lr.BX));
-{
+DosMemLargest(lr.BX);
 if (DosMemCheck() != SUCCESS)
 panic(MCB chain corrupted);
-}
 goto error_exit;
   }
-  else
-++(lr.AX);  /* DosMemAlloc() returns seg of MCB rather than data 
*/
+  lr.AX++; /* DosMemAlloc() returns seg of MCB rather than data */
   break;
 
   /* Free memory */
 case 0x49:
-  if ((rc = DosMemFree((lr.ES) - 1))  0)
-{
+  if ((rc = DosMemFree(lr.ES - 1))  SUCCESS)
+  {
 if (DosMemCheck() != SUCCESS)
 panic(MCB chain corrupted);
-goto error_exit;
-}
+goto error_exit;
+  }
   break;
 
   /* Set memory block size */
 case 0x4a:
-if (DosMemCheck() != SUCCESS)
-  panic(before 4a: MCB chain corrupted);
-
-  if ((rc = DosMemChange(lr.ES, lr.BX, lr.BX))  0)
+  if (DosMemCheck() != SUCCESS)
+panic(before 4a: MCB chain corrupted);
+  if ((rc = DosMemChange(lr.ES, lr.BX, lr.BX))  SUCCESS)
   {
 #if 0
 if (cu_psp == lr.ES)
-{
-
-  psp FAR *p;
-  
-  p = MK_FP(cu_psp, 0);
-  p-ps_size = lr.BX + cu_psp;
-}
+  ((psp FAR*)MK_FP(cu_psp, 0))-ps_size = lr.BX + cu_psp;
 #endif
 if (DosMemCheck() != SUCCESS)
   panic(after 4a: MCB chain corrupted);
@@ -1031,21 +1017,17 @@ dispatch:
   if (((psp FAR *)MK_FP(cu_psp, 0))-ps_parent == cu_psp)
 break;
   tsr = FALSE;
+  return_code = lr.AL;
   if (ErrorMode)
   {
 ErrorMode = FALSE;
-rc = 2;
+return_code |= 0x200;
   }
   else if (break_flg)
   {