From b8a19f9da0634bc1f1eb6537da3b3f5f3be95fad Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Wed, 21 Jun 2000 18:16:46 +0000 Subject: [PATCH] Add UMB code, patch, and code fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@32 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fat.h | 8 +++- hdr/mcb.h | 9 ++++ kernel/config.c | 119 ++++++++++++++++++++++++++++++++++++++++++---- kernel/dosfns.c | 25 ++++------ kernel/dosnames.c | 12 ++++- kernel/dsk.c | 72 +++++++++++++++++++++------- kernel/fatdir.c | 23 ++++++--- kernel/fatfs.c | 5 +- kernel/fcbfns.c | 33 ++++++++++--- kernel/globals.h | 22 +++++++-- kernel/int2f.asm | 37 +++++++++++--- kernel/inthndlr.c | 118 +++++++++++++++++++++++++-------------------- kernel/io.asm | 7 ++- kernel/ioctl.c | 119 ++++++++++++++++++++++++++++++++-------------- kernel/kernel.asm | 31 ++++++------ kernel/main.c | 32 ++++++++----- kernel/memmgr.c | 43 +++++++++-------- kernel/network.c | 7 ++- kernel/newstuff.c | 7 ++- kernel/proto.h | 8 +++- 20 files changed, 528 insertions(+), 209 deletions(-) diff --git a/hdr/fat.h b/hdr/fat.h index bc52089..e27a768 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -112,8 +115,11 @@ static BYTE *fat_hRcsId = "$Id$"; /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define FAT_MAGIC 4086 +#define FAT_MAGIC16 65526 +#define FAT_MAGIC32 268435456 -#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC) +#define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 || ((dpbp)->dpb_size)<=FAT_MAGIC32 ) +#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC || ((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) /* FAT file system directory entry */ diff --git a/hdr/mcb.h b/hdr/mcb.h index 70d4adf..c34c03a 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,6 +36,9 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -85,6 +88,12 @@ static BYTE *mcb_hRcsId = "$Id$"; #define FIRST_FIT 0 #define BEST_FIT 1 #define LAST_FIT 2 +#define FIRST_FIT_UO 0x40 +#define BEST_FIT_UO 0x41 +#define LAST_FIT_UO 0x42 +#define FIRST_FIT_U 0x80 +#define BEST_FIT_U 0x81 +#define LAST_FIT_U 0x82 #define MCB_NORMAL 0x4d #define MCB_LAST 0x5a diff --git a/kernel/config.c b/kernel/config.c index f8dfae4..2a57f1e 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -140,7 +143,9 @@ void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ #endif BYTE FAR *lpBase; +BYTE FAR *upBase; static BYTE FAR *lpOldLast; +static BYTE FAR *upOldLast; static COUNT nCfgLine; static COUNT nPass; static BYTE szLine[256]; @@ -148,14 +153,19 @@ static BYTE szBuf[256]; int singleStep = 0; +INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); + INIT VOID Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); INIT VOID sysVersion(BYTE * pLine); INIT VOID Break(BYTE * pLine); INIT VOID Device(BYTE * pLine); +INIT VOID DeviceHigh(BYTE * pLine); INIT VOID Files(BYTE * pLine); INIT VOID Fcbs(BYTE * pLine); INIT VOID Lastdrive(BYTE * pLine); +INIT VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode); +INIT VOID Dosmem(BYTE * pLine); INIT VOID Country(BYTE * pLine); INIT VOID InitPgm(BYTE * pLine); INIT VOID Switchar(BYTE * pLine); @@ -190,6 +200,8 @@ static struct table commands[] = {"command", 1, InitPgm}, {"country", 1, Country}, {"device", 2, Device}, + {"devicehigh", 2, DeviceHigh}, + {"dos", 1, Dosmem}, {"fcbs", 1, Fcbs}, {"files", 1, Files}, {"lastdrive", 1, Lastdrive}, @@ -251,7 +263,7 @@ INIT void PreConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive + 1)); + KernelAlloc(0x58 * (lastdrive)); #ifdef DEBUG @@ -289,13 +301,15 @@ INIT void PreConfig(void) /* Also, run config.sys to load drivers. */ INIT void PostConfig(void) { + + COUNT tmp = 0xc000; + /* Set pass number */ nPass = 2; - /* compute lastdrive ... */ lastdrive = Config.cfgLastdrive; - if (lastdrive < nblkdev -1) - lastdrive = nblkdev -1; + if (lastdrive < nblkdev ) + lastdrive = nblkdev ; /* Initialize the base memory pointers from last time. */ lpBase = AlignParagraph(lpOldLast); @@ -326,7 +340,7 @@ INIT void PostConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive + 1)); + KernelAlloc(0x58 * (lastdrive)); #ifdef DEBUG @@ -353,6 +367,21 @@ INIT void PostConfig(void) printf("Allocation completed: top at 0x%04x:0x%04x\n", FP_SEG(lpBase), FP_OFF(lpBase)); #endif + + if(uppermem_link) + { + upBase = MK_FP(tmp , 0); + uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + umcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), 0 ); + + upBase += 16; + +#ifdef DEBUG + printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", + FP_SEG(upBase), FP_OFF(upBase)); +#endif + } + } /* This code must be executed after device drivers has been loaded */ @@ -360,13 +389,13 @@ INIT VOID configDone(VOID) { COUNT i; - if (lastdrive < nblkdev -1) { + if (lastdrive < nblkdev) { #ifdef DEBUG printf("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1); #endif /* DEBUG */ - lastdrive = nblkdev -1; + lastdrive = nblkdev; CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive +1)); + KernelAlloc(0x58 * (lastdrive )); } first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); @@ -374,6 +403,13 @@ INIT VOID configDone(VOID) mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), (ram_top << 6) - first_mcb - 1); + if(uppermem_link) + { + uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), + (UMB_top << 6) - uppermem_root - 1); + } + /* The standard handles should be reopened here, because we may have loaded new console or printer drivers in CONFIG.SYS */ } @@ -636,9 +672,29 @@ INIT static VOID Lastdrive(BYTE * pLine) return; } drv -= 'A'; + drv++; /* Make real number*/ Config.cfgLastdrive = max(Config.cfgLastdrive, drv); } +INIT static VOID Dosmem(BYTE * pLine) +{ + COUNT tmp; + COUNT FAR * u = MK_FP(0xc000, 0); + + GetStringArg(pLine, szBuf); + uppermem_link = strcmp(szBuf, "UMB") ? 1 : 0; + + if(uppermem_link) + { + tmp = *u; + *u = 0x1234; + if(*u == 0x1234) + *u = tmp; + else + uppermem_link = 0; + } +} + INIT static VOID Switchar(BYTE * pLine) { /* Format: SWITCHAR = character */ @@ -769,14 +825,37 @@ INIT static VOID Break(BYTE * pLine) break_ena = strcmp(szBuf, "OFF") ? 1 : 0; } +INIT static VOID DeviceHigh(BYTE * pLine) +{ + if(uppermem_link) + { + LoadDevice(pLine, UMB_top, TRUE); + } + else + { + printf("UMB's unavalable!\n"); + LoadDevice(pLine, ram_top, FALSE); + } +} + INIT static VOID Device(BYTE * pLine) +{ + LoadDevice(pLine, ram_top, FALSE); +} + +INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { VOID FAR *driver_ptr; BYTE *pTmp; exec_blk eb; struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; - UWORD dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; + UWORD dev_seg; + + if(mode) + dev_seg = (((ULONG) FP_SEG(upBase) << 4) + FP_OFF(upBase) + 0xf) >> 4; + else + dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; /* Get the device driver name */ GetStringArg(pLine, szBuf); @@ -797,7 +876,7 @@ INIT static VOID Device(BYTE * pLine) next_dhp = dhp->dh_next = nul_dev.dh_next; nul_dev.dh_next = dhp; - if(init_device(dhp, pLine)){ + if(init_device(dhp, pLine, mode, top)){ nul_dev.dh_next = next_dhp; /* return orig pointer if error */ } } @@ -962,6 +1041,26 @@ INIT VOID mcbp->m_name[i] = '\0'; mem_access_mode = FIRST_FIT; } +INIT VOID + umcb_init(mcb FAR * mcbp, UWORD size) +{ + COUNT i; + static char name[8] = "UMB "; + + mcbp->m_type = 0x4d; + mcbp->m_psp = 0x08; + mcbp->m_size = size; + for (i = 0; i < 8; i++) + mcbp->m_name[i] = name[i]; +} +INIT VOID + zumcb_init(mcb FAR * mcbp, UWORD size) +{ + COUNT i; + mcbp->m_type = MCB_LAST; + mcbp->m_psp = FREE_PSP; + mcbp->m_size = size; +} #endif INIT VOID diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 85e2611..ce3727a 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,6 +34,9 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.6 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -230,13 +233,7 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, if (s->sft_flags & SFT_FSHARED) { ReadCount = Remote_RW(REM_READ, n, bp, s, err); - if (err) - { - *err = SUCCESS; - return ReadCount; - } - else - return 0; + return *err == SUCCESS ? ReadCount : 0; } /* Do a device read if device */ if (s->sft_flags & SFT_FDEVICE) @@ -346,12 +343,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) if (s->sft_flags & SFT_FSHARED) { WriteCount = Remote_RW(REM_WRITE, n, bp, s, err); - if (err) - { - return WriteCount; - } - else - return 0; + return *err == SUCCESS ? WriteCount : 0; } /* Do a device write if device */ @@ -962,7 +954,7 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive > lastdrive) + if (drive < 0 || drive > (lastdrive - 1)) { *spc = -1; return; @@ -1011,7 +1003,7 @@ COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive > lastdrive) { + if (drive < 0 || drive > (lastdrive - 1)) { return DE_INVLDDRV; } @@ -1190,6 +1182,7 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) else { result = dos_getfattr(name, attrp); } + return result; } COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) @@ -1228,7 +1221,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) BYTE DosSelectDrv(BYTE drv) { - if ((drv <= lastdrive) && (CDSp->cds_table[drv].cdsFlags & 0xf000)) + if ((drv <= (lastdrive -1 )) && (CDSp->cds_table[drv].cdsFlags & 0xf000)) { current_ldt = &CDSp->cds_table[drv]; default_drive = drv; diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 6210baf..e82488c 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -138,7 +141,13 @@ VOID SpacePad(BYTE * szString, COUNT nChars) for (i = strlen(szString); i < nChars; i++) szString[i] = ' '; } +/* + MSD durring an FindFirst search string looks like this; + (*), & (.) == Current directory *.* + (\) == Root directory *.* + (..) == Back one directory *.* + */ COUNT ParseDosName(BYTE FAR * lpszFileName, COUNT * pnDrive, BYTE * pszDir, @@ -254,8 +263,9 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, ++nExtCnt; ++lpszFileName; } - else + else{ return DE_FILENOTFND; + } } } else if (*lpszFileName) diff --git a/kernel/dsk.c b/kernel/dsk.c index fcc68aa..9a5b3d3 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.7 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -215,9 +218,13 @@ WORD init(rqptr), blockio(rqptr), IoctlQueblk(rqptr), Genblkdev(rqptr), + Getlogdev(rqptr), + Setlogdev(rqptr), blk_Open(rqptr), blk_Close(rqptr), blk_Media(rqptr), + blk_noerr(rqptr), + blk_nondr(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); WORD dskerr(COUNT); @@ -229,9 +236,13 @@ WORD init(), blockio(), IoctlQueblk(), Genblkdev(), + Getlogdev(), + Setlogdev(), blk_Open(), blk_Close(), blk_Media(), + blk_noerr(), + blk_nondr(), blk_error(); WORD dskerr(); COUNT processtable(); @@ -247,31 +258,31 @@ static WORD(*dispatch[NENTRY]) (rqptr) = static WORD(*dispatch[NENTRY]) () = #endif { - init, /* Initialize */ + init, /* Initialize */ mediachk, /* Media Check */ bldbpb, /* Build BPB */ blk_error, /* Ioctl In */ blockio, /* Input (Read) */ - blk_error, /* Non-destructive Read */ - blk_error, /* Input Status */ - blk_error, /* Input Flush */ + blk_nondr, /* Non-destructive Read */ + blk_noerr, /* Input Status */ + blk_noerr, /* Input Flush */ blockio, /* Output (Write) */ blockio, /* Output with verify */ - blk_error, /* Output Status */ - blk_error, /* Output Flush */ + blk_noerr, /* Output Status */ + blk_noerr, /* Output Flush */ blk_error, /* Ioctl Out */ blk_Open, /* Device Open */ blk_Close, /* Device Close */ blk_Media, /* Removable Media */ - blk_error, /* Output till busy */ + blk_noerr, /* Output till busy */ blk_error, /* undefined */ blk_error, /* undefined */ Genblkdev, /* Generic Ioctl Call */ blk_error, /* undefined */ blk_error, /* undefined */ blk_error, /* undefined */ - blk_error, /* Get Logical Device */ - blk_error, /* Set Logical Device */ + Getlogdev, /* Get Logical Device */ + Setlogdev, /* Set Logical Device */ IoctlQueblk /* Ioctl Query */ }; @@ -535,10 +546,30 @@ static WORD RWzero(rqptr rp, WORD t) return ret; } +/* + 0 if not set, 1 = a, 2 = b, etc, assume set. + page 424 MS Programmer's Ref. + */ +static WORD Getlogdev(rqptr rp) +{ + BYTE x = rp->r_unit; + x++; + if( x > nblk_rel ) + return failure(E_UNIT); + + rp->r_unit = x; + return S_DONE; +} + +static WORD Setlogdev(rqptr rp) +{ + return S_DONE; +} + static WORD blk_Open(rqptr rp) { - miarray[rp->r_unit].mi_FileOC++; - return S_DONE; + miarray[rp->r_unit].mi_FileOC++; + return S_DONE; } static WORD blk_Close(rqptr rp) @@ -547,11 +578,14 @@ static WORD blk_Close(rqptr rp) return S_DONE; } +static WORD blk_nondr(rqptr rp) +{ + return S_BUSY|S_DONE; +} + static WORD blk_Media(rqptr rp) { - COUNT drive = miarray[rp->r_unit].mi_drive; - - if (hd(drive)) + if (hd( miarray[rp->r_unit].mi_drive)) return S_BUSY|S_DONE; /* Hard Drive */ else return S_DONE; /* Floppy */ @@ -652,7 +686,7 @@ static WORD IoctlQueblk(rqptr rp) case 0x0867: break; default: - return S_ERROR; + return failure(E_CMD); } return S_DONE; @@ -738,7 +772,7 @@ static WORD Genblkdev(rqptr rp) case 0x0847: /* set access flag, no real use*/ break; default: - return S_ERROR; + return failure(E_CMD); } return S_DONE; } @@ -818,6 +852,12 @@ static WORD blk_error(rqptr rp) return failure(E_FAILURE); /* general failure */ } + +static WORD blk_noerr(rqptr rp) +{ + return S_DONE; +} + static WORD dskerr(COUNT code) { /* printf("diskette error:\nhead = %d\ntrack = %d\nsector = %d\ncount = %d\n", diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 5855291..760d343 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.7 2000/06/01 06:46:57 jimtabor * Removed Debug printf * @@ -190,7 +193,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) { drive = default_drive; } - if (drive > lastdrive) { + if (drive > (lastdrive-1)) { release_f_node(fnp); return NULL; } @@ -580,7 +583,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) fscopy(name, (BYTE FAR *)&Tname); /* printf("ff %s", Tname); -*/ + */ /* The findfirst/findnext calls are probably the worst of the */ /* DOS calls. They must work somewhat on the fly (i.e. - open */ /* but never close). Since we don't want to lose fnodes every */ @@ -611,7 +614,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) else nDrive = default_drive; - if (nDrive > lastdrive) { + if (nDrive > (lastdrive -1)) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[nDrive]; @@ -658,7 +661,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) if (current_ldt->cdsFlags & CDSNETWDRV) { - if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) + if (Remote_find(REM_FINDFIRST, name, dmp) != 0) return DE_FILENOTFND; return SUCCESS; } @@ -751,7 +754,7 @@ COUNT dos_findnext(void) */ nDrive = dmp->dm_drive & 0x1f; - if (nDrive > lastdrive) { + if (nDrive > (lastdrive -1)) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[nDrive]; @@ -763,7 +766,7 @@ COUNT dos_findnext(void) if (current_ldt->cdsFlags & CDSNETWDRV) { - if (Remote_find(REM_FINDNEXT, 0, 0, dmp) != 0) + if (Remote_find(REM_FINDNEXT, 0, dmp) != 0) return DE_FILENOTFND; return SUCCESS; } @@ -777,7 +780,7 @@ COUNT dos_findnext(void) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - if (dmp->dm_drive > lastdrive) { + if (dmp->dm_drive > (lastdrive -1)) { return DE_INVLDDRV; } /* Select the default to help non-drive specified path */ @@ -815,6 +818,12 @@ COUNT dos_findnext(void) { if (fcmp_wild((BYTE FAR *) (dmp->dm_name_pat), (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { + /* + MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. + Bits 0x21 seem to get set some where in MSD so Rd and Arc + files are returned. FD assumes the user knows what they need + to see. + */ /* Test the attribute as the final step */ if (!(~dmp->dm_attr_srch & fnp->f_dir.dir_attrib)) { diff --git a/kernel/fatfs.c b/kernel/fatfs.c index ce2d95a..2d25f77 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -329,7 +332,7 @@ static struct f_node FAR * SpacePad(fname, FNAME_SIZE); SpacePad(fext, FEXT_SIZE); - if (nDrive > lastdrive) { + if (nDrive > (lastdrive -1)) { return (struct f_node FAR *)0; } cdsp = &CDSp->cds_table[nDrive]; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index c728a3c..7e91cd1 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -143,7 +146,7 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, printf("FGDD\n"); /* first check for valid drive */ - if ((drive < 0) || (drive > lastdrive) || (drive > NDEVS)) + if ((drive < 0) || (drive > (lastdrive -1)) || (drive > NDEVS)) { *spc = -1; return; @@ -226,7 +229,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) if (Drive < 'A' || Drive > 'Z') return PARSE_RET_BADDRIVE; Drive -= ('A' - 1); - if (Drive > lastdrive) + if (Drive > (lastdrive -1)) return PARSE_RET_BADDRIVE; else lpFcb->fcb_drive = Drive; @@ -650,7 +653,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = - (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; @@ -786,7 +789,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = - (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; @@ -800,7 +803,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) return TRUE; } fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { + if ((FcbDrive < 0) || (FcbDrive > (lastdrive -1))) { return DE_INVLDDRV; } if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { @@ -846,7 +849,7 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { + if ((FcbDrive < 0) || (FcbDrive > (lastdrive -1))) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[FcbDrive]; @@ -1123,8 +1126,19 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) } MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); + lpFcb->fcb_dirclst = Dmatch.dm_cluster; lpFcb->fcb_diroff = Dmatch.dm_entry; +/* + This is undocumented and seen using Pcwatch. + The First byte is the current directory count and the second seems + to be the attribute byte. + */ +#if 0 + lpFcb->fcb_cublock = Dmatch.dm_entry; + lpFcb->fcb_cublock *= 0x100; + lpFcb->fcb_cublock += wAttr; +#endif dta = lpPsp->ps_dta; return TRUE; } @@ -1159,6 +1173,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); upFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_diroff; Dmatch.dm_cluster = lpFcb->fcb_dirclst; @@ -1166,6 +1181,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) if (dos_findnext() != SUCCESS) { dta = lpPsp->ps_dta; + CritErrCode = 0x12; return FALSE; } @@ -1173,6 +1189,11 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) lpFcb->fcb_dirclst = Dmatch.dm_cluster; lpFcb->fcb_diroff = Dmatch.dm_entry; dta = lpPsp->ps_dta; +#if 0 + lpFcb->fcb_cublock = Dmatch.dm_entry; + lpFcb->fcb_cublock *= 0x100; + lpFcb->fcb_cublock += wAttr; +#endif return TRUE; } #endif diff --git a/kernel/globals.h b/kernel/globals.h index b38af57..7f4126d 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -419,7 +422,9 @@ extern BYTE NetDelay, NetRetry; extern UWORD - first_mcb; /* Start of user memory */ + first_mcb, /* Start of user memory */ + UMB_top, + uppermem_root; /* Start of umb chain ? */ extern struct dpb FAR *DPBp; /* First drive Parameter Block */ extern sfttbl @@ -441,7 +446,8 @@ extern WORD nprotfcb; /* number of protected fcbs */ extern BYTE nblkdev, /* number of block devices */ - lastdrive; /* value of last drive */ + lastdrive, /* value of last drive */ + uppermem_link; /* UMB Link flag */ extern struct dhdr nul_dev; extern BYTE @@ -452,9 +458,15 @@ extern BYTE OpenMode, /* File Open Attributes */ SAttr, /* Attrib Mask for Dir Search */ dosidle_flag, + Server_Call, + CritErrLocus, + CritErrAction, + CritErrClass, njoined; /* number of joined devices */ extern UWORD Int21AX; +extern COUNT CritErrCode; +extern BYTE FAR * CritErrDev; extern struct dirent SearchDir; @@ -545,9 +557,9 @@ extern BYTE return_code; /* " " " */ extern BYTE + BootDrive, /* Drive we came up from */ scr_pos; /* screen position for bs, ht, etc */ extern WORD - BootDrive, /* Drive we came up from */ NumFloppies; /* How many floppies we have */ extern keyboard @@ -639,7 +651,7 @@ VOID FAR CharMapSrvc(VOID); VOID FAR set_stack(VOID); VOID FAR restore_stack(VOID); #ifndef IN_INIT_MOD -VOID execrh(request FAR *, struct dhdr FAR *); +WORD execrh(request FAR *, struct dhdr FAR *); #endif VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); @@ -659,7 +671,7 @@ VOID putdirent(struct dirent FAR *, BYTE FAR *); VOID FAR CharMapSrvc(); VOID FAR set_stack(); VOID FAR restore_stack(); -VOID execrh(); +WORD execrh(); VOID exit(); /*VOID INRPT FAR handle_break(); */ VOID tmark(); diff --git a/kernel/int2f.asm b/kernel/int2f.asm index e2a1a82..273d553 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2000/06/21 18:16:46 jimtabor +; Add UMB code, patch, and code fixes +; ; Revision 1.4 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -108,9 +111,27 @@ Int2f3: iret ; Default, interrupt return ; +;return dos data seg. +IntDosCal: + cmp al,03 + jne IntDosCal_1 + push ax + mov ax, seg _nul_dev + mov ds,ax + pop ax + clc + jmp FarTabRetn +; +;Set FastOpen but does nothing. +IntDosCal_1: + cmp al,02ah + jne IntDosCal_2 + clc + jmp FarTabRetn +; ; added by James Tabor For Zip Drives ;Return Null Device Pointer -IntDosCal: +IntDosCal_2: cmp al,02ch jne Int2f2 mov ax,_nul_dev @@ -157,6 +178,7 @@ int2f_r_1: jnc short int2f_skip1 jmp int2f_rfner int2f_skip1: + xor ax,ax les di,[bp+18] ; do return data stuff mov [es:di],cx jmp short int2f_rfner @@ -170,6 +192,7 @@ int2f_r_2: mov [es:di+2],bx mov [es:di+4],cx mov [es:di+6],dx + xor ax,ax jmp short int2f_rfner int2f_r_3: cmp al,0fh ; Get Remote File Attrib @@ -183,7 +206,7 @@ int2f_r_3: mov [es:di+4],bx ; high mov [es:di+6],cx mov [es:di+8],dx - mov ax,0000h + xor ax,ax jmp short int2f_rfner int2f_r_4: cmp al,01eh @@ -214,8 +237,8 @@ int2f_r_7: ; everything else goes through here. ; call int2f_call - jc int2f_rfner - xor ax,ax + jc int2f_rfner + xor ax,ax int2f_rfner: pop bx pop cx @@ -242,9 +265,9 @@ _QRemote_Fn les di,[bp+8] stc int 2fh - mov ax,0xffff - jnc QRemote_Fn_out - xor ax,ax + mov ax,0xffff + jnc QRemote_Fn_out + xor ax,ax QRemote_Fn_out: pop di pop si diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 933ccbb..3bf0bc4 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.7 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -335,6 +338,7 @@ dispatch: error_exit: r->AX = -rc; error_out: + CritErrCode = r->AX; /* Maybe set */ r->FLAGS |= FLG_CARRY; break; @@ -504,23 +508,19 @@ dispatch: case 0x14: { - COUNT nErrorCode; - - if (FcbRead(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbRead(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } case 0x15: { - COUNT nErrorCode; - - if (FcbWrite(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbWrite(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } @@ -596,12 +596,13 @@ dispatch: /* Get default DPB */ case 0x1f: - if (default_drive <= lastdrive) + if (default_drive <= (lastdrive -1)) { struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; if (dpb == 0) { r->AL = 0xff; + CritErrCode = 0x0f; break; } @@ -609,31 +610,29 @@ dispatch: r->BX = FP_OFF(dpb); r->AL = 0; } - else + else{ r->AL = 0xff; + CritErrCode = 0x0f; + } break; /* Random read using FCB */ case 0x21: { - COUNT nErrorCode; - - if (FcbRandomRead(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbRandomRead(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } /* Random write using FCB */ case 0x22: { - COUNT nErrorCode; - - if (FcbRandomWrite(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbRandomWrite(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } @@ -671,24 +670,20 @@ dispatch: /* Read random record(s) using FCB */ case 0x27: { - COUNT nErrorCode; - - if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &nErrorCode)) + if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } /* Write random record(s) using FCB */ case 0x28: { - COUNT nErrorCode; - - if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &nErrorCode)) + if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } @@ -782,20 +777,24 @@ dispatch: /* Get DPB */ case 0x32: r->DL = ( r->DL == 0 ? default_drive : r->DL - 1); - if (r->DL <= lastdrive) + if (r->DL <= (lastdrive - 1)) { struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; if (dpb == 0) { r->AL = 0xff; + CritErrCode = 0x0f; break; } r->DS = FP_SEG(dpb); r->BX = FP_OFF(dpb); r->AL = 0; } - else + else { r->AL = 0xFF; + CritErrCode = 0x0f; + + } break; /* Get InDOS flag */ @@ -943,8 +942,8 @@ dispatch: if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } else { @@ -958,8 +957,8 @@ dispatch: rc = DosWrite(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1); if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } else { @@ -973,8 +972,8 @@ dispatch: rc = DosDelete((BYTE FAR *) MK_FP(r->DS, r->DX)); if (rc < 0) { - r->FLAGS |= FLG_CARRY; r->AX = -rc; + goto error_out; } else r->FLAGS &= ~FLG_CARRY; @@ -1026,13 +1025,10 @@ dispatch: if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } - else - { - if((r->AL == 0x02) || (r->AL == 0x03) || (r->AL == 0x04) || (r->AL == 0x05)) - r->AX = r->CX; + else{ r->FLAGS &= ~FLG_CARRY; } } @@ -1198,8 +1194,7 @@ dispatch: if (r->AX == 2) r->AX = 18; - - r->FLAGS |= FLG_CARRY; + goto error_out; } else { @@ -1282,15 +1277,25 @@ dispatch: break; case 0x01: - if (((COUNT) r->BX) < 0 || r->BX > 2) +/* if (((COUNT) r->BX) < 0 || r->BX > 2) goto error_invalid; else - { + { */ + mem_access_mode = r->BX; r->FLAGS &= ~FLG_CARRY; - } + +/* }*/ break; + case 0x02: + r->AL = uppermem_link; + break; + + case 0x03: + uppermem_link = r->BL; + break; + default: goto error_invalid; #ifdef DEBUG @@ -1301,6 +1306,17 @@ dispatch: } break; + /* Get Extended Error */ + case 0x59: + r->AX = CritErrCode; + r->ES = FP_SEG(CritErrDev); + r->DI = FP_OFF(CritErrDev); + r->CH = CritErrLocus; + r->BH = CritErrClass; + r->BL = CritErrAction; + r->FLAGS &= ~FLG_CARRY; + break; + /* Create Temporary File */ case 0x5a: if ((rc = DosMkTmp(MK_FP(r->DS, r->DX), r->CX)) < 0) @@ -1318,7 +1334,7 @@ dispatch: { DosClose(rc); r->AX = 80; - r->FLAGS |= FLG_CARRY; + goto error_out; } else { @@ -1367,7 +1383,7 @@ dispatch: result = int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); r->AX = result; if (result != SUCCESS) { - r->FLAGS |= FLG_CARRY; + goto error_out; } else { r->FLAGS &= ~FLG_CARRY; } @@ -1395,7 +1411,7 @@ dispatch: result = int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); r->AX = result; if (result != SUCCESS) { - r->FLAGS |= FLG_CARRY; + goto error_out; } else { r->FLAGS &= ~FLG_CARRY; } @@ -1408,13 +1424,13 @@ dispatch: switch (r->AL) { case 0x07: - if (r->DL <= lastdrive) { + if (r->DL <= (lastdrive -1)) { CDSp->cds_table[r->DL].cdsFlags |= 0x100; } break; case 0x08: - if (r->DL <= lastdrive) { + if (r->DL <= (lastdrive -1)) { CDSp->cds_table[r->DL].cdsFlags &= ~0x100; } break; @@ -1425,7 +1441,7 @@ dispatch: result = int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); r->AX = result; if (result != SUCCESS) { - r->FLAGS |= FLG_CARRY; + goto error_out; } else { r->FLAGS &= ~FLG_CARRY; } @@ -1563,7 +1579,7 @@ dispatch: /* Get/Set Serial Number */ case 0x69: rc = ( r->BL == 0 ? default_drive : r->BL - 1); - if (rc <= lastdrive) + if (rc <= (lastdrive -1)) { if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) { goto error_invalid; @@ -1583,8 +1599,8 @@ dispatch: } if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } else { @@ -1771,7 +1787,7 @@ VOID int25_handler(struct int25regs FAR * r) buf = MK_FP(r->ds, r->bx); } - if (drv >= nblkdev) + if (drv >= (lastdrive - 1)) { r->ax = 0x202; r->flags |= FLG_CARRY; @@ -1814,7 +1830,7 @@ VOID int26_handler(struct int25regs FAR * r) buf = MK_FP(r->ds, r->bx); } - if (drv >= nblkdev) + if (drv >= (lastdrive -1)) { r->ax = 0x202; r->flags |= FLG_CARRY; diff --git a/kernel/io.asm b/kernel/io.asm index 67940c9..1adff0f 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.6 2000/06/21 18:16:46 jimtabor +; Add UMB code, patch, and code fixes +; ; Revision 1.5 2000/06/01 06:37:38 jimtabor ; Read History for Changes ; @@ -559,8 +562,8 @@ blk_entry: pop cx pop cx les bx,[cs:_ReqPktPtr] ; now return completion code - mov word [es:bx+status],ax ; mark operation complete - cli ; no interrupts + mov word [es:bx+status],ax ; mark operation complete + cli ; no interrupts mov sp,[blk_dos_stk] ; use dos stack mov ss,[blk_dos_seg] pop es diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 4c354ec..e53998b 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -117,7 +120,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) struct dpb FAR *dpbp; struct cds FAR *cdsp; BYTE FAR *pBuffer = MK_FP(r->DS, r->DX); - COUNT nMode; + COUNT nMode , dev; /* Test that the handle is valid */ switch (r->AL) @@ -159,17 +162,16 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* JPP - changed to use default drive if drive=0 */ /* JT Fixed it */ - r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); + dev = ( r->BL == 0 ? default_drive : r->BL - 1); - - if (r->BL > lastdrive) + if (dev > (lastdrive -1)) { *err = DE_INVLDDRV; return 0; } else { - cdsp = &CDSp->cds_table[r->BL]; + cdsp = &CDSp->cds_table[dev]; dpbp = cdsp->cdsDpb; } break; @@ -191,10 +193,10 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) { case 0x00: /* Get the flags from the SFT */ - r->DX = r->AX = s->sft_flags; - -/* r->DX = r->AX = s->sft_dev->dh_attr;*/ - + r->AX = s->sft_dev->dh_attr; + r->DH = r->AH; +/* Undocumented result, Ax = Dx seen using Pcwatch */ + r->DL = r->AL = s->sft_flags; break; case 0x01: @@ -238,12 +240,23 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) execrh((request FAR *) & CharReqHdr, s->sft_dev); if (CharReqHdr.r_status & S_ERROR) - return char_error(&CharReqHdr, s->sft_dev); + { + *err = DE_DEVICE; + return 0; + } if (r->AL == 0x07) { - r->AL = - CharReqHdr.r_status & S_BUSY ? - 00 : 0xff; + r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; + + } + if (r->AL == 0x02 || r->AL == 0x03) + { + r->AX = CharReqHdr.r_count; + } + + if (r->AL == 0x0c || r->AL == 0x10) + { + r->AX = CharReqHdr.r_status; } break; } @@ -262,6 +275,11 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x05: nMode = C_IOCTLOUT; IoBlockCommon: + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) @@ -271,7 +289,8 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) return 0; } - CharReqHdr.r_unit = r->BL; + + CharReqHdr.r_unit = dev; CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; CharReqHdr.r_count = r->CX; @@ -279,24 +298,28 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) CharReqHdr.r_status = 0; execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); - if (r->AL == 0x08) - { + if (CharReqHdr.r_status & S_ERROR) { - *err = DE_DEVICE; - return 0; + *err = DE_DEVICE; + return 0; } - r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; - } - else - { - if (CharReqHdr.r_status & S_ERROR) + if (r->AL == 0x08) { - *err = DE_DEVICE; - return 0; + r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; + } - } - break; + + if (r->AL == 0x04 || r->AL == 0x05) + { + r->AX = CharReqHdr.r_count; + + } + if (r->AL == 0x0d || r->AL == 0x11) + { + r->AX = CharReqHdr.r_status; + } + break; case 0x06: if (s->sft_flags & SFT_FDEVICE) @@ -310,12 +333,18 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x07: if (s->sft_flags & SFT_FDEVICE) { + nMode = C_OSTAT; goto IoCharCommon; } r->AL = 0; break; case 0x08: + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) { nMode = C_REMMEDIA; @@ -326,13 +355,26 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x09: if(cdsp->cdsFlags & CDSNETWDRV) - r->DX = ATTR_REMOTE; - else - r->DX = dpbp->dpb_device->dh_attr; + { + r->DX = ATTR_REMOTE ; + r->AX = S_DONE|S_BUSY; + } + else + { + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } +/* Need to add subst bit 15 */ + r->DX = dpbp->dpb_device->dh_attr; + r->AX = S_DONE|S_BUSY; + } break; case 0x0a: - r->DX = s->sft_flags & SFT_FSHARED; + r->DX = s->sft_flags; + r->AX = 0; break; case 0x0e: @@ -341,12 +383,16 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x0f: nMode = C_SETLDEV; IoLogCommon: + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) { - if (r->BL == 0) - r->BL = default_drive; - CharReqHdr.r_unit = r->BL; + + CharReqHdr.r_unit = dev; CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; CharReqHdr.r_count = r->CX; @@ -358,7 +404,10 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) if (CharReqHdr.r_status & S_ERROR) *err = DE_ACCESS; else - *err = SUCCESS; + { + r->AL = CharReqHdr.r_unit; + *err = SUCCESS; + } return 0; } *err = DE_INVLDFUNC; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 055c8ea..63eec19 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2000/06/21 18:16:46 jimtabor +; Add UMB code, patch, and code fixes +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -178,7 +181,7 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from mov ax,ds mov es,ax - jmp _main + jmp _main segment INIT_TEXT_END init_end: @@ -291,7 +294,7 @@ setverPtr dw 0,0 ; 0037 setver list dw 1 ; 003F number of buffers dw 1 ; 0041 size of pre-read buffer global _BootDrive -_BootDrive dw 0 ; 0043 drive we booted from +_BootDrive db 0 ; 0043 drive we booted from db 0 ; 0044 cpu type (1 if >=386) dw 0 ; 0045 Extended memory in KBytes buf_info dd 0 ; 0047 disk buffer chain @@ -301,14 +304,17 @@ buf_info dd 0 ; 0047 disk buffer chain db 0 ; 0053 00=conv 01=HMA dw 0 ; 0054 deblock buf in conv deblock_seg dw 0 ; 0056 (offset always zero) - times 3 db 0 ; 0058 unknown + times 3 db 0 ; 0058 unknown dw 0 ; 005B unknown db 0, 0FFh, 0 ; 005D unknown db 0 ; 0060 unknown dw 0 ; 0061 unknown -dmd_upper_link db 0 ; 0063 upper memory link flag - dw 0 ; 0064 unknown -dmd_upper_root dw 0FFFFh ; 0066 dmd_upper_root + global _uppermem_link +_uppermem_link db 0 ; 0063 upper memory link flag + global _UMB_top +_UMB_top dw 0 ; 0064 unknown UMB_top will do for now + global _uppermem_root +_uppermem_root dw 0FFFFh ; 0066 dmd_upper_root dw 0 ; 0068 para of last mem search SysVarEnd: @@ -471,15 +477,12 @@ _SAttr db 0 ;24D - Attribute Mask for Dir Search global _OpenMode _OpenMode db 0 ;24E - File Open Attribute -; times 3 db 0 -; global _Server_Call -;_Server_Call db 0 ;252 - Server call Func 5D sub 0 - - - ; Pad to 0570h - times (250h - ($ - _internal_data)) db 0 + times 3 db 0 + global _Server_Call +_Server_Call db 0 ;252 - Server call Func 5D sub 0 + db 0 global _lpUserStack -_lpUserStack dd 0 ;250 - pointer to user stack frame +_lpUserStack dd 0 ;254 - pointer to user stack frame ; Pad to 057Ch times (25ch - ($ - _internal_data)) db 0 diff --git a/kernel/main.c b/kernel/main.c index 573b3c2..c23bc6d 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,6 +39,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -147,6 +150,8 @@ static BYTE *mainRcsId = "$Id$"; extern UWORD DaysSinceEpoch; extern WORD days[2][13]; +extern BYTE FAR * lpBase; +extern BYTE FAR * upBase; INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); VOID FAR init_call_WritePCClock(ULONG); @@ -189,6 +194,8 @@ INIT static VOID init_kernel(void) /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); + UMB_top = 3; /* testing for now* + /* Fake int 21h stack frame */ user_r = (iregs FAR *) DOS_PSP + 0xD0; @@ -359,7 +366,7 @@ INIT VOID FsConfig(VOID) default_drive = BootDrive - 1; /* Initialzie the current directory structures */ - for (i = 0; i < lastdrive + 1; i++) + for (i = 0; i < lastdrive ; i++) { fbcopy((VOID FAR *) "A:\\\0", @@ -427,14 +434,13 @@ INIT static VOID kernel() p_0(); } -extern BYTE FAR *lpBase; - /* If cmdLine is NULL, this is an internal driver */ -BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) +BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_top) { request rq; - ULONG memtop = ((ULONG) ram_top) << 10; + + ULONG memtop = ((ULONG) r_top) << 10; ULONG maxmem = memtop - ((ULONG) FP_SEG(dhp) << 4); if (maxmem >= 0x10000) @@ -455,10 +461,14 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) if (rq.r_status & S_ERROR) return TRUE; - if (cmdLine) - lpBase = rq.r_endaddr; + if(cmdLine){ + if (mode) + upBase = rq.r_endaddr; + else + lpBase = rq.r_endaddr; + } - /* check for a block device and update device control block */ +/* check for a block device and update device control block */ if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { REG COUNT Index; @@ -497,9 +507,9 @@ INIT static void InitIO(void) /* Initialize driver chain */ nul_dev.dh_next = (struct dhdr FAR *)&con_dev; setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - init_device((struct dhdr FAR *)&con_dev, NULL); - init_device((struct dhdr FAR *)&clk_dev, NULL); - init_device((struct dhdr FAR *)&blk_dev, NULL); + init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); + init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top); + init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { diff --git a/kernel/memmgr.c b/kernel/memmgr.c index f5b2664..f80e8dc 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -107,10 +110,10 @@ VOID show_chain(); #define para2far(seg) (mcb FAR *)MK_FP((seg) , 0) /* - * Join any following unused MCBs to MCB 'p'. - * Return: - * SUCCESS: on success - * else: error number <> + * Join any following unused MCBs to MCB 'p'. + * Return: + * SUCCESS: on success + * else: error number <> */ static COUNT joinMCBs(mcb FAR * p) { @@ -142,7 +145,7 @@ seg long2para(LONG size) } /* - * Add a displacement to a far pointer and return the result normalized. + * Add a displacement to a far pointer and return the result normalized. */ VOID FAR *add_far(VOID FAR * fp, ULONG off) { @@ -152,7 +155,7 @@ VOID FAR *add_far(VOID FAR * fp, ULONG off) } /* - * Return a normalized far pointer + * Return a normalized far pointer */ VOID FAR *adjust_far(VOID FAR * fp) { @@ -297,12 +300,12 @@ COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FA } /* - * Unlike the name and the original prototype could suggest, this function - * is used to return the _size_ of the largest available block rather than - * the block itself. + * Unlike the name and the original prototype could suggest, this function + * is used to return the _size_ of the largest available block rather than + * the block itself. * - * Known bug: a memory area with a size of the data area of 0 (zero) is - * not considered a "largest" block. <> + * Known bug: a memory area with a size of the data area of 0 (zero) is + * not considered a "largest" block. <> */ COUNT DosMemLargest(UWORD FAR * size) { @@ -345,9 +348,9 @@ COUNT DosMemLargest(UWORD FAR * size) } /* - * Deallocate a memory block. para is the segment of the MCB itself - * This function can be called with para == 0, which eases other parts - * of the kernel. + * Deallocate a memory block. para is the segment of the MCB itself + * This function can be called with para == 0, which eases other parts + * of the kernel. */ COUNT DosMemFree(UWORD para) { @@ -400,12 +403,12 @@ COUNT DosMemFree(UWORD para) } /* - * Resize an allocated memory block. - * para is the segment of the data portion of the block rather than - * the segment of the MCB itself. + * Resize an allocated memory block. + * para is the segment of the data portion of the block rather than + * the segment of the MCB itself. * - * If the block shall grow, it is resized to the maximal size less than - * or equal to size. This is the way MS DOS is reported to work. + * If the block shall grow, it is resized to the maximal size less than + * or equal to size. This is the way MS DOS is reported to work. */ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) { @@ -461,7 +464,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) } /* - * Check the MCB chain for allocation corruption + * Check the MCB chain for allocation corruption */ COUNT DosMemCheck(void) { diff --git a/kernel/network.c b/kernel/network.c index 6bfaa09..3a433e9 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -112,7 +115,7 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e /* */ -COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp ) +COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) { COUNT i, x; char FAR *p, *q; @@ -142,7 +145,7 @@ COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dm dta = (BYTE FAR *) &TempBuffer; i = int2f_Remote_call(func, 0, 0, 0, test, 0, 0); dta = p; - fsncopy((BYTE FAR *) &TempBuffer[0], &dta[0], 21); + fsncopy((BYTE FAR *) &TempBuffer, dta, 21); if (i != 0) return i; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 2454359..c5e2bd7 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.6 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -214,7 +217,7 @@ COUNT get_verify_drive(char FAR *src) } else drive = default_drive; - if ((drive < 0) || (drive > lastdrive)) { + if ((drive < 0) || (drive > (lastdrive - 1))) { drive = DE_INVLDDRV; } return drive; @@ -248,7 +251,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] > lastdrive + 'A') + if (buf[0] > (lastdrive - 1) + 'A') return DE_PATHNOTFND; src += 2; diff --git a/kernel/proto.h b/kernel/proto.h index c5b9193..cb3b9fd 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -186,6 +189,7 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); INIT COUNT tolower(COUNT c); INIT COUNT toupper(COUNT c); INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID umcb_init(mcb FAR * mcbp, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); /* dosfns.c */ @@ -354,7 +358,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); /* main.c */ INIT VOID main(void); -INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine); +INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); /* memmgr.c */ seg far2para(VOID FAR * p); @@ -459,7 +463,7 @@ COUNT QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); -COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp); +COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp);