Streamline ioctl.c code so OW saves 2 more words of stack.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1425 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-06-08 19:40:41 +00:00
parent b8cabddd8e
commit 0231b7efd0

View File

@ -78,7 +78,7 @@ int DosDevIOctl(lregs * r)
sft FAR *s; sft FAR *s;
struct dpb FAR *dpbp; struct dpb FAR *dpbp;
unsigned attr; unsigned attr;
unsigned char unit, al = r->AL; unsigned char al = r->AL;
if (al > 0x11) if (al > 0x11)
return DE_INVLDFUNC; return DE_INVLDFUNC;
@ -125,8 +125,6 @@ int DosDevIOctl(lregs * r)
if ((s = get_sft(r->BX)) == (sft FAR *) - 1) if ((s = get_sft(r->BX)) == (sft FAR *) - 1)
return DE_INVLDHNDL; return DE_INVLDHNDL;
dev = s->sft_dev;
attr = dev->dh_attr;
flags = s->sft_flags; flags = s->sft_flags;
switch (r->AL) switch (r->AL)
@ -134,7 +132,7 @@ int DosDevIOctl(lregs * r)
case 0x00: case 0x00:
/* Get the flags from the SFT */ /* Get the flags from the SFT */
if (flags & SFT_FDEVICE) if (flags & SFT_FDEVICE)
r->AX = (attr & 0xff00) | (flags & 0xff); r->AX = (flags & 0xff) | (s->sft_dev->dh_attr & 0xff00);
else else
r->AX = flags; r->AX = flags;
/* Undocumented result, Ax = Dx seen using Pcwatch */ /* Undocumented result, Ax = Dx seen using Pcwatch */
@ -163,38 +161,29 @@ int DosDevIOctl(lregs * r)
r->DX = flags; r->DX = flags;
r->AX = 0; r->AX = 0;
return SUCCESS; return SUCCESS;
}
case 0x06:
if (!(flags & SFT_FDEVICE)) if (!(flags & SFT_FDEVICE))
{ {
if (r->AL == 0x06)
r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF; r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF;
return SUCCESS; else if (r->AL == 0x07)
}
goto IoCharCommon;
case 0x07:
if (!(flags & SFT_FDEVICE))
{
r->AL = 0; r->AL = 0;
else
return DE_INVLDFUNC;
return SUCCESS; return SUCCESS;
} }
/* fall through */ dev = s->sft_dev;
attr = dev->dh_attr;
default: /* 0x02, 0x03, 0x0c, 0x10 */ if ((r->AL <= 0x03 && (attr & ATTR_IOCTL))
IoCharCommon:
if ((flags & SFT_FDEVICE) &&
( (r->AL <= 0x03 && (attr & ATTR_IOCTL))
|| r->AL == 0x06 || r->AL == 0x07 || r->AL == 0x06 || r->AL == 0x07
|| (r->AL == 0x10 && (attr & ATTR_QRYIOCTL)) || (r->AL == 0x10 && (attr & ATTR_QRYIOCTL))
|| (r->AL == 0x0c && (attr & ATTR_GENIOCTL)))) || (r->AL == 0x0c && (attr & ATTR_GENIOCTL)))
{ {
CharReqHdr.r_unit = 0; CharReqHdr.r_unit = 0;
break; break;
} }
return DE_INVLDFUNC; return DE_INVLDFUNC;
} }
break;
}
default: /* block IOCTL: 4, 5, 8, 9, d, e, f, 11 */ default: /* block IOCTL: 4, 5, 8, 9, d, e, f, 11 */
@ -208,20 +197,13 @@ int DosDevIOctl(lregs * r)
/* JPP - changed to use default drive if drive=0 */ /* JPP - changed to use default drive if drive=0 */
/* JT Fixed it */ /* JT Fixed it */
#define NDN_HACK
/* NDN feeds the actual ASCII drive letter to this function */ /* NDN feeds the actual ASCII drive letter to this function */
#ifdef NDN_HACK dpbp = get_dpb((r->BL & 0x1f) == 0 ? default_drive : (r->BL & 0x1f) - 1);
unit = ((r->BL & 0x1f) == 0 ? default_drive : (r->BL & 0x1f) - 1);
#else
unit = (r->BL == 0 ? default_drive : r->BL - 1);
#endif
dpbp = get_dpb(unit);
if (dpbp) if (dpbp)
{ {
CharReqHdr.r_unit = dpbp->dpb_subunit;
dev = dpbp->dpb_device; dev = dpbp->dpb_device;
attr = dev->dh_attr; attr = dev->dh_attr;
CharReqHdr.r_unit = dpbp->dpb_subunit;
} }
else else
{ {
@ -237,7 +219,7 @@ int DosDevIOctl(lregs * r)
{ {
/* note from get_dpb() */ /* note from get_dpb() */
/* that if cdsp == NULL then dev must be NULL too */ /* that if cdsp == NULL then dev must be NULL too */
struct cds FAR *cdsp = get_cds(unit); struct cds FAR *cdsp = get_cds1(r->BL & 0x1f);
if (cdsp == NULL) if (cdsp == NULL)
return DE_INVLDDRV; return DE_INVLDDRV;
if (cdsp->cdsFlags & CDSSUBST) if (cdsp->cdsFlags & CDSSUBST)