diff --git a/docs/history.txt b/docs/history.txt index 8845505..432ad6a 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,12 +1,14 @@ -2004 July 8 - UNSTABLE branch +2005 Jan XX - UNSTABLE (-w) branch -------- Jeremy Davis (jeremyd@computer.org) + Changes Bart - * int2f.asm - - bugfix: call_nls: DI register was not preserved * exeflat.c - new version exploiting better UPX compression for SYS files; calls UPX itself + * int2f.asm + - bugfix: call_nls: DI register was not preserved * inthndlr.c - int21/ah=6/dl=ff now calls int28 + * sys.c + - correct fat32readwrite's prototype to explicitly return int + Changes Tom * inthndlr.c - improve handling of case where eg. FindFirst(I:\*.*) fails, causes Int24, @@ -316,7 +318,7 @@ (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 - optimised Int 21h/AH=38h Get Country Information, removed cntry hack - * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF + * 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 @@ -330,16 +332,16 @@ - optimisation and clean-up * fattab.c: ISFAT32 function removed (now macro), "wasfree" optimised * globals.h: __TIME__ removed - no two kernels released on same day - * initdisk.c: + * initdisk.c - 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: + * ioctl.c - r_si/r_di contents added as documented in PC-DOS Technical Update - r_unit now set to dpb_subunit (allows ZIP disk serial number) - * main.c: + * main.c - copyright message cleanup, now shows URL for the full GNU GPL text - (with Bart) LoL pointer made const (saves some size for Watcom) - InitializeAllBPBs() kludge removed (no longer needed - verified) @@ -353,7 +355,7 @@ + Changes Eduardo * config.c: update hardcoded country and codepage IDs * country.asm: added NLS uppercase/collating tables (437,850,857,858) - * inthndlr.c: + * inthndlr.c - added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) - DOS-63-00 returns DBCS table from the active NLS package, not the harcoded one. @@ -368,27 +370,44 @@ - DosYesNo(): arg is now UWORD, not unsigned char. - nlsYesNo(): Add DBCS support - syscall_MUX14(): arg of nlsYesNo() is now CX instead of CL. - * nls.h: + * nls.h - yeschar and nochar are now UWORD instead of UBYTE. - NLS_FREEDOS_NLSFUNC_VERSION bumped to 0xFD02. - Add a small comment. * nls_hc.asm: YesChar and NoChar are now two bytes each. - * proto.h: + * proto.h - DosYesNo(): Argument is now UWORD (dual byte) - Add prototype for DosGetDBCS() + Changes Jeremy - * config.txt - - update to include all CONFIG.SYS options (except ANYDOS) + * updated build system to use NT OW binaries when building on NT + and add some additional options to build.bat command line + * added debug.h and changed to more easily allow selective DEBUG output * boot.asm - use static read buffer to avoid crossing 64KB boundary + - drop test for drive==0xFF, use sys to NOP use of BIOS provided # + * config.c + - always initialize boot time master environment + - KernelAlloc always 0's returned memory (fixes potential boot + time failure finding/loading CONFIG.SYS) + * config.txt + - update to include all CONFIG.SYS options (except ANYDOS) + * exeflat.c + - show usage also when number of arguments incorrect + * fatdir.c + - be more restrictive in what considered a volume search + * initdisk.c + - set hidden & huge fields in floppy bpb (bugfix 1789) * main.c - treat block devices returning 0 units as load failure * oemboot.asm - add [optional] PC/MS DOS compatible boot sector * sys.c - incorporate changes from/for DR-DOS enhancement project - rework option handling, add backup & restore boot sector - * exeflat.c - - show usage also when number of arguments incorrect + - change boot time drive selection (BIOS provided or one in + boot sector) to be selected as SYS time via NOPing mov [drive],dl + * add sys.txt (documentation) and sys.html (htmlhelp file) + * task.c + - add debug output to see env & cmd line passed to exec'd program < many other changes to be added by Jeremy himself :-> *** Sync - Stable Build 2035 *** diff --git a/hdr/debug.h b/hdr/debug.h index f2ef7f3..d4cf7f1 100644 --- a/hdr/debug.h +++ b/hdr/debug.h @@ -55,6 +55,13 @@ /* show stored IRQ vectors */ /* #define DEBUGIRQ */ +/* show output related to moving kernel into HMA */ +#ifdef DEBUG +#define HMAInitPrintf(x) printf x +#else +#define HMAInitPrintf(x) +#endif + /* display output during kernel config processing phase */ /* #define DEBUGCFG */ #ifdef DEBUGCFG diff --git a/hdr/lol.h b/hdr/lol.h index b0cb59e..ff2174b 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -26,7 +26,8 @@ /* Boston, MA 02111-1307 USA. */ /****************************************************************/ -enum {LOC_CONV=0, LOC_HMA=1}; +#ifndef __LOL_H +#define __LOL_H /* note: we start at DOSDS:0, but the "official" list of lists starts a little later at DOSDS:26 (this is what is returned by int21/ah=52) */ @@ -84,3 +85,5 @@ struct lol { unsigned short f_nodes_cnt; /* 74 number of allocated f_nodes */ char *os_release; /* 76 near pointer to os_release string */ }; + +#endif /* __LOL_H */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 7ef142c..8a8b40a 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -27,6 +27,7 @@ /****************************************************************/ #include "portab.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *dosfnsRcsId = @@ -504,11 +505,19 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) result = truename(fname, PriPathName, CDS_MODE_CHECK_DEV_PATH); if (result < SUCCESS) + { + DFnsDbgPrintf(("DosOpenSft: truename failed\n")); return result; + } + else DFnsDbgPrintf(("DosOpenSft: truename succeeded\n")); /* now get a free system file table entry */ if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) + { + DFnsDbgPrintf(("DosOpenSft: file table full\n")); return DE_TOOMANY; + } + else DFnsDbgPrintf(("DosOpenSft: obtained sft entry\n")); fmemset(sftp, 0, sizeof(sft)); @@ -519,10 +528,14 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_attrib = attrib = attrib | D_ARCHIVE; + DFnsDbgPrintf(("DosOpenSft: mode=%02X, flags=%02X, attrib=%02X\n", \ + sftp->sft_mode, OpenMode, attrib)); + if (result & IS_NETWORK) { int status; unsigned cmd; + DFnsDbgPrintf(("DosOpenSft: IS_NETWORK\n")); if ((flags & (O_TRUNC | O_CREAT)) == O_CREAT) attrib |= 0x100; @@ -558,6 +571,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* check the status code returned by the * driver when we tried to open it */ + DFnsDbgPrintf(("DosOpenSft: IS_DEVICE\n")); if (rc < SUCCESS) return rc; return sft_idx; @@ -566,6 +580,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { + DFnsDbgPrintf(("DosOpenSft: using SHARE\n")); if ((sftp->sft_shroff = share_open_check(PriPathName, cu_psp, flags & 0x03, (flags >> 4) & 0x07)) < 0) @@ -578,9 +593,13 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* ... though FCB's are weird :) */ if (!(flags & O_FCB) && (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE | D_VOLID))) + { + DFnsDbgPrintf(("DosOpenSft: invalid request\n")); return DE_ACCESS; + } result = dos_open(PriPathName, flags, attrib); + DFnsDbgPrintf(("DosOpenSft: dos_open returned %02X\n", result)); if (result >= 0) { int status = (int)(result >> 16); @@ -591,6 +610,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) (do not allow to open volume labels/directories) */ if (sftp->sft_attrib & (D_DIR | D_VOLID)) { + DFnsDbgPrintf(("DosOpenSft: closing, invalid attributes DIR|VOLID\n")); dos_close((COUNT)result); return DE_ACCESS; } @@ -603,6 +623,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) dos_getftime(sftp->sft_status, (date FAR *) & sftp->sft_date, (time FAR *) & sftp->sft_time); + DFnsDbgPrintf(("DosOpenSft: returning %lu (decimal)\n", (sft_idx | ((long)status << 16)))); return sft_idx | ((long)status << 16); } else @@ -944,7 +965,6 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) return SUCCESS; } -#undef CHDIR_DEBUG COUNT DosChangeDir(BYTE FAR * s) { COUNT result; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 9350072..0461e55 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -38,12 +38,7 @@ additionally: #include "portab.h" #include "init-mod.h" #include "dyndata.h" - -#if defined(DEBUG) -#define DebugPrintf(x) printf x -#else -#define DebugPrintf(x) -#endif +#include "debug.h" /*extern struct DynS FAR Dyn;*/ diff --git a/kernel/fatdir.c b/kernel/fatdir.c index b66ce08..c7c98dd 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -29,6 +29,7 @@ #include "portab.h" #include "globals.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *fatdirRcsId = @@ -62,9 +63,12 @@ f_node_ptr dir_open(register const char *dirname) int i; char fcbname[FNAME_SIZE + FEXT_SIZE]; + FDirDbgPrintf(("dir_open: trying to open %s\n", dirname)); + /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (f_node_ptr) 0) { + FDirDbgPrintf(("dir_open: failed to get f_node\n")); return (f_node_ptr) 0; } @@ -78,6 +82,7 @@ f_node_ptr dir_open(register const char *dirname) if (media_check(fnp->f_dpb) < 0) { + FDirDbgPrintf(("dir_open: media_check failed\n")); release_f_node(fnp); return (f_node_ptr) 0; } @@ -136,6 +141,7 @@ f_node_ptr dir_open(register const char *dirname) if (!i || !(fnp->f_dir.dir_attrib & D_DIR)) { + FDirDbgPrintf(("dir_open: no match found, returning failure\n")); release_f_node(fnp); return (f_node_ptr) 0; } @@ -146,6 +152,7 @@ f_node_ptr dir_open(register const char *dirname) dir_init_fnode(fnp, getdstart(fnp->f_dpb, &fnp->f_dir)); } } + FDirDbgPrintf(("dir_open: returning, ok\n")); return fnp; } @@ -188,7 +195,10 @@ COUNT dir_read(REG f_node_ptr fnp) /* can't have more than 65535 directory entries */ if (fnp->f_diroff >= 65535U) + { + FDirDbgPrintf(("dir_read: exceed dir entry count\n")); return DE_SEEK; + } /* Determine if we hit the end of the directory. If we have, */ /* bump the offset back to the end and exit. If not, fill the */ @@ -198,7 +208,10 @@ COUNT dir_read(REG f_node_ptr fnp) if (fnp->f_dirstart == 0) { if (fnp->f_diroff >= fnp->f_dpb->dpb_dirents) + { + FDirDbgPrintf(("dir_read: end of dir\n")); return DE_SEEK; + } bp = getblock(fnp->f_diroff / (secsize / DIRENT_SIZE) + fnp->f_dpb->dpb_dirstrt, fnp->f_dpb->dpb_unit); @@ -217,7 +230,10 @@ COUNT dir_read(REG f_node_ptr fnp) printf("dir_read: "); #endif if (map_cluster(fnp, XFR_READ) != SUCCESS) + { + DebugPrintf(("dir_read: map_cluster failed\n")); return DE_SEEK; + } bp = getblock_from_off(fnp, secsize); #ifdef DISPLAY_GETBLOCK @@ -228,7 +244,10 @@ COUNT dir_read(REG f_node_ptr fnp) /* Now that we have the block for our entry, get the */ /* directory entry. */ if (bp == NULL) + { + FDirDbgPrintf(("dir_read: invalid block\n")); return DE_BLKINVLD; + } bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_VALID; @@ -245,6 +264,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* and for efficiency, stop when we hit the first */ /* unused entry. */ /* either returns 1 or 0 */ + FDirDbgPrintf(("dir_read: dir_name is %11s\n", fnp->f_dir.dir_name)); return (fnp->f_dir.dir_name[0] != '\0'); } @@ -423,9 +443,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) { dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); -#ifdef DEBUG - printf("dos_findfirst: %11s\n", fnp->f_dir.dir_name); -#endif + FDirDbgPrintf(("dos_findfirst: %11s\n", fnp->f_dir.dir_name)); + dir_close(fnp); return SUCCESS; } @@ -511,9 +530,7 @@ COUNT dos_findnext(void) return SUCCESS; } } -#ifdef DEBUG - printf("dos_findnext: %11s\n", fnp->f_dir.dir_name); -#endif + FDirDbgPrintf(("dos_findnext: %11s\n", fnp->f_dir.dir_name)); /* return the result */ release_f_node(fnp); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 8e010a3..9012a07 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -29,6 +29,7 @@ #include "portab.h" #include "globals.h" +#include "debug.h" #ifdef VERSION_STRINGS BYTE *RcsId = "$Id$"; @@ -142,12 +143,16 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* next, split the passed dir into components (i.e. - path to */ /* new directory and name of new directory. */ if ((fnp = split_path(path, fcbname)) == NULL) + { + FatFSDbgPrintf(("dos_open: splitpath(\"%s\", \"%11s\") failed.\n", path, fcbname)); return DE_PATHNOTFND; + } /* Check that we don't have a duplicate name, so if we */ /* find one, truncate it (O_CREAT). */ if (find_fname(fnp, fcbname, D_ALL | attrib)) { + FatFSDbgPrintf(("dos_open: filename match found\n")); if (flags & O_TRUNC) { /* The only permissable attribute is archive, */ @@ -189,6 +194,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) else if (flags & O_CREAT) { int ret = alloc_find_free(fnp, path, fcbname); + FatFSDbgPrintf(("dos_open: create\n")); if (ret != SUCCESS) return ret; status = S_CREATED; @@ -198,6 +204,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* open: If we can't find the file, just return a not */ /* found error. */ dir_close(fnp); + FatFSDbgPrintf(("dos_open: file not found\n")); return DE_FILENOTFND; } @@ -312,6 +319,8 @@ f_node_ptr split_path(char * path, char * fcbname) /* Start off by parsing out the components. */ int dirlength = ParseDosName(path, fcbname, FALSE); + FatFSDbgPrintf(("split_path: dirlen=%i, path=\"%s\", fcbname=\"%11s\"\n", \ + dirlength, path, fcbname)); if (dirlength < SUCCESS) return (f_node_ptr) 0; @@ -330,7 +339,7 @@ f_node_ptr split_path(char * path, char * fcbname) #ifdef DEBUG if (get_cds(path[0]-'A')->cdsFlags & CDSNETWDRV) { - printf("split path called for redirected file: `%s'\n", + printf("split path called for redirected file: `%11s'\n", fcbname); return (f_node_ptr) 0; } @@ -349,10 +358,14 @@ f_node_ptr split_path(char * path, char * fcbname) /* note: an invalid fd is indicated by a 0 return */ if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) { + FatFSDbgPrintf(("split_path: failing, fnp is %sNULL, f_count=%i\n", \ + (fnp==(f_node_ptr)0)?"":"NOT", \ + (fnp==(f_node_ptr)0)?123:fnp->f_count)); dir_close(fnp); return (f_node_ptr) 0; } + FatFSDbgPrintf(("split_path: success\n")); return fnp; } @@ -1817,18 +1830,18 @@ int dos_cd(char * PathName) /* try to allocate a near f_node */ /* (there are just two of them, in the SDA) */ - f_node_ptr get_near_f_node(void) { f_node_ptr fnp = fnode; + DebugPrintf(("get_near_f_node: fnp is %p\n", fnp)); if (fnp->f_count && (++fnp)->f_count) panic("more than two near fnodes requested at the same time!\n"); fnp->f_count++; + DebugPrintf(("got near fnode, fnp->f_count=%i\n", fnp->f_count)); return fnp; } /* Try to allocate an f_node from the available files array */ - f_node_ptr get_f_node(void) { REG int i; @@ -1836,17 +1849,22 @@ f_node_ptr get_f_node(void) if (fnp != (f_node_ptr)0) { + FatFSDbgPrintf(("get_f_node: &f_nodes[0]=%p, f_nodes_cnt=%i\n", (void far *)&f_nodes, f_nodes_cnt)); for (i = 0; i < f_nodes_cnt; i++) { if (f_nodes[i].f_count == 0) { ++f_nodes[i].f_count; fnode_fd[fnp - fnode] = i; + FatFSDbgPrintf(("f_nodes[%i].f_count=%i, fnode_fd[%i]=%i\n", \ + i, f_nodes[i].f_count, (fnp-fnode), i)); return fnp; } } release_near_f_node(fnp); + FatFSDbgPrintf(("get_f_node: failure finding free entry in f_nodes[]\n")); } + else FatFSDbgPrintf(("get_f_node: get_near_fnode() failed, returned NULL\n")); return (f_node_ptr) 0; } @@ -1854,6 +1872,8 @@ VOID release_f_node(f_node_ptr fnp) { struct f_node FAR *fp = &f_nodes[xlt_fnp(fnp)]; + FatFSDbgPrintf(("release_f_node: fp->f_count=%i\n", fp->f_count)); + if (fp->f_count > 0) --fp->f_count; else @@ -2048,28 +2068,37 @@ COUNT media_check(REG struct dpb FAR * dpbp) /* First test if anyone has changed the removable media */ ret = rqblockio(C_MEDIACHK, dpbp); if (ret < SUCCESS) + { + FatFSDbgPrintf(("media_check: failed\n")); return ret; + } switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) { case M_NOT_CHANGED: /* It was definitely not changed, so ignore it */ + DebugPrintf(("media_check: no change\n")); return SUCCESS; /* If it is forced or the media may have changed, */ /* rebuild the bpb */ case M_DONT_KNOW: /* hazard: no error checking! */ + DebugPrintf(("media_check: unknown\n")); flush_buffers(dpbp->dpb_unit); /* If it definitely changed, don't know (falls through) */ /* or has been changed, rebuild the bpb. */ /* case M_CHANGED: */ default: + DebugPrintf(("media_check: assumming changed\n")); setinvld(dpbp->dpb_unit); ret = rqblockio(C_BLDBPB, dpbp); if (ret < SUCCESS) + { + DebugPrintf(("media_check: build BPB failed\n")); return ret; + } #ifdef WITHFAT32 /* extend dpb only for internal or FAT32 devices */ bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, @@ -2077,6 +2106,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) #else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); #endif + DebugPrintf(("media_check: returning ok\n")); return SUCCESS; } } @@ -2089,19 +2119,25 @@ f_node_ptr xlt_fd(int fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ + FatFSDbgPrintf(("xlt_fd: fd(%i) ?< f_nodes_cnt(%i)\n", fd, f_nodes_cnt)); if (fd < f_nodes_cnt) { fnp = get_near_f_node(); if (fnp != (f_node_ptr)0) { fmemcpy(fnp, &f_nodes[fd], sizeof(*fnp)); + FatFSDbgPrintf(("xlt_fd: fnp->f_count=%i, fnp-fnode=%i\n", fnp->f_count, (fnp-fnode))); if (fnp->f_count <= 0) { release_near_f_node(fnp); fnp = (f_node_ptr) 0; } else + { fnode_fd[fnp - fnode] = fd; + FatFSDbgPrintf(("xlt_fd: success\n")); + } } + else FatFSDbgPrintf(("xlt_fd: get_near_f_node failed\n")); } return fnp; } @@ -2109,6 +2145,7 @@ f_node_ptr xlt_fd(int fd) /* copy a near fnode to the corresponding far one and release it */ STATIC void save_far_f_node(f_node_ptr fnp) { + FatFSDbgPrintf(("save_far_f_node: copying near fnode to far one\n")); fmemcpy(&f_nodes[xlt_fnp(fnp)], fnp, sizeof(*fnp)); release_near_f_node(fnp); } diff --git a/kernel/globals.h b/kernel/globals.h index c8f912a..2696ab8 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -27,6 +27,9 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ +#ifndef __GLOBALS_H +#define __GLOBALS_H + #ifdef VERSION_STRINGS #ifdef MAIN static BYTE *Globals_hRcsId = @@ -422,3 +425,6 @@ GLOBAL BYTE ReturnAnyDosVersionExpected; GLOBAL struct f_node fnode[2]; GLOBAL int fnode_fd[2]; + +#endif /* __GLOBALS_H */ + diff --git a/kernel/inithma.c b/kernel/inithma.c index 952d5e2..3afc67d 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -65,6 +65,7 @@ #include "portab.h" #include "init-mod.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -90,12 +91,6 @@ void int3() #define int3() #endif -#ifdef DEBUG -#define HMAInitPrintf(x) printf x -#else -#define HMAInitPrintf(x) -#endif - #ifdef DEBUG VOID hdump(BYTE FAR * p) { @@ -295,9 +290,11 @@ void MoveKernel(unsigned NewKernelSegment) unsigned len; unsigned jmpseg = CurrentKernelSegment; + /* on 1st call use original link time (unrelocated) TGROUP segment */ if (CurrentKernelSegment == 0) CurrentKernelSegment = FP_SEG(_HMATextEnd); + /* if already relocated to HMA, then ignore move request */ if (CurrentKernelSegment == 0xffff) return; diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index 63dc3c7..fd55d3b 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -34,7 +34,8 @@ segment _LOWTEXT -old_vectors times 16 dd 0 +global _old_vectors +_old_vectors times 16 dd 0 stack_size dw 0 stack_top dw 0 stack_offs dw 0 @@ -129,7 +130,7 @@ general_irq_service: sub [stack_top], ax pushf - call far word [old_vectors+bx] + call far word [_old_vectors+bx] cli add [stack_top], ax @@ -147,7 +148,7 @@ general_irq_service: iret dont_switch: pushf - call far word [old_vectors+bx] + call far word [_old_vectors+bx] pop ds pop ax pop dx @@ -190,7 +191,7 @@ _init_stacks: mov ax, _LOWTEXT mov es, ax - mov di, old_vectors + mov di, _old_vectors mov si, 8 * 4 mov cx, 10h rep movsw diff --git a/kernel/main.c b/kernel/main.c index 30f7cda..691ab83 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -234,6 +234,23 @@ STATIC void setup_int_vectors(void) setvec(0x29, int29_handler); /* required for printf! */ } +#ifdef DEBUGIRQ +extern short old_vectors; +STATIC void printIRQvectors(void) +{ + int i,c=0; + short FAR *pv = MK_FP(0x70 /* ??? */, (short)&old_vectors); + printf("Original IRQ1-16 Int vectors: %x:%x\n", FP_SEG(pv), FP_OFF(pv)); + for (i = 0; i < 16; i++, pv+=2) + { + printf("(%x)%04X:%04X ", i, *pv, *(pv+1)); + c = (c+1)%6; + if (c==0) printf("\n"); + } + printf("\n"); +} +#endif + STATIC void init_kernel(void) { COUNT i; @@ -243,6 +260,8 @@ STATIC void init_kernel(void) LoL->rev_number = REVISION_SEQ; /* move kernel to high conventional RAM, just below the init code */ + /* Note: kernel.asm actually moves and jumps here, but MoveKernel + must still be called to do the necessary segment fixups */ #ifdef __WATCOMC__ lpTop = MK_FP(_CS, 0); #else @@ -251,6 +270,10 @@ STATIC void init_kernel(void) MoveKernel(FP_SEG(lpTop)); /* lpTop should be para-aligned */ + /* Note: during init time (before our MCB chain established) + KernelAlloc returns a para aligned chunk just below last + chunk allocated, lpTop. I.e. lpTop is top of free conv memory + */ lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); /* Initialize IO subsystem */ @@ -258,7 +281,7 @@ STATIC void init_kernel(void) InitPrinters(); InitSerialPorts(); - init_PSPSet(DOS_PSP); + init_PSPSet(DOS_PSP); /* LoL->_cu_psp = DOS_PSP; */ set_DTA(MK_FP(DOS_PSP, 0x80)); PSPInit(); @@ -289,6 +312,11 @@ STATIC void init_kernel(void) /* and do final buffer allocation. */ PostConfig(); +#ifdef DEBUGIRQ + /* displayed stored IRQ vectors, should be original values */ + printIRQvectors(); +#endif + /* Init the file system one more time */ FsConfig(); @@ -423,6 +451,10 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) int nunits = dhp->dh_name[0]; struct dpb FAR *dpb = LoL->DPBp; + /* if we have already chained to at least block driver, + then find last DPB in list, reserve some space in + unused (top of convential) memory, and link it in. + */ if (LoL->nblkdev) { while ((LONG) dpb->dpb_next != -1l) diff --git a/kernel/prf.c b/kernel/prf.c index 338d3da..cc82ba4 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -27,6 +27,7 @@ /****************************************************************/ #include "portab.h" +#include "debug.h" #ifdef FORSYS #include @@ -118,7 +119,7 @@ void put_console(int c) } #endif /* DOSEMU */ -#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) || defined(TEST) +#if defined(DEBUG_NEED_PRINTF) || defined(FORSYS) || defined(_INIT) || defined(TEST) #ifndef FORSYS /* copied from bcc (Bruce's C compiler) stdarg.h */