From c5c7128a02502ad9258be41e4f0c3a79b5da7ce2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 20 Jun 2003 19:54:18 +0000 Subject: [PATCH] Move externs to header files; sft init cleanup (+3 files need to be low) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@623 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 110 ++++++---------------------------------------- kernel/dyninit.c | 1 - kernel/init-mod.h | 82 ++++++++++++++++++++++++++++++++-- kernel/initclk.c | 2 - kernel/initdisk.c | 11 ----- kernel/inithma.c | 33 -------------- kernel/initoem.c | 1 - kernel/main.c | 72 ++++++++++-------------------- 8 files changed, 116 insertions(+), 196 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index c1cf321..2cd2561 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -29,9 +29,7 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" #include "dyndata.h" -#include "lol.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -45,27 +43,6 @@ static BYTE *RcsId = #endif #define para2far(seg) ((mcb FAR *)MK_FP((seg), 0)) -/* - These are the far variables from the DOS data segment that we need here. The - init procedure uses a different default DS data segment, which is discarded - after use. I hope to clean this up to use the DOS List of List and Swappable - Data Area obtained via INT21. - - -- Bart - */ - -extern struct dhdr -DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ -extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ -extern struct lol ASM DOSFAR DATASTART; -struct lol FAR *LoL = &DATASTART; - -extern BYTE DOSFAR _HMATextAvailable, /* first byte of available CODE area */ - FAR _HMATextStart[], /* first byte of HMAable CODE area */ - FAR _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ - DOSFAR _InitTextStart, /* first available byte of ram */ - DOSFAR ReturnAnyDosVersionExpected; - UWORD umb_start = 0, UMB_top = 0; UWORD ram_top = 0; /* How much ram in Kbytes */ @@ -273,22 +250,17 @@ void PreConfig(void) #ifdef DEBUG { - extern BYTE FAR ASM internal_data[]; printf("SDA located at 0x%p\n", internal_data); } #endif /* Begin by initializing our system buffers */ - /* the dms_scratch buffer is statically allocated - in the DSK module */ - /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ -/* DebugPrintf(("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch));*/ - -/* buffers = (struct buffer FAR *) - KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ #ifdef DEBUG /* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/ #endif + LoL->DPBp = + DynAlloc("DPBp", blk_dev.dh_name[0], sizeof(struct dpb)); + /* Initialize the file table */ /* f_nodes = (f_node_ptr) KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ @@ -305,19 +277,13 @@ void PreConfig(void) config_init_buffers(Config.cfgBuffers); - LoL->sfthead->sftt_next = - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', 0); - LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - LoL->sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); - LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', 0); - #ifdef DEBUG printf("Preliminary:\n f_node 0x%x", LoL->f_nodes); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ - printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); + printf(" sft table 0x%p\n", LoL->sfthead); printf(" CDS table 0x%p\n", LoL->CDSp); printf(" DPB table 0x%p\n", LoL->DPBp); #endif @@ -355,13 +321,17 @@ void PreConfig2(void) mcb_init(LoL->first_mcb, ram_top * 64 - LoL->first_mcb - 1); if (UmbState == 2) umb_init(); + + LoL->sfthead->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); + LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; + LoL->sfthead->sftt_next->sftt_count = 3; } /* Do third pass initialization. */ /* Also, run config.sys to load drivers. */ void PostConfig(void) { - struct dpb FAR *old_dpbp; + sfttbl FAR *sp; /* We could just have loaded FDXMS or HIMEM */ if (HMAState == HMA_REQ && MoveKernelToHMA()) @@ -374,8 +344,6 @@ void PostConfig(void) Config.cfgStacksHigh = TRUE; } - /* close all (device) files */ - /* compute lastdrive ... */ LoL->lastdrive = Config.cfgLastdrive; if (LoL->lastdrive < LoL->nblkdev) @@ -395,19 +363,15 @@ void PostConfig(void) /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ /* LoL->FCBp = KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - LoL->sfthead->sftt_next = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', + sp = LoL->sfthead->sftt_next; + sp = sp->sftt_next = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 8) * sizeof(sft), 'F', Config.cfgFilesHigh); - LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - LoL->sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; + sp->sftt_next = (sfttbl FAR *) - 1; + sp->sftt_count = Config.cfgFiles - 8; LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); - old_dpbp = LoL->DPBp; - LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', - Config.cfgDosDataUmb); - fmemcpy(LoL->DPBp, old_dpbp, blk_dev.dh_name[0] * sizeof(struct dpb)); - #ifdef DEBUG printf("Final: \n f_node 0x%x\n", LoL->f_nodes); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ @@ -951,8 +915,6 @@ STATIC VOID Dosmem(BYTE * pLine) BYTE *pTmp; BYTE UMBwanted = FALSE; -/* extern BYTE FAR INITDataSegmentClaimed; */ - pLine = GetStringArg(pLine, szBuf); for (pTmp = szBuf; *pTmp != '\0'; pTmp++) @@ -997,8 +959,6 @@ STATIC VOID DosData(BYTE * pLine) { BYTE *pTmp; -/* extern BYTE FAR INITDataSegmentClaimed; */ - pLine = GetStringArg(pLine, szBuf); for (pTmp = szBuf; *pTmp != '\0'; pTmp++) @@ -1018,7 +978,6 @@ STATIC VOID CfgSwitchar(BYTE * pLine) STATIC VOID CfgSwitches(BYTE * pLine) { - extern unsigned char FAR kbdType; pLine = skipwh(pLine); if (commands[0].pass == 0) { if ('=' != *pLine) @@ -1201,8 +1160,6 @@ STATIC VOID CfgBreak(BYTE * pLine) STATIC VOID Numlock(BYTE * pLine) { - extern VOID ASMCFUNC keycheck(void); - /* Format: NUMLOCK = (ON | OFF) */ BYTE FAR *keyflags = (BYTE FAR *) MK_FP(0x40, 0x17); @@ -1861,38 +1818,12 @@ STATIC VOID CfgMenuDefault(BYTE * pLine) } } - - - - /********************************************************************************* National specific things. this handles only Date/Time/Currency, and NOT codepage things. Some may consider this a hack, but I like to see 24 Hour support. tom. *********************************************************************************/ - -struct CountrySpecificInfo { - short CountryID; /* = W1 W437 # Country ID & Codepage */ - short CodePage; - short DateFormat; /* Date format: 0/1/2: U.S.A./Europe/Japan */ - char CurrencyString[5]; /* '$' ,'EUR' */ - char ThousandSeparator[2]; /* ',' # Thousand's separator */ - char DecimalPoint[2]; /* '.' # Decimal point */ - char DateSeparator[2]; /* '-' */ - char TimeSeparator[2]; /* ':' */ - char CurrencyFormat; /* = 0 # Currency format (bit array) - 0Fh BYTE currency format - bit 2 = set if currency symbol replaces decimal point - bit 1 = number of spaces between value and currency symbol - bit 0 = 0 if currency symbol precedes value - 1 if currency symbol follows value - */ - char CurrencyPrecision; /* = 2 # Currency precision */ - char TimeFormat; /* = 0 # time format: 0/1: 12/24 houres */ -}; - - #define _DATE_MDY 0 /* mm/dd/yy */ #define _DATE_DMY 1 /* dd.mm.yy */ #define _DATE_YMD 2 /* yy/mm/dd */ @@ -2299,18 +2230,6 @@ struct CountrySpecificInfo specificCountriesSupported[] = { Aitor Santamar­a Merino (SP) */ - - -extern struct { - char ThisIsAConstantOne; - short TableSize; - - struct CountrySpecificInfo C; - -} FAR nlsCountryInfoHardcoded; - - - STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage) { int i; @@ -2440,7 +2359,6 @@ VOID DoInstall(void) { int i; iregs r; - extern BYTE ASM _init_end[]; unsigned short installMemory; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 417488d..46acb1a 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -38,7 +38,6 @@ additionally: #include "portab.h" #include "init-mod.h" #include "dyndata.h" -#include "lol.h" #if defined(DEBUG) #define DebugPrintf(x) printf x diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 9bf571f..9b71929 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -20,6 +20,9 @@ #include "nls.h" #include "buffer.h" #include "dcb.h" +#include "lol.h" + +#include "init-dat.h" #include "kconfig.h" extern struct _KernelConfig InitKernelConfig; @@ -49,6 +52,7 @@ void strcpy(char *dest, const char *src); /*inithma.c*/ extern BYTE DosLoadedInHMA; int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); +void MoveKernel(unsigned NewKernelSegment); #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) @@ -122,6 +126,7 @@ COUNT ASMCFUNC Umb_Test(void); COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); void DoInstall(void); +UWORD GetBiosKey(int timeout); /* diskinit.c */ COUNT dsk_init(VOID); @@ -185,10 +190,83 @@ VOID init_fatal(BYTE * err_msg); WORD CDECL init_printf(CONST BYTE * fmt, ...); WORD CDECL init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); -void MoveKernel(unsigned NewKernelSegment); +/* initclk.c */ +extern void Init_clk_driver(void); + extern UWORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; +extern struct _KernelConfig FAR ASM LowKernelConfig; +extern WORD days[2][13]; +extern BYTE FAR *lpOldTop; +extern BYTE FAR *lpTop; +extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; +extern UWORD ram_top; /* How much ram in Kbytes */ +extern char MenuSelected; +extern unsigned Menus; +extern char singleStep; +extern char SkipAllConfig; + +extern struct lol FAR *LoL; + +extern struct dhdr DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ + +extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ +extern struct lol ASM DOSFAR DATASTART; + +extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE area */ + FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ + FAR ASM _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ + DOSFAR _InitTextStart, /* first available byte of ram */ + DOSFAR ReturnAnyDosVersionExpected; + +extern BYTE FAR ASM internal_data[]; +extern unsigned char FAR kbdType; + +extern struct { + char ThisIsAConstantOne; + short TableSize; + + struct CountrySpecificInfo C; + +} FAR nlsCountryInfoHardcoded; + +/* + data shared between DSK.C and INITDISK.C +*/ + +extern UWORD DOSFAR LBA_WRITE_VERIFY; + +/* floppy parameter table, at 70:xxxx */ +extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; + +struct RelocationTable { + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + UBYTE callNear; + UWORD callOffset; +}; + +struct RelocatedEntry { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; +}; + +extern struct RelocationTable + DOSTEXTFAR ASM _HMARelocationTableStart[], + DOSTEXTFAR ASM _HMARelocationTableEnd[]; + +extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; +extern VOID ASMCFUNC FAR _EnableA20(VOID); +extern VOID ASMCFUNC FAR _DisableA20(VOID); + +extern void FAR * ASMCFUNC DetectXMSDriver(VOID); +extern int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, + UWORD dx); #if defined(WATCOM) && 0 ULONG ASMCFUNC FAR MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ @@ -197,5 +275,3 @@ ULONG ASMCFUNC FAR DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShor ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif -extern struct lol FAR *LoL; - diff --git a/kernel/initclk.c b/kernel/initclk.c index b19a907..b895e74 100644 --- a/kernel/initclk.c +++ b/kernel/initclk.c @@ -28,8 +28,6 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" -#include "lol.h" #ifdef VERSION_STRINGS static char *RcsId = diff --git a/kernel/initdisk.c b/kernel/initdisk.c index dda8348..0204466 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -26,9 +26,7 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" #include "dyndata.h" -#include "lol.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; @@ -37,15 +35,6 @@ static BYTE *dskRcsId = UBYTE InitDiskTransferBuffer[SEC_SIZE]; COUNT nUnits; -/* - data shared between DSK.C and INITDISK.C -*/ - -extern UWORD DOSFAR LBA_WRITE_VERIFY; - -/* floppy parameter table, at 70:xxxx */ -extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; - /* * Rev 1.0 13 May 2001 tom ehlert * Initial revision. diff --git a/kernel/inithma.c b/kernel/inithma.c index 9db01d8..7763721 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -65,12 +65,6 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" -#include "lol.h" - -extern BYTE FAR ASM _HMATextAvailable, /* first byte of available CODE area */ - FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ - FAR ASM _HMATextEnd[]; /* and the last byte of it */ #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -81,13 +75,6 @@ BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */ UWORD HMAFree = 0; /* first byte in HMA not yet used */ -extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; -VOID ASMCFUNC FAR _EnableA20(VOID); -VOID ASMCFUNC FAR _DisableA20(VOID); - -void FAR * ASMCFUNC DetectXMSDriver(VOID); -int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, - UWORD dx); STATIC void InstallVDISK(void); #ifdef DEBUG @@ -109,8 +96,6 @@ void int3() #define HMAInitPrintf(x) #endif -void MoveKernel(unsigned NewKernelSegment); - #ifdef DEBUG VOID hdump(BYTE FAR * p) { @@ -381,24 +366,6 @@ void MoveKernel(unsigned NewKernelSegment) style table */ - struct RelocationTable { - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - UBYTE callNear; - UWORD callOffset; - }; - struct RelocatedEntry { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct RelocationTable - DOSTEXTFAR ASM _HMARelocationTableStart[], - DOSTEXTFAR ASM _HMARelocationTableEnd[]; - struct RelocationTable FAR *rp, rtemp; /* verify, that all entries are valid */ diff --git a/kernel/initoem.c b/kernel/initoem.c index 58ef9b9..ca0b094 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -29,7 +29,6 @@ #include "portab.h" #include "init-mod.h" -#include "lol.h" #ifdef VERSION_STRINGS static BYTE *RcsId = diff --git a/kernel/main.c b/kernel/main.c index 1cf3ff4..a302947 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -30,44 +30,20 @@ #include "portab.h" #include "init-mod.h" #include "dyndata.h" -#include "init-dat.h" -#include "lol.h" - -char copyright[] = - "(C) Copyright 1995-2003 Pasquale J. Villani and The FreeDOS Project.\n" - "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" - "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" - "GNU General Public License as published by the Free Software Foundation;\n" - "either version 2, or (at your option) any later version.\n"; - -/* - These are the far variables from the DOS data segment that we need here. The - init procedure uses a different default DS data segment, which is discarded - after use. I hope to clean this up to use the DOS List of List and Swappable - Data Area obtained via INT21. - - -- Bart - */ - -extern struct dhdr ASM DOSTEXTFAR con_dev, /* console device drive */ - DOSTEXTFAR ASM clk_dev, /* Clock device driver */ - DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ -extern BYTE FAR ASM _HMATextEnd[]; - -extern struct _KernelConfig FAR ASM LowKernelConfig; #ifdef VERSION_STRINGS static BYTE *mainRcsId = "$Id$"; #endif -struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0, 0 }; +static char copyright[] = + "(C) Copyright 1995-2003 Pasquale J. Villani and The FreeDOS Project.\n" + "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" + "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" + "GNU General Public License as published by the Free Software Foundation;\n" + "either version 2, or (at your option) any later version.\n"; -extern WORD days[2][13]; -extern BYTE FAR *lpOldTop; -extern BYTE FAR *lpTop; -extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; -extern UWORD ram_top; /* How much ram in Kbytes */ +struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0, 0 }; STATIC VOID InitIO(void); @@ -77,9 +53,7 @@ STATIC VOID signon(VOID); STATIC VOID kernel(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); -void CheckContinueBootFromHarddisk(void); - -extern void Init_clk_driver(void); +STATIC void CheckContinueBootFromHarddisk(void); #ifdef _MSC_VER BYTE _acrtused = 0; @@ -93,6 +67,8 @@ __segment DosTextSeg = 0; #endif +struct lol FAR *LoL = &DATASTART; + /* little functions - could be ASM but does not really matter in this context */ void memset(void *s, int c, unsigned n) { @@ -269,6 +245,7 @@ STATIC void init_kernel(void) /* and process CONFIG.SYS one last time for device drivers */ DoConfig(2); + /* Close all (device) files */ for (i = 0; i < LoL->lastdrive; i++) close(i); @@ -278,7 +255,7 @@ STATIC void init_kernel(void) /* Init the file system one more time */ FsConfig(); - + configDone(); InitializeAllBPBs(); @@ -286,10 +263,8 @@ STATIC void init_kernel(void) STATIC VOID FsConfig(VOID) { - REG COUNT i; - struct dpb FAR *dpb; - - dpb = LoL->DPBp; + struct dpb FAR *dpb = LoL->DPBp; + int i; /* Initialize the current directory structures */ for (i = 0; i < LoL->lastdrive; i++) @@ -380,9 +355,6 @@ STATIC void kernel() CommandTail Cmd; int rc; - extern char MenuSelected; - extern unsigned Menus; - BYTE master_env[32]; char *masterenv_ptr = master_env; @@ -415,8 +387,6 @@ STATIC void kernel() if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 3) { - extern int singleStep; - extern int SkipAllConfig; char *insertString = NULL; if (singleStep) @@ -581,10 +551,16 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, STATIC void InitIO(void) { + struct dhdr far *device = &LoL->nul_dev; + /* Initialize driver chain */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - init_device(&con_dev, NULL, NULL, lpTop); - init_device(&clk_dev, NULL, NULL, lpTop); + device = &LoL->nul_dev; + do { + init_device(device, NULL, NULL, lpTop); + device = device->dh_next; + } + while (FP_OFF(device) != 0xffff); } /* issue an internal error message */ @@ -630,8 +606,6 @@ STATIC VOID InitPrinters(VOID) booted from HD */ -extern UWORD GetBiosKey(int timeout); - EmulatedDriveStatus(int drive,char statusOnly) { iregs r; @@ -650,7 +624,7 @@ EmulatedDriveStatus(int drive,char statusOnly) return TRUE; } -void CheckContinueBootFromHarddisk(void) +STATIC void CheckContinueBootFromHarddisk(void) { char *bootedFrom = "Floppy/CD"; iregs r;