From f22376eec8bee10d4f9a53af424f1c98c46376d4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 19 Mar 2001 04:50:56 +0000 Subject: [PATCH] See history.txt for overview: put kernel 2022beo1 into CVS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@164 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 9 + docs/history.txt | 16 ++ hdr/portab.h | 10 +- kernel/config.c | 56 +++--- kernel/dsk.c | 213 +++++++++++++---------- kernel/fatdir.c | 10 +- kernel/fatfs.c | 9 +- kernel/inthndlr.c | 13 +- kernel/kernel.asm | 8 +- kernel/kernel.mak | 9 +- kernel/memmgr.c | 62 ++++--- kernel/nls/001-437.hc | 4 +- kernel/nls/049-850.hc | 4 +- kernel/nls_hc.asm | 4 +- kernel/nlssupt.asm | 11 +- kernel/prf.c | 387 ++++++++++++++++++++---------------------- kernel/task.c | 45 ++++- lib/libm.mak | 16 +- 18 files changed, 524 insertions(+), 362 deletions(-) diff --git a/config.m b/config.m index 840eb45..5f11ece 100644 --- a/config.m +++ b/config.m @@ -20,6 +20,8 @@ NASM=nasm #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include +#MATH_EXTRACT=*LDIV *LLSH *LURSH *LXMUL *LRSH *SPUSH *SCOPY +#MATH_INSERT=+LDIV +LLSH +LURSH +LXMUL +LRSH +SPUSH +SCOPY # Use these for Turbo C 3.0 @@ -31,6 +33,8 @@ NASM=nasm #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include +#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY +#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY # Use these for Borland C++ @@ -42,12 +46,17 @@ NASM=nasm #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include +#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY +#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY # # $Id$ # # $Log$ +# Revision 1.4 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# # Revision 1.3 2000/05/25 20:56:19 jimtabor # Fixed project history # diff --git a/docs/history.txt b/docs/history.txt index eb49936..270f5fa 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,19 @@ +2001 Mar 08 - Build 2022 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes MCB chain corruption fix (thanks Tom Ehlert and Martin Stromberg) + Redirector fixes (CDROMs and DOSEmu lredir'ed drives appear to work fine now) + UMB fixes + Various recodings (dsk.c, prf.c, portab.h) to make kernel + object footprint 3k smaller (Tom Ehlert) + Fix handling of very long path names (Tom Ehlert) + FindFirst/FindNext fixes (Tom Ehlert) + Configuration for libm.mak is in config.mak (Martin Stromberg) + NLS fix to include pointer to CharMapSrvc. Note: these are + changes to automatically generated .asm files, but the + generator (GRAB_UNF.EXE) is missing. (thanks Tom Ehlert) + DosSelectDrv fix (Martin Stromberg) + config.c always converts to upper case and handles dos=umb correctly + 2000 Dec 15 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) + Fixes Added Patches from Bart Oldeman (Bart.Oldeman@bristol.ac.uk) diff --git a/hdr/portab.h b/hdr/portab.h index 08f2783..c948574 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,12 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.5 2001/03/08 21:15:00 bartoldeman + * Fixes for MK_FP and friends from Tom Ehlert; reduces kernel by 1.5k. + * * Revision 1.4 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -201,8 +207,8 @@ typedef signed long LONG; /* General far pointer macros */ #ifdef I86 #ifndef MK_FP -#define MK_FP(seg,ofs) ((VOID far *)(((LONG)(seg)<<16)|(UWORD)(ofs))) -#define FP_SEG(fp) ((UWORD)((LONG)(VOID FAR *)(fp)>>16)) +#define MK_FP(seg,ofs) ((VOID far *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) +#define FP_SEG(fp) ((UWORD)((ULONG)(VOID FAR *)(fp)>>16)) #define FP_OFF(fp) ((UWORD)(fp)) #endif #endif diff --git a/kernel/config.c b/kernel/config.c index c3cdb28..38df5da 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,12 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.9 2001/03/08 21:15:00 bartoldeman + * Fixed handling of "DOS=UMB", use toupper instead of tolower consistently. + * * Revision 1.8 2000/08/07 22:51:34 jimtabor * Remove unused code * @@ -206,23 +212,23 @@ struct table static struct table commands[] = { - {"break", 1, Break}, - {"buffers", 1, Buffers}, - {"command", 1, InitPgm}, - {"country", 1, Country}, - {"device", 2, Device}, - {"devicehigh", 2, DeviceHigh}, - {"dos", 2, Dosmem}, - {"fcbs", 1, Fcbs}, - {"files", 1, Files}, - {"lastdrive", 1, Lastdrive}, + {"BREAK", 1, Break}, + {"BUFFERS", 1, Buffers}, + {"COMMAND", 1, InitPgm}, + {"COUNTRY", 1, Country}, + {"DEVICE", 2, Device}, + {"DEVICEHIGH", 2, DeviceHigh}, + {"DOS", 2, Dosmem}, + {"FCBS", 1, Fcbs}, + {"FILES", 1, Files}, + {"LASTDRIVE", 1, Lastdrive}, /* rem is never executed by locking out pass */ - {"rem", 0, CfgFailure}, - {"shell", 1, InitPgm}, - {"stacks", 1, Stacks}, - {"switchar", 1, Switchar}, - {"screen", 1, sysScreenMode}, /* JPP */ - {"version", 1, sysVersion}, /* JPP */ + {"REM", 0, CfgFailure}, + {"SHELL", 1, InitPgm}, + {"STACKS", 1, Stacks}, + {"SWITCHAR", 1, Switchar}, + {"SCREEN", 1, sysScreenMode}, /* JPP */ + {"VERSION", 1, sysVersion}, /* JPP */ /* default action */ {"", -1, CfgFailure} }; @@ -403,8 +409,8 @@ INIT VOID configDone(VOID) if(UmbState == 1) { - mumcb_init((mcb FAR *) (MK_FP(0x9fff, 0)), - umb_start - 0x9fff - 1); + mumcb_init((mcb FAR *) (MK_FP(64*ram_top - 1, 0)), + umb_start - 64*ram_top); /* Check if any devices were loaded in umb */ if(umb_start != FP_SEG(upBase) ){ /* make last block normal with SC for the devices */ @@ -535,9 +541,9 @@ INIT VOID DoConfig(VOID) /* Skip leading white space and get verb. */ pLine = scan(pLine, szBuf); - /* Translate the verb to lower case ... */ + /* Translate the verb to upper case ... */ for (pTmp = szBuf; *pTmp != '\0'; pTmp++) - *pTmp = tolower(*pTmp); + *pTmp = toupper(*pTmp); /* If the line was blank, skip it. Otherwise, look up */ /* the verb and execute the appropriate function. */ @@ -715,11 +721,15 @@ INIT static VOID Lastdrive(BYTE * pLine) INIT static VOID Dosmem(BYTE * pLine) { + BYTE *pTmp; + if(UmbState == 0){ uppermem_link = 0; uppermem_root = 0; GetStringArg(pLine, szBuf); - UmbState = strcmp(szBuf, "UMB") ? 2 : 0; + for (pTmp = szBuf; *pTmp != '\0'; pTmp++) + *pTmp = toupper(*pTmp); + UmbState = strcmp(szBuf, "UMB") ? 0 : 2; } } @@ -861,7 +871,7 @@ INIT static VOID DeviceHigh(BYTE * pLine) } else { - printf("UMB's unavalable!\n"); + printf("UMB's unavailable!\n"); LoadDevice(pLine, ram_top, FALSE); } } @@ -1037,6 +1047,7 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) } /* Yet another change for true portability (WDL) */ +#if 0 INIT COUNT tolower(COUNT c) { if (c >= 'A' && c <= 'Z') @@ -1044,6 +1055,7 @@ INIT COUNT tolower(COUNT c) else return c; } +#endif /* Yet another change for true portability (PJV) */ INIT COUNT toupper(COUNT c) diff --git a/kernel/dsk.c b/kernel/dsk.c index 9a5b3d3..e6e6952 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,12 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.9 2001/03/08 21:15:00 bartoldeman + * Space saving fixes from Tom Ehlert + * * Revision 1.8 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -181,6 +187,10 @@ static struct FS_info fsarray[NDEV]; static bpb bpbarray[NDEV]; /* BIOS parameter blocks */ static bpb *bpbptrs[NDEV]; /* pointers to bpbs */ +/*TE - array access functions */ +struct media_info *getPMiarray(int dev) { return &miarray[dev];} + bpb *getPBpbarray(unsigned dev){ return &bpbarray[dev];} + #define N_PART 4 /* number of partitions per table partition */ @@ -226,7 +236,7 @@ WORD init(rqptr), blk_noerr(rqptr), blk_nondr(rqptr), blk_error(rqptr); -COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); +COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr); WORD dskerr(COUNT); COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); #else @@ -311,7 +321,8 @@ COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, LONG peStartSector; LONG peSectors; } - temp_part[N_PART]; + temp_part[N_PART], + *ptemp_part; /*TE*/ REG retry = N_RETRY; UBYTE packed_byte, @@ -363,49 +374,52 @@ COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, array and process extended partitions */ for (Part = 0; Part < N_PART && nUnits < NDEV; Part++) { - if (temp_part[Part].peFileSystem == FAT12 || - temp_part[Part].peFileSystem == FAT16SMALL || - temp_part[Part].peFileSystem == FAT16LARGE) +/*TE*/ + ptemp_part = &temp_part[Part]; + + if (ptemp_part->peFileSystem == FAT12 || + ptemp_part->peFileSystem == FAT16SMALL || + ptemp_part->peFileSystem == FAT16LARGE) { miarray[nUnits].mi_offset = - temp_part[Part].peStartSector + ptAccuOff; + ptemp_part->peStartSector + ptAccuOff; miarray[nUnits].mi_drive = ptDrive; miarray[nUnits].mi_partidx = nPartitions; nUnits++; dos_partition[nPartitions].peDrive = ptDrive; dos_partition[nPartitions].peBootable = - temp_part[Part].peBootable; + ptemp_part->peBootable; dos_partition[nPartitions].peBeginHead = - temp_part[Part].peBeginHead; + ptemp_part->peBeginHead; dos_partition[nPartitions].peBeginSector = - temp_part[Part].peBeginSector; + ptemp_part->peBeginSector; dos_partition[nPartitions].peBeginCylinder = - temp_part[Part].peBeginCylinder; + ptemp_part->peBeginCylinder; dos_partition[nPartitions].peFileSystem = - temp_part[Part].peFileSystem; + ptemp_part->peFileSystem; dos_partition[nPartitions].peEndHead = - temp_part[Part].peEndHead; + ptemp_part->peEndHead; dos_partition[nPartitions].peEndSector = - temp_part[Part].peEndSector; + ptemp_part->peEndSector; dos_partition[nPartitions].peEndCylinder = - temp_part[Part].peEndCylinder; + ptemp_part->peEndCylinder; dos_partition[nPartitions].peStartSector = - temp_part[Part].peStartSector; + ptemp_part->peStartSector; dos_partition[nPartitions].peSectors = - temp_part[Part].peSectors; + ptemp_part->peSectors; dos_partition[nPartitions].peAbsStart = - temp_part[Part].peStartSector + ptAccuOff; + ptemp_part->peStartSector + ptAccuOff; nPartitions++; } - else if (temp_part[Part].peFileSystem == EXTENDED) + else if (ptemp_part->peFileSystem == EXTENDED) { /* call again to process extended part table */ processtable(ptDrive, - temp_part[Part].peBeginHead, - temp_part[Part].peBeginCylinder, - temp_part[Part].peBeginSector, - temp_part[Part].peStartSector + ptAccuOff); + ptemp_part->peBeginHead, + ptemp_part->peBeginCylinder, + ptemp_part->peBeginSector, + ptemp_part->peStartSector + ptAccuOff); }; }; return TRUE; @@ -429,6 +443,9 @@ static WORD init(rqptr rp) COUNT HardDrive, nHardDisk, Unit; + struct media_info *pmiarray; + bpb *pbpbarray; + /* Reset the drives */ fl_reset(0x80); @@ -441,26 +458,31 @@ static WORD init(rqptr rp) /* Setup media info and BPBs arrays */ for (Unit = 0; Unit < NDEV; Unit++) { - miarray[Unit].mi_size = 720l; - miarray[Unit].mi_heads = 2; - miarray[Unit].mi_cyls = 40; - miarray[Unit].mi_sectors = 9; - miarray[Unit].mi_offset = 0l; - miarray[Unit].mi_drive = Unit; + pmiarray = getPMiarray(Unit); + + pmiarray->mi_size = 720l; + pmiarray->mi_heads = 2; + pmiarray->mi_cyls = 40; + pmiarray->mi_sectors = 9; + pmiarray->mi_offset = 0l; + pmiarray->mi_drive = Unit; fsarray[Unit].fs_serialno = 0x12345678; +/*TE*/ + pbpbarray = getPBpbarray(Unit); - bpbarray[Unit].bpb_nbyte = SEC_SIZE; - bpbarray[Unit].bpb_nsector = 2; - bpbarray[Unit].bpb_nreserved = 1; - bpbarray[Unit].bpb_nfat = 2; - bpbarray[Unit].bpb_ndirent = 112; - bpbarray[Unit].bpb_nsize = 720l; - bpbarray[Unit].bpb_mdesc = 0xfd; - bpbarray[Unit].bpb_nfsect = 2; - bpbptrs[Unit] = &bpbarray[Unit]; + pbpbarray->bpb_nbyte = SEC_SIZE; + pbpbarray->bpb_nsector = 2; + pbpbarray->bpb_nreserved = 1; + pbpbarray->bpb_nfat = 2; + pbpbarray->bpb_ndirent = 112; + pbpbarray->bpb_nsize = 720l; + pbpbarray->bpb_mdesc = 0xfd; + pbpbarray->bpb_nfsect = 2; + + bpbptrs[Unit] = pbpbarray; }; nHardDisk = fl_nrdrives(); @@ -596,25 +618,31 @@ static WORD bldbpb(rqptr rp) ULONG count, i; byteptr trans; WORD local_word; +/*TE*/ + bpb *pbpbarray; + struct media_info *pmiarray; ret = RWzero( rp, 0); if (ret != 0) return (dskerr(ret)); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NBYTE]), &bpbarray[rp->r_unit].bpb_nbyte); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECTOR]), &bpbarray[rp->r_unit].bpb_nsector); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NRESERVED]), &bpbarray[rp->r_unit].bpb_nreserved); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFAT]), &bpbarray[rp->r_unit].bpb_nfat); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NDIRENT]), &bpbarray[rp->r_unit].bpb_ndirent); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &bpbarray[rp->r_unit].bpb_nsize); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &bpbarray[rp->r_unit].bpb_nsize); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_MDESC]), &bpbarray[rp->r_unit].bpb_mdesc); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFSECT]), &bpbarray[rp->r_unit].bpb_nfsect); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECS]), &bpbarray[rp->r_unit].bpb_nsecs); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &bpbarray[rp->r_unit].bpb_nheads); - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &bpbarray[rp->r_unit].bpb_hidden); - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &bpbarray[rp->r_unit].bpb_huge); +/*TE ~ 200 bytes*/ + pbpbarray = getPBpbarray(rp->r_unit); + + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); /* Needs fat32 offset code */ @@ -627,40 +655,43 @@ static WORD bldbpb(rqptr rp) #ifdef DSK_DEBUG - printf("BPB_NBYTE = %04x\n", bpbarray[rp->r_unit].bpb_nbyte); - printf("BPB_NSECTOR = %02x\n", bpbarray[rp->r_unit].bpb_nsector); - printf("BPB_NRESERVED = %04x\n", bpbarray[rp->r_unit].bpb_nreserved); - printf("BPB_NFAT = %02x\n", bpbarray[rp->r_unit].bpb_nfat); - printf("BPB_NDIRENT = %04x\n", bpbarray[rp->r_unit].bpb_ndirent); - printf("BPB_NSIZE = %04x\n", bpbarray[rp->r_unit].bpb_nsize); - printf("BPB_MDESC = %02x\n", bpbarray[rp->r_unit].bpb_mdesc); - printf("BPB_NFSECT = %04x\n", bpbarray[rp->r_unit].bpb_nfsect); + printf("BPB_NBYTE = %04x\n", pbpbarray->bpb_nbyte); + printf("BPB_NSECTOR = %02x\n", pbpbarray->bpb_nsector); + printf("BPB_NRESERVED = %04x\n", pbpbarray->bpb_nreserved); + printf("BPB_NFAT = %02x\n", pbpbarray->bpb_nfat); + printf("BPB_NDIRENT = %04x\n", pbpbarray->bpb_ndirent); + printf("BPB_NSIZE = %04x\n", pbpbarray->bpb_nsize); + printf("BPB_MDESC = %02x\n", pbpbarray->bpb_mdesc); + printf("BPB_NFSECT = %04x\n", pbpbarray->bpb_nfsect); #endif - rp->r_bpptr = &bpbarray[rp->r_unit]; - count = miarray[rp->r_unit].mi_size = - bpbarray[rp->r_unit].bpb_nsize == 0 ? - bpbarray[rp->r_unit].bpb_huge : - bpbarray[rp->r_unit].bpb_nsize; - getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NHEADS])), &miarray[rp->r_unit].mi_heads); - head = miarray[rp->r_unit].mi_heads; - getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NSECS])), &miarray[rp->r_unit].mi_sectors); - if (miarray[rp->r_unit].mi_size == 0) - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &miarray[rp->r_unit].mi_size); - sector = miarray[rp->r_unit].mi_sectors; + rp->r_bpptr = pbpbarray; + + pmiarray = getPMiarray(rp->r_unit); + + count = pmiarray->mi_size = + pbpbarray->bpb_nsize == 0 ? + pbpbarray->bpb_huge : + pbpbarray->bpb_nsize; + getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NHEADS])), &pmiarray->mi_heads); + head = pmiarray->mi_heads; + getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NSECS])), &pmiarray->mi_sectors); + if (pmiarray->mi_size == 0) + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); + sector = pmiarray->mi_sectors; if (head == 0 || sector == 0) { tmark(); return failure(E_FAILURE); } - miarray[rp->r_unit].mi_cyls = count / (head * sector); + pmiarray->mi_cyls = count / (head * sector); tmark(); #ifdef DSK_DEBUG printf("BPB_NSECS = %04x\n", sector); printf("BPB_NHEADS = %04x\n", head); - printf("BPB_HIDDEN = %08lx\n", bpbarray[rp->r_unit].bpb_hidden); - printf("BPB_HUGE = %08lx\n", bpbarray[rp->r_unit].bpb_huge); + printf("BPB_HIDDEN = %08lx\n", pbpbarray->bpb_hidden); + printf("BPB_HUGE = %08lx\n", pbpbarray->bpb_huge); #endif return S_DONE; } @@ -893,29 +924,39 @@ static WORD dskerr(COUNT code) /* */ /* Do logical block number to physical head/track/sector mapping */ /* */ -static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, REG COUNT unit, COUNT count, LONG strt_sect, byteptr strt_addr) +static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, COUNT unit, COUNT count, ULONG strt_sect, byteptr strt_addr) { #ifdef I86 - ULONG ltemp; + UWORD utemp; #endif - REG ls, - ps; + REG struct media_info *pmiarray; #ifdef I86 +/*TE*/ /* Adjust for segmented architecture */ - ltemp = (((ULONG) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)) & 0xffff; + utemp = (((UWORD) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)); /* Test for 64K boundary crossing and return count large */ /* enough not to exceed the threshold. */ - count = (((ltemp + SEC_SIZE * count) & 0xffff0000l) != 0l) - ? (0xffffl - ltemp) / SEC_SIZE - : count; + +#define SEC_SHIFT 9 /* = 0x200 = 512 */ + + utemp >>= SEC_SHIFT; + + if (count > (0xffff >> SEC_SHIFT) - utemp) + { + count = (0xffff >> SEC_SHIFT) - utemp; + } + #endif - *trackp = strt_sect / (miarray[unit].mi_heads * miarray[unit].mi_sectors); - *sectorp = strt_sect % miarray[unit].mi_sectors + 1; - *headp = (strt_sect % (miarray[unit].mi_sectors * miarray[unit].mi_heads)) - / miarray[unit].mi_sectors; - if (*sectorp + count > miarray[unit].mi_sectors + 1) - count = miarray[unit].mi_sectors + 1 - *sectorp; +/*TE*/ + pmiarray = getPMiarray(unit); + + *trackp = strt_sect / (pmiarray->mi_heads * pmiarray->mi_sectors); + *sectorp = strt_sect % pmiarray->mi_sectors + 1; + *headp = (strt_sect % (pmiarray->mi_sectors * pmiarray->mi_heads)) + / pmiarray->mi_sectors; + if (*sectorp + count > pmiarray->mi_sectors + 1) + count = pmiarray->mi_sectors + 1 - *sectorp; return count; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index d005fba..f406317 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,12 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.10 2001/03/08 21:00:00 bartoldeman + * Fix handling of very long path names (Tom Ehlert) + * * Revision 1.9 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -583,7 +589,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) local_ext[FEXT_SIZE + 1], Tname[65]; - fscopy(name, (BYTE FAR *)&Tname); + fsncopy(name, (BYTE FAR *)&Tname, sizeof(Tname)); + Tname[sizeof(Tname)-1]=0; + /* printf("ff %s", Tname); */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index c3bfa72..102916a 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,12 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.9 2001/03/08 21:00:00 bartoldeman + * Disabled select_unit() since it's not used + * * Revision 1.8 2000/10/29 23:51:56 jimtabor * Adding Share Support by Ron Cemer * @@ -2300,6 +2306,7 @@ COUNT xlt_fnp(struct f_node FAR * fnp) return fnp - f_nodes; } +#if 0 struct dhdr FAR *select_unit(COUNT drive) { /* Just get the header from the dhdr array */ @@ -2308,4 +2315,4 @@ struct dhdr FAR *select_unit(COUNT drive) return (struct dhdr FAR *)CDSp->cds_table[drive].cdsDpb; } - +#endif diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 45d4867..26b34ae 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,12 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.13 2001/03/08 21:00:00 bartoldeman + * MCB chain corruption and DosFindNext fix (thanks Martin Stromberg and Tom Ehlert) + * * Revision 1.12 2000/12/16 01:38:35 jimtabor * Added patches from Bart Oldeman * @@ -1199,6 +1205,7 @@ dispatch: else { r->FLAGS &= ~FLG_CARRY; + r->AX = -SUCCESS; } } break; @@ -1305,8 +1312,10 @@ dispatch: break; case 0x03: - DosUmbLink(r->BL); - break; + if (uppermem_root) { + DosUmbLink(r->BL); + break; + } /* else fall through */ default: goto error_invalid; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9cfba57..3afcbd8 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,12 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/03/19 04:50:56 bartoldeman +; See history.txt for overview: put kernel 2022beo1 into CVS +; +; Revision 1.6 2001/03/08 21:15:00 bartoldeman +; uppermem_root initialised to 0 (no UMBs). +; ; Revision 1.5 2000/08/06 05:50:17 jimtabor ; Add new files and update cvs with patches and changes ; @@ -318,7 +324,7 @@ _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 +_uppermem_root dw 0 ; 0066 dmd_upper_root global _umb_start _umb_start dw 0 ; 0068 para of last mem search SysVarEnd: diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 10988f6..59dc98d 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.5 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# # Revision 1.4 2000/08/06 05:50:17 jimtabor # Add new files and update cvs with patches and changes # @@ -209,7 +212,7 @@ clean: # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 kernel.exe: $(EXE_dependencies) $(LIBS) - del kernel.lib + $(RM) kernel.lib $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs $(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl +nls_hc @@ -218,9 +221,9 @@ kernel.exe: $(EXE_dependencies) $(LIBS) $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break $(LIBUTIL) kernel +dosidle - del kernel.bak + $(RM) kernel.bak $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); - del kernel.lib + $(RM) kernel.lib # *Individual File Dependencies* kernel.obj: kernel.asm segs.inc diff --git a/kernel/memmgr.c b/kernel/memmgr.c index cd1116d..710e706 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,12 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.8 2001/03/08 21:00:00 bartoldeman + * UMB and MCB chain corruption (thanks Martin Stromberg) fixes + * * Revision 1.7 2000/08/07 04:53:54 jimtabor * Cleanup code * @@ -191,18 +197,19 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) REG mcb FAR *p; mcb FAR *foundSeg; mcb FAR *biggestSeg; - /* Initialize */ + +searchAgain: + p = para2far(first_mcb); biggestSeg = foundSeg = NULL; /* Hack to the Umb Region direct for now. Save time and program space. */ - if((mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link) { - if(uppermem_root) + if((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && + uppermem_link && uppermem_root) p = para2far(uppermem_root); - } /* Search through memory blocks */ FOREVER @@ -265,6 +272,11 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ + if((mode != LARGEST) && (mode & FIRST_FIT_UO) && + uppermem_link && uppermem_root) { + mode &= !FIRST_FIT_UO; + goto searchAgain; + } if (asize) *asize = biggestSeg ? biggestSeg->m_size : 0; return DE_NOMEM; @@ -337,7 +349,9 @@ COUNT DosMemLargest(UWORD FAR * size) COUNT found; /* Initialize */ - p = para2far(first_mcb); + p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root) + ? para2far(uppermem_root) + : para2far(first_mcb); /* Cycle through the whole MCB chain to find the largest unused area. Join all unused areas together. */ @@ -611,29 +625,28 @@ VOID DosUmbLink(BYTE n) { REG mcb FAR *p; REG mcb FAR *q; + mcb FAR *end_of_conv_mem = para2far(ram_top*64-1); - if(uppermem_root){ - - q = p = para2far(first_mcb); + q = p = para2far(first_mcb); /* like a xor thing! */ - if((uppermem_link == 1) && (n == 0)) + if((uppermem_link == 1) && (n == 0)) + { + while ( p != end_of_conv_mem ) { - while ( p != (mcb FAR *) para2far(0x9fff) ) - { - if (mcbFree(p)) - joinMCBs(p); - if (!mcbValid(p)) - goto DUL_exit; - q = p; - p = nxtMCB(p); - } - - if(q->m_type == MCB_NORMAL) - q->m_type = MCB_LAST; - uppermem_link = n; - + if (mcbFree(p)) + joinMCBs(p); + if (!mcbValid(p)) + goto DUL_exit; + q = p; + p = nxtMCB(p); } - else + + if(q->m_type == MCB_NORMAL) + q->m_type = MCB_LAST; + uppermem_link = n; + + } + else if((uppermem_link == 0) && (n == 1)) { while( q->m_type != MCB_LAST) @@ -647,7 +660,6 @@ VOID DosUmbLink(BYTE n) q->m_type = MCB_NORMAL; uppermem_link = n; } - } DUL_exit: return; } diff --git a/kernel/nls/001-437.hc b/kernel/nls/001-437.hc index 087c9e7..c963ee4 100644 --- a/kernel/nls/001-437.hc +++ b/kernel/nls/001-437.hc @@ -30,7 +30,9 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h - DB 0e8h, 058h, 000h, 000h, 02ch, 000h +extern _CharMapSrvc:wrt TGROUP + DW _CharMapSrvc, SEG _CharMapSrvc + DB 02ch, 000h GLOBAL _hcTablesStart _hcTablesStart: GLOBAL _nlsFUpcaseHardcoded diff --git a/kernel/nls/049-850.hc b/kernel/nls/049-850.hc index aa4a6f9..4f0204a 100644 --- a/kernel/nls/049-850.hc +++ b/kernel/nls/049-850.hc @@ -30,7 +30,9 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 031h, 000h, 052h, 003h, 001h, 000h DB 044h, 04dh, 000h, 000h, 000h, 02eh, 000h, 02ch DB 000h, 02eh, 000h, 03ah, 000h, 003h, 002h, 001h - DB 0e8h, 058h, 000h, 003h, 03bh, 000h +extern _CharMapSrvc:wrt TGROUP + DW _CharMapSrvc, SEG _CharMapSrvc + DB 03bh, 000h GLOBAL _hcTablesStart _hcTablesStart: GLOBAL _nlsFUpcaseHardcoded diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index 087c9e7..c963ee4 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -30,7 +30,9 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h - DB 0e8h, 058h, 000h, 000h, 02ch, 000h +extern _CharMapSrvc:wrt TGROUP + DW _CharMapSrvc, SEG _CharMapSrvc + DB 02ch, 000h GLOBAL _hcTablesStart _hcTablesStart: GLOBAL _nlsFUpcaseHardcoded diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index b188c98..c348b3c 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,6 +29,13 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/03/19 04:50:56 bartoldeman +; See history.txt for overview: put kernel 2022beo1 into CVS +; +; +; Revision 1.5 2001/03/08 21:15:00 bartoldeman +; Fixed typo in dosUpChar (Tom Ehlert) +; ; Revision 1.4 2000/08/06 05:50:17 jimtabor ; Add new files and update cvs with patches and changes ; @@ -82,7 +89,7 @@ segment _TEXT global _CharMapSrvc - extern _upChar:wrt TGROUP + extern _DosUpChar:wrt TGROUP ; ; CharMapSrvc: ; User callable character mapping service. @@ -102,7 +109,7 @@ _CharMapSrvc: mov ax, DGROUP mov ds, ax - call _upChar + call _DosUpChar ;add sp, byte 2 // next POP retrieves orig AX pop bx diff --git a/kernel/prf.c b/kernel/prf.c index 919ebf2..e0bca67 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,6 +34,16 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.4 2001/03/07 10:00:00 tomehlert + * recoded for smaller object footprint, added main() for testing+QA + * + * $Log$ + * Revision 1.4 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -85,13 +95,11 @@ static BYTE *charp; VOID handle_char(COUNT); VOID put_console(COUNT); BYTE *ltob(LONG, BYTE *, COUNT); -static BYTE *itob(COUNT, BYTE *, COUNT); COUNT do_printf(CONST BYTE *, REG BYTE **); #else VOID handle_char(); VOID put_console(); BYTE *ltob(); -static BYTE *itob(); COUNT do_printf(); #endif @@ -122,35 +130,32 @@ static VOID } /* ltob -- convert an long integer to a string in any base (2-16) */ -static BYTE * +BYTE * ltob(LONG n, BYTE * s, COUNT base) { ULONG u; - REG BYTE *p, - *q; - REG negative, - c; + BYTE *p, *q; + int c; - if (n < 0 && base == -10) - { - negative = 1; - u = -n; - } - else - { - negative = 0; u = n; - } + if (base == -10) /* signals signed conversion */ + { base = 10; + if (n < 0 ) + { + u = -n; + *s++ = '-'; + } + } + p = q = s; do { /* generate digits in reverse order */ *p++ = "0123456789abcdef"[u % base]; } while ((u /= base) > 0); - if (negative) - *p++ = '-'; + *p = '\0'; /* terminate the string */ while (q < --p) { /* reverse the digits */ @@ -161,49 +166,9 @@ static BYTE * return s; } -/* itob -- convert an long integer to a string in any base (2-16) */ -static BYTE * - itob(COUNT n, BYTE * s, COUNT base) -{ - UWORD u; - REG BYTE *p, - *q; - REG negative, - c; - if (n < 0 && base == -10) - { - negative = 1; - u = -n; - } - else - { - negative = 0; - u = n; - } - if (base == -10) /* signals signed conversion */ - base = 10; - p = q = s; - do - { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[u % base]; - } - while ((u /= base) > 0); - if (negative) - *p++ = '-'; - *p = '\0'; /* terminate the string */ - while (q < --p) - { /* reverse the digits */ - c = *q; - *q++ = *p; - *p = c; - } - return s; -} - -#define NONE 0 -#define LEFT 1 -#define RIGHT 2 +#define LEFT 0 +#define RIGHT 1 /* printf -- short version of printf to conserve space */ WORD FAR @@ -214,7 +179,7 @@ WORD FAR } WORD -sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args) +sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args,...) { WORD ret; @@ -224,194 +189,214 @@ sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args) return ret; } -static COUNT - do_printf(CONST BYTE * fmt, REG BYTE ** arg) +COUNT + do_printf(CONST BYTE * fmt, BYTE ** arg) { - REG base; + int base; BYTE s[11], *p, *ltob(); - BYTE c, - slen, + int c, flag, size, fill; + int longarg; + long currentArg; - flag = NONE; - size = 0; while ((c = *fmt++) != '\0') { - if (size == 0 && flag == NONE && c != '%') + if (c != '%') { handle_char(c); continue; } - if (flag == NONE && *fmt == '0') + + longarg = FALSE; + size = 0; + flag = RIGHT; + fill = ' '; + + if ( *fmt == '-') + { + flag = LEFT; + fmt++; + } + + if ( *fmt == '0') { - flag = RIGHT; fill = '0'; + fmt++; } - switch (*fmt) + + while (*fmt >= '0' && *fmt <= '9') + { + size = size * 10 + (*fmt++ - '0'); + } + + + + if (*fmt == 'l') { - case '-': - flag = RIGHT; - fill = *(fmt + 1) == '0' ? '0' : ' '; - continue; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (flag == NONE) - flag = LEFT; - size = *fmt++ - '0'; - while ((c = *fmt++) != '\0') - { - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - size = size * 10 + (c - '0'); - continue; - - default: - --fmt; - break; - } - break; - } - break; + longarg = TRUE; + fmt++; } + + switch (c = *fmt++) { + case '\0': + return 0; + case 'c': - handle_char(*(COUNT *) arg++); - continue; + handle_char(*(COUNT *) arg++); + continue; + + case 's': + p = *((BYTE **) arg)++; + goto do_outputstring; case 'd': - base = -10; - goto prt; - - case 'o': - base = 8; - goto prt; - - case 'u': - base = 10; - goto prt; - - case 'x': - base = 16; - - prt: - itob(*((COUNT *) arg)++, s, base); - if (flag == RIGHT || flag == LEFT) - { - for (slen = 0, p = s; *p != '\0'; p++) - ++slen; - } - if (flag == RIGHT && slen < size) - { - WORD i; - - for (i = size - slen; i > 0; i--) - handle_char(fill); - } - for (p = s; *p != '\0'; p++) - handle_char(*p); - if (flag == LEFT) - { - WORD i; - BYTE sp = ' '; - - for (i = size - slen; i > 0; i--) - handle_char(sp); - } - size = 0; - flag = NONE; - continue; - - case 'l': - switch (c = *fmt++) - { - case 'd': base = -10; goto lprt; - case 'o': + case 'o': base = 8; goto lprt; - case 'u': + case 'u': base = 10; goto lprt; - case 'x': + case 'x': base = 16; lprt: - ltob(*((LONG *) arg)++, s, base); - if (flag == RIGHT || flag == LEFT) - { - for (slen = 0, p = s; *p != '\0'; p++) - ++slen; - } - if (flag == RIGHT && slen < size) - { - WORD i; + if (longarg) + currentArg = *((LONG *) arg)++; + else + if (base < 0) currentArg = *((int*) arg)++; + else currentArg = *((unsigned int*) arg)++; + + + ltob(currentArg, s, base); - for (i = size - slen; i > 0; i--) + p = s; +do_outputstring: + + size -= strlen(p); + + if (flag == RIGHT ) + { + for ( ; size > 0; size--) handle_char(fill); } - for (p = s; *p != '\0'; p++) + for (; *p != '\0'; p++) handle_char(*p); - if (flag == LEFT) - { - WORD i; - BYTE sp = ' '; - for (i = size - slen; i > 0; i--) - handle_char(sp); - } - size = 0; - flag = NONE; + for ( ; size > 0; size--) + handle_char(fill); + continue; default: handle_char(c); - } + break; - case 's': - for (p = *arg; *p != '\0'; p++) - { - --size; - handle_char(*p); - } - for (; size > 0; size--) - handle_char(' '); - ++arg; - size = 0; - flag = NONE; - continue; - default: - handle_char(c); - continue; } } return 0; } + + +#ifdef TEST +/* + this testprogram verifies that the strings are printed correctly + ( or the way, I expect them to print) + + compile like (note -DTEST !) + + c:\tc\tcc -DTEST -DI86 -I..\hdr prf.c + + and run. if strings are wrong, the program will wait for the ANYKEY + +*/ +#include +void cso(char c) { putch(c); } + + +struct { + char *should; + char *format; + unsigned lowint; + unsigned highint; + +} testarray[] = + { + { "hello world", "%s %s", (unsigned)"hello",(unsigned)"world"}, + { "hello", "%3s", (unsigned)"hello",0}, + { " hello", "%7s", (unsigned)"hello",0}, + { "hello ", "%-7s", (unsigned)"hello",0}, + { "hello", "%s", (unsigned)"hello",0}, + + + + { "1", "%d", 1, 0}, + { "-1", "%d", -1,0}, + { "65535", "%u", -1,0}, + { "-32768", "%d", 0x8000,0}, + { "32767", "%d", 0x7fff,0}, + { "-32767", "%d", 0x8001,0}, + + {"8000", "%x", 0x8000, 0}, + {" 1", "%4x", 1, 0}, + {"0001", "%04x", 1, 0}, + {"1 ", "%-4x", 1, 0}, + {"1000", "%-04x", 1, 0}, + + { "1", "%ld", 1, 0}, + { "-1", "%ld", -1,-1}, + { "65535", "%ld", -1,0}, + { "65535", "%u", -1,0}, + {"8000", "%lx", 0x8000, 0}, + {"80000000", "%lx", 0,0x8000}, + {" 1", "%4lx", 1, 0}, + {"0001", "%04lx", 1, 0}, + {"1 ", "%-4lx", 1, 0}, + {"1000", "%-04lx", 1, 0}, + + { "-2147483648", "%ld", 0,0x8000}, + { "2147483648", "%lu", 0,0x8000}, + { "2147483649", "%lu", 1,0x8000}, + { "-2147483647", "%ld", 1,0x8000}, + { "32767", "%ld", 0x7fff,0}, + { "32769", "%ld", 0x8001,0}, + + + + 0 + }; + +test(char *should, char *format, unsigned lowint, unsigned highint) +{ + char b[100]; + + sprintf(b, format, lowint,highint); + + printf("'%s' = '%s'\n", should, b); + + if (strcmp(b,should)) { printf("\nhit the ANYKEY\n"); getch(); } +} + + +main() +{ + int i; + printf("hello world\n"); + + for (i = 0; testarray[i].should; i++) + { + test(testarray[i].should,testarray[i].format, testarray[i].lowint, testarray[i].highint); + } +} +#endif diff --git a/kernel/task.c b/kernel/task.c index 447e238..1f6ca26 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,12 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.6 2001/03/08 21:00:00 bartoldeman + * UMB fixes to DosComLoader + * * Revision 1.5 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -246,7 +252,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* allocate enough space for env + path */ if ((RetCode = DosMemAlloc(long2para(nEnvSize + ENV_KEEPFREE), - FIRST_FIT, (seg FAR *) pChildEnvSeg, + mem_access_mode, (seg FAR *) pChildEnvSeg, NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) return RetCode; pDest = MK_FP(*pChildEnvSeg + 1, 0); @@ -457,12 +463,39 @@ static COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { return rc; } - /* Allocate our memory and pass back any errors */ - if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem, (UWORD FAR *) & asize)) < 0) + /* Now find out how many paragraphs are available */ + if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) { - DosMemFree(env); /* env may be 0 */ + DosMemFree(env); return rc; } + com_size = asize; + /* Allocate our memory and pass back any errors */ + if ((rc = DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem + ,(UWORD FAR *) & asize)) < 0) + { + if (rc == DE_NOMEM) + { + if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem + ,(UWORD FAR *) & asize)) < 0) + { + DosMemFree(env); + return rc; + } + /* This should never happen, but ... */ + if (asize < com_size) + { + DosMemFree(mem); + DosMemFree(env); + return rc; + } + } + else + { + DosMemFree(env); /* env may be 0 */ + return rc; + } + } ++mem; } else @@ -675,7 +708,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* Allocate our memory and pass back any errors */ /* We can still get an error on first fit if the above */ /* returned size was a bet fit case */ - if ((rc = DosMemAlloc((seg) exe_size, FIRST_FIT, (seg FAR *) & mem + if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode, (seg FAR *) & mem ,(UWORD FAR *) & asize)) < 0) { if (rc == DE_NOMEM) @@ -686,7 +719,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) DosMemFree(env); return rc; } - /* This should never happen, but ... */ + /* This should never happen, but ... */ if (asize < exe_size) { DosMemFree(mem); diff --git a/lib/libm.mak b/lib/libm.mak index 5576317..d97d8d6 100644 --- a/lib/libm.mak +++ b/lib/libm.mak @@ -5,6 +5,12 @@ # # $Log$ +# Revision 1.4 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# +# Revision 1.4 2001/03/08 21:15:00 bartoldeman +# Fix from Martin Stromberg to make this fully configurable from config.mak +# # Revision 1.3 2000/05/25 20:56:22 jimtabor # Fixed project history # @@ -32,13 +38,9 @@ libm.lib: $(CLIB) -# use these for Turbo 2 - $(LIBUTIL) $(CLIB) *LDIV *LLSH *LURSH *LXMUL *LRSH *SPUSH *SCOPY - $(LIBUTIL) libm +LDIV +LLSH +LURSH +LXMUL +LRSH +SPUSH +SCOPY -# use these for Turbo 3 or better -# $(LIBUTIL) $(CLIB) *H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY -# $(LIBUTIL) libm +H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY - del *.OBJ + $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) + $(LIBUTIL) libm $(MATH_INSERT) + $(RM) *.OBJ clobber: clean