From e9716d990d3f9ba105c01fd1089b1f3f03268ec2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 11:54:09 +0000 Subject: [PATCH] Document the fact the MSCL8 compiled kernels don't work. Don't initialize BSS variables anymore -- now done by the memset in main.c Removed obsolete BYTE cfgCSYS_fnam[NAMEMAX]; config variable. Changed cfgInit and cfgInitTail to pointers, adjusted some code to work with them. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@874 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 7 +++-- kernel/config.c | 74 +++++++++++++++++++---------------------------- kernel/config.h | 5 ++-- kernel/kernel.asm | 6 ++-- kernel/main.c | 5 ++-- kernel/segs.inc | 26 ++++++++++------- kernel/task.c | 5 ++-- 7 files changed, 61 insertions(+), 67 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index a5e487b..b808da6 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -29,11 +29,12 @@ Optionally, the kernel can be compressed using UPX. You can find UPX at http://upx.sourceforge.net. Simply adjust config.bat to enable it. -This kernel will now compile with Turbo C 2.01, Turbo C++ 1.01 (now freely +This kernel compiles with Turbo C 2.01, Turbo C++ 1.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers, Microsoft C and (Open)Watcom C. +other Borland compilers and (Open)Watcom C. Microsoft C and GCC can +compile the kernel but the result does *not* work. -The OpenWatcom 1.0 compiler (or later) for DOS can now be downloaded at +The OpenWatcom 1.0 compiler (or later) for DOS can be downloaded at www.openwatcom.org: you need at least the following zips from ftp://ftp.openwatcom.org/watcom/zips/ (see ftp://ftp.openwatcom.org/watcom/zips/layout.txt) diff --git a/kernel/config.c b/kernel/config.c index 6c77b37..272e2c2 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -58,21 +58,9 @@ struct MenuSelector }; /** Structure below holds the menu-strings */ -STATIC struct MenuSelector MenuStruct[MENULINESMAX] = -{ - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}} -}; +STATIC struct MenuSelector MenuStruct[MENULINESMAX]; -int nMenuLine=0; +int nMenuLine; BOOL MenuColor = -1; STATIC void WriteMenuLine(int MenuSelected) @@ -128,14 +116,13 @@ STATIC void SelectLine(int MenuSelected) WriteMenuLine(MenuSelected); } -UWORD umb_start = 0, UMB_top = 0; -UWORD ram_top = 0; /* How much ram in Kbytes */ -size_t ebda_size = 0; +UWORD umb_start, UMB_top; +UWORD ram_top; /* How much ram in Kbytes */ +size_t ebda_size; static UBYTE ErrorAlreadyPrinted[128]; - -char master_env[128] = {0}; +char master_env[128]; static char *envp = master_env; struct config Config = { @@ -155,34 +142,29 @@ struct config Config = { /* COUNTRY= is initialized within DoConfig() */ , 0 /* country ID */ , 0 /* codepage */ - , "" /* filename */ , 0 /* amount required memory */ , 0 /* pointer to loaded data */ , 0 /* strategy for command.com is low by default */ , 0xFFFF /* default value for switches=/E:nnnn */ }; - /* MSC places uninitialized data into COMDEF records, - that end up in DATA segment. this can't be tolerated - in INIT code. - please make sure, that ALL data in INIT is initialized !! - */ -STATIC seg base_seg = 0; -STATIC seg umb_base_seg = 0; -BYTE FAR *lpTop = 0; -STATIC unsigned nCfgLine = 0; -COUNT UmbState = 0; -STATIC BYTE szLine[256] = { 0 }; -STATIC BYTE szBuf[256] = { 0 }; -BYTE singleStep = FALSE; /* F8 processing */ -BYTE SkipAllConfig = FALSE; /* F5 processing */ -BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ -BYTE DontAskThisSingleCommand = FALSE; /* !files= */ +STATIC seg base_seg; +STATIC seg umb_base_seg; +BYTE FAR *lpTop; +STATIC unsigned nCfgLine; +COUNT UmbState; +STATIC BYTE szLine[256]; +STATIC BYTE szBuf[256]; + +BYTE singleStep; /* F8 processing */ +BYTE SkipAllConfig; /* F5 processing */ +BYTE askThisSingleCommand; /* ?device= device?= */ +BYTE DontAskThisSingleCommand; /* !files= */ COUNT MenuTimeout = -1; -BYTE MenuSelected = 0; -UCOUNT MenuLine = 0; -UCOUNT Menus = 0; +BYTE MenuSelected; +UCOUNT MenuLine; +UCOUNT Menus; STATIC VOID CfgMenuColor(BYTE * pLine); @@ -331,9 +313,9 @@ int findend(BYTE * s) return nLen; } -BYTE *pLineStart = 0; +BYTE *pLineStart; -BYTE HMAState = 0; +BYTE HMAState; #define HMA_NONE 0 /* do nothing */ #define HMA_REQ 1 /* DOS = HIGH detected */ #define HMA_DONE 2 /* Moved kernel to HMA */ @@ -343,8 +325,6 @@ BYTE HMAState = 0; /* later. */ void PreConfig(void) { - memset(ErrorAlreadyPrinted,0,sizeof(ErrorAlreadyPrinted)); - /* Initialize the base memory pointers */ #ifdef DEBUG @@ -1257,6 +1237,12 @@ STATIC VOID InitPgmHigh(BYTE * pLine) STATIC VOID InitPgm(BYTE * pLine) { + static char init[NAMEMAX]; + static char inittail[NAMEMAX]; + + Config.cfgInit = init; + Config.cfgInitTail = inittail; + /* Get the string argument that represents the new init pgm */ pLine = GetStringArg(pLine, Config.cfgInit); @@ -1648,7 +1634,7 @@ STATIC VOID mcb_init_copy(UCOUNT seg, UWORD size, mcb *near_mcb) STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type) { - static mcb near_mcb = {0}; + static mcb near_mcb; near_mcb.m_type = type; mcb_init_copy(seg, size, &near_mcb); } diff --git a/kernel/config.h b/kernel/config.h index c55cc52..50dff68 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -34,8 +34,8 @@ struct config { /* Configuration variables */ UBYTE cfgFilesHigh; UBYTE cfgFcbs; /* number of available FCBs */ UBYTE cfgProtFcbs; /* number of protected FCBs */ - BYTE cfgInit[NAMEMAX]; /* init of command.com */ - BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ + BYTE *cfgInit; /* init of command.com */ + BYTE *cfgInitTail; /* command.com's tail */ UBYTE cfgLastdrive; /* last drive */ UBYTE cfgLastdriveHigh; BYTE cfgStacks; /* number of stacks */ @@ -47,7 +47,6 @@ struct config { /* Configuration variables */ */ WORD cfgCSYS_cntry; /* country ID to be loaded */ UWORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ - BYTE cfgCSYS_fnam[NAMEMAX];/* filename of COUNTRY= */ WORD cfgCSYS_memory; /* # of bytes required for the NLS pkg; 0 if none */ VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ UBYTE cfgP_0_startmode; /* load command.com high or not */ diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9c33093..f5c1126 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -129,13 +129,13 @@ kernel_start: shr dx,cl sub ax,dx mov es,ax - mov dx,__INIT_DATA_START wrt INIT_TEXT + mov dx,__INIT_DATA_START wrt INIT_TEXT ; para aligned shr dx,cl add ax,dx mov ss,ax ; set SS to init data segment sti ; now enable them mov ax,cs - mov dx,__InitTextStart wrt HMA_TEXT + mov dx,__InitTextStart wrt HMA_TEXT ; para aligned %ifdef WATCOM mov si,dx mov cl,4 @@ -143,7 +143,7 @@ kernel_start: add ax,si %endif mov ds,ax - mov cx,-2 + init_end wrt INIT_TEXT + mov cx,-2 + init_end wrt INIT_TEXT ; word aligned mov si,cx mov di,cx shr cx,1 diff --git a/kernel/main.c b/kernel/main.c index 8b3ebd3..79eba2e 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -43,7 +43,7 @@ static char copyright[] = "GNU General Public License as published by the Free Software Foundation;\n" "either version 2, or (at your option) any later version.\n"; -struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0, 0 }; +struct _KernelConfig InitKernelConfig; STATIC VOID InitIO(void); @@ -445,7 +445,8 @@ STATIC void kernel() break; } } - strcpy(Config.cfgInitTail, Cmd.ctBuffer); /* save buffer */ + /* save buffer -- on the stack it's fine here */ + Config.cfgInitTail = Cmd.ctBuffer; } } init_call_p_0(&Config); /* go execute process 0 (the shell) */ diff --git a/kernel/segs.inc b/kernel/segs.inc index 592760f..f54100f 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -32,11 +32,12 @@ group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA %ifdef WATCOM group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END +group I_GROUP ID_B I_DATA ICONST ICONST2 ID_E IB_B I_BSS IB_E %else group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END +group I_GROUP ID_B ID ID_E IC IDATA IB_B IB IB_E %endif -group I_GROUP ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E segment PSP class=PSP segment _LOWTEXT class=LCODE @@ -59,18 +60,23 @@ segment HMA_TEXT_END class=CODE segment INIT_TEXT_START class=CODE align=16 segment INIT_TEXT class=CODE segment INIT_TEXT_END class=CODE -segment ID_B class=ID align=16 -segment ID class=ID align=2 -segment ID_E class=ID align=2 -segment IDATA class=ID align=2 -segment IC class=IC align=2 -;for Watcom +%ifdef WATCOM +segment ID_B class=FAR_DATA align=16 +segment I_DATA class=FAR_DATA align=2 segment ICONST class=FAR_DATA align=2 segment ICONST2 class=FAR_DATA align=2 -segment I_DATA class=FAR_DATA align=2 - -segment IB_B class=IB align=2 +segment ID_E class=FAR_DATA align=2 +segment IB_B class=FAR_DATA align=2 segment I_BSS class=FAR_DATA align=2 +segment IB_E class=FAR_DATA align=2 +%else +segment ID_B class=ID align=16 +segment ID class=ID align=2 +segment IDATA class=ID align=2 +segment ID_E class=ID align=2 +segment IC class=IC align=2 +segment IB_B class=IB align=2 segment IB class=IB align=2 segment IB_E class=IB align=2 +%endif diff --git a/kernel/task.c b/kernel/task.c index e3d5ed0..c4653bf 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -800,8 +800,9 @@ VOID ASMCFUNC P_0(struct config FAR *Config) /* build exec block and save all parameters here as init part will vanish! */ exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *)-1L; exb.exec.env_seg = DOS_PSP + 8; - fstrcpy(Shell, Config->cfgInit); - fstrcpy(Shell + strlen(Shell), Config->cfgInitTail); /* join name and tail */ + fstrcpy(Shell, MK_FP(FP_SEG(Config), Config->cfgInit)); + /* join name and tail */ + fstrcpy(Shell + strlen(Shell), MK_FP(FP_SEG(Config), Config->cfgInitTail)); endp = Shell + strlen(Shell); for ( ; ; ) /* endless shell load loop - reboot or shut down to exit it! */