mirror of https://github.com/FDOS/kernel.git
(mostly from Lucho) deal with the correct structure for generic and
query ioctls. Fixes issues with 3rd party device drivers (or ones that use dsk.c) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@965 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
0168037d73
commit
dace548223
22
hdr/device.h
22
hdr/device.h
|
@ -366,6 +366,19 @@ typedef struct {
|
|||
struct {
|
||||
unsigned char _r_ndbyte; /* Byte Read From Device */
|
||||
} _r_nd;
|
||||
struct {
|
||||
UBYTE _r_cat; /* Category code */
|
||||
UBYTE _r_fun; /* Function code */
|
||||
UBYTE unused[4]; /* SI or DI contents or DS:reqhdr */
|
||||
union
|
||||
{
|
||||
struct gblkio FAR *_r_io;
|
||||
struct gblkrw FAR *_r_rw;
|
||||
struct gblkfv FAR *_r_fv;
|
||||
struct Gioc_media FAR *_r_gioc;
|
||||
struct Access_info FAR *_r_ai;
|
||||
} _r_par; /* Pointer to param. block from 440C/440D */
|
||||
} _r_gen;
|
||||
} _r_x;
|
||||
} request;
|
||||
|
||||
|
@ -403,6 +416,15 @@ typedef struct {
|
|||
/* ndread packet macros */
|
||||
#define r_ndbyte _r_x._r_nd._r_ndbyte
|
||||
|
||||
/* generic IOCTL and IOCTL query macros */
|
||||
#define r_cat _r_x._r_gen._r_cat
|
||||
#define r_fun _r_x._r_gen._r_fun
|
||||
#define r_rw _r_x._r_gen._r_par._r_rw
|
||||
#define r_io _r_x._r_gen._r_par._r_io
|
||||
#define r_fv _r_x._r_gen._r_par._r_fv
|
||||
#define r_gioc _r_x._r_gen._r_par._r_gioc
|
||||
#define r_ai _r_x._r_gen._r_par._r_ai
|
||||
|
||||
/*
|
||||
*interrupt support (spl & splx) support - IBM style
|
||||
*/
|
||||
|
|
52
kernel/dsk.c
52
kernel/dsk.c
|
@ -472,19 +472,23 @@ STATIC WORD IoctlQueblk(rqptr rp, ddt * pddt)
|
|||
{
|
||||
UNREFERENCED_PARAMETER(pddt);
|
||||
|
||||
switch (rp->r_count)
|
||||
#ifdef WITHFAT32
|
||||
if (rp->r_cat == 8 || rp->r_cat == 0x48)
|
||||
#else
|
||||
if (rp->r_cat == 8)
|
||||
#endif
|
||||
{
|
||||
case 0x0846:
|
||||
case 0x0847:
|
||||
case 0x0860:
|
||||
case 0x0866:
|
||||
case 0x0867:
|
||||
break;
|
||||
default:
|
||||
return failure(E_CMD);
|
||||
switch (rp->r_fun)
|
||||
{
|
||||
case 0x46:
|
||||
case 0x47:
|
||||
case 0x60:
|
||||
case 0x66:
|
||||
case 0x67:
|
||||
return S_DONE;
|
||||
}
|
||||
}
|
||||
return S_DONE;
|
||||
|
||||
return failure(E_CMD);
|
||||
}
|
||||
|
||||
STATIC COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track,
|
||||
|
@ -506,18 +510,18 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
#ifdef WITHFAT32
|
||||
int extended = 0;
|
||||
|
||||
if ((rp->r_count >> 8) == 0x48)
|
||||
if (rp->r_cat == 0x48)
|
||||
extended = 1;
|
||||
else
|
||||
#endif
|
||||
if ((rp->r_count >> 8) != 8)
|
||||
if (rp->r_cat != 8)
|
||||
return failure(E_CMD);
|
||||
|
||||
switch (rp->r_count & 0xff)
|
||||
switch (rp->r_fun)
|
||||
{
|
||||
case 0x40: /* set device parameters */
|
||||
{
|
||||
struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans;
|
||||
struct gblkio FAR *gblp = rp->r_io;
|
||||
bpb *pbpb;
|
||||
|
||||
pddt->ddt_type = gblp->gbio_devtype;
|
||||
|
@ -539,7 +543,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
}
|
||||
case 0x41: /* write track */
|
||||
{
|
||||
struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans;
|
||||
struct gblkrw FAR *rw = rp->r_rw;
|
||||
ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl,
|
||||
rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer);
|
||||
if (ret != 0)
|
||||
|
@ -548,7 +552,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
break;
|
||||
case 0x42: /* format/verify track */
|
||||
{
|
||||
struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans;
|
||||
struct gblkfv FAR *fv = rp->r_fv;
|
||||
COUNT tracks;
|
||||
struct thst {
|
||||
UBYTE track, head, sector, type;
|
||||
|
@ -650,7 +654,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
|
||||
case 0x62: /* verify track */
|
||||
{
|
||||
struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans;
|
||||
struct gblkfv FAR *fv = rp->r_fv;
|
||||
|
||||
ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0,
|
||||
(fv->gbfv_spcfunbit ?
|
||||
|
@ -663,7 +667,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
break;
|
||||
case 0x46: /* set volume serial number */
|
||||
{
|
||||
struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans;
|
||||
struct Gioc_media FAR *gioc = rp->r_gioc;
|
||||
struct FS_info *fs;
|
||||
|
||||
ret = getbpb(pddt);
|
||||
|
@ -682,14 +686,14 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
break;
|
||||
case 0x47: /* set access flag */
|
||||
{
|
||||
struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans;
|
||||
struct Access_info FAR *ai = rp->r_ai;
|
||||
pddt->ddt_descflags = (descflags & ~DF_NOACCESS) |
|
||||
(ai->AI_Flag ? 0 : DF_NOACCESS);
|
||||
}
|
||||
break;
|
||||
case 0x60: /* get device parameters */
|
||||
{
|
||||
struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans;
|
||||
struct gblkio FAR *gblp = rp->r_io;
|
||||
bpb *pbpb;
|
||||
|
||||
gblp->gbio_devtype = pddt->ddt_type;
|
||||
|
@ -712,7 +716,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
}
|
||||
case 0x61: /* read track */
|
||||
{
|
||||
struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans;
|
||||
struct gblkrw FAR *rw = rp->r_rw;
|
||||
ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl,
|
||||
rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer);
|
||||
if (ret != 0)
|
||||
|
@ -721,7 +725,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
break;
|
||||
case 0x66: /* get volume serial number */
|
||||
{
|
||||
struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans;
|
||||
struct Gioc_media FAR *gioc = rp->r_gioc;
|
||||
|
||||
ret = getbpb(pddt);
|
||||
if (ret != 0)
|
||||
|
@ -734,7 +738,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt)
|
|||
break;
|
||||
case 0x67: /* get access flag */
|
||||
{
|
||||
struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans;
|
||||
struct Access_info FAR *ai = rp->r_ai;
|
||||
ai->AI_Flag = descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -59,13 +59,25 @@ COUNT DosDevIOctl(lregs * r)
|
|||
sft FAR *s;
|
||||
struct dpb FAR *dpbp;
|
||||
COUNT nMode;
|
||||
unsigned char al = r->AL;
|
||||
|
||||
if (al > 0x11)
|
||||
return DE_INVLDFUNC;
|
||||
|
||||
/* 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_trans = MK_FP(r->DS, r->DX);
|
||||
CharReqHdr.r_status = 0;
|
||||
CharReqHdr.r_count = r->CX;
|
||||
|
||||
/* Test that the handle is valid */
|
||||
switch (r->AL)
|
||||
|
|
Loading…
Reference in New Issue