[Freedos-kernel] (no subject)
Hi! (replaces previous patch) - 3 nested switch splitted into 2 switch (1st prepares parameters for 2nd, which calls execrh()). - device attribute word checked through table lookup. - CharReqHdr.r_command computed through table lookup. - removed all goto, except one. Result: DGROUP increased from 1646 to 167c (54 bytes), TGROUP decreased from de6e to dd4e (288 bytes). _DATA segment increased from 248 to 27e (54 bytes), HMA_DATA segment decreased from a482 to a36e (276 bytes). ---BeginMessage--- diff -ruNp old/kernel/ioctl.c new/kernel/ioctl.c --- old/kernel/ioctl.c 2004-05-29 02:51:30.0 + +++ new/kernel/ioctl.c 2004-06-02 03:20:14.0 + @@ -56,38 +56,55 @@ static BYTE *RcsId = COUNT DosDevIOctl(lregs * r) { - sft FAR *s; - struct dpb FAR *dpbp; - COUNT nMode; - unsigned attr; - unsigned char al = r-AL; - - if (al 0x11) -return DE_INVLDFUNC; + static UBYTE cmds [] = { + 0, 0, + /* 0x02 */ C_IOCTLIN, + /* 0x03 */ C_IOCTLOUT, + /* 0x04 */ C_IOCTLIN, + /* 0x05 */ C_IOCTLOUT, + /* 0x06 */ C_ISTAT, + /* 0x07 */ C_OSTAT, + /* 0x08 */ C_REMMEDIA, + 0, 0, 0, + /* 0x0c */ C_GENIOCTL, + /* 0x0d */ C_GENIOCTL, + /* 0x0e */ C_GETLDEV, + /* 0x0f */ C_SETLDEV, + /* 0x10 */ C_IOCTLQRY, + /* 0x11 */ C_IOCTLQRY, + }; + static UWORD required_attr [] = { + 0, 0, + /* 0x02 */ ATTR_IOCTL, + /* 0x03 */ ATTR_IOCTL, + /* 0x04 */ ATTR_IOCTL, + /* 0x05 */ ATTR_IOCTL, + 0, 0, + /* 0x08 */ ATTR_EXCALLS, + 0, 0, 0, + /* 0x0c */ ATTR_GENIOCTL, + /* 0x0d */ ATTR_GENIOCTL, + /* 0x0e */ ATTR_GENIOCTL, + /* 0x0f */ ATTR_GENIOCTL, + /* 0x10 */ ATTR_QRYIOCTL, + /* 0x11 */ ATTR_QRYIOCTL, + }; - /* commonly used, shouldn't harm to do front up */ - if (al == 0x0C || al == 0x0D || al = 0x10) /* generic or query */ - { -CharReqHdr.r_cat = r-CH;/* category (major) code */ -CharReqHdr.r_fun = r-CL;/* function (minor) code */ -CharReqHdr.r_io = MK_FP(r-DS, r-DX);/* parameter block */ - } - else - { -CharReqHdr.r_count = r-CX; -CharReqHdr.r_trans = MK_FP(r-DS, r-DX); - } - CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_status = 0; + sft FAR *s; + struct dhdr FAR *dev; + unsigned attr, flags; + UBYTE cmd; switch (r-AL) { +default: /* 0x12+ */ + return DE_INVLDFUNC; + 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; - break; + NetDelay = r-CX; + return SUCCESS; case 0x00: case 0x01: @@ -98,31 +115,86 @@ COUNT DosDevIOctl(lregs * r) case 0x0a: case 0x0c: case 0x10: -{ - unsigned flags; - /* Test that the handle is valid and*/ /* get the SFT block that contains the SFT */ - if ((s = get_sft(r-BX)) == (sft FAR *) - 1) + if ((s = get_sft(r-BX)) == (sft FAR *)-1) return DE_INVLDHNDL; - - attr = s-sft_dev-dh_attr; flags = s-sft_flags; + attr = (dev = s-sft_dev)-dh_attr; + break; + +case 0x04: +case 0x05: +case 0x08: +case 0x09: +case 0x0d: +case 0x0e: +case 0x0f: +case 0x11: +{ + struct dpb FAR *dpbp; +/* + Line below previously returned the deviceheader at r-bl. But, + DOS numbers its drives starting at 1, not 0. A=1, B=2, and so + on. Changed this line so it is now zero-based. --SRM + */ +/* changed to use default drive if drive=0. --JPP */ +/* Fixed it. --JT */ - switch (r-AL) +#define NDN_HACK +#ifdef NDN_HACK +/* NDN feeds the actual ASCII drive letter to this function */ + UBYTE unit = (r-BL 0x1f) - 1; +#else + UBYTE unit = r-BL - 1; +#endif + if (unit == 0xff) + unit = default_drive; + CharReqHdr.r_unit = unit; + + if ((dpbp = get_dpb(unit)) == NULL) { -case 0x00: +if (r-AL != 0x09) + return DE_INVLDDRV; +attr = ATTR_REMOTE; + } + else +attr = (dev = dpbp-dpb_device)-dh_attr; +} + } /* switch */ + + /* required_attr[] may be zero and in this case attr ignored */ + if (~attr required_attr [r-AL]) +return DE_INVLDFUNC; + + /* commonly used, shouldn't harm to do front up */ + CharReqHdr.r_command = cmd = cmds [r-AL]; + if (cmd == C_GENIOCTL || cmd == C_IOCTLQRY) + { +CharReqHdr.r_cat = r-CH;/* category (major) code */ +CharReqHdr.r_fun = r-CL;/* function (minor) code */ +CharReqHdr.r_io = MK_FP(r-DS, r-DX);/* parameter block */ + } + else + { +CharReqHdr.r_count = r-CX; +CharReqHdr.r_trans = MK_FP(r-DS, r-DX); + } + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_status = 0; + + switch (r-AL) + { +case 0x00:
[Freedos-kernel] Q: ioctl.c
Hi! DosDevIOctl() returns AX = S_DONE | S_BUSY on SUCCESS for AL=9 (INT21/4409). RBIL says nothing about AX on return. Same for AL=0xA (there returned AX=0). Why? If there are some reasons, these reasons should be commented (especially for strange value S_DONE|S_BUSY). --- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 ___ Freedos-kernel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freedos-kernel
Re: [Freedos-kernel] (no subject)
Hi! 2--2004 07:47 Arkady V.Belousov wrote to [EMAIL PROTECTED]: AVB Subject: [Freedos-kernel] (no subject) This was should be patch: ioctl.c. AVB (replaces previous patch) AVB - 3 nested switch splitted into 2 switch (1st prepares parameters for AVB 2nd, which calls execrh()). AVB - device attribute word checked through table lookup. AVB - CharReqHdr.r_command computed through table lookup. AVB - removed all goto, except one. AVB Result: AVB DGROUP increased from 1646 to 167c (54 bytes), AVB TGROUP decreased from de6e to dd4e (288 bytes). AVB _DATA segment increased from 248 to 27e (54 bytes), AVB HMA_DATA segment decreased from a482 to a36e (276 bytes). AVB diff -ruNp old/kernel/ioctl.c new/kernel/ioctl.c --- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 ___ Freedos-kernel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freedos-kernel
[Freedos-kernel] patch: dsk.c
Hi! - small source cleanup (expressions simplified, extraneous casts removed). - removed all references to PROTO macro name. - removed remained excerpt from history.txt at the end. - bugfix: getlogdev(): in case of no DF_CURLOG flag is set, in rp-r_unit now returned last+1 (equal to blk_dev.dh_name[0]) unit (was last+2). - mediachk(): code flow optimization. - getbpb(): removed extraneous stack variable; instead (x+y-1)/y for roundup used (x-1)/y+1 expression; printf sequences joined into one printf. - IoctlQueblk(): small code optimization. Result: TGROUP decreased from dd4e to dd0e (64 bytes). HMA_TEXT segment decreased from a36a to a32c (62 bytes). BTW, previous patch for break.c also decreases HMA_TEXT by 4 bytes. ---BeginMessage--- diff -ruNp old/kernel/dsk.c new/kernel/dsk.c --- old/kernel/dsk.c2004-05-29 02:51:30.0 + +++ new/kernel/dsk.c2004-06-02 06:21:48.0 + @@ -92,7 +92,7 @@ extern struct DynS ASM Dyn; /*TE - array access functions */ ddt *getddt(int dev) { - return (((ddt *) Dyn.Buffer)[dev]); + return (ddt*)Dyn.Buffer + dev; } STATIC VOID tmark(ddt *pddt) @@ -110,22 +110,14 @@ STATIC BOOL tdelay(ddt *pddt, ULONG tick #define PARTOFF 0x1be -#ifdef PROTO typedef WORD dsk_proc(rqptr rq, ddt * pddt); -#else -typedef WORD dsk_proc(); -#endif STATIC dsk_proc mediachk, bldbpb, blockio, IoctlQueblk, Genblkdev, Getlogdev, Setlogdev, blk_Open, blk_Close, blk_Media, blk_noerr, blk_nondr, blk_error; -STATIC WORD getbpb(ddt * pddt); -#ifdef PROTO +STATIC WORD getbpb(ddt*); STATIC WORD dskerr(COUNT); -#else -STATIC WORD dskerr(); -#endif /* */ /* the function dispatch table */ @@ -245,32 +237,35 @@ STATIC WORD diskchange(ddt * pddt) STATIC WORD mediachk(rqptr rp, ddt * pddt) { + int ret; /* check floppy status */ if (pddt-ddt_descflags DF_REFORMAT) { pddt-ddt_descflags = ~DF_REFORMAT; rp-r_mcretcode = M_CHANGED; +ret = S_DONE; } else if (pddt-ddt_descflags DF_DISKCHANGE) { pddt-ddt_descflags = ~DF_DISKCHANGE; rp-r_mcretcode = M_DONT_KNOW; +ret = S_DONE; } - else + else if ((rp-r_mcretcode = diskchange(pddt)) == M_DONT_KNOW) { -rp-r_mcretcode = diskchange(pddt); -if (rp-r_mcretcode == M_DONT_KNOW) +/* don't know but can check serial number ... */ +ULONG serialno = pddt-ddt_serialno; +ret = getbpb(pddt); +if (ret == 0) { - /* don't know but can check serial number ... */ - ULONG serialno = pddt-ddt_serialno; - COUNT result = getbpb(pddt); - if (result != 0) -return (result); if (serialno != pddt-ddt_serialno) rp-r_mcretcode = M_CHANGED; + ret = S_DONE; } } - return S_DONE; + else +ret = S_DONE; + return ret; } /* @@ -279,9 +274,8 @@ STATIC WORD mediachk(rqptr rp, ddt * pdd STATIC WORD RWzero(ddt * pddt, UWORD mode) { UWORD done; - return LBA_Transfer(pddt, mode, - (UBYTE FAR *) DiskTransferBuffer, + DiskTransferBuffer, pddt-ddt_offset, 1, done); } @@ -291,36 +285,29 @@ STATIC WORD RWzero(ddt * pddt, UWORD mod */ STATIC WORD Getlogdev(rqptr rp, ddt * pddt) { - int i; - ddt *pddt2; - - if (!(pddt-ddt_descflags DF_MULTLOG)) { -rp-r_unit = 0; -return S_DONE; - } - - pddt2 = getddt(0); - for (i = 0; i blk_dev.dh_name[0]; i++, pddt2++) + UBYTE unit = 0; + if (pddt-ddt_descflags DF_MULTLOG) { -if (pddt-ddt_driveno == pddt2-ddt_driveno -(pddt2-ddt_descflags (DF_MULTLOG | DF_CURLOG)) == -(DF_MULTLOG | DF_CURLOG)) -break; +ddt *pddt2 = getddt(0); +while (++unit blk_dev.dh_name[0] + (pddt-ddt_driveno != pddt2-ddt_driveno || + (~pddt2-ddt_descflags (DF_MULTLOG | DF_CURLOG + pddt2++; } - - rp-r_unit = i+1; + rp-r_unit = unit; return S_DONE; } STATIC WORD Setlogdev(rqptr rp, ddt * pddt) { - unsigned char unit = rp-r_unit; + UBYTE unit = rp-r_unit + 1; Getlogdev(rp, pddt); - if (rp-r_unit == 0) -return S_DONE; - getddt(rp-r_unit - 1)-ddt_descflags = ~DF_CURLOG; - pddt-ddt_descflags |= DF_CURLOG; - rp-r_unit = unit + 1; + if (rp-r_unit) + { +getddt(rp-r_unit - 1)-ddt_descflags = ~DF_CURLOG; +pddt-ddt_descflags |= DF_CURLOG; +rp-r_unit = unit; /* ??? - avb */ + } return S_DONE; } @@ -360,8 +347,7 @@ STATIC WORD blk_Media(rqptr rp, ddt * pd STATIC WORD getbpb(ddt * pddt) { - ULONG count; - bpb *pbpbarray = pddt-ddt_bpb; + bpb *pbpbarray; unsigned secs_per_cyl; WORD ret; @@ -374,9 +360,10 @@ STATIC WORD getbpb(ddt * pddt) ret = RWzero(pddt, LBA_READ); if (ret != 0) -return (dskerr(ret)); +return dskerr(ret); - pbpbarray-bpb_nbyte = getword(DiskTransferBuffer[BT_BPB]); + pbpbarray = pddt-ddt_bpb; + pbpbarray-bpb_nbyte =