diff --git a/docs/build.txt b/docs/build.txt index 3de6f96..e7700fd 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -27,10 +27,24 @@ ftp://ftp.kernel.org/pub/software/devel/nasm or a mirror of ftp.kernel.org. -This program will now compile with Turbo C 2.01 (now freely +This kernel will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with other Borland compilers, Microsoft C and Watcom C. +The Watcom C 11.0c beta compiler for DOS can now be downloaded at +www.openwatcom.org: you need at least the following zips from +ftp://ftp.openwatcom.org/watcom/zips/ + +core_all - Core binaries (All hosts) +clib_hdr - C runtime library header files +clib_a16 - C runtime libraries (16-bit all targets) +clib_d16 - C runtime libraries (16-bit DOS) +core_binw - Core binaries (DOS host) +c_binw - C compiler (DOS host) + +Replace binw by binnt for an NT host or binp for an OS/2 host. +The host needs to be a 386+ with at least 8MB of memory. + If you feel hardy, read on to understand the directory structure. A more complete description of the build environment is contained in a companion book, "The FreeDOS Kernel" (ISBN: 0-87930-436-7) published diff --git a/docs/history.txt b/docs/history.txt index d3c2bc1..9530274 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,9 +1,24 @@ -2002 Feb xx - Build 2026test +2002 Feb 9 - Build 2026 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom - * FCB clean-ups and fixes (CYRUS CHESS, bug #1014) + * fixed various typos, #includes ++ Changes Bart + * fixed ECHO in config.sys + * made passing parameters to command.com more robust: + zero commandline before use, fixed buffer overflow for F5+F8 + * "uppermem_root" in the List of Lists is now FFFF if no UMBs + available, as documented in RBIL + * removed all direct hooks from init_text to hma_text; duplicated + the remaining functions (memset, memcpy and friends). + * bumped up default DOS version of FAT32 enabled kernel to 7.10 +2002 Feb 3 - Build 2026test +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * FCB clean-ups and fixes (bug in FCB Random IO, + CYRUS CHESS, bug #1014) * initial config.sys menus (see config.txt) - * execrh + * execrh.asm: construct 'interrupt' address after strategy to avoid + some issues with non-trivial 'strategy' routines. * make kernel UPX-able * cleaned up midnight flag, dates * tmark() and friends are floppy specific and implemented in C @@ -11,7 +26,7 @@ * DMA boundary checking gives the right number of sectors if the start sector is 512-bytes-aligned. + Changes Victor - * lfn fixes + * lfn fixes (lfn is only a place holder, does not work yet) * FAT32 fixes * dosemu log nicer + Changes Martin diff --git a/docs/sys.txt b/docs/sys.txt index 1782b0b..d7e15b5 100644 --- a/docs/sys.txt +++ b/docs/sys.txt @@ -134,7 +134,7 @@ file (CONFIG.SYS) processing). A 0 means you must have pressed the key precisely for when the kernel checks for it - essentially skipping, though a well timed finger will still get to use it. And any value -greater than 0 I belive is the seconds the kernel will +greater than 0 is the number of seconds the kernel will display the prompt and wait for you to press the key before assuming you didn't. @@ -143,7 +143,7 @@ FORCELBA=0 or FORCELBA=1 If 1 then the kernel will use LBA (extended INT13) techniques to address all partitions if possible, even if these have a non-LBA partition type and -are completely below cylinder 1023 (usually the 8MB +are completely below cylinder 1023 (usually the 8GB boundary). This is 0 by default, for compatibility reasons. Setting this to 1 may bypass some buggy BIOSes and gives slightly better performance. diff --git a/hdr/version.h b/hdr/version.h index e63510e..fc08849 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -33,10 +33,14 @@ static BYTE *date_hRcsId = #endif #endif -/* This Kernel is at a min Dos Ver. 5.00 */ - +/* This Kernel is at a min Dos Ver. 5.00 or 7.10 with FAT32 support */ +#ifdef WITHFAT32 +#define MAJOR_RELEASE 7 +#define MINOR_RELEASE 10 +#else #define MAJOR_RELEASE 5 #define MINOR_RELEASE 00 +#endif #define REV_NUMBER 0 #define OEM_ID 0xfd /* FreeDos version */ @@ -45,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 26 #define BUILD "2026" -#define SUB_BUILD "test" -#define KERNEL_VERSION_STRING "1.1.26test" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2026test" /*#BUILD SUB_BUILD */ +#define SUB_BUILD "" +#define KERNEL_VERSION_STRING "1.1.26" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2026" /*#BUILD SUB_BUILD */ diff --git a/kernel/config.c b/kernel/config.c index f05ccce..7556830 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -591,7 +591,7 @@ VOID DoConfig(int pass) if (pEntry->pass >= 0 && pEntry->pass != nPass) continue; - if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ + if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ { (*(pEntry->func)) (pLine); continue; @@ -602,9 +602,10 @@ VOID DoConfig(int pass) continue; } - pLine = skipwh(pLine); + if (pEntry->func != CfgMenu) + pLine = skipwh(pLine); - if ('=' != *pLine) + if ('=' != *pLine && pEntry->func != CfgMenu) CfgFailure(pLine); else /* YES. DO IT */ (*(pEntry->func)) (skipwh(pLine + 1)); @@ -948,7 +949,7 @@ STATIC VOID Dosmem(BYTE * pLine) if (UmbState == 0) { uppermem_link = 0; - uppermem_root = 0; + uppermem_root = 0xffff; UmbState = UMBwanted ? 2 : 0; } /* Check if HMA is available straight away */ diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 42868a2..d3e79ef 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -42,7 +42,9 @@ segment HMA_TEXT ; The stack is very critical in here. ; global _execrh -_execrh: + global _init_execrh + +%macro EXECRH 0 push bp ; perform c entry mov bp,sp push si @@ -67,6 +69,15 @@ _execrh: pop si pop bp ret +%endmacro + +_execrh: + EXECRH + +segment INIT_TEXT + +_init_execrh: + EXECRH ; Log: execrh.asm,v ; Revision 1.3 2000/03/09 06:07:11 kernel diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 8312106..82d94d5 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -31,21 +31,16 @@ extern struct _KernelConfig InitKernelConfig; */ #define printf init_printf #define sprintf init_sprintf -#define execrh reloc_call_execrh -#define fmemcpy reloc_call_fmemcpy -#define fmemset reloc_call_fmemset -#define memset reloc_call_memset -#define fstrncpy reloc_call_fstrncpy -#define strcpy reloc_call_strcpy -#define strlen reloc_call_strlen +#define execrh init_execrh +#define fmemcpy init_fmemcpy +#define fmemset init_fmemset +#define memset init_memset +#define strcpy init_strcpy WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); -VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); -void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); -VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); -VOID ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); -COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); -COUNT ASMCFUNC strlen(REG BYTE * s); +void fmemcpy(void far *d, const void far *s, unsigned n); +void fmemset(void far *s, int ch, unsigned n); +void memset(void *s, int ch, unsigned n); +void strcpy(char *dest, const char *src); #undef LINESIZE #define LINESIZE KBD_MAXLENGTH @@ -56,7 +51,6 @@ int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) -#define fbcopy(s, d, n) fmemcpy(d,s,n) #define GLOBAL extern #define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ #define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ diff --git a/kernel/inithma.c b/kernel/inithma.c index d906122..3f5d9a8 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -460,42 +460,6 @@ void MoveKernel(unsigned NewKernelSegment) } } - { - struct initRelocationTable { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct initRelocationTable - ASM _HMAinitRelocationTableStart[], ASM _HMAinitRelocationTableEnd[]; - struct initRelocationTable *rp; - - /* verify, that all entries are valid */ - - for (rp = _HMAinitRelocationTableStart; - rp < _HMAinitRelocationTableEnd; rp++) - { - if (rp->callNear != 0xe8 || /* call NEAR */ - rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ - 0) - { - printf("illegal init relocation entry # %d\n", - rp - _HMAinitRelocationTableStart); - goto errorReturn; - } - } - - /* OK, all valid, go to relocate */ - - for (rp = _HMAinitRelocationTableStart; - rp < _HMAinitRelocationTableEnd; rp++) - { - rp->jmpSegment = NewKernelSegment; - } - } CurrentKernelSegment = NewKernelSegment; return; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 73744bc..882968f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1119,7 +1119,7 @@ dispatch: break; case 0x03: - if (uppermem_root) /* always error if not exists */ + if (uppermem_root != 0xffff) /* always error if not exists */ { DosUmbLink(r->BL); break; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index f46f87c..02969eb 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -343,7 +343,7 @@ _uppermem_link db 0 ; 0063 upper memory link flag _min_pars dw 0 ; 0064 minimum paragraphs of memory ; required by program being EXECed global _uppermem_root -_uppermem_root dw 0 ; 0066 dmd_upper_root (usually 9fff) +_uppermem_root dw 0ffffh ; 0066 dmd_upper_root (usually 9fff) _last_para dw 0 ; 0068 para of last mem search SysVarEnd: @@ -623,8 +623,6 @@ segment IB_E __ib_end: ;; do not clear the other init BSS variables + STACK: too late. - retoff resw 1 ; return offset to jump to from HMA_TEXT - ; kernel startup stack global init_tos resw 512 @@ -708,10 +706,6 @@ __U4D: LDIVMODU %endif -init_ret_np: push ds - push word [retoff] - retf ; return from init_calls. - ;End of HMA segment segment HMA_TEXT_END global __HMATextEnd @@ -748,70 +742,6 @@ _DGROUP_: dw DGROUP -segment INIT_TEXT - - call far initforceEnableA20 ; first enable A20 or not -manip_stack_A20: - pop dx ; get last ret address - pop word [retoff] ; get near ret address of init caller - mov ax, init_ret_np ; new init caller ret address - push ax - jmp dx ; and back to the relocation entry - - global __HMAinitRelocationTableStart -__HMAinitRelocationTableStart: - - extern _execrh - global _reloc_call_execrh -_reloc_call_execrh: - call manip_stack_A20 - jmp far _execrh - - extern _fmemcpy - global _reloc_call_fmemcpy -_reloc_call_fmemcpy: - call manip_stack_A20 - jmp far _fmemcpy - - extern _strcpy - global _reloc_call_strcpy -_reloc_call_strcpy: - call manip_stack_A20 - jmp far _strcpy - - extern _fstrncpy - global _reloc_call_fstrncpy -_reloc_call_fstrncpy: - call manip_stack_A20 - jmp far _fstrncpy - - extern _strlen - global _reloc_call_strlen -_reloc_call_strlen: - call manip_stack_A20 - jmp far _strlen - - extern _fstrlen - global _reloc_call_fstrlen -_reloc_call_fstrlen: - call manip_stack_A20 - jmp far _fstrlen - - extern _fmemset - global _reloc_call_fmemset -_reloc_call_fmemset: - call manip_stack_A20 - jmp far _fmemset - - extern _memset - global _reloc_call_memset -_reloc_call_memset: - call manip_stack_A20 - jmp far _memset - - global __HMAinitRelocationTableEnd -__HMAinitRelocationTableEnd: - segment _TEXT global _initforceEnableA20 diff --git a/kernel/main.c b/kernel/main.c index 88cd488..f4e8571 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -107,6 +107,33 @@ __segment DosTextSeg = 0; #endif +/* little functions - could be ASM but does not really matter in this context */ +void memset(void *s, int c, unsigned n) +{ + char *t = s; + while(n--) *t++ = c; +} + +void fmemset(void far *s, int c, unsigned n) +{ + char far *t = s; + while(n--) *t++ = c; +} + +void strcpy(char *dest, const char *src) +{ + while(*src) + *dest++ = *src++; + *dest = '\0'; +} + +void fmemcpy(void far *dest, const void far *src, unsigned n) +{ + char far *d = dest; + const char far *s = src; + while(n--) *d++ = *s++; +} + VOID ASMCFUNC FreeDOSmain(void) { #ifdef _MSC_VER @@ -408,16 +435,16 @@ STATIC void kernel() /* process 0 */ /* Execute command.com /P from the drive we just booted from */ - fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, - sizeof(Config.cfgInitTail) - 1); + memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); + fmemcpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)); - for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) + for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') break; /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ - if (Cmd.ctCount < 127 - 3) + if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 3) { extern int singleStep; extern int SkipAllConfig; @@ -433,14 +460,14 @@ STATIC void kernel() { /* insert /D, /Y as first argument */ - int cmdEnd, i, slen = strlen(insertString); + int cmdEnd, i, slen = 3; /* strlen(insertString); */ - for (cmdEnd = 0; cmdEnd < 127; cmdEnd++) + for (cmdEnd = 0; cmdEnd < sizeof(Cmd.ctBuffer); cmdEnd++) { if (Cmd.ctBuffer[cmdEnd] == ' ' || Cmd.ctBuffer[cmdEnd] == '\t' || Cmd.ctBuffer[cmdEnd] == '\r') { - for (i = 127 - slen; i >= cmdEnd; i--) + for (i = sizeof(Cmd.ctBuffer) - slen - 1; i >= cmdEnd; i--) Cmd.ctBuffer[i + slen] = Cmd.ctBuffer[i]; fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString, slen); diff --git a/kernel/memmgr.c b/kernel/memmgr.c index ab8b795..f39f7c9 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -152,7 +152,7 @@ searchAgain: Hack to the Umb Region direct for now. Save time and program space. */ if ((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && - uppermem_link && uppermem_root) + uppermem_link && uppermem_root != 0xffff) p = para2far(uppermem_root); /* Search through memory blocks */ @@ -217,7 +217,7 @@ searchAgain: if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ if ((mode != LARGEST) && (mode & FIRST_FIT_U) && - uppermem_link && uppermem_root) + uppermem_link && uppermem_root != 0xffff) { mode &= ~FIRST_FIT_U; goto searchAgain; @@ -290,7 +290,7 @@ COUNT DosMemLargest(UWORD FAR * size) /* Initialize */ p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link - && uppermem_root) ? para2far(uppermem_root) : para2far(first_mcb); + && uppermem_root != 0xffff) ? para2far(uppermem_root) : para2far(first_mcb); /* Cycle through the whole MCB chain to find the largest unused area. Join all unused areas together. */ @@ -569,7 +569,7 @@ VOID DosUmbLink(BYTE n) REG mcb FAR *p; REG mcb FAR *q; - if (uppermem_root == 0) + if (uppermem_root == 0xffff) return; q = p = para2far(first_mcb); diff --git a/kernel/prf.c b/kernel/prf.c index aa978fb..fa6c36b 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -41,7 +41,7 @@ static char buff[MAX_BUFSIZE]; #endif #ifdef _INIT -#define fstrlen reloc_call_fstrlen +#define fstrlen init_fstrlen #define handle_char init_handle_char #define put_console init_put_console #define ltob init_ltob @@ -53,8 +53,6 @@ static char buff[MAX_BUFSIZE]; #define hexDigits init_hexDigits #endif -COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ - #ifdef VERSION_STRINGS static BYTE *prfRcsId = "$Id$"; @@ -71,7 +69,7 @@ WORD CDECL printf(CONST BYTE * fmt, ...); /* The following is user supplied and must match the following prototype */ VOID cso(COUNT); -#ifdef FORSYS +#if defined(FORSYS) || defined(_INIT) COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ { int i = 0; @@ -81,6 +79,8 @@ COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ return i; } +#else +COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ #endif /* special console output routine */ diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index d7541fe..e75f7ef 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -43,6 +43,7 @@ unsigned long lseek(int fildes, unsigned long offset, int whence); #else #include +#include #endif #define FAR far