From c07675522e50f3dc7e5eb4eb9aac6a5c16413c4a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Apr 2001 01:45:26 +0000 Subject: [PATCH] Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@197 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 9 ++++ hdr/dirmatch.h | 15 +++--- hdr/error.h | 5 ++ kernel/chario.c | 9 +++- kernel/config.c | 8 +++ kernel/dsk.c | 17 +++--- kernel/fatfs.c | 4 +- kernel/inithma.c | 5 +- kernel/inthndlr.c | 132 ++++++++++++++++------------------------------ kernel/main.c | 24 ++++++++- kernel/memmgr.c | 5 +- kernel/prf.c | 23 ++++++-- kernel/proto.h | 5 +- kernel/task.c | 13 ++--- 14 files changed, 152 insertions(+), 122 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 67cb613..530c8da 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,12 @@ +2001 Apr 16 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes * Thanks to Martin Stromberg for pointing some bugs out: + * more warnings fixed. + * accidentally opened too many file handles at boot time. + * device drivers should not be linked into the device chain + if they do not take up memory. ++ Add * added printf "%S" and "%Fs" to print far strings. + * enabled and cleaned up INT21/AH=6C (extended open/create). 2001 Apr 15 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 5001ec9..0767990 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,6 +36,9 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -98,17 +101,17 @@ typedef struct struct { - UWORD /* directory has been modified */ + BITS /* directory has been modified */ f_dmod:1; - UWORD /* directory is the root */ + BITS /* directory is the root */ f_droot:1; - UWORD /* fnode is new and needs fill */ + BITS /* fnode is new and needs fill */ f_dnew:1; - UWORD /* fnode is assigned to dir */ + BITS /* fnode is assigned to dir */ f_ddir:1; - UWORD /* directory is full */ + BITS /* directory is full */ f_dfull:1; - UWORD /* filler to avoid a bad bug (feature?) in */ + BITS /* filler to avoid a bad bug (feature?) in */ f_filler:11; /* TC 2.01 */ } dm_flags; /* file flags */ diff --git a/hdr/error.h b/hdr/error.h index 83b9057..1fcb216 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,6 +36,9 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.4 2000/11/02 06:56:53 jimtabor * Fix Share Patch * @@ -117,6 +120,8 @@ static BYTE *error_hRcsId = "$Id$"; #define DE_DEADLOCK -36 #define DE_LOCK -39 +#define DE_FILEEXISTS -80 /* File exists */ + /* Critical error flags */ #define EFLG_READ 0x00 /* Read error */ #define EFLG_WRITE 0x01 /* Write error */ diff --git a/kernel/chario.c b/kernel/chario.c index 318cd55..33cc6a0 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -121,11 +124,11 @@ static BYTE *charioRcsId = "$Id$"; #include "globals.h" #ifdef PROTO -VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); +static VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); struct dhdr FAR *finddev(UWORD attr_mask); #else -VOID kbfill(); +static VOID kbfill(); struct dhdr FAR *finddev(); #endif @@ -147,6 +150,7 @@ struct dhdr FAR *finddev(UWORD attr_mask) return &nul_dev; } +#if 0 VOID cso(COUNT c) { BYTE buf = c; @@ -162,6 +166,7 @@ VOID cso(COUNT c) if (CharReqHdr.r_status & S_ERROR) char_error(&CharReqHdr, lpDevice); } +#endif VOID sto(COUNT c) diff --git a/kernel/config.c b/kernel/config.c index 0d5435e..0044fe8 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.17 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -381,6 +384,9 @@ INIT void PreConfig(void) /* Also, run config.sys to load drivers. */ INIT void PostConfig(void) { + /* close all (device) files */ + + /* Set pass number */ nPass = 2; /* compute lastdrive ... */ @@ -1067,6 +1073,8 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) (result=init_device(dhp, pTmp, mode, top))==SUCCESS ; dhp = next_dhp) { + + printf("result=%d\n", result); next_dhp = dhp->dh_next; if (FP_SEG(next_dhp) == 0xffff) /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 7b9dccb..9688f40 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -32,6 +32,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.14 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -1008,23 +1011,23 @@ static WORD Genblkdev(rqptr rp) y = 2; x = 8; /* any odd ball drives return this */ if (miarray[rp->r_unit].mi_size <= 0xffff) - switch(miarray[rp->r_unit].mi_size) + switch((UWORD)miarray[rp->r_unit].mi_size) { - case 640l: - case 720l: /* 320-360 */ + case 640: + case 720: /* 320-360 */ x = 0; z = 1; break; - case 1440l: /* 720 */ + case 1440: /* 720 */ x = 2; break; - case 2400l: /* 1.2 */ + case 2400: /* 1.2 */ x = 1; break; - case 2880l: /* 1.44 */ + case 2880: /* 1.44 */ x = 7; break; - case 5760l: /* 2.88 almost forgot this one*/ + case 5760: /* 2.88 almost forgot this one*/ x = 9; break; } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 23f4671..625e2be 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.14 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -394,7 +397,6 @@ struct f_node FAR * */ #ifdef DEBUG if (cdsp->cdsFlags & CDSNETWDRV) { - BYTE FAR *p; printf("split path called for redirected file: `%s.%s'\n", fname, fext); return (struct f_node FAR *)0; diff --git a/kernel/inithma.c b/kernel/inithma.c index 725bd26..aa2d772 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -75,6 +75,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.3 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -116,7 +119,7 @@ extern void FAR *DetectXMSDriver(VOID); #ifdef DEBUG -hdump(BYTE FAR *p) +VOID hdump(BYTE FAR *p) { int loop; HMAInitPrintf(("%p", p)); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d8cdd28..0ad6227 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.20 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -1639,99 +1642,52 @@ dispatch: case 0x6a: see case 0x68 case 0x6b: dummy func: return AL=0 */ -#if 0 - /* Extended Open-Creat, not fully functional.*/ + /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ case 0x6c: - switch(r->DL) { - case 0x12: - { - COUNT x = 0; - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) - { - DosClose(rc); - x = 1; - } - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - x += 2; - r->CX = x; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - } - break; - case 0x10: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) - { - DosClose(rc); - r->AX = 80; - r->FLAGS |= FLG_CARRY; - } - else - { - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - r->CX = 0x02; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - } - break; - case 0x02: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) < 0) - goto error_exit; - DosClose(rc); - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - r->CX = 0x03; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - break; - - case 0x11: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) - { - r->CX = 0x01; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - else{ - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - r->CX = 0x02; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - } - break; - - case 0x01: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), r->BL )) < 0 ) - goto error_exit; - else - { - r->CX = 0x01; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - break; - - default: + { + COUNT x = 0; + + if (r->AL != 0 || r->DH != 0 || + (r->DL&0x0f) > 0x2 || (r->DL&0xf0) > 0x10) goto error_invalid; - } + CLEAR_CARRY_FLAG(); + if ((rc = DosOpen(MK_FP(r->DS, r->SI), + (r->DL&0x0f) == 0x1 ? r->BL : 0)) < 0) + { + if (r->DL < 0x10) + goto error_exit; + /* else try to create below */ + } + else switch (r->DL & 0x0f) + { + case 0x0: + /* fail if file exists */ + DosClose(rc); + rc = DE_FILEEXISTS; + goto error_exit; + case 0x1: + /* file exists and opened: OK */ + r->CX = 0x01; + goto break_out; + case 0x2: + /* file exists: replace/open */ + DosClose(rc); + x = 1; + break; + } + /* cases 0x00, 0x01 are finished now */ + if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX)) < 0) + goto error_exit; + + r->CX = x+2; +break_out: + r->AX = rc; + break; + } + /* case 0x6d and above not implemented : see default; return AL=0 */ -#endif } #ifdef DEBUG diff --git a/kernel/main.c b/kernel/main.c index 493dab4..af591ca 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -38,6 +38,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.13 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -312,6 +315,11 @@ INIT void init_kernel(void) #ifndef KDB /* Now process CONFIG.SYS */ DoConfig(); + + /* Close all (device) files */ + for (i = 0; i < lastdrive; i++) + init_DosClose(i); + /* and do final buffer allocation. */ PostConfig(); nblkdev = 0; @@ -324,6 +332,10 @@ INIT void init_kernel(void) DoConfig(); configDone(); + /* Close all (device) files */ + for (i = 0; i < lastdrive; i++) + init_DosClose(i); + /* Now config the final file system */ FsConfig(); @@ -351,7 +363,6 @@ INIT VOID FsConfig(VOID) sfthead->sftt_count = Config.cfgFiles; for (i = 0; i < sfthead->sftt_count; i++) { - init_DosClose(i); sfthead->sftt_table[i].sft_count = 0; sfthead->sftt_table[i].sft_status = -1; } @@ -516,10 +527,21 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ if(cmdLine){ if (mode) + { + /* Don't link in device drivers which do not take up memory */ + if (rq.r_endaddr == (BYTE FAR *)dhp) + return TRUE; + else upBase = rq.r_endaddr; + } else + { + if (rq.r_endaddr == (BYTE FAR *)dhp) + return TRUE; + else lpBase = rq.r_endaddr; } + } if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { dhp->dh_name[0] = rq.r_nunits; diff --git a/kernel/memmgr.c b/kernel/memmgr.c index cd0bcb0..0118975 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.12 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -612,7 +615,7 @@ COUNT DosGetLargestBlock(UWORD FAR * block) #ifdef DEBUG VOID show_chain(void) { - mcb FAR *p, FAR *u; + mcb FAR *p; p = para2far(first_mcb); for (;;) diff --git a/kernel/prf.c b/kernel/prf.c index 8be3991..44fc9f3 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,7 +28,7 @@ #include "portab.h" -COUNT strlen (BYTE * s); /* don't want globals.h, sorry */ +COUNT fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ #ifdef VERSION_STRINGS @@ -37,6 +37,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.7 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -50,6 +53,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.8 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.7 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -224,7 +230,7 @@ COUNT { int base; BYTE s[11], - *p; + FAR *p; int c, flag, size, @@ -303,8 +309,15 @@ COUNT } case 's': - p = *((BYTE **) arg)++; - goto do_outputstring; + p = *((BYTE **) arg)++; + goto do_outputstring; + + case 'F': + fmt++; + /* we assume %Fs here */ + case 'S': + p = *((BYTE FAR **) arg)++; + goto do_outputstring; case 'd': base = -10; @@ -334,7 +347,7 @@ COUNT p = s; do_outputstring: - size -= strlen(p); + size -= fstrlen(p); if (flag == RIGHT ) { diff --git a/kernel/proto.h b/kernel/proto.h index 8b5495a..6081852 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.13 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -180,7 +183,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod /* *** End of change /* chario.c */ -VOID cso(COUNT c); +/* VOID cso(COUNT c);*/ VOID sto(COUNT c); VOID mod_sto(REG UCOUNT c); VOID destr_bs(void); diff --git a/kernel/task.c b/kernel/task.c index c7702a9..c94d867 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.10 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -783,15 +786,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) asize = exe_size; #ifdef DEBUG -{ COUNT i = 0; - printf("loading '"); - while (namep[i]!=0) - { - cso(namep[i]); - i++; - } - printf("' at %04x\n", mem); -} + printf("loading '%S' at %04x\n", namep, mem); #endif /* /// Added open curly brace and "else" clause. We should not attempt