diff --git a/docs/history.txt b/docs/history.txt index a1551be..ce1d18f 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -308,11 +308,13 @@ (the last 2 changes needed to fix bugs discovered by Michael Devore) - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF + * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino * country.asm / country.sys support now replaces hard-coded data - * 8 countries added to country.asm: GR, RO, AT, KR, TR, IN, M.East, IL - * dyninit.c: unused function DynFree() commented out + * 11 countries added to country.asm: GR,RO,AT,MA,SG,KR,CN,TR,IN,M.E,IL + * dosnames.c: macro to function conversion, optimisation and clean-up + * dyninit.c: excluded unused DynFree(), "what" passed only on DEBUG * fatfs.c: - zero creation/access stamp on directory entry write as MS-DOS 7.10 - prevent removal or renaming of the current directory of that drive @@ -323,6 +325,7 @@ - if no floppy drives present, don't initialise DDT for drive A: - " - Initdisk" no longer shifts text if no FAT partitions found - converted cdiv() from macro to function; optimise and clean-up + * inithma: InstallVDISK() function inlined, optimised and cleaned up * intr.asm: lseek() added (necessary for COUNTRY.SYS processing) * ioctl.c: - r_si/r_di contents added as documented in PC-DOS Technical Update diff --git a/kernel/break.c b/kernel/break.c index 7ad2963..a8d3218 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -53,7 +53,7 @@ unsigned char ctrl_break_pressed(void) unsigned char check_handle_break(struct dhdr FAR **pdev) { - unsigned char c; + unsigned char c = 0; if (ctrl_break_pressed() || (c = (unsigned char)ndread(&syscon)) == CTL_C || *pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C) @@ -76,7 +76,7 @@ unsigned char check_handle_break(struct dhdr FAR **pdev) void handle_break(struct dhdr FAR **pdev, int sft_out) { - char *buf = "^C\r\n"; + static char *buf = "^C\r\n"; CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ con_flush(pdev); diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 0d53d6a..c474d7d 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -39,30 +39,10 @@ static BYTE *dosnamesRcsId = const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; -#define PathSep(c) ((c)=='/'||(c)=='\\') -#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) -#define DirChar(c) (((unsigned char)(c)) >= ' ' && \ - !strchr(_DirWildNameChars+5, (c))) -#define WildChar(c) (((unsigned char)(c)) >= ' ' && \ - !strchr(_DirWildNameChars+2, (c))) -#define NameChar(c) (((unsigned char)(c)) >= ' ' && \ - !strchr(_DirWildNameChars, (c))) - -VOID XlateLcase(BYTE * szFname, COUNT nChars); -VOID DosTrimPath(BYTE * lpszPathNamep); - -/* Should be converted to a portable version after v1.0 is released. */ -#if 0 -VOID XlateLcase(BYTE * szFname, COUNT nChars) +STATIC BOOL charOK(const char *s, const char c) { - while (nChars--) - { - if (*szFname >= 'a' && *szFname <= 'z') - *szFname -= ('a' - 'A'); - ++szFname; - } + return (UBYTE)c >= ' ' && !strchr(s, c); } -#endif /* MSD durring an FindFirst search string looks like this; @@ -89,18 +69,15 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) lpszLclDir = lpszLclFile = filename; filename += 2; - while (DirChar(*filename)) - { - if (*filename == '\\') - lpszLclFile = filename + 1; - ++filename; - } + while (charOK(_DirWildNameChars + 5, *filename)) + if (*filename++ == '\\') + lpszLclFile = filename; nDirCnt = lpszLclFile - lpszLclDir; /* Parse out the file name portion. */ filename = lpszLclFile; - while (bAllowWildcards ? WildChar(*filename) : - NameChar(*filename)) + while (charOK(bAllowWildcards ? _DirWildNameChars + 2 + : _DirWildNameChars, *filename)) { ++nFileCnt; ++filename; @@ -108,12 +85,11 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) if (nFileCnt == 0) { - int err = DE_PATHNOTFND; if (bAllowWildcards && *filename == '\0' && (nDirCnt == 3 || filename[-1] != '\\')) /* D:\ or D:\DOS but not D:\DOS\ */ - err = DE_NFILES; - return err; + return DE_NFILES; + return DE_PATHNOTFND; } /* Now we have pointers set to the directory portion and the */ @@ -124,8 +100,8 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) lpszLclExt = ++filename; while (*filename) { - if (bAllowWildcards ? WildChar(*filename) : - NameChar(*filename)) + if (charOK(bAllowWildcards ? _DirWildNameChars + 2 + : _DirWildNameChars, *filename)) { ++nExtCnt; ++filename; diff --git a/kernel/dyndata.h b/kernel/dyndata.h index e980a2c..ff474bf 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -9,7 +9,13 @@ moveable and Dyn.Buffer resizable, but not before */ +#ifdef DEBUG void far *DynAlloc(char *what, unsigned num, unsigned size); +#else +void far *_DynAlloc(unsigned num, unsigned size); +#define DynAlloc(what, num, size) (_DynAlloc((num), (size))) +#endif + void far *DynLast(void); void DynFree(void *ptr); diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 575998e..9350072 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -54,16 +54,16 @@ extern struct DynS DOSFAR ASM Dyn; extern struct DynS FAR ASM Dyn; #endif +#ifdef DEBUG void far *DynAlloc(char *what, unsigned num, unsigned size) +#else +void far *_DynAlloc(unsigned num, unsigned size) +#endif { void far *now; unsigned total = num * size; struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); -#ifndef DEBUG - UNREFERENCED_PARAMETER(what); -#endif - if ((ULONG) total + Dynp->Allocated > 0xffff) { printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated); diff --git a/kernel/inithma.c b/kernel/inithma.c index 0c68f50..952d5e2 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -224,12 +224,33 @@ int MoveKernelToHMA() DosLoadedInHMA = TRUE; } - /* - on finalize, will install a VDISK - */ + now protect against HIMEM/FDXMS/... by simulating a VDISK + FDXMS should detect us and not give HMA access to ohers + unfortunately this also disables HIMEM completely - InstallVDISK(); + so: we install this after all drivers have been loaded + */ + { + static struct { /* Boot sector of a RAM-Disk */ + UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ + char Name[5]; + BYTE dummy2[3]; + WORD BpS; + BYTE dummy3[6]; + WORD Sectors; + BYTE dummy4; + } VDISK_BOOT_SECTOR = { + {0xcf,' ',' '}, + {"VDISK"}, + {" "}, 512, + {"FDOS "}, 128, /* 128 * 512 = 64K */ + ' ' + }; + fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SECTOR, + sizeof(VDISK_BOOT_SECTOR)); + *(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64; + } /* report the fact we are running high through int 21, ax=3306 */ LoL->version_flags |= 0x10; @@ -238,43 +259,6 @@ int MoveKernelToHMA() } -/* - now protect against HIMEM/FDXMS/... by simulating a VDISK - FDXMS should detect us and not give HMA access to ohers - unfortunately this also disables HIMEM completely - - so: we install this after all drivers have been loaded -*/ -STATIC void InstallVDISK(void) -{ - static struct { /* Boot-Sektor of a RAM-Disk */ - UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ - char Name[5]; - BYTE dummy2[3]; - WORD BpS; - BYTE dummy3[6]; - WORD Sektoren; - BYTE dummy4; - } VDISK_BOOT_SEKTOR = { - { - 0xcf, ' ', ' '}, - { - 'V', 'D', 'I', 'S', 'K'}, - { - ' ', ' ', ' '}, 512, - { - 'F', 'D', 'O', 'S', ' ', ' '}, 128, /* 128*512 = 64K */ - ' '}; - - if (!DosLoadedInHMA) - return; - - fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SEKTOR, - sizeof(VDISK_BOOT_SEKTOR)); - - *(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64; -} - /* this allocates some bytes from the HMA area only available if DOS=HIGH was successful @@ -368,7 +352,8 @@ void MoveKernel(unsigned NewKernelSegment) FP_OFF(_HMARelocationTableStart)) / sizeof(struct RelocationTable)); int3(); - goto errorReturn; + for (;;) + ; } } @@ -402,9 +387,5 @@ void MoveKernel(unsigned NewKernelSegment) } CurrentKernelSegment = NewKernelSegment; - return; - -errorReturn: - for (;;) ; } diff --git a/kernel/prf.c b/kernel/prf.c index eb06e5c..338d3da 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -118,7 +118,7 @@ void put_console(int c) } #endif /* DOSEMU */ -#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) +#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) || defined(TEST) #ifndef FORSYS /* copied from bcc (Bruce's C compiler) stdarg.h */ @@ -264,6 +264,7 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) { long n; ULONG u; + BOOL minus = FALSE; BYTE *t = s + sizeof(s) - 1; if (flags & LONGARG) @@ -280,13 +281,16 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) { base = -base; if (n < 0) + { u = -n; + minus++; + } } *t = '\0'; /* terminate the number string */ do /* generate digits in reverse order */ - *--t = "0123456789ABCDEF"[(UWORD)u % base]; + *--t = "0123456789ABCDEF"[(UWORD)(u % base)]; while ((u /= base) > 0); - if (n < 0) + if (minus) *--t = '-'; p = t; } @@ -380,12 +384,12 @@ void put_string(const char *s) compile like (note -DTEST !) - c:\tc\tcc -DTEST -DI86 -Ihdr kernel\prf.c + c:\tc\tcc -DTEST -Ihdr kernel\prf.c - and run. If strings are wrong, the program will wait for ENTER + and run. If strings are wrong, the program will wait for a key */ -#include +#include #include struct { @@ -470,8 +474,8 @@ void test(char *should, char *format, unsigned lowint, unsigned highint) if (strcmp(b, should)) { - printf("\nhit ENTER\n"); - getchar(); + printf("\nhit a key\n"); + getch(); } }