From be2ae12b541f84c01f69f53a4d15e406e5225c54 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Apr 2001 03:21:50 +0000 Subject: [PATCH] See history.txt for the list of fixes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@196 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 7 +- docs/history.txt | 43 ++++++ drivers/devend.asm | 7 +- drivers/floppy.asm | 12 +- drivers/getvec.asm | 11 +- drivers/rdatclk.asm | 52 +++---- drivers/rdpcclk.asm | 5 +- drivers/timer.asm | 35 ++--- drivers/wratclk.asm | 21 ++- drivers/wrpcclk.asm | 15 +-- hdr/cds.h | 4 + hdr/dcb.h | 6 +- hdr/device.h | 9 +- hdr/fat.h | 7 +- hdr/fnode.h | 5 +- hdr/mcb.h | 5 +- hdr/pcb.h | 5 +- hdr/portab.h | 12 +- kernel/asmsupt.asm | 148 ++++++-------------- kernel/blockio.c | 5 +- kernel/break.c | 27 +--- kernel/chario.c | 12 +- kernel/config.c | 157 ++++++++++------------ kernel/console.asm | 7 +- kernel/dosfns.c | 159 ++++++++++------------ kernel/dosnames.c | 5 +- kernel/dsk.c | 32 ++--- kernel/error.c | 7 +- kernel/execrh.asm | 64 +++------ kernel/fatdir.c | 97 ++++++------- kernel/fatfs.c | 142 ++++++++------------ kernel/fattab.c | 39 +++--- kernel/fcbfns.c | 197 ++++++++------------------- kernel/globals.h | 21 ++- kernel/init-mod.h | 7 +- kernel/inithma.c | 79 +++++++---- kernel/inthndlr.c | 321 +++++++++++++++++--------------------------- kernel/intr.asm | 83 +++++++++++- kernel/ioctl.c | 67 ++++----- kernel/kernel.asm | 310 ++++++++++++++++++++++-------------------- kernel/kernel.mak | 16 ++- kernel/main.c | 198 +++++++++++---------------- kernel/memmgr.c | 97 +++++++++---- kernel/misc.c | 22 +-- kernel/network.c | 9 +- kernel/newstuff.c | 95 ++++++------- kernel/nls.c | 5 +- kernel/prf.c | 19 ++- kernel/procsupt.asm | 36 +++-- kernel/proto.h | 109 +++++++-------- kernel/segs.inc | 12 +- kernel/strings.c | 13 +- kernel/sysclk.c | 14 +- kernel/systime.c | 8 +- kernel/task.c | 99 +++++++------- sys/sys.mak | 21 ++- 56 files changed, 1423 insertions(+), 1597 deletions(-) diff --git a/config.m b/config.m index b2911b0..363a6b4 100644 --- a/config.m +++ b/config.m @@ -8,7 +8,9 @@ # These are generic definitions RM=..\utils\rm -f -NASM=nasm + +# Give path to nasm here (or if it's in your path just uncomment the line). +#NASM=nasm # Use these for Turbo C 2.01 @@ -54,6 +56,9 @@ NASM=nasm # $Id$ # # $Log$ +# Revision 1.6 2001/04/15 03:21:49 bartoldeman +# See history.txt for the list of fixes. +# # Revision 1.5 2001/03/22 10:51:04 bartoldeman # Suggest to extract F_SCOPY into libm.lib for Borland C++. # diff --git a/docs/history.txt b/docs/history.txt index a3d6c65..67cb613 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,46 @@ +2001 Apr 15 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Tom: + * apisupt.asm not necessary anymore. + * fix warnings. + * Don't allow directories to be created in DOS_CREAT. + * LoadDevice: drivers should not hang the computer if they fail. + Bart: + * fixed SYS. + * made most calls near again, with a jump/stack trick to + switch between INIT_TEXT and HMA_TEXT. + * INIT_TEXT now calls INT21 itself for some things (setting + PSP, opening/reading/closing devices and (fd)config.sys). + * fixed some carry handling in inthndlr.c and + * drives are checked before trying to access them. + * fixed console driver "busy state" confusion: the built-in + driver had it wrong, nansi.sys had it right: + "If no characters in buffer, return BUSY". + * space savings (RTL related and various other places) + * redirector fixes for find_next. + * CREAT on a device file failed (FD said it already existed). + But for some reason it should not fail in DOS. + * get ATTRIB/other things on a device file should return + FILENOTFOUND, not PATHNOTFOUND. + The sft_status field is not used for redirected drives. + * DosSelectDrv checks the media before setting the default + drive. + * Fixed INT21/AH=3,4,5 (character R/W AUX/PRN). + Hans Lermen: + * critical error handler destroyed AH (entry.asm). + Martin Stromberg + * find_first for volume labels fix. + * check drive at more places and avoid drive "@:" for drive "':". + * config.m: comment out NASM= by default. + * printf fix with DEBUG on. ++ Add Tom: Introduce init_data segment. + New temp file creation implementation. + Bart: added INT21/AH=53. XMSDSK works fine now. + dynamic allocation of Drive Parameter Blocks (they are + all FAR now). ++ Update Bart: moved DOS_PSP to segment 0x60 as segment 0x50 is already used by + GWBASIC/BASICA + 2001 Apr 2 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Bart: Volkov Commander revealed a few bugs: diff --git a/drivers/devend.asm b/drivers/devend.asm index 30bff1e..30031b1 100644 --- a/drivers/devend.asm +++ b/drivers/devend.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -72,7 +75,6 @@ %include "..\kernel\segs.inc" -segment _DATA align=2 class=DATA extern __bssend:wrt DGROUP segment HMA_TEXT @@ -80,9 +82,6 @@ segment HMA_TEXT global _device_end _device_end: - push bp - mov bp,sp mov ax,__bssend mov dx,DGROUP - pop bp ret diff --git a/drivers/floppy.asm b/drivers/floppy.asm index aa502cc..a48273b 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -80,8 +83,13 @@ ;Initial revision. ; - %include "..\kernel\segs.inc" - +%ifndef SYS + %include "..\kernel\segs.inc" +%else +group TGROUP HMA_TEXT _TEXT +segment _TEXT class=CODE +segment HMA_TEXT class=CODE +%endif segment HMA_TEXT ; diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 1dd298e..73a7aaf 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -75,12 +78,8 @@ segment HMA_TEXT global _getvec _getvec: - push bp - mov bp,sp - mov ax,[bp+4] - call getvec - pop bp - ret + mov bx,sp + mov ax,[ss:bx+2] ; ; assembler version - ax = vector number diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 8f66e6d..b98870b 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -60,9 +60,9 @@ ;Initial revision. ; -group IGROUP INIT_TEXT + %include "..\kernel\segs.inc" -segment INIT_TEXT class=INIT +segment INIT_TEXT ; ;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) @@ -73,49 +73,29 @@ segment INIT_TEXT class=INIT ; global _ReadATClock _ReadATClock: + mov ah,2 + int 1ah + jnc @RdAT1140 + sbb ax,ax + ret +@RdAT1140: push bp mov bp,sp - sub sp,byte 10 -; Days = -6 -; Hours = -2 -; Minutes = -8 -; Seconds = -10 ; bcdSeconds = 10 ; bcdMinutes = 8 ; bcdHours = 6 ; bcdDays = 4 - mov ah,2 - int 26 - jnc @RdAT1140 - sbb ax,ax - mov sp,bp - pop bp - ret - nop -@RdAT1140: - mov byte [bp-2],ch ;Hours - mov byte [bp-8],cl ;Minutes - mov byte [bp-10],dh ;Seconds - mov ah,4 - int 26 - mov word [bp-6],dx ;Days - mov word [bp-4],cx - mov ax,word [bp-6] ;Days - mov dx,word [bp-4] - mov bx,word [bp+4] ;bcdDays - mov word [bx],ax - mov word [bx+2],dx - mov al,byte [bp-2] ;Hours mov bx,word [bp+6] ;bcdHours - mov byte [bx],al - mov al,byte [bp-8] ;Minutes + mov byte [bx],ch ;Hours mov bx,word [bp+8] ;bcdMinutes - mov byte [bx],al - mov al,byte [bp-10] ;Seconds + mov byte [bx],cl ;Minutes mov bx,word [bp+10] ;bcdSeconds - mov byte [bx],al + mov byte [bx],dh ;Seconds + mov ah,4 + int 1ah + mov bx,word [bp+4] ;bcdDays + mov word [bx],dx ;Days + mov word [bx+2],cx sub ax,ax - mov sp,bp pop bp ret - nop diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 4288a80..12b52a8 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -84,7 +87,7 @@ segment HMA_TEXT global _ReadPCClock _ReadPCClock: xor ah,ah - int 26 + int 1ah mov bx,sp mov bx,[bx+2] mov [bx],dx diff --git a/drivers/timer.asm b/drivers/timer.asm index 5600daa..757eb95 100644 --- a/drivers/timer.asm +++ b/drivers/timer.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -78,14 +81,11 @@ segment HMA_TEXT ; global _tmark _tmark: - push bp - mov bp,sp xor ah,ah int 01aH ; get current time in ticks xor ah,ah mov word [LastTime],dx ; and store it mov word [LastTime+2],cx - pop bp ret @@ -96,12 +96,11 @@ _tmark: _tdelay: push bp mov bp,sp - sub sp,byte 4 xor ah,ah int 01aH ; get current time in ticks xor ah,ah - mov word [bp-4],dx ; and save it to a local variable - mov word [bp-2],cx ; "Ticks" + mov word bx,dx ; and save it to a local variable + ; "Ticks" (cx:bx) ; ; Do a c equivalent of: ; @@ -111,19 +110,16 @@ _tdelay: mov dx,word [LastTime] add dx,word [bp+4] adc ax,word [bp+6] - cmp ax,word [bp-2] + cmp ax,cx + mov ax,0 ; mov does not affect flags ja short tdel_1 jne short tdel_2 - cmp dx,word [bp-4] + cmp dx,bx ja short tdel_1 tdel_2: - mov ax,1 ; True return - jmp short tdel_3 + inc ax ; True return tdel_1: - xor ax,ax ; False return -tdel_3: - mov sp,bp - pop bp + pop bp ; False return ret @@ -134,7 +130,6 @@ tdel_3: _twait: push bp mov bp,sp - sub sp,byte 4 call _tmark ; mark a start ; ; c equivalent @@ -145,8 +140,7 @@ twait_1: xor ah,ah int 01aH xor ah,ah ; do GetNowTime - mov word [bp-4],dx ; and save it to "Now" - mov word [bp-2],cx + mov bx,dx ; and save it to "Now" (cx:bx) ; ; do comparison ; @@ -154,15 +148,14 @@ twait_1: mov dx,word [LastTime] add dx,word [bp+4] adc ax,word [bp+6] - cmp ax,word [bp-2] + cmp ax,cx jb short twait_1 jne short twait_2 - cmp dx,word [bp-4] + cmp dx,bx jb short twait_1 twait_2: - mov sp,bp pop bp ret -segment _BSS align=2 class=BSS +segment _BSS LastTime: resd 1 diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index 067edc5..c931676 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -84,28 +87,20 @@ segment HMA_TEXT _WriteATClock: push bp mov bp,sp - sub sp,byte 4 -; LocalCopy = -4 ; bcdSeconds = 10 ; bcdMinutes = 8 ; bcdHours = 6 ; bcdDays = 4 - mov bx,word [bp+4] ;bcdDays - mov ax,word [bx] - mov dx,word [bx+2] - mov word [bp-4],ax ;LocalCopy - mov word [bp-2],dx mov ch,byte [bp+6] ;bcdHours mov cl,byte [bp+8] ;bcdMinutes mov dh,byte [bp+10] ;bcdSeconds mov dl,0 mov ah,3 - int 26 - mov cx,word [bp-2] - mov dx,word [bp-4] ;LocalCopy + int 1ah + mov bx,word [bp+4] ;bcdDays + mov dx,word [bx] + mov cx,word [bx+2] mov ah,5 - int 26 - mov sp,bp + int 1ah pop bp ret - nop diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 3e06f73..bd5a4fb 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -79,14 +82,10 @@ segment HMA_TEXT ; global _WritePCClock _WritePCClock: - push bp - mov bp,sp + mov bx,sp ; Ticks = 4 - mov cx,word [bp+6] - mov dx,word [bp+4] ;Ticks + mov cx,word [ss:bx+4] + mov dx,word [ss:bx+2] ;Ticks mov ah,1 - int 26 - mov sp,bp - pop bp + int 1ah ret - nop diff --git a/hdr/cds.h b/hdr/cds.h index 2e42adf..27ca283 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -34,6 +34,9 @@ static BYTE *Cds_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -116,4 +119,5 @@ cdstbl; #define CDSPHYSDRV 0x4000 #define CDSJOINED 0x2000 #define CDSSUBST 0x1000 +#define CDSVALID (CDSNETWDRV | CDSPHYSDRV) diff --git a/hdr/dcb.h b/hdr/dcb.h index 662aa11..8caa11e 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,6 +36,9 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -112,5 +115,6 @@ struct dpb }; -#define UNKNCLUSTER 0xffff /* 0xffff = unknown for DOS */ +#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ +#define UNKNCLSTFREE 0xffff /* 0xffff = unknown for DOS */ diff --git a/hdr/device.h b/hdr/device.h index 8f1e0cd..93f25ce 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -448,12 +451,6 @@ typedef bpb FAR *bpbptr; typedef BYTE FAR *byteptr; typedef struct dhdr FAR *dhdrptr; -/* - * externals - */ - -extern BYTE FAR *device_end(); - /* * end of device.h */ diff --git a/hdr/fat.h b/hdr/fat.h index 145b9a3..6a287a0 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.5 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -117,8 +120,8 @@ static BYTE *fat_hRcsId = "$Id$"; /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define FAT_MAGIC 4086 -#define FAT_MAGIC16 65526 -#define FAT_MAGIC32 268435456 +#define FAT_MAGIC16 ((unsigned)65526l) +#define FAT_MAGIC32 268435456l #define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 || ((dpbp)->dpb_size)<=FAT_MAGIC32 ) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC || ((dpbp)->dpb_size)<=FAT_MAGIC16 ) diff --git a/hdr/fnode.h b/hdr/fnode.h index 349706e..fc829f0 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -108,7 +111,7 @@ struct f_node ULONG f_diroff; /* offset of the dir entry */ UWORD f_dirstart; /* the starting cluster of dir */ /* when dir is not root */ - struct dpb *f_dpb; /* the block device for file */ + struct dpb FAR *f_dpb; /* the block device for file */ ULONG f_dsize; /* file size (for directories) */ ULONG f_offset; /* byte offset for next op */ diff --git a/hdr/mcb.h b/hdr/mcb.h index 4e8e117..273d3b6 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,6 +36,9 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.6 2000/08/06 04:27:07 jimtabor * See history.txt * @@ -104,7 +107,7 @@ static BYTE *mcb_hRcsId = "$Id$"; #define MCB_NORMAL 0x4d #define MCB_LAST 0x5a -#define DOS_PSP 0x0050 /* 0x0008 What? seg 8 =0:0080 */ +#define DOS_PSP 0x0060 /* 0x0008 What? seg 8 =0:0080 */ #define FREE_PSP 0 #define MCB_SIZE(x) ((((LONG)(x))<<4)+sizeof(mcb)) diff --git a/hdr/pcb.h b/hdr/pcb.h index 292f39a..bec11d1 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -57,6 +57,9 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -128,7 +131,7 @@ xreg; Furthermore, the PUSH$ALL macro must push ES first and AX last. -- 2000/03/22 ska*/ /* maps MS-DOS unique stacking order */ -typedef struct +typedef struct _iregss { xreg a, b, diff --git a/hdr/portab.h b/hdr/portab.h index 0214ea3..936d66a 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,9 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -238,4 +241,11 @@ typedef signed long LONG; #else #define FDCALL #define CDECL -#endif \ No newline at end of file +#endif + +#ifdef I86 + /* commandline overflow - removing /DPROTO + TE*/ + #define PROTO +#endif + diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index baac182..27ebb59 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -34,6 +34,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -92,10 +95,9 @@ segment HMA_TEXT ;********************************************************************* ; this implements some of the common string handling functions ; -; every function has 2 entries +; every function has 1 entry ; ; NEAR FUNC() -; FAR init_call_FUNC() ; ; currently done: ; @@ -143,28 +145,23 @@ common_setup: ; are preloaded here ; the destination pointer, d = arg1 - mov di,[bp+6] + mov di,[bp+4] ; Get the source pointer, s = arg2 - mov si,[bp+8] + mov si,[bp+6] ; Get the repitition count, n = arg3 - mov cx,[bp+10] + mov cx,[bp+8] jmp bx - + ;*********************************************** ; ; VOID memcpy(REG BYTE *s, REG BYTE *d, REG COUNT n); ; global _memcpy - global _init_call_memcpy _memcpy: - pop ax - push cs - push ax -_init_call_memcpy: call common_setup @@ -186,7 +183,7 @@ common_return: pop di pop si pop bp - retf + ret @@ -196,23 +193,18 @@ common_return: ; global __fmemcpy global _fmemcpy - global _init_call_fmemcpy _fmemcpy: __fmemcpy: - pop ax - push cs - push ax -_init_call_fmemcpy: call common_setup ; Get the far source pointer, s - lds si,[bp+10] + lds si,[bp+8] ; Get the far destination pointer d - les di,[bp+6] + les di,[bp+4] ; Get the repetition count, n - mov cx,[bp+14] + mov cx,[bp+12] jmp short domemcpy @@ -222,23 +214,17 @@ _init_call_fmemcpy: ; VOID fmemset(REG VOID FAR *d, REG BYTE ch, REG COUNT n); ; global _fmemset - global _init_call_fmemset _fmemset: - pop ax - push cs - push ax -_init_call_fmemset: - call common_setup ; Get the repetition count, n - mov cx,[bp+12] + mov cx,[bp+10] ; Get the far source pointer, s - les di,[bp+6] + les di,[bp+4] ; Get the far destination pointer ch - mov al,[bp+10] + mov al,[bp+8] domemset: mov ah, al @@ -255,23 +241,17 @@ domemset: ; VOID memset(REG VOID *d, REG BYTE ch, REG COUNT n); ; global _memset - global _init_call_memset _memset: - pop ax - push cs - push ax -_init_call_memset: - call common_setup ; Get the far source pointer, s - ; mov di,[bp+6] + ; mov di,[bp+4] ; Get the char ch - mov ax,si ; mov al, [bp+8] + mov ax,si ; mov al, [bp+6] ; Get the repititon count, n - ; mov cx,[bp+10] + ; mov cx,[bp+8] jmp short domemset @@ -281,21 +261,16 @@ _init_call_memset: ;*************************************************************** global _fstrncpy - global _init_call_fstrncpy _fstrncpy: - pop ax - push cs - push ax -_init_call_fstrncpy: call common_setup ; Get the source pointer, ss - lds si,[bp+10] + lds si,[bp+8] ; and the destination pointer, d - les di,[bp+6] + les di,[bp+4] - mov cx,[bp+14] + mov cx,[bp+12] jcxz common_return ;; dec cx @@ -318,38 +293,28 @@ store_one_byte: xor al,al global _fstrcpy - global _init_call_fstrcpy _fstrcpy: - pop ax - push cs - push ax -_init_call_fstrcpy: call common_setup ; Get the source pointer, ss - lds si,[bp+10] + lds si,[bp+8] ; and the destination pointer, d - les di,[bp+6] + les di,[bp+4] jmp short dostrcpy ;****** global _strcpy - global _init_call_strcpy _strcpy: - pop ax - push cs - push ax -_init_call_strcpy: call common_setup ; Get the source pointer, ss - ;mov si,[bp+8] + ;mov si,[bp+6] ; and the destination pointer, d - ;mov di,[bp+6] + ;mov di,[bp+4] dostrcpy: @@ -364,27 +329,17 @@ strcpy_loop: ;****************************************************************** global _fstrlen - global _init_call_fstrlen _fstrlen: - pop ax - push cs - push ax -_init_call_fstrlen: call common_setup ; Get the source pointer, ss - les di,[bp+6] + les di,[bp+4] jmp short dostrlen ;********************************************** global _strlen - global _init_call_strlen _strlen: - pop ax - push cs - push ax -_init_call_strlen: call common_setup ; The source pointer, ss, arg1 was loaded as di @@ -398,21 +353,16 @@ dostrlen: not ax dec ax - jmp common_return + jmp short common_return ;************************************************************ global _strchr - global _init_call_strchr _strchr: - pop ax - push cs - push ax -_init_call_strchr: call common_setup ; Get the source pointer, ss - ; mov si,[bp+6] - ; mov bx,[bp+8] + ; mov si,[bp+4] + ; mov bx,[bp+6] mov bx,si mov si,di @@ -432,38 +382,28 @@ strchr_found: ;********************************************************************** global _fstrcmp - global _init_call_fstrcmp _fstrcmp: - pop ax - push cs - push ax -_init_call_fstrcmp: call common_setup ; Get the source pointer, ss - lds si,[bp+6] + lds si,[bp+4] ; and the destination pointer, d - les di,[bp+10] + les di,[bp+8] jmp dostrcmp ;****** global _strcmp - global _init_call_strcmp _strcmp: - pop ax - push cs - push ax -_init_call_strcmp: call common_setup ; Get the source pointer, ss - ; mov si,[bp+6] + ; mov si,[bp+4] ; and the destination pointer, d - ; mov di,[bp+8] + ; mov di,[bp+6] xchg si,di dostrcmp: @@ -475,39 +415,29 @@ dostrcmp: ;********************************************************************** global _fstrncmp - global _init_call_fstrncmp _fstrncmp: - pop ax - push cs - push ax -_init_call_fstrncmp: call common_setup ; Get the source pointer, ss - lds si,[bp+6] + lds si,[bp+4] ; and the destination pointer, d - les di,[bp+10] - mov cx,[bp+12] + les di,[bp+8] + mov cx,[bp+10] jmp short dostrncmp ;****** global _strncmp - global _init_call_strncmp _strncmp: - pop ax - push cs - push ax -_init_call_strncmp: call common_setup ; Get the source pointer, ss - ;mov si,[bp+6] + ;mov si,[bp+4] ; and the destination pointer, d - ;mov di,[bp+8] - ;mov cx,[bp+10] + ;mov di,[bp+6] + ;mov cx,[bp+8] xchg si,di dostrncmp: diff --git a/kernel/blockio.c b/kernel/blockio.c index 76ed45e..fc99943 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -530,7 +533,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod { /* REG struct dpb *dpbp = &blk_devices[dsk]; */ - REG struct dpb *dpbp = (struct dpb *)CDSp->cds_table[dsk].cdsDpb; + REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb; for (;;) { diff --git a/kernel/break.c b/kernel/break.c index a05f407..4cfb36e 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -30,7 +30,7 @@ #include "portab.h" #include "globals.h" -extern void FAR init_call_spawn_int23(void); +extern void spawn_int23(void); #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -90,25 +93,5 @@ void handle_break(void) if (InDOS) --InDOS; /* fail-safe */ - { - /*TE PATCH - CtrlC at DosInput (like C:>DATE does) - Nukes the Kernel. - - it looks like ENTRY.ASM+PROCSUPT.ASM - got out of sync. - - spawn_int() assumes a stack layout at - usr_ss:usr:sp. but usr:ss currently contains 0 - - this patch helps FreeDos to survive CtrlC, - but should clearly be done somehow else. - */ - extern ULONG lpUserStack; - - usr_ss = FP_SEG(lpUserStack); - usr_sp = FP_OFF(lpUserStack); - } - - init_call_spawn_int23(); /* invoke user INT-23 and never come back */ + spawn_int23(); /* invoke user INT-23 and never come back */ } diff --git a/kernel/chario.c b/kernel/chario.c index 45aa2be..318cd55 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -117,8 +120,6 @@ static BYTE *charioRcsId = "$Id$"; #include "globals.h" -static BYTE *con_name = "CON"; - #ifdef PROTO VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); struct dhdr FAR *finddev(UWORD attr_mask); @@ -192,7 +193,7 @@ VOID Do_DosIdle_loop(void) { FOREVER { - if (StdinBusy()) + if (!StdinBusy()) return; else { @@ -407,8 +408,3 @@ VOID sti(keyboard FAR * kp) } } } - -VOID FAR init_call_sti(keyboard FAR * kp) -{ - sti(kp); -} diff --git a/kernel/config.c b/kernel/config.c index 0967909..0d5435e 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -27,7 +27,7 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ - +#define CONFIG #include "init-mod.h" #include "portab.h" @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.16 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -178,15 +181,14 @@ static BYTE *RcsId = "$Id$"; #define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) #endif -BYTE FAR *lpBase; -BYTE FAR *upBase; -static BYTE FAR *lpOldLast; -static BYTE FAR *upOldLast; -static COUNT nCfgLine; -static COUNT nPass; - COUNT UmbState; -static BYTE szLine[256]; -static BYTE szBuf[256]; +BYTE FAR *lpBase = 0; +BYTE FAR *upBase = 0; +static BYTE FAR *lpOldLast = 0; +static COUNT nCfgLine = 0; +static COUNT nPass = 0; + COUNT UmbState = 0; +static BYTE szLine[256]={0}; +static BYTE szBuf[256]={0}; int singleStep = 0; @@ -220,8 +222,6 @@ INIT int SkipLine(char *pLine); INIT char *stristr(char *s1, char *s2); INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); -INIT BYTE FAR *KernelAlloc(WORD nBytes); - extern void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ @@ -337,9 +337,9 @@ INIT void PreConfig(void) f_nodes_cnt = Config.cfgFiles; /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ - FCBp = (sfttbl FAR *) + /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft)); + + Config.cfgFiles * sizeof(sft));*/ sfthead = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); @@ -347,11 +347,15 @@ INIT void PreConfig(void) CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + DPBp = (struct dpb FAR *) + KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); + #ifdef DEBUG printf("Preliminary f_node allocated at at 0x%p\n",f_nodes); printf("Preliminary FCB table allocated at 0x%p\n",FCBp); printf("Preliminary sft table allocated at 0x%p\n",sfthead); printf("Preliminary CDS table allocated at 0x%p\n",CDSp); + printf("Preliminary DPB table allocated at 0x%p\n",DPBp); #endif /* Done. Now initialize the MCB structure */ @@ -369,7 +373,7 @@ INIT void PreConfig(void) /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), - (ram_top << 6) - first_mcb - 1); + ((UCOUNT)ram_top << 6) - first_mcb - 1); nPass = 1; } @@ -416,9 +420,9 @@ INIT void PostConfig(void) f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ - FCBp = (sfttbl FAR *) + /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft)); + + Config.cfgFiles * sizeof(sft));*/ sfthead = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); @@ -426,12 +430,17 @@ INIT void PostConfig(void) CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + DPBp = (struct dpb FAR *) + KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); + + #ifdef DEBUG printf("f_node allocated at 0x%p\n",f_nodes); printf("FCB table allocated at 0x%p\n",FCBp); printf("sft table allocated at 0x%p\n",sfthead); printf("CDS table allocated at 0x%p\n",CDSp); + printf("DPB table allocated at 0x%p\n",DPBp); #endif if (Config.cfgStacks) { @@ -452,8 +461,6 @@ INIT void PostConfig(void) /* This code must be executed after device drivers has been loaded */ INIT VOID configDone(VOID) { - COUNT i; - HMAconfig(TRUE); /* final HMA processing */ @@ -470,7 +477,7 @@ INIT VOID configDone(VOID) /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), - (ram_top << 6) - first_mcb - 1); + ((UCOUNT)ram_top << 6) - first_mcb - 1); if(UmbState == 1) { @@ -480,10 +487,12 @@ INIT VOID configDone(VOID) /* Check if any devices were loaded in umb */ if(umb_start != FP_SEG(upBase) ){ /* make last block normal with SC for the devices */ - mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), - (FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4)) - uppermem_root - 1); + + UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + + mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), umr_new - uppermem_root - 1); - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + uppermem_root = umr_new; zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), (umb_start + UMB_top ) - uppermem_root - 1); upBase += 16; @@ -511,12 +520,12 @@ INIT VOID DoConfig(VOID) /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ - if ((nFileDesc = dos_open((BYTE FAR *) "fdconfig.sys", 0)) < 0) + if ((nFileDesc = init_DosOpen("fdconfig.sys", 0)) < 0) { #ifdef DEBUG printf("FDCONFIG.SYS not found\n"); #endif - if ((nFileDesc = dos_open((BYTE FAR *) "config.sys", 0)) < 0) + if ((nFileDesc = init_DosOpen("config.sys", 0)) < 0) { #ifdef DEBUG printf("CONFIG.SYS not found\n"); @@ -557,7 +566,7 @@ INIT VOID DoConfig(VOID) /* Read a line from config */ /* Interrupt processing if read error or no bytes read */ - if ((nRetCode = dos_read(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) + if ((nRetCode = init_DosRead(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) break; /* If the buffer was not filled completely, append a @@ -571,6 +580,7 @@ INIT VOID DoConfig(VOID) while (!bEof && *pLine != EOF) { + /* Do it here in the loop. */ @@ -581,11 +591,10 @@ INIT VOID DoConfig(VOID) if(!Umb_Test()){ UmbState = 1; upBase = MK_FP(umb_start , 0); - uppermem_root = umb_start; /* reset root */ - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + uppermem_root = umb_start; /* setup the real mcb for the devicehigh block */ - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), UMB_top - 1); + zumcb_init((mcb FAR *) upBase, UMB_top - 1); upBase += 16; } } @@ -632,7 +641,7 @@ INIT VOID DoConfig(VOID) pLine += strlen(pLine) + 1; } } - dos_close(nFileDesc); + init_DosClose(nFileDesc); } INIT struct table *LookUp(struct table *p, BYTE * token) @@ -763,7 +772,6 @@ INIT static VOID Files(BYTE * pLine) INIT static VOID Lastdrive(BYTE * pLine) { /* Format: LASTDRIVE = letter */ - COUNT nFiles; BYTE drv; pLine = skipwh(pLine); @@ -789,6 +797,7 @@ INIT static VOID Dosmem(BYTE * pLine) BYTE *pTmp; BYTE UMBwanted = FALSE, HMAwanted = FALSE; + extern BYTE INITDataSegmentClaimed; pLine = GetStringArg(pLine, szBuf); @@ -801,7 +810,7 @@ INIT static VOID Dosmem(BYTE * pLine) { if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; } if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; } - + if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; } pTmp = skipwh(pTmp); if (*pTmp != ',') @@ -966,16 +975,16 @@ INIT static VOID Break(BYTE * pLine) INIT static VOID Numlock(BYTE * pLine) { + extern VOID keycheck(); + /* Format: NUMLOCK = (ON | OFF) */ - iregs regs; BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17); GetStringArg(pLine, szBuf); *keyflags &= ~32; *keyflags |= strcasecmp(szBuf, "OFF") ? 32 : 0; - regs.a.b.h = 1; - init_call_intr(0x16, ®s); + keycheck(); } INIT static VOID DeviceHigh(BYTE * pLine) @@ -1002,41 +1011,32 @@ INIT void Device(BYTE * pLine) INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { - VOID FAR *driver_ptr; BYTE *pTmp; exec_blk eb; struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; - UWORD dev_seg; BOOL result; if(mode) - dev_seg = (((ULONG) FP_SEG(upBase) << 4) + FP_OFF(upBase) + 0xf) >> 4; + dhp = AlignParagraph(upBase); else - dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; + dhp = AlignParagraph(lpBase); /* Get the device driver name */ GetStringArg(pLine, szBuf); /* The driver is loaded at the top of allocated memory. */ /* The device driver is paragraph aligned. */ - eb.load.reloc = eb.load.load_seg = dev_seg; - dhp = MK_FP(dev_seg, 0); + eb.load.reloc = eb.load.load_seg = FP_SEG(dhp); #ifdef DEBUG printf("Loading device driver %s at segment %04x\n", - szBuf, dev_seg); + szBuf, FP_SEG(dhp)); #endif if (DosExec(3, &eb, szBuf) == SUCCESS) { - /* TE this fixes the loading of devices drivers with - multiple devices in it. NUMEGA's SoftIce is such a beast - */ - - for ( ; ; ) - { /* that's a nice hack >:-) although we don't want HIMEM.SYS,(it's not free), other people @@ -1058,28 +1058,27 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) strcat(pTmp, " /TESTMEM:OFF\r\n"); } } - /* end of HIMEM.SYS HACK */ + /* end of HIMEM.SYS HACK */ - result=init_device(dhp, pTmp, mode, top); - - if(!result){ - next_dhp = dhp->dh_next; - /* Link in device driver and save nul_dev pointer to next */ - dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; - } - - /* multiple devices end */ - if (FP_OFF(next_dhp) == 0xffff) /* end of internal chain */ - break; - - FP_OFF(dhp) = FP_OFF(next_dhp); - - if (FP_SEG(next_dhp) != 0xffff) - { - printf("multisegmented device driver found, next %p\n",next_dhp); /* give warning message */ - dhp = next_dhp; - } + /* TE this fixes the loading of devices drivers with + multiple devices in it. NUMEGA's SoftIce is such a beast + */ + for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && + (result=init_device(dhp, pTmp, mode, top))==SUCCESS + ; dhp = next_dhp) + { + next_dhp = dhp->dh_next; + if (FP_SEG(next_dhp) == 0xffff) + /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ + next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(next_dhp)); +#ifdef DEBUG + else if (FP_OFF(next_dhp) != 0xffff) /* end of internal chain */ + printf("multisegmented device driver found, next %p\n",next_dhp); + /* give warning message */ +#endif + /* Link in device driver and save nul_dev pointer to next */ + dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; } HMAconfig(FALSE); /* let the HMA claim HMA usage */ @@ -1109,7 +1108,7 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes) lpBase = AlignParagraph(lpBase); lpAllocated = lpBase; - if (0x10000 - FP_OFF(lpBase) <= nBytes) + if (0xffff - FP_OFF(lpBase) <= nBytes) { UWORD newOffs = (FP_OFF(lpBase) + nBytes) & 0xFFFF; UWORD newSeg = FP_SEG(lpBase) + 0x1000; @@ -1140,19 +1139,13 @@ INIT BYTE FAR *KernelAllocDma(WORD bytes) INIT void FAR *AlignParagraph(VOID FAR * lpPtr) { - ULONG lTemp; UWORD uSegVal; /* First, convert the segmented pointer to linear address */ - lTemp = FP_SEG(lpPtr); - lTemp = (lTemp << 4) + FP_OFF(lpPtr); - - /* Next, round up the linear address to a paragraph boundary. */ - lTemp += 0x0f; - lTemp &= 0xfffffff0l; - - /* Break it into segments. */ - uSegVal = (UWORD) (lTemp >> 4); + uSegVal = FP_SEG(lpPtr); + uSegVal += (FP_OFF(lpPtr)+0xf) >> 4; + if (FP_OFF(lpPtr) > 0xfff0) + uSegVal += 0x1000; /* handle overflow */ /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ @@ -1238,7 +1231,7 @@ INIT COUNT toupper(COUNT c) /* The following code is 8086 dependant */ -#ifdef KERNEL +#if 1 /* ifdef KERNEL */ INIT VOID mcb_init(mcb FAR * mcbp, UWORD size) { @@ -1314,8 +1307,6 @@ char *stristr(char *s1, char *s2) /* compare two ASCII strings ignoring case */ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s) { - int loop; - while (*s != '\0' && *d != '\0') { diff --git a/kernel/console.asm b/kernel/console.asm index ad5b0fa..8705147 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.6 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.5 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -285,8 +288,8 @@ ConIS2: lds bx,[_ReqPktPtr] ; Set the status mov [bx+0Dh],al ConCharReady: - jmp _IODone ; key ready (busy=1) + jmp _IOExit ; key ready (busy=0) ConNoChar: - jmp _IOExit ; no key ready (busy=0) + jmp _IODone ; no key ready (busy=1) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index da67c3d..3cc66b5 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.15 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.14 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -776,6 +779,12 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) /* WORD i;*/ COUNT result, drive; + /* NEVER EVER allow directories to be created */ + if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + { + return DE_ACCESS; + } + /* get a free handle */ if ((hndl = get_free_hndl()) == 0xff) return DE_TOOMANY; @@ -815,8 +824,7 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; sftp->sft_mode = attrib; - result = int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); - result = -result; + result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); if (result == SUCCESS) { sftp->sft_count += 1; p->ps_filetab[hndl] = sft_idx; @@ -892,7 +900,7 @@ COUNT DosDup(COUNT Handle) return DE_TOOMANY; /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & SFT_FDEVICE) || (Sftp->sft_status >= 0)) + if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[Handle]; Sftp->sft_count += 1; @@ -925,7 +933,7 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) } /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & SFT_FDEVICE) || (Sftp->sft_status >= 0)) + if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[OldHandle]; @@ -1004,8 +1012,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; - result = int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); - result = -result; + result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); if (result == SUCCESS) { sftp->sft_count += 1; p->ps_filetab[hndl] = sft_idx; @@ -1080,25 +1087,20 @@ COUNT DosClose(COUNT hndl) /* remote sub sft_count. */ + p->ps_filetab[hndl] = 0xff; if (s->sft_flags & SFT_FSHARED) { int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); - p->ps_filetab[hndl] = 0xff; return SUCCESS; } /* now just drop the count if a device, else */ /* call file system handler */ + s->sft_count -= 1; if (s->sft_flags & SFT_FDEVICE) - { - p->ps_filetab[hndl] = 0xff; - s->sft_count -= 1; return SUCCESS; - } else { - p->ps_filetab[hndl] = 0xff; - s->sft_count -= 1; if (s->sft_count > 0) return SUCCESS; else { @@ -1113,9 +1115,9 @@ COUNT DosClose(COUNT hndl) } } -VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) +VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) { - struct dpb *dpbp; + struct dpb FAR *dpbp; struct cds FAR *cdsp; static COUNT rg[4]; @@ -1123,36 +1125,29 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive >= lastdrive) - { - *spc = -1; - return; - } + *spc = -1; + if (drive >= lastdrive) + return; + + cdsp = &CDSp->cds_table[drive]; - cdsp = &CDSp->cds_table[drive]; - if (cdsp->cdsFlags & CDSNETWDRV) + if (!(cdsp->cdsFlags & CDSVALID)) + return; + + if (cdsp->cdsFlags & CDSNETWDRV) { - int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); - *spc = (COUNT) rg[0]; - *nc = (COUNT) rg[1]; - *bps = (COUNT) rg[2]; - *navc = (COUNT) rg[3]; - return; + *spc = (COUNT) rg[0]; + *nc = (COUNT) rg[1]; + *bps = (COUNT) rg[2]; + *navc = (COUNT) rg[3]; + return; } - dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; - if (dpbp == 0) - { - *spc = -1; - return; - } - - if ((media_check(dpbp) < 0)) - { - *spc = -1; - return; - } + dpbp = CDSp->cds_table[drive].cdsDpb; + if (dpbp == NULL || media_check(dpbp) < 0) + return; /* get the data vailable from dpb */ *nc = dpbp->dpb_size; @@ -1164,26 +1159,20 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, *navc = dos_free(dpbp); } -COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) +COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { - REG struct cds FAR *cdsp; - /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); - /* first check for valid drive */ - if (drive < 0 || drive >= lastdrive) { - return DE_INVLDDRV; - } - - cdsp = &CDSp->cds_table[drive]; - current_ldt = cdsp; - - if (!(cdsp->cdsFlags & CDSNETWDRV) && (cdsp->cdsDpb == 0)) { - return DE_INVLDDRV; + /* first check for valid drive */ + if (drive >= lastdrive || !(CDSp->cds_table[drive].cdsFlags & CDSVALID)) { + return DE_INVLDDRV; } + + current_ldt = &CDSp->cds_table[drive]; - fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[1 + cdsp->cdsJoinOffset], s, 64); + fsncopy((BYTE FAR *) & current_ldt->cdsCurrentPath[1 + current_ldt->cdsJoinOffset], + s, 64); return SUCCESS; } @@ -1225,13 +1214,12 @@ COUNT DosChangeDir(BYTE FAR * s) p = PriPathName; while(*p) printf("%c", *p++); printf("'\n"); #endif - result = int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0); + result = -int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0); #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='", result); p = cdsd->cdsCurrentPath; while(p) printf("%c", *p++) printf("'\n"); #endif - result = -result; if (result != SUCCESS) { return DE_PATHNOTFND; } @@ -1330,10 +1318,9 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) static UWORD srfa[5]; COUNT result, drive; struct cds FAR *last_cds; - BYTE FAR * p; if (IsDevice(name)) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive = get_verify_drive(name); @@ -1360,10 +1347,10 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) { last_cds = current_ldt; current_ldt = &CDSp->cds_table[drive]; - result = int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); - result = -result; + result = -int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); current_ldt = last_cds; *attrp = srfa[0]; + return result; } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1378,20 +1365,17 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) int i; for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; tmp_name[i] = '\0'; - result = dos_getfattr(tmp_name, attrp); + return dos_getfattr(tmp_name, attrp); } -/* Sorry Ron someone else found this, see history.txt */ - return result; } COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) { COUNT result, drive; struct cds FAR *last_cds; - BYTE FAR *p; if (IsDevice(name) ) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive = get_verify_drive(name); @@ -1408,9 +1392,9 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) { last_cds = current_ldt; current_ldt = &CDSp->cds_table[drive]; - result = int2f_Remote_call(REM_SETATTR, 0, 0, 0, 0, 0, MK_FP(0, attrp)); - result = -result; + result = -int2f_Remote_call(REM_SETATTR, 0, 0, 0, 0, 0, MK_FP(0, attrp)); current_ldt = last_cds; + return result; } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1422,16 +1406,19 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) int i; for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; tmp_name[i] = '\0'; - result = dos_setfattr(name, attrp); + return dos_setfattr(name, attrp); } - return result; } -BYTE DosSelectDrv(BYTE drv) +UBYTE DosSelectDrv(UBYTE drv) { - if ((0 <= drv) && (drv < lastdrive) &&(CDSp->cds_table[drv].cdsFlags & 0xf000)) + struct cds FAR *cdsp = &CDSp->cds_table[drv]; + + if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID) && + ((cdsp->cdsFlags & CDSNETWDRV) || + (cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS))) { - current_ldt = &CDSp->cds_table[drv]; + current_ldt = cdsp; default_drive = drv; } return lastdrive; @@ -1442,7 +1429,7 @@ COUNT DosDelete(BYTE FAR *path) COUNT result, drive; if (IsDevice(path)) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive = get_verify_drive(path); @@ -1455,12 +1442,10 @@ COUNT DosDelete(BYTE FAR *path) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); } else { - result = dos_delete(path); + return dos_delete(path); } - return result; } COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) @@ -1468,7 +1453,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) COUNT result, drive1, drive2; if (IsDevice(path1) || IsDevice(path2)) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive1 = get_verify_drive(path1); @@ -1486,12 +1471,10 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) } current_ldt = &CDSp->cds_table[drive1]; if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); } else { - result = dos_rename(path1, path2); + return dos_rename(path1, path2); } - return result; } COUNT DosMkdir(BYTE FAR * dir) @@ -1512,12 +1495,10 @@ COUNT DosMkdir(BYTE FAR * dir) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); } else { - result = dos_mkdir(dir); + return dos_mkdir(dir); } - return result; } COUNT DosRmdir(BYTE FAR * dir) @@ -1538,12 +1519,10 @@ COUNT DosRmdir(BYTE FAR * dir) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); } else { - result = dos_rmdir(dir); + return dos_rmdir(dir); } - return result; } /* /// Added for SHARE. - Ron Cemer */ diff --git a/kernel/dosnames.c b/kernel/dosnames.c index bb2a929..32d7866 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -206,7 +209,7 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, lpszLclFile = lpszFileName + 1; ++lpszFileName; } - nDirCnt = lpszLclFile - lpszLclDir; + nDirCnt = FP_OFF(lpszLclFile) - FP_OFF(lpszLclDir); /* Parse out the file name portion. */ lpszFileName = lpszLclFile; while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) diff --git a/kernel/dsk.c b/kernel/dsk.c index 685a8e0..7b9dccb 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -26,13 +26,15 @@ #include "portab.h" #include "globals.h" - #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; #endif /* * $Log$ + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.13 2001/03/27 20:27:43 bartoldeman * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. * @@ -662,7 +664,7 @@ restart: /* yes, it's a GOTO >:-) */ return PartitionDone; } -COUNT FAR init_call_blk_driver(rqptr rp) +COUNT FAR blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) return failure(E_UNIT); @@ -705,7 +707,7 @@ WORD _dsk_init(rqptr rp) pmiarray->mi_offset = 0l; pmiarray->mi_drive = Unit; - fsarray[Unit].fs_serialno = 0x12345678; + fsarray[Unit].fs_serialno = 0x12345678l; pbpbarray = getPBpbarray(Unit); @@ -1004,8 +1006,10 @@ static WORD Genblkdev(rqptr rp) if (!hd(miarray[rp->r_unit].mi_drive)){ y = 2; - switch(miarray[rp->r_unit].mi_size) - { + x = 8; /* any odd ball drives return this */ + if (miarray[rp->r_unit].mi_size <= 0xffff) + switch(miarray[rp->r_unit].mi_size) + { case 640l: case 720l: /* 320-360 */ x = 0; @@ -1023,15 +1027,13 @@ static WORD Genblkdev(rqptr rp) case 5760l: /* 2.88 almost forgot this one*/ x = 9; break; - default: - x = 8; /* any odd ball drives return this */ - } + } } gblp->gbio_devtype = (UBYTE) x; gblp->gbio_devattrib = (UWORD) y; gblp->gbio_media = (UBYTE) z; gblp->gbio_ncyl = miarray[rp->r_unit].mi_cyls; - gblp->gbio_bpb = bpbarray[rp->r_unit]; + fmemcpy(&gblp->gbio_bpb, &bpbarray[rp->r_unit], sizeof(gblp->gbio_bpb)); gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; break; } @@ -1092,13 +1094,10 @@ WORD blockio(rqptr rp) total = 0; trans = rp->r_trans; tmark(); - for ( - remaining = rp->r_count, - start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) + remaining = rp->r_count; + start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) + miarray[rp->r_unit].mi_offset; - remaining > 0; - remaining -= count, trans += count * SEC_SIZE, start += count - ) + while(remaining > 0) { count = ltop(&track, §or, &head, rp->r_unit, remaining, start, trans); @@ -1151,6 +1150,9 @@ WORD blockio(rqptr rp) return dskerr(ret); } total += count; + remaining -= count; + trans += count * SEC_SIZE; + start += count; } rp->r_count = total; return S_DONE; diff --git a/kernel/error.c b/kernel/error.c index 2f3b65a..507cbbd 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -34,6 +34,9 @@ static BYTE *errorRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -125,10 +128,6 @@ VOID fatal(BYTE * err_msg) for (;;) ; } -VOID FAR init_call_fatal(BYTE * err_msg) -{ - fatal(err_msg); -} #endif /* Abort, retry or fail for character devices */ diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 63fbad8..7f7bd98 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.5 2001/04/02 23:18:30 bartoldeman ; Misc, zero terminated device names and redirector bugs fixed. ; @@ -99,62 +102,33 @@ segment HMA_TEXT _execrh: push bp ; perform c entry mov bp,sp - push bp ; it will get destroyed push bx ; random char on display push si push es ; sometimes it get lost - push ds + push ds ; sp=bp-8 lds si,[bp+8] ; ds:si = device header les bx,[bp+4] ; es:bx = request header - push ds ; needed later - push si - - mov bp, execrh_ret1 ; construct return frame - push cs - push bp - - push ds ; call far the strategy - push word [si+6] + push bp + push ds + push si ; needed later + mov ax, [si+6] + mov [bp+8], ax + call far[bp+8] ; call far the strategy + pop si ; these were saved + pop ds + pop bp + + mov ax, [si+8] + mov [bp+8], ax + call far[bp+8] ; call far the interrupt - retf -execrh_ret1: - pop si ; these were saved - pop ds - - mov bp, execrh_ret2 ; construct return frame - push cs - push bp - - push ds ; call far the interrupt - push word [si+8] - - retf -execrh_ret2: - -exit_execrh: sti ; damm driver turn off ints - cld ; has gone backwards + sti ; damm driver turn off ints + cld ; has gone backwards pop ds pop es pop si pop bx pop bp - mov sp,bp - pop bp ret - - global _init_call_execrh - -_init_call_execrh: - push bp - mov bp,sp - push word [bp+12] - push word [bp+10] - push word [bp+8] - push word [bp+6] - call _execrh - mov sp,bp - pop bp - retf - diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 773bccb..e2e3cdd 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.13 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -241,12 +244,12 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) return NULL; } - fnp->f_dpb = (struct dpb *)TempCDS.cdsDpb; + fnp->f_dpb = TempCDS.cdsDpb; /* Perform all directory common handling after all special */ /* handling has been performed. */ - if (media_check((struct dpb *)TempCDS.cdsDpb) < 0) + if (media_check(TempCDS.cdsDpb) < 0) { release_f_node(fnp); return (struct f_node FAR *)0; @@ -450,7 +453,7 @@ COUNT dir_read(REG struct f_node FAR * fnp) /* Now that we have the block for our entry, get the */ /* directory entry. */ if (bp != NULL) - getdirent((BYTE FAR *) & bp->b_buffer[fnp->f_diroff % fnp->f_dpb->dpb_secsize], + getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize], (struct dirent FAR *)&fnp->f_dir); else { @@ -484,7 +487,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) if (fnp->f_flags.f_droot) { bp = getblock( - (ULONG) (fnp->f_diroff / fnp->f_dpb->dpb_secsize + (ULONG) ((UWORD)fnp->f_diroff / fnp->f_dpb->dpb_secsize + fnp->f_dpb->dpb_dirstrt), fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); @@ -554,7 +557,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) return 0; } putdirent((struct dirent FAR *)&fnp->f_dir, - (VOID FAR *) & bp->b_buffer[fnp->f_diroff % fnp->f_dpb->dpb_secsize]); + (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); bp->b_flag |= BFR_DIRTY; } return DIRENT_SIZE; @@ -589,7 +592,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) REG COUNT i; COUNT nDrive; BYTE *p; -/* BYTE FAR *ptr;*/ static BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; @@ -604,7 +606,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* current directory, do a seek and read, then close the fnode. */ /* Start out by initializing the dirmatch structure. */ - dmp->dm_drive = default_drive ; + dmp->dm_drive = default_drive; dmp->dm_entry = 0; dmp->dm_cluster = 0; @@ -621,7 +623,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) */ if (nDrive >= 0) { - dmp->dm_drive = nDrive ; + dmp->dm_drive = nDrive; } else nDrive = default_drive; @@ -661,9 +663,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) if (current_ldt->cdsFlags & CDSNETWDRV) { - if (Remote_find(REM_FINDFIRST, name, dmp) != 0) - return DE_FILENOTFND; - return SUCCESS; + dmp->dm_drive |= 0x80; + return -Remote_find(REM_FINDFIRST, name, dmp); } /* /// Added code here to do matching against device names. @@ -708,17 +709,31 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* Now search through the directory to find the entry... */ + + /* Complete building the directory from the passed in */ + /* name */ + if (nDrive >= 0) + LocalPath[0] = 'A' + nDrive; + else + LocalPath[0] = 'A' + default_drive; + LocalPath[1] = ':'; + /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - /* Now open this directory so that we can read the */ - /* fnode entry and do a match on it. */ - if ((fnp = dir_open((BYTE FAR *) "\\")) == NULL) - return DE_PATHNOTFND; + LocalPath[2] = '\\'; + LocalPath[3] = '\0'; + } + /* Now open this directory so that we can read the */ + /* fnode entry and do a match on it. */ + if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) + return DE_PATHNOTFND; + if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + { /* Now do the search */ while (dir_read(fnp) == DIRENT_SIZE) { @@ -736,23 +751,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) dir_close(fnp); return DE_FILENOTFND; } - /* Otherwise just do a normal find next */ else { - /* Complete building the directory from the passed in */ - /* name */ - if (nDrive >= 0) - LocalPath[0] = 'A' + nDrive; - else - LocalPath[0] = 'A' + default_drive; - LocalPath[1] = ':'; - - /* Now open this directory so that we can read the */ - /* fnode entry and do a match on it. */ - if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) - return DE_PATHNOTFND; - pop_dmp(dmp, fnp); dmp->dm_entry = 0; if (!fnp->f_flags.f_droot) @@ -775,9 +776,6 @@ COUNT dos_findnext(void) REG dmatch FAR *dmp = (dmatch FAR *) dta; REG struct f_node FAR *fnp; BOOL found = FALSE; -/* BYTE FAR *p;*/ -/* BYTE FAR *q;*/ - COUNT nDrive; /* assign our match parameters pointer. */ dmp = (dmatch FAR *) dta; @@ -790,50 +788,43 @@ COUNT dos_findnext(void) * test 40h. I used RamView to see location MSD 116:04be and * FD f??:04be, the byte set with 0xc4 = Remote/Network drive 4. * Ralf Brown docs for dos 4eh say bit 7 set == remote so what is - * bit 6 for? SHSUCDX Mod info say "test redir not network bit". + * bit 6 for? + * SHSUCDX Mod info say "test redir not network bit". * Just to confuse the rest, MSCDEX sets bit 5 too. * * So, assume bit 6 is redirector and bit 7 is network. * jt + * Bart: dm_drive can be the drive _letter_. + * but better just stay independent of it: we only use + * bit 7 to detect a network drive; the rest untouched. + * RBIL says that findnext can only return one error type anyway + * (12h, DE_NFILES) */ - nDrive = dmp->dm_drive & 0x1f; - - if (nDrive >= lastdrive) { - return DE_INVLDDRV; - } - current_ldt = &CDSp->cds_table[nDrive]; #if 0 - printf("findnext: %c %s\n", - nDrive + 'A', (current_ldt->cdsFlags & CDSNETWDRV)?"remote":"local"); + printf("findnext: %d\n", + dmp->dm_drive); #endif - if (current_ldt->cdsFlags & CDSNETWDRV) - { - if (Remote_find(REM_FINDNEXT, 0, dmp) != 0) - return DE_FILENOTFND; - return SUCCESS; - } + if (dmp->dm_drive & 0x80) + return -Remote_find(REM_FINDNEXT, 0, dmp); /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (struct f_node FAR *)0) { - return DE_FILENOTFND; + return DE_NFILES; } /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - if (dmp->dm_drive >= lastdrive) { - return DE_INVLDDRV; - } /* Select the default to help non-drive specified path */ /* searches... */ - fnp->f_dpb = (struct dpb *)CDSp->cds_table[dmp->dm_drive].cdsDpb; + fnp->f_dpb = CDSp->cds_table[dmp->dm_drive].cdsDpb; if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); - return DE_FILENOTFND; + return DE_NFILES; } fnp->f_dsize = DIRENT_SIZE * (fnp->f_dpb)->dpb_dirents; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 0d574d3..23f4671 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.13 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -247,8 +250,6 @@ COUNT map_cluster(struct f_node FAR *, COUNT); COUNT dos_open(BYTE FAR * path, COUNT flag) { REG struct f_node FAR *fnp; - COUNT i; - BYTE FAR *fnamep; /* First test the flag to see if the user has passed a valid */ /* file mode... */ @@ -296,11 +297,6 @@ COUNT dos_open(BYTE FAR * path, COUNT flag) return xlt_fnp(fnp); } -COUNT FAR init_call_dos_open(BYTE FAR * path, COUNT flag) -{ - return dos_open(path, flag); -} - BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n) { while (n--) @@ -349,11 +345,6 @@ COUNT dos_close(COUNT fd) return SUCCESS; } -COUNT FAR init_call_dos_close(COUNT fd) -{ - return dos_close(fd); -} - /* */ /* split a path into it's component directory and file name */ /* */ @@ -378,7 +369,7 @@ struct f_node FAR * SpacePad(fname, FNAME_SIZE); SpacePad(fext, FEXT_SIZE); - if (nDrive > (lastdrive -1)) { + if (nDrive >= lastdrive) { return (struct f_node FAR *)0; } cdsp = &CDSp->cds_table[nDrive]; @@ -525,6 +516,12 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) { REG struct f_node FAR *fnp; + /* NEVER EVER allow directories to be created */ + if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + { + return DE_ACCESS; + } + /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) @@ -555,9 +552,6 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) else { BOOL is_free; - REG COUNT idx; - struct buffer FAR *bp; - BYTE FAR *p; /* Reset the directory by a close followed by */ /* an open */ @@ -877,7 +871,7 @@ static VOID wipe_out(struct f_node FAR * fnp) { REG UWORD st, next; - struct dpb *dpbp = fnp->f_dpb; + struct dpb FAR *dpbp = fnp->f_dpb; /* if already free or not valid file, just exit */ if ((fnp == NULL) || (fnp->f_dir.dir_start == FREE)) @@ -954,11 +948,6 @@ date dos_getdate() #endif } -date FAR init_call_dos_getdate() -{ - return dos_getdate(); -} - /* */ /* dos_gettime for the file time */ /* */ @@ -969,8 +958,6 @@ time dos_gettime() Minute, Second, Hundredth; - time Time; - BYTE h; /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ @@ -984,11 +971,6 @@ time dos_gettime() #endif } -time FAR init_call_dos_gettime() -{ - return dos_gettime(); -} - /* */ /* dos_getftime for the file time */ /* */ @@ -1509,7 +1491,6 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) REG struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; - ULONG idx; UWORD secsize; UCOUNT to_xfer = count; @@ -1666,7 +1647,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) if (fnp->f_flags.f_ddir) xfr_cnt = min(to_xfer, secsize - fnp->f_boff); else - xfr_cnt = min(min(to_xfer, secsize - fnp->f_boff), + xfr_cnt = (UWORD)min(min(to_xfer, secsize - fnp->f_boff), fnp->f_dir.dir_size - fnp->f_offset); fbcopy((BYTE FAR *) & bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); @@ -1688,7 +1669,6 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; - ULONG idx; UWORD secsize; UCOUNT to_xfer = count; @@ -1927,11 +1907,6 @@ COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) return err != SUCCESS ? err : xfr; } -COUNT FAR init_call_dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) -{ - return dos_read(fd, buffer, count); -} - #ifndef IPL COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) { @@ -2016,7 +1991,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) } /* returns the number of unused clusters */ -UWORD dos_free(struct dpb * dpbp) +UWORD dos_free(struct dpb FAR *dpbp) { /* There's an unwritten rule here. All fs */ /* cluster start at 2 and run to max_cluster+2 */ @@ -2029,7 +2004,7 @@ UWORD dos_free(struct dpb * dpbp) UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) / (dpbp->dpb_clsmask + 1) ) + 1; - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) return dpbp->dpb_nfreeclst; else { @@ -2048,18 +2023,13 @@ UWORD dos_free(struct dpb * dpbp) #ifndef IPL COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) { - BYTE FAR *p; struct f_node FAR *fnp; - REG struct dpb *dpbp; - COUNT x; /* first check for valid drive */ if (cdsp->cdsDpb == 0) return DE_INVLDDRV; - - dpbp = (struct dpb *)cdsp->cdsDpb; - if ((media_check(dpbp) < 0)) + if ((media_check(cdsp->cdsDpb) < 0)) return DE_INVLDDRV; /* now test for its existance. If it doesn't, return an error. */ @@ -2174,11 +2144,50 @@ COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) } #endif -COUNT media_check(REG struct dpb * dpbp) +VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) { - bpb FAR *bpbp; ULONG size; REG COUNT i; + + dpbp->dpb_mdb = bpbp->bpb_mdesc; + dpbp->dpb_secsize = bpbp->bpb_nbyte; + dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; + dpbp->dpb_fatstrt = bpbp->bpb_nreserved; + dpbp->dpb_fats = bpbp->bpb_nfat; + dpbp->dpb_dirents = bpbp->bpb_ndirent; + size = bpbp->bpb_nsize == 0 ? + bpbp->bpb_huge : + (ULONG) bpbp->bpb_nsize; +/* patch point + dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); +*/ + dpbp->dpb_fatsize = bpbp->bpb_nfsect; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_data = dpbp->dpb_dirstrt + + ((DIRENT_SIZE * dpbp->dpb_dirents + + (dpbp->dpb_secsize - 1)) + / dpbp->dpb_secsize); +/* + Michal Meller patch to jimtabor +*/ + dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); + + dpbp->dpb_flags = 0; +/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ + dpbp->dpb_cluster = UNKNCLUSTER; + dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ + for (i = 1, dpbp->dpb_shftcnt = 0; + i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ + dpbp->dpb_shftcnt++, i <<= 1) + { + if (i >= bpbp->bpb_nsector) + break; + } +} + +COUNT media_check(REG struct dpb FAR * dpbp) +{ /* First test if anyone has changed the removable media */ FOREVER { @@ -2257,42 +2266,7 @@ COUNT media_check(REG struct dpb * dpbp) } } } - bpbp = MediaReqHdr.r_bpptr; - dpbp->dpb_mdb = bpbp->bpb_mdesc; - dpbp->dpb_secsize = bpbp->bpb_nbyte; - dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; - dpbp->dpb_fatstrt = bpbp->bpb_nreserved; - dpbp->dpb_fats = bpbp->bpb_nfat; - dpbp->dpb_dirents = bpbp->bpb_ndirent; - size = bpbp->bpb_nsize == 0 ? - bpbp->bpb_huge : - (ULONG) bpbp->bpb_nsize; -/* patch point - dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); -*/ - dpbp->dpb_fatsize = bpbp->bpb_nfsect; - dpbp->dpb_dirstrt = dpbp->dpb_fatstrt - + dpbp->dpb_fats * dpbp->dpb_fatsize; - dpbp->dpb_data = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * dpbp->dpb_dirents - + (dpbp->dpb_secsize - 1)) - / dpbp->dpb_secsize); -/* - Michal Meller patch to jimtabor -*/ - dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); - - dpbp->dpb_flags = 0; -/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ - dpbp->dpb_cluster = UNKNCLUSTER; - dpbp->dpb_nfreeclst = UNKNCLUSTER; /* number of free clusters */ - for (i = 1, dpbp->dpb_shftcnt = 0; - i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ - dpbp->dpb_shftcnt++, i <<= 1) - { - if (i >= bpbp->bpb_nsector) - break; - } + bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); return SUCCESS; } } @@ -2306,7 +2280,7 @@ struct f_node FAR *xlt_fd(COUNT fd) /* translate the f_node pointer into an fd */ COUNT xlt_fnp(struct f_node FAR * fnp) { - return fnp - f_nodes; + return (COUNT)(fnp - f_nodes); } #if 0 diff --git a/kernel/fattab.c b/kernel/fattab.c index 671b5a4..2b7fe89 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -99,10 +102,10 @@ static BYTE *RcsId = "$Id$"; */ #ifdef PROTO -UCOUNT link_fat12(struct dpb *, UCOUNT, UCOUNT); -UCOUNT link_fat16(struct dpb *, UCOUNT, UCOUNT); -UWORD next_cl12(struct dpb *, UCOUNT); -UWORD next_cl16(struct dpb *, UCOUNT); +UCOUNT link_fat12(struct dpb FAR *, UCOUNT, UCOUNT); +UCOUNT link_fat16(struct dpb FAR *, UCOUNT, UCOUNT); +UWORD next_cl12(struct dpb FAR *, UCOUNT); +UWORD next_cl16(struct dpb FAR *, UCOUNT); #else UCOUNT link_fat12(); UCOUNT link_fat16(); @@ -132,7 +135,7 @@ UWORD next_cl16(); /* 12 bytes are compressed to 9 bytes */ /* */ -UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) +UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) { if (ISFAT12(dpbp)) return link_fat12(dpbp, Cluster1, Cluster2); @@ -142,7 +145,7 @@ UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) return DE_BLKINVLD; } -UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { UCOUNT idx; struct buffer FAR *bp; @@ -164,7 +167,7 @@ UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((LONG) Cluster1) * SIZEOF_CLST16) % dpbp->dpb_secsize; + idx = (UWORD)((((LONG) Cluster1) * SIZEOF_CLST16) % dpbp->dpb_secsize); /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ @@ -177,21 +180,21 @@ UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { /* update the free space count for returned */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) ++dpbp->dpb_nfreeclst; } else { /* update the free space count for removed */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) --dpbp->dpb_nfreeclst; } return SUCCESS; } -UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { REG UBYTE FAR *fbp0, FAR * fbp1; @@ -253,7 +256,7 @@ UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) else { *fbp0 = Cluster2 & 0xff; - *fbp1 = (*fbp1 & 0xf0) | (Cluster2 >> 8) & 0x0f; + *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); } /* update the free space count */ @@ -261,14 +264,14 @@ UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { /* update the free space count for returned */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) ++dpbp->dpb_nfreeclst; } else { /* update the free space count for removed */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) --dpbp->dpb_nfreeclst; } @@ -277,7 +280,7 @@ UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ -UWORD next_cluster(struct dpb * dpbp, REG UCOUNT ClusterNum) +UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { if (ISFAT12(dpbp)) return next_cl12(dpbp, ClusterNum); @@ -287,7 +290,7 @@ UWORD next_cluster(struct dpb * dpbp, REG UCOUNT ClusterNum) return LONG_LAST_CLUSTER; } -UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) +UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { UCOUNT idx; struct buffer FAR *bp; @@ -309,7 +312,7 @@ UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((LONG) ClusterNum) * SIZEOF_CLST16) % dpbp->dpb_secsize; + idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; /* Get the cluster number, */ fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); @@ -318,7 +321,7 @@ UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) return RetCluster; } -UWORD next_cl12(struct dpb * dpbp, REG UCOUNT ClusterNum) +UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { REG UBYTE FAR *fbp0, FAR * fbp1; @@ -373,7 +376,7 @@ UWORD next_cl12(struct dpb * dpbp, REG UCOUNT ClusterNum) /* Now to unpack the contents of the FAT entry. Odd and */ /* even bytes are packed differently. */ if (ClusterNum & 0x01) - ClusterNum = ((*fbp0 & 0xf0) >> 4) | *fbp1 << 4; + ClusterNum = ((*fbp0 & 0xf0) >> 4) | (*fbp1 << 4); else ClusterNum = *fbp0 | ((*fbp1 & 0x0f) << 8); diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 3993b4a..1b05700 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.8 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -131,7 +134,7 @@ fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive) void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); sft FAR *FcbGetSft(COUNT SftIndex); VOID FcbNextRecord(fcb FAR * lpFcb); -sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); +/* sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); */ BOOL FcbCalcRec(xfcb FAR * lpXfcb); VOID MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); #else @@ -140,7 +143,7 @@ fcb FAR *CommonFcbInit(); void FcbNameInit(); sft FAR *FcbGetSft(); VOID FcbNextRecord(); -sft FAR *FcbGetFreeSft(); +/* sft FAR *FcbGetFreeSft(); */ BOOL FcbCalcRec(); VOID MoveDirInfo(); #endif @@ -150,12 +153,12 @@ static dmatch Dmatch; VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp) { - struct dpb *dpbp; + struct dpb FAR *dpbp; printf("FGDD\n"); /* first check for valid drive */ - if ((drive < 0) || (drive >= lastdrive) || (drive >= NDEVS)) + if ((UCOUNT)drive >= lastdrive) { *spc = -1; return; @@ -168,7 +171,7 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, *spc = -1; return; } - dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; + dpbp = CDSp->cds_table[drive].cdsDpb; dpbp->dpb_flags = -1; if ((media_check(dpbp) < 0)) { @@ -181,8 +184,8 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; - /* Point to the media desctriptor fotr this drive */ - *mdp = &(dpbp->dpb_mdb); + /* Point to the media desctriptor for this drive */ + *mdp = (BYTE FAR*)&(dpbp->dpb_mdb); } #define PARSE_SEP_STOP 0x01 @@ -347,6 +350,13 @@ static VOID FcbNextRecord(fcb FAR * lpFcb) } } +static ULONG FcbRec(VOID) +{ + UWORD tmp = 128; + + return ((ULONG)lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec; +} + BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) { sft FAR *s; @@ -367,8 +377,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* Now update the fcb and compute where we need to position */ /* to. */ - lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) - * lpFcb->fcb_recsiz; + lPosit = FcbRec() * lpFcb->fcb_recsiz; if (SftSeek(s, lPosit, 0) != SUCCESS) { *nErrorCode = FCB_ERR_EOF; @@ -439,8 +448,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* Now update the fcb and compute where we need to position */ /* to. */ - lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) - * lpFcb->fcb_recsiz; + lPosit = FcbRec() * lpFcb->fcb_recsiz; if (SftSeek(s, lPosit, 0) != SUCCESS) { *nErrorCode = FCB_ERR_EOF; @@ -511,30 +519,27 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) BOOL FcbSetRandom(xfcb FAR * lpXfcb) { - LONG lPosit; - /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ - /* to. */ - lpFcb->fcb_rndm = (lpFcb->fcb_cublock * 128) - + lpFcb->fcb_curec; + /* to. */ + lpFcb->fcb_rndm = FcbRec(); return TRUE; } BOOL FcbCalcRec(xfcb FAR * lpXfcb) { - LONG lPosit; - + UWORD div=128; + /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ /* to. */ - lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; - lpFcb->fcb_curec = lpFcb->fcb_rndm % 128; + lpFcb->fcb_cublock = lpFcb->fcb_rndm / div; + lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; return TRUE; } @@ -551,7 +556,7 @@ BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) while ((--nRecords > 0) && (*nErrorCode == 0)); /* Now update the fcb */ - lpFcb->fcb_rndm = lpFcb->fcb_cublock * 128 + lpFcb->fcb_curec; + lpFcb->fcb_rndm = FcbRec(); return TRUE; } @@ -568,12 +573,13 @@ BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) while ((--nRecords > 0) && (*nErrorCode == 0)); /* Now update the fcb */ - lpFcb->fcb_rndm = lpFcb->fcb_cublock * 128 + lpFcb->fcb_curec; + lpFcb->fcb_rndm = FcbRec(); return TRUE; } -BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) +BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, + BOOL (*FcbFunc)(xfcb FAR *, COUNT *)) { UWORD uwCurrentBlock; UBYTE ucCurrentRecord; @@ -586,57 +592,17 @@ BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) uwCurrentBlock = lpFcb->fcb_cublock; ucCurrentRecord = lpFcb->fcb_curec; - FcbRead(lpXfcb, nErrorCode); - - lpFcb->fcb_cublock = uwCurrentBlock; - lpFcb->fcb_curec = ucCurrentRecord; - return TRUE; -} - -BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) -{ - UWORD uwCurrentBlock; - UBYTE ucCurrentRecord; - - FcbCalcRec(lpXfcb); - - /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); - - uwCurrentBlock = lpFcb->fcb_cublock; - ucCurrentRecord = lpFcb->fcb_curec; - - FcbWrite(lpXfcb, nErrorCode); + (*FcbFunc)(lpXfcb, nErrorCode); lpFcb->fcb_cublock = uwCurrentBlock; lpFcb->fcb_curec = ucCurrentRecord; return TRUE; } +/* static sft FAR *FcbGetFreeSft(WORD FAR * sft_idx) -{ - WORD sys_idx = 0; - sfttbl FAR *sp; - - /* Get the SFT block that contains the SFT */ - for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) - { - REG WORD i; - - for (i = 0; i < sp->sftt_count; i++) - { - if (sp->sftt_table[i].sft_count == 0) - { - *sft_idx = sys_idx + i; - return (sft FAR *) & sp->sftt_table[sys_idx + i]; - } - } - sys_idx += i; - } - - /* If not found, return an error */ - return (sft FAR *) - 1; -} +see get_free_sft in dosfns.c +*/ BOOL FcbCreate(xfcb FAR * lpXfcb) { @@ -646,7 +612,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) COUNT FcbDrive; /* get a free system file table entry */ - if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; /* Build a traditional DOS file name */ @@ -654,46 +620,27 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) /* check for a device */ dhp = IsDevice(PriPathName); - if (dhp) + if (dhp || ((sftp->sft_status = dos_creat(PriPathName, 0)) >= 0)) { - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - sftp->sft_psp = cu_psp; - fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - lpFcb->fcb_sftno = sft_idx; - lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = 0; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); - lpFcb->fcb_rndm = 0; - return TRUE; - } - sftp->sft_status = dos_creat(PriPathName, 0); - if (sftp->sft_status >= 0) - { - lpFcb->fcb_drive = FcbDrive; + sftp->sft_count += 1; + sftp->sft_mode = O_RDWR; + sftp->sft_attrib = 0; + sftp->sft_flags = dhp ? + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF : 0; + sftp->sft_psp = cu_psp; + fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = 128; + lpFcb->fcb_recsiz = (dhp ? 0 : 128); + if (!dhp) lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_fsize = 0; lpFcb->fcb_date = dos_getdate(); lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = 0; - sftp->sft_psp = cu_psp; - fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); return TRUE; } - else - return FALSE; + return FALSE; } static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) @@ -707,11 +654,6 @@ static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) static fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive) { - BYTE FAR *lpszFcbFname, - *lpszFcbFext; - COUNT nDrvIdx, - nFnameIdx, - nFextIdx; fcb FAR *lpFcb; /* convert to fcb if needed first */ @@ -726,10 +668,6 @@ static fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) { - BYTE FAR *lpszFcbFname, - FAR * lpszFcbFext; - COUNT loop; - /* Build a traditional DOS file name */ if (lpFcb->fcb_drive != 0) { @@ -779,7 +717,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) COUNT FcbDrive; /* get a free system file table entry */ - if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; /* Build a traditional DOS file name */ @@ -807,7 +745,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) return TRUE; } fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - if ((FcbDrive < 0) || (FcbDrive >= lastdrive)) { + if ((UCOUNT)FcbDrive >= lastdrive) { return DE_INVLDDRV; } if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { @@ -853,7 +791,7 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - if ((FcbDrive < 0) || (FcbDrive >= lastdrive)) { + if ((UCOUNT)FcbDrive >= lastdrive) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[FcbDrive]; @@ -927,16 +865,8 @@ BOOL FcbRename(xfcb FAR * lpXfcb) /* First, expand the find match into fcb style */ /* file name entry */ /* Fill with blanks first */ - for (pToName = LocalFcb.fcb_fname, nIndex = 0; - nIndex < FNAME_SIZE; nIndex++) - { - *pToName++ = ' '; - } - for (pToName = LocalFcb.fcb_fext, nIndex = 0; - nIndex < FEXT_SIZE; nIndex++) - { - *pToName++ = ' '; - } + memset(LocalFcb.fcb_fname, ' ', FNAME_SIZE); + memset(LocalFcb.fcb_fext, ' ', FEXT_SIZE); /* next move in the file name while overwriting */ /* the filler blanks */ @@ -1006,21 +936,14 @@ void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) /* First, expand the find match into dir style */ /* file name entry */ /* Fill with blanks first */ - for (lpToName = lpDir->dir_name, nIndex = 0; - nIndex < FNAME_SIZE; nIndex++) - { - *lpToName++ = ' '; - } - for (lpToName = lpDir->dir_ext, nIndex = 0; - nIndex < FEXT_SIZE; nIndex++) - { - *lpToName++ = ' '; - } + + fmemset(lpDir->dir_name, ' ', FNAME_SIZE); + fmemset(lpDir->dir_ext , ' ', FEXT_SIZE ); /* next move in the file name while overwriting */ /* the filler blanks */ lpszFrom = lpDmatch->dm_name; - lpToName = lpDir->dir_name; + lpToName = (BYTE FAR *)lpDir->dir_name; for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) { if (*lpszFrom != 0 && *lpszFrom != '.') @@ -1033,7 +956,7 @@ void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) { if (*lpszFrom == '.') ++lpszFrom; - lpToName = lpDir->dir_ext; + lpToName = (BYTE FAR *)lpDir->dir_ext; for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) { if (*lpszFrom != '\0') @@ -1098,10 +1021,8 @@ BOOL FcbClose(xfcb FAR * lpXfcb) BOOL FcbFindFirst(xfcb FAR * lpXfcb) { - BYTE FAR *lpOldDta; BYTE FAR *lpDir; - COUNT nIdx, - FcbDrive; + COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ @@ -1152,10 +1073,8 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) BOOL FcbFindNext(xfcb FAR * lpXfcb) { - BYTE FAR *lpOldDta; BYTE FAR *lpDir; - COUNT nIdx, - FcbDrive; + COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ diff --git a/kernel/globals.h b/kernel/globals.h index 005b8dc..b609010 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.10 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -226,7 +229,6 @@ static BYTE *Globals_hRcsId = "$Id$"; #define PARSE_MAX 67 /* maximum # of bytes in path */ #define NFILES 16 /* number of files in table */ #define NFCBS 16 /* number of fcbs */ -#define NDEVS 26 /* number of supported devices */ #define NSTACKS 8 /* number of stacks */ #define NLAST 6 /* last drive */ #define NAMEMAX PARSE_MAX /* Maximum path for CDS */ @@ -476,7 +478,7 @@ extern sfttbl FAR * FCBp; /* FCB table pointer */ extern WORD nprotfcb; /* number of protected fcbs */ -extern BYTE +extern UBYTE nblkdev, /* number of block devices */ lastdrive, /* value of last drive */ uppermem_link; /* UMB Link flag */ @@ -615,9 +617,6 @@ GLOBAL iregs error_regs; /* registers for dump */ GLOBAL WORD dump_regs; /* dump registers of bad call */ -GLOBAL struct dpb - blk_devices[NDEVS]; - GLOBAL struct f_node FAR * f_nodes; /* pointer to the array */ @@ -635,7 +634,7 @@ GLOBAL iregs FAR * kstackp; /* kernel stack */ /* Start of configuration variables */ -GLOBAL struct config +extern struct config { UBYTE cfgBuffers; /* number of buffers in the system */ UBYTE cfgFiles; /* number of available files */ @@ -643,7 +642,7 @@ GLOBAL struct config UBYTE cfgProtFcbs; /* number of protected FCBs */ BYTE cfgInit[NAMEMAX]; /* init of command.com */ BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ - BYTE cfgLastdrive; /* last drive */ + UBYTE cfgLastdrive; /* last drive */ BYTE cfgStacks; /* number of stacks */ UWORD cfgStackSize; /* stacks size for each stack */ /* COUNTRY= @@ -658,7 +657,7 @@ GLOBAL struct config VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ UBYTE cfgP_0_startmode; /* load command.com high or not */ } Config -#ifdef MAIN +#ifdef CONFIG = { NUMBUFF, @@ -704,11 +703,7 @@ CriticalError( VOID FAR CharMapSrvc(VOID); VOID FAR set_stack(VOID); VOID FAR restore_stack(VOID); -#ifndef IN_INIT_MOD WORD execrh(request FAR *, struct dhdr FAR *); -#endif -VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *); -VOID FAR reloc_call_execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); /*VOID INRPT FAR handle_break(VOID); */ VOID tmark(VOID); @@ -783,7 +778,7 @@ VOID fputbyte(); /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ -void FAR _init_call_spawn_int23(void); /* procsupt.asm */ +void spawn_int23(void); /* procsupt.asm */ int control_break(void); /* break.c */ void handle_break(void); /* break.c */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 2356520..cea37a0 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -12,11 +12,6 @@ */ #define DosExec reloc_call_DosExec #define DosMemAlloc reloc_call_DosMemAlloc -#define dos_close reloc_call_dos_close -#define dos_getdate reloc_call_dos_getdate -#define dos_gettime reloc_call_dos_gettime -#define dos_open reloc_call_dos_open -#define dos_read reloc_call_dos_read #define execrh reloc_call_execrh #define fatal reloc_call_fatal #define fmemcpy reloc_call_fmemcpy @@ -29,3 +24,5 @@ #define strlen reloc_call_strlen #define WritePCClock reloc_call_WritePCClock #define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay +#define p_0 reloc_call_p_0 + diff --git a/kernel/inithma.c b/kernel/inithma.c index eb1cd1f..725bd26 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -75,6 +75,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.2 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -92,11 +95,11 @@ WORD HMAFree; /* first byte in HMA not yet used */ extern BYTE FAR * FAR XMSDriverAddress; -extern FAR _EnableA20(); -extern FAR _DisableA20(); +extern FAR _EnableA20(VOID); +extern FAR _DisableA20(VOID); -void FAR *DetectXMSDriver(); +extern void FAR *DetectXMSDriver(VOID); #ifdef DEBUG #define int3() __int__(3); @@ -105,7 +108,7 @@ void FAR *DetectXMSDriver(); #endif -#if defined( DEBUG ) || 1 /* experimental kernel !! */ +#ifdef DEBUG #define HMAInitPrintf(x) printf x #else #define HMAInitPrintf(x) @@ -184,7 +187,7 @@ void _DisableHMA() if so, it simply leaves it on */ -int EnableHMA() +int EnableHMA(VOID) { _EnableA20(); @@ -263,12 +266,13 @@ int MoveKernelToHMA() /* A) for debugging purpose, suppress this, if any shift key is pressed */ - +#ifdef DEBUG if (KeyboardShiftState() & 0x0f) { printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState()); return FALSE; } +#endif /* B) check out, if we can have HMA */ @@ -288,7 +292,7 @@ int MoveKernelToHMA() len = FP_OFF(_HMATextEnd) - FP_OFF(_HMATextStart); - HMASource = _HMATextStart; + HMASource = (UBYTE FAR *)_HMATextStart; len += FP_OFF(HMASource) & 0x000f; @@ -340,7 +344,6 @@ int MoveKernelToHMA() struct RelocationTable FAR *rp, rtemp ; - UWORD HMATextSegment = FP_SEG( _HMATextStart ); /* verify, that all entries are valid */ @@ -371,8 +374,46 @@ int MoveKernelToHMA() rel->callNear = rtemp.callNear; rel->callOffset = rtemp.callOffset+5; /* near calls are relative */ } + } + { + struct initRelocationTable { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct initRelocationTable + FAR _HMAinitRelocationTableStart[], + FAR _HMAinitRelocationTableEnd[]; + struct initRelocationTable FAR *rp, FAR *endrp; + + /* verify, that all entries are valid */ + + UWORD HMATextSegment = FP_SEG( _HMATextStart ); + endrp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableEnd)); - + for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++) + { + if ( + rp->callNear != 0xe8 || /* call NEAR */ + rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != HMATextSegment || /* will only relocate HMA_TEXT */ + 0) + { + printf("illegal init relocation entry # %d\n", + FP_OFF(rp) - FP_OFF(_HMAinitRelocationTableStart)); + goto errorReturn; + } + } + + /* OK, all valid, go to relocate*/ + + for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++) + { + rp->jmpSegment = HMASEGMENT; + rp->callOffset = rp->callOffset-5; /* near calls are relative */ + } } { @@ -414,7 +455,7 @@ errorReturn: so: we install this after all drivers have been loaded */ -void InstallVDISK() +void InstallVDISK(VOID) { static struct { /* Boot-Sektor of a RAM-Disk */ UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ @@ -447,7 +488,6 @@ void InstallVDISK() int init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); -void init_call_intr(int intrnr, iregs *rp); /* @@ -455,7 +495,7 @@ void init_call_intr(int intrnr, iregs *rp); it might be HIMEM.SYS we just loaded. */ -void ClaimHMA() +void ClaimHMA(VOID) { void FAR *pXMS; @@ -476,21 +516,6 @@ void ClaimHMA() } } } -void FAR *DetectXMSDriver() -{ - iregs regs; - - regs.a.x = 0x4300; /* XMS installation check */ - init_call_intr(0x2f, ®s); - - if ((regs.a.x & 0xff) != 0x80) return NULL; - - regs.a.x = 0x4310; /* XMS get driver address */ - init_call_intr(0x2f, ®s); - - return MK_FP(regs.es, regs.b.x); -} - /* this should be called, after each device driver diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index a205d12..d8cdd28 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -26,6 +26,7 @@ /* Cambridge, MA 02139, USA. */ /* */ /****************************************************************/ +#define MAIN #include "portab.h" #include "globals.h" @@ -36,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.19 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -344,10 +348,6 @@ VOID int21_service(iregs FAR * r) #define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY p->ps_stack = (BYTE FAR *) r; - - - - #ifdef DEBUG if (bDumpRegs) @@ -359,6 +359,10 @@ VOID int21_service(iregs FAR * r) } #endif + if(r->AH >=0x38 && r->AH <= 0x4F) + CLEAR_CARRY_FLAG(); + /* Clear carry by default for these functions */ + dispatch: /* Check for Ctrl-Break */ @@ -385,7 +389,6 @@ dispatch: { /* int 21h common error handler */ case 0x64: - case 0x6b: error_invalid: r->AX = -DE_INVLDFUNC; goto error_out; @@ -393,7 +396,7 @@ dispatch: r->AX = -rc; error_out: CritErrCode = r->AX; /* Maybe set */ - r->FLAGS |= FLG_CARRY; + SET_CARRY_FLAG(); break; /* case 0x00: --> Simulate a DOS-4C-00 */ @@ -412,32 +415,40 @@ dispatch: /* Auxiliary Input */ case 0x03: - r->AL = _sti(); + { + COUNT scratch; + GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL, (COUNT FAR *) & scratch, TRUE); break; + } /* Auxiliary Output */ case 0x04: - sto(r->DL); + { + COUNT scratch; + DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch); break; - + } /* Print Character */ case 0x05: - sto(r->DL); - break; + { + COUNT scratch; + DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch); + break; + } - /* Direct Cosole I/O */ + /* Direct Console I/O */ case 0x06: if (r->DL != 0xff) sto(r->DL); else if (StdinBusy()) { - r->FLAGS &= ~FLG_ZERO; - r->AL = _sti(); + r->AL = 0x00; + r->FLAGS |= FLG_ZERO; } else { - r->AL = 0x00; - r->FLAGS |= FLG_ZERO; + r->FLAGS &= ~FLG_ZERO; + r->AL = _sti(); } break; @@ -457,7 +468,7 @@ dispatch: q = FP_DS_DX; while (*q != '$') ++q; - DosWrite(STDOUT, q - (BYTE FAR*)FP_DS_DX, FP_DS_DX, (COUNT FAR *) & scratch); + DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, (COUNT FAR *) & scratch); } r->AL = '$'; break; @@ -587,6 +598,7 @@ dispatch: #ifndef TSC case 0x61: #endif + case 0x6b: r->AL = 0; break; @@ -639,7 +651,7 @@ dispatch: case 0x1f: if (default_drive < lastdrive) { - struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; + struct dpb FAR *dpb = CDSp->cds_table[default_drive].cdsDpb; if (dpb == 0) { r->AL = 0xff; @@ -660,7 +672,7 @@ dispatch: /* Random read using FCB */ case 0x21: { - if (FcbRandomRead(FP_DS_DX, &CritErrCode)) + if (FcbRandomIO(FP_DS_DX, &CritErrCode, FcbRead)) r->AL = 0; else r->AL = CritErrCode; @@ -670,7 +682,7 @@ dispatch: /* Random write using FCB */ case 0x22: { - if (FcbRandomWrite(FP_DS_DX, &CritErrCode)) + if (FcbRandomIO(FP_DS_DX, &CritErrCode, FcbWrite)) r->AL = 0; else r->AL = CritErrCode; @@ -851,8 +863,7 @@ dispatch: struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; if (dpb == 0 || (CDSp->cds_table[r->DL].cdsFlags & CDSNETWDRV) || - FP_SEG(dpb) != FP_SEG(&dpb) || /* check if it's a NEAR pointer */ - media_check((struct dpb *)dpb) < 0) + media_check(dpb) < 0) { r->AL = 0xff; CritErrCode = 0x0f; @@ -869,6 +880,10 @@ dispatch: } break; +/* + case 0x33: + see int21_syscall +*/ /* Get InDOS flag */ case 0x34: { @@ -894,7 +909,7 @@ dispatch: /* Dos Get Disk Free Space */ case 0x36: DosGetFree( - (COUNT) r->DL, + r->DL, (COUNT FAR *) & r->AX, (COUNT FAR *) & r->BX, (COUNT FAR *) & r->CX, @@ -942,7 +957,6 @@ dispatch: goto error_invalid; r->AX = r->BX = cntry; } - CLEAR_CARRY_FLAG(); } break; @@ -951,10 +965,6 @@ dispatch: rc = DosMkdir((BYTE FAR *) FP_DS_DX); if (rc != SUCCESS) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; /* Dos Remove Directory */ @@ -962,20 +972,12 @@ dispatch: rc = DosRmdir((BYTE FAR *) FP_DS_DX); if (rc != SUCCESS) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; /* Dos Change Directory */ case 0x3b: if ((rc = DosChangeDir((BYTE FAR *) FP_DS_DX)) < 0) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; /* Dos Create File */ @@ -983,10 +985,7 @@ dispatch: if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0) goto error_exit; else - { r->AX = rc; - CLEAR_CARRY_FLAG(); - } break; /* Dos Open */ @@ -994,61 +993,38 @@ dispatch: if ((rc = DosOpen(FP_DS_DX, r->AL)) < 0) goto error_exit; else - { r->AX = rc; - CLEAR_CARRY_FLAG(); - } break; /* Dos Close */ case 0x3e: if ((rc = DosClose(r->BX)) < 0) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Dos Read */ case 0x3f: - rc = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1); - - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } + rc1 = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + if (rc != SUCCESS) + goto error_exit; else - { - CLEAR_CARRY_FLAG(); - r->AX = rc; - } + r->AX = rc1; break; /* Dos Write */ case 0x40: - rc = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1); - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } + rc1 = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + if (rc != SUCCESS) + goto error_exit; else - { - CLEAR_CARRY_FLAG(); - r->AX = rc; - } + r->AX = rc1; break; /* Dos Delete File */ case 0x41: rc = DosDelete((BYTE FAR *) FP_DS_DX); if (rc < 0) - { - r->AX = -rc; - goto error_out; - } - else - CLEAR_CARRY_FLAG(); + goto error_exit; break; /* Dos Seek */ @@ -1059,7 +1035,6 @@ dispatch: { r->DX = (lrc >> 16); r->AX = (UWORD)lrc; - CLEAR_CARRY_FLAG(); } break; @@ -1069,41 +1044,25 @@ dispatch: { case 0x00: rc = DosGetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); - if (rc != SUCCESS) - goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; case 0x01: rc = DosSetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); - if (rc != SUCCESS) - goto error_exit; - else - CLEAR_CARRY_FLAG(); break; default: goto error_invalid; } + if (rc != SUCCESS) + goto error_exit; break; /* Device I/O Control */ case 0x44: - { - rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + rc = DosDevIOctl(r); - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } - else{ - CLEAR_CARRY_FLAG(); - } - } + if (rc != SUCCESS) + goto error_exit; break; /* Duplicate File Handle */ @@ -1112,10 +1071,7 @@ dispatch: if (rc < SUCCESS) goto error_exit; else - { - CLEAR_CARRY_FLAG(); r->AX = rc; - } break; /* Force Duplicate File Handle */ @@ -1123,8 +1079,6 @@ dispatch: rc = DosForceDup(r->BX, r->CX); if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Get Current Directory */ @@ -1132,10 +1086,7 @@ dispatch: if ((rc = DosGetCuDir(r->DL, MK_FP(r->DS, r->SI))) < 0) goto error_exit; else - { - CLEAR_CARRY_FLAG(); r->AX = 0x0100; /*jpp: from interrupt list */ - } break; /* Allocate memory */ @@ -1146,18 +1097,13 @@ dispatch: goto error_exit; } else - { ++(r->AX); /* DosMemAlloc() returns seg of MCB rather than data */ - CLEAR_CARRY_FLAG(); - } break; /* Free memory */ case 0x49: if ((rc = DosMemFree((r->ES) - 1)) < 0) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Set memory block size */ @@ -1182,8 +1128,6 @@ dispatch: #endif goto error_exit; } - else - CLEAR_CARRY_FLAG(); break; } @@ -1195,8 +1139,6 @@ dispatch: if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) != SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Terminate Program */ @@ -1242,40 +1184,31 @@ dispatch: /* Dos Find First */ case 0x4e: - { - /* dta for this call is set on entry. This */ - /* needs to be changed for new versions. */ - if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0) - goto error_exit; - else - { - r->AX = 0; - CLEAR_CARRY_FLAG(); - } - } + /* dta for this call is set on entry. This */ + /* needs to be changed for new versions. */ + if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0) + goto error_exit; + r->AX = 0; break; /* Dos Find Next */ case 0x4f: + /* dta for this call is set on entry. This */ + /* needs to be changed for new versions. */ + if ((rc = DosFindNext()) < 0) { - /* dta for this call is set on entry. This */ - /* needs to be changed for new versions. */ - if ((rc = DosFindNext()) < 0) - { - r->AX = -rc; - - if (r->AX == 2) - r->AX = 18; - goto error_out; - } - else - { - CLEAR_CARRY_FLAG(); - r->AX = -SUCCESS; - } + if (rc == DE_FILENOTFND) + rc = DE_NFILES; + goto error_exit; } + else + r->AX = -SUCCESS; break; - +/* + case 0x50: + case 0x51: + see int21_syscall +*/ /* ************UNDOCUMENTED************************************* */ /* Get List of Lists */ case 0x52: @@ -1288,6 +1221,11 @@ dispatch: } break; + case 0x53: + /* DOS 2+ internal - TRANSLATE BIOS PARAMETER BLOCK TO DRIVE PARAM BLOCK */ + bpb_to_dpb((bpb FAR *)MK_FP(r->DS, r->SI), (struct dpb FAR *)MK_FP(r->ES, r->BP)); + break; + /* Get verify state */ case 0x54: r->AL = (verify_ena ? TRUE : FALSE); @@ -1306,13 +1244,12 @@ dispatch: if (rc < SUCCESS) goto error_exit; else - { CLEAR_CARRY_FLAG(); - } break; /* Get/Set File Date and Time */ case 0x57: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x00: @@ -1322,8 +1259,6 @@ dispatch: (time FAR *) & r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; case 0x01: @@ -1333,8 +1268,6 @@ dispatch: (time FAR *) & r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; default: @@ -1344,6 +1277,7 @@ dispatch: /* Get/Set Allocation Strategy */ case 0x58: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x00: @@ -1358,7 +1292,6 @@ dispatch: case LAST_FIT: case LAST_FIT_U: case LAST_FIT_UO: - case LARGEST: case BEST_FIT: case BEST_FIT_U: case BEST_FIT_UO: @@ -1372,7 +1305,6 @@ dispatch: goto error_invalid; } } - CLEAR_CARRY_FLAG(); break; case 0x02: @@ -1419,7 +1351,7 @@ dispatch: /* Create New File */ case 0x5b: - if ((rc = DosOpen(FP_DS_DX, 0)) >= 0) + if (!IsDevice(FP_DS_DX) && (rc = DosOpen(FP_DS_DX, 0)) >= 0) { DosClose(rc); r->AX = 80; @@ -1445,10 +1377,8 @@ dispatch: (((unsigned long)r->CX)<<16)|(((unsigned long)r->DX)&0xffffL), (((unsigned long)r->SI)<<16)|(((unsigned long)r->DI)&0xffffL), ((r->AX & 0xff) != 0))) != 0) - r->FLAGS |= FLG_CARRY; - else - CLEAR_CARRY_FLAG(); - r->AX = -rc; + goto error_exit; + CLEAR_CARRY_FLAG(); break; /* /// End of additions for SHARE. - Ron Cemer */ @@ -1482,17 +1412,11 @@ dispatch: case 0x07: case 0x08: case 0x09: - { - COUNT result; - result = int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); - r->AX = result; - if (result != SUCCESS) { - goto error_out; - } else { - CLEAR_CARRY_FLAG(); - } + rc = -int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); + if (rc != SUCCESS) + goto error_exit; + CLEAR_CARRY_FLAG(); break; - } default: goto error_invalid; } @@ -1511,54 +1435,44 @@ dispatch: break; default: - { - COUNT result; - result = int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); - r->AX = result; - if (result != SUCCESS) goto error_out; - break; - } + rc = -int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + if (rc != SUCCESS) goto error_exit; + r->AX=SUCCESS; + break; } break; case 0x5f: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x07: if (r->DL < lastdrive) { - CDSp->cds_table[r->DL].cdsFlags |= 0x100; + CDSp->cds_table[r->DL].cdsFlags |= 0x100; } break; case 0x08: if (r->DL < lastdrive) { - CDSp->cds_table[r->DL].cdsFlags &= ~0x100; + CDSp->cds_table[r->DL].cdsFlags &= ~0x100; } break; default: - { - COUNT result; - result = int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); - r->AX = result; - if (result != SUCCESS) { - goto error_out; - } else { - CLEAR_CARRY_FLAG(); - } + rc = -int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, + (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + if (rc != SUCCESS) + goto error_exit; + r->AX=SUCCESS; break; - } } break; case 0x60: /* TRUENAME */ + CLEAR_CARRY_FLAG(); if ((rc = truename(MK_FP(r->DS, r->SI), adjust_far(MK_FP(r->ES, r->DI)), TRUE)) != SUCCESS) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; #ifdef TSC @@ -1582,11 +1496,12 @@ dispatch: break; #endif - /* UNDOCUMENTED: return current psp */ - case 0x62: + /* UNDOCUMENTED: return current psp + case 0x62: is in int21_syscall r->BX = cu_psp; break; - + */ + /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { @@ -1606,6 +1521,10 @@ dispatch: #endif break; } +/* + case 0x64: + see above (invalid) +*/ /* Extended country info */ case 0x65: @@ -1648,6 +1567,7 @@ dispatch: } CLEAR_CARRY_FLAG(); break; + /* Code Page functions */ case 0x66: { @@ -1675,13 +1595,12 @@ dispatch: if ((rc = SetJFTSize(r->BX)) != SUCCESS) goto error_exit; else - { CLEAR_CARRY_FLAG(); - } break; - /* Flush file buffer -- dummy function right now. */ + /* Flush file buffer -- COMMIT FILE -- dummy function right now. */ case 0x68: + case 0x6a: CLEAR_CARRY_FLAG(); break; @@ -1698,31 +1617,28 @@ dispatch: case 0x00: r->AL = 0x0d; r->CX = 0x0866; - rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + rc = DosDevIOctl(r); break; case 0x01: r->AL = 0x0d; r->CX = 0x0846; - rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + rc = DosDevIOctl(r); break; } r->CX = saveCX; - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } - else - { - CLEAR_CARRY_FLAG(); - } + if (rc != SUCCESS) + goto error_exit; + CLEAR_CARRY_FLAG(); break; } else r->AL = 0xFF; break; - +/* + case 0x6a: see case 0x68 + case 0x6b: dummy func: return AL=0 +*/ #if 0 /* Extended Open-Creat, not fully functional.*/ case 0x6c: @@ -1812,6 +1728,9 @@ dispatch: default: goto error_invalid; } + + /* case 0x6d and above not implemented : see default; return AL=0 */ + #endif } diff --git a/kernel/intr.asm b/kernel/intr.asm index 3151904..649bd73 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -96,8 +96,8 @@ _int3: retf - segment INIT_TEXT +%if 0 ; ; void init_call_intr(nr, rp) ; REG int nr @@ -159,7 +159,7 @@ init_intr?1: ret - +%endif ; ; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX) ; @@ -177,4 +177,83 @@ _init_call_XMScall: pop bp ret +; void FAR *DetectXMSDriver(VOID) +global _DetectXMSDriver +_DetectXMSDriver: + mov ax, 4300h + int 2fh ; XMS installation check + + cmp al, 80h + je detected + xor ax, ax + xor dx, dx + ret + +detected: + push es + push bx + mov ax, 4310h ; XMS get driver address + int 2fh + + mov ax, bx + mov dx, es + pop bx + pop es + ret + +global _keycheck +_keycheck: + mov ah, 1 + int 16h + ret + +;; COUNT init_DosOpen(BYTE *fname, COUNT mode) + global _init_DosOpen +_init_DosOpen: + ;; first implementation of init calling DOS through ints: + mov bx, sp + mov ah, 3dh + ;; we know that SS=DS during init stage. + mov al, [bx+4] + mov dx, [bx+2] + int 21h +common_exit: + jnc open_no_error + ;; AX has file handle + neg ax + ;; negative value for error code +open_no_error: + ret + +;; COUNT init_DosClose(COUNT hndl) + global _init_DosClose +_init_DosClose: + mov bx, sp + mov bx, [bx+2] + mov ah, 3eh + int 21h + jmp common_exit + +;; COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n) + global _init_DosRead +_init_DosRead: + mov bx, sp + mov cx, [bx+6] + mov dx, [bx+4] + mov bx, [bx+2] + mov ah, 3fh + int 21h + jmp common_exit + +;; VOID init_PSPInit(seg psp_seg) + global _init_PSPInit +_init_PSPInit: + push si + mov ah, 55h + mov bx, sp + mov dx, [bx+4] + xor si, si + int 21h + pop si + ret \ No newline at end of file diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 04519d6..867bf95 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -117,7 +120,7 @@ sft FAR *get_sft(); * WARNING: this code is non-portable (8086 specific). */ -COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) +COUNT DosDevIOctl(iregs FAR * r) { sft FAR *s; struct dpb FAR *dpbp; @@ -139,10 +142,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* Get the SFT block that contains the SFT */ if ((s = get_sft(r->BX)) == (sft FAR *) - 1) - { - *err = DE_INVLDHNDL; - return 0; - } + return DE_INVLDHNDL; break; case 0x04: @@ -168,10 +168,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) dev = ( r->BL == 0 ? default_drive : r->BL - 1); if (dev >= lastdrive) - { - *err = DE_INVLDDRV; - return 0; - } + return DE_INVLDDRV; else { cdsp = &CDSp->cds_table[dev]; @@ -188,8 +185,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) break; default: - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; } switch (r->AL) @@ -206,10 +202,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* sft_flags is a file, return an error because you */ /* can't set the status of a file. */ if (!(s->sft_flags & SFT_FDEVICE)) - { - *err = DE_INVLDFUNC; - return 0; - } + return DE_INVLDFUNC; /* Set it to what we got in the DL register from the */ /* user. */ @@ -243,10 +236,8 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) execrh((request FAR *) & CharReqHdr, s->sft_dev); if (CharReqHdr.r_status & S_ERROR) - { - *err = DE_DEVICE; - return 0; - } + return DE_DEVICE; + if (r->AL == 0x07) { r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; @@ -263,8 +254,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) } break; } - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; case 0x0d: nMode = C_GENIOCTL; @@ -280,16 +270,14 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) IoBlockCommon: if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) || ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) { - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; } @@ -304,8 +292,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) if (CharReqHdr.r_status & S_ERROR) { - *err = DE_DEVICE; - return 0; + return DE_DEVICE; } if (r->AL == 0x08) { @@ -345,16 +332,14 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x08: if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) { nMode = C_REMMEDIA; goto IoBlockCommon; } - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; case 0x09: if(cdsp->cdsFlags & CDSNETWDRV) @@ -366,8 +351,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) { if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } /* Need to add subst bit 15 */ r->DX = dpbp->dpb_device->dh_attr; @@ -388,8 +372,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) IoLogCommon: if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) { @@ -405,22 +388,18 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) dpbp->dpb_device); if (CharReqHdr.r_status & S_ERROR) - *err = DE_ACCESS; + return DE_ACCESS; else { r->AL = CharReqHdr.r_unit; - *err = SUCCESS; + return SUCCESS; } - return 0; } - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; default: - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; } - *err = SUCCESS; - return 0; + return SUCCESS; } diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9b8db85..4736eac 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.9 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.8 2001/03/30 19:30:06 bartoldeman ; Misc fixes and implementation of SHELLHIGH. See history.txt for details. ; @@ -131,6 +134,8 @@ STACK_SIZE equ 384/2 ; stack allocated in words ..start: entry: jmp far kernel_start +beyond_entry: resb 256-(beyond_entry-entry) + ; scratch area for data (DOS_PSP) segment INIT_TEXT @@ -143,7 +148,7 @@ kernel_start: mov ax,DGROUP cli mov ss,ax - mov sp,tos + mov sp,init_tos int 12h ; move the init code to higher memory mov cl,6 shl ax,cl @@ -321,10 +326,13 @@ _uppermem_root dw 0 ; 0066 dmd_upper_root _umb_start dw 0 ; 0068 para of last mem search SysVarEnd: +; We've got (01fb-006a) some room here: don't use all zeros! + + ; Some references seem to indicate that this data should start at 01fbh in ; order to maintain 100% MS-DOS compatibility. - times (01fbh - (SysVarEnd - DATASTART)) db 0 + times (01fbh - ($ - DATASTART)) db 0 global MARK01FBH MARK01FBH equ $ @@ -600,23 +608,34 @@ __bssend: segment _BSSEND ; blockdev private stack global blk_stk_top - times 256 dw 0 + times 192 dw 0 blk_stk_top: ; clockdev private stack global clk_stk_top - times 256 dw 0 + times 64 dw 0 clk_stk_top: +; this is nowhere needed ; interrupt stack - global intr_stk_top - times 256 dw 0 -intr_stk_top: +; global intr_stk_top +; times 256 dw 0 +;intr_stk_top: +segment ID ; init data + retaddr dd 0 ; return address to jump to from HMA_TEXT ; kernel startup stack - global tos - times 128 dw 0 -tos: + global init_tos + times 256 dw 0 +init_tos: + +segment ID_B + global __INIT_DATA_START +__INIT_DATA_START: +segment ID_E + global __INIT_DATA_END +__INIT_DATA_END: + segment INIT_TEXT_START global __InitTextStart @@ -639,6 +658,8 @@ __HMATextStart: segment HMA_TEXT times 16 db 0 ; filler [ffff:0..ffff:10] times 22 db 0 ; filler [sizeof VDISK info] + +init_ret: jmp far [retaddr] ; return from init_calls. ;End of HMA segment segment HMA_TEXT_END @@ -674,127 +695,124 @@ _DGROUP_: dw DGROUP +segment INIT_TEXT + + call far initforceEnableA20 ; first enable A20 or not +manip_stack_A20: + pop word [retaddr+2] ; get last ret address + pop word [retaddr] ; get near ret address of init caller + mov ax, init_ret ; new init caller ret address + push ax + push word [retaddr+2] ; and back to the relocation entry + mov [retaddr+2], cs ; retaddr is now a far pointer to where we came from + ret + + global __HMAinitRelocationTableStart +__HMAinitRelocationTableStart: + + + extern _DosExec + global _reloc_call_DosExec +_reloc_call_DosExec: + call manip_stack_A20 + jmp far _DosExec + + extern _DosMemAlloc + global _reloc_call_DosMemAlloc +_reloc_call_DosMemAlloc: + call manip_stack_A20 + jmp far _DosMemAlloc + + extern _execrh + global _reloc_call_execrh +_reloc_call_execrh: + call manip_stack_A20 + jmp far _execrh + + extern _fatal + global _reloc_call_fatal +_reloc_call_fatal: + call manip_stack_A20 + jmp far _fatal + + extern _fmemcpy + global _reloc_call_fmemcpy +_reloc_call_fmemcpy: + call manip_stack_A20 + jmp far _fmemcpy + + extern _memcpy + global _reloc_call_memcpy +_reloc_call_memcpy: + call manip_stack_A20 + jmp far _memcpy + + extern _printf + global _reloc_call_printf +_reloc_call_printf: + call manip_stack_A20 + jmp far _printf + + extern _strcpy + global _reloc_call_strcpy +_reloc_call_strcpy: + call manip_stack_A20 + jmp far _strcpy + + extern _sti + global _reloc_call_sti +_reloc_call_sti: + call manip_stack_A20 + jmp far _sti + + extern _strcmp + global _reloc_call_strcmp +_reloc_call_strcmp: + call manip_stack_A20 + jmp far _strcmp + + extern _strlen + global _reloc_call_strlen +_reloc_call_strlen: + call manip_stack_A20 + jmp far _strlen + + extern _WritePCClock + global _reloc_call_WritePCClock +_reloc_call_WritePCClock: + call manip_stack_A20 + jmp far _WritePCClock + + extern _DaysFromYearMonthDay + global _reloc_call_DaysFromYearMonthDay +_reloc_call_DaysFromYearMonthDay: + call manip_stack_A20 + jmp far _DaysFromYearMonthDay + + extern _fmemset + global _reloc_call_fmemset +_reloc_call_fmemset: + call manip_stack_A20 + jmp far _fmemset + + extern _p_0 + global _reloc_call_p_0 +_reloc_call_p_0: + call manip_stack_A20 + jmp far _p_0 + + global __HMAinitRelocationTableEnd +__HMAinitRelocationTableEnd: + segment _TEXT +global _initforceEnableA20 +initforceEnableA20: + call near forceEnableA20 + retf + global __HMARelocationTableStart -__HMARelocationTableStart: - - - extern _init_call_DosExec - global _reloc_call_DosExec -_reloc_call_DosExec: jmp far _init_call_DosExec - call near forceEnableA20 - - extern _init_call_DosMemAlloc - global _reloc_call_DosMemAlloc -_reloc_call_DosMemAlloc: jmp far _init_call_DosMemAlloc - call near forceEnableA20 - - extern _init_call_dos_close - global _reloc_call_dos_close -_reloc_call_dos_close: jmp far _init_call_dos_close - call near forceEnableA20 - - extern _init_call_dos_getdate - global _reloc_call_dos_getdate -_reloc_call_dos_getdate: jmp far _init_call_dos_getdate - call near forceEnableA20 - - extern _init_call_dos_gettime - global _reloc_call_dos_gettime -_reloc_call_dos_gettime: jmp far _init_call_dos_gettime - call near forceEnableA20 - - extern _init_call_dos_open - global _reloc_call_dos_open -_reloc_call_dos_open: jmp far _init_call_dos_open - call near forceEnableA20 - - extern _init_call_dos_read - global _reloc_call_dos_read -_reloc_call_dos_read: jmp far _init_call_dos_read - call near forceEnableA20 - - extern _init_call_execrh - global _reloc_call_execrh -_reloc_call_execrh: jmp far _init_call_execrh - call near forceEnableA20 - - extern _init_call_fatal - global _reloc_call_fatal -_reloc_call_fatal: jmp far _init_call_fatal - call near forceEnableA20 - - extern _init_call_fmemcpy - global _reloc_call_fmemcpy -_reloc_call_fmemcpy: jmp far _init_call_fmemcpy - call near forceEnableA20 - - - extern _init_call_memcpy - global _reloc_call_memcpy -_reloc_call_memcpy: jmp far _init_call_memcpy - call near forceEnableA20 - - extern _init_call_printf - global _reloc_call_printf -_reloc_call_printf: jmp far _init_call_printf - call near forceEnableA20 - - extern _init_call_strcpy - global _reloc_call_strcpy -_reloc_call_strcpy: jmp far _init_call_strcpy - call near forceEnableA20 - - extern _init_call_sti - global _reloc_call_sti -_reloc_call_sti: jmp far _init_call_sti - call near forceEnableA20 - - extern _init_call_strcmp - global _reloc_call_strcmp -_reloc_call_strcmp: jmp far _init_call_strcmp - call near forceEnableA20 - - extern _init_call_strlen - global _reloc_call_strlen -_reloc_call_strlen: jmp far _init_call_strlen - call near forceEnableA20 - - - extern _init_call_WritePCClock - global _reloc_call_WritePCClock -_reloc_call_WritePCClock: jmp far _init_call_WritePCClock - call near forceEnableA20 - - extern _init_call_DaysFromYearMonthDay - global _reloc_call_DaysFromYearMonthDay -_reloc_call_DaysFromYearMonthDay: jmp far _init_call_DaysFromYearMonthDay - call near forceEnableA20 - - global _CharMapSrvc - extern _reloc_call_CharMapSrvc -_CharMapSrvc: jmp far _reloc_call_CharMapSrvc - call near forceEnableA20 - - global _reloc_call_clk_driver - extern _init_call_clk_driver -_reloc_call_clk_driver: jmp far _init_call_clk_driver - call near forceEnableA20 - - - - global _reloc_call_fmemset - extern _init_call_fmemset -_reloc_call_fmemset: jmp far _init_call_fmemset - call near forceEnableA20 - - - global _reloc_call_blk_driver - extern _init_call_blk_driver -_reloc_call_blk_driver: jmp far _init_call_blk_driver - call near forceEnableA20 - +__HMARelocationTableStart: global _int2f_handler extern reloc_call_int2f_handler @@ -806,9 +824,6 @@ _int2f_handler: jmp far reloc_call_int2f_handler _int20_handler: jmp far reloc_call_int20_handler call near forceEnableA20 - - - global _int21_handler extern reloc_call_int21_handler _int21_handler: jmp far reloc_call_int21_handler @@ -837,17 +852,24 @@ _int0_handler: jmp far reloc_call_int0_handler global _cpm_entry extern reloc_call_cpm_entry -_cpm_entry: jmp far reloc_call_cpm_entry +_cpm_entry: jmp far reloc_call_cpm_entry call near forceEnableA20 -; global _init_call_init_buffers -; extern _reloc_call_init_buffers -;_init_call_init_buffers: jmp far _reloc_call_init_buffers -; call near forceEnableA20 + global _reloc_call_blk_driver + extern _blk_driver +_reloc_call_blk_driver: + jmp far _blk_driver + call near forceEnableA20 - global _init_call_p_0 - extern _reloc_call_p_0 -_init_call_p_0: jmp far _reloc_call_p_0 + global _reloc_call_clk_driver + extern _clk_driver +_reloc_call_clk_driver: + jmp far _clk_driver + call near forceEnableA20 + + global _CharMapSrvc + extern _reloc_call_CharMapSrvc +_CharMapSrvc: jmp far _reloc_call_CharMapSrvc call near forceEnableA20 @@ -1006,16 +1028,6 @@ _int24_handler: mov al,FAIL iret -segment HMA_TEXT - extern _init_call_printf:wrt TGROUP - global _printf - -_printf: - pop ax - push cs - push ax - jmp _init_call_printf - diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 26808d1..f813bd2 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.8 2001/04/15 03:21:50 bartoldeman +# See history.txt for the list of fixes. +# # Revision 1.7 2001/03/25 17:11:54 bartoldeman # Fixed sys.com compilation. Updated to 2023. Also: see history.txt. # @@ -131,10 +134,9 @@ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB #ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ # -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ - -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT \ - -g1 -INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT + -D__STDC__=0;I86;ASMSUPT -w -g1 +INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -zDIB -zRID -zTID +CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT HDR=../hdr/ # *Implicit Rules* @@ -272,7 +274,7 @@ config.obj: config.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ $(HDR)error.h $(HDR)version.h proto.h - $(CC) $(INITCFLAGS) -c config.c + $(CC) $(INITCFLAGS) -c config.c initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h \ @@ -288,7 +290,7 @@ main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h proto.h - $(CC) $(INITCFLAGS) -c main.c + $(CC) $(INITCFLAGS) -c main.c initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ @@ -296,7 +298,7 @@ initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h proto.h - $(CC) $(INITCFLAGS) -c initHMA.c + $(CC) $(INITCFLAGS) -c initHMA.c # XXX: I generated these using `gcc -MM' and `sed', so they may not be # completely correct... -- ror4 diff --git a/kernel/main.c b/kernel/main.c index 62cf002..493dab4 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -29,7 +29,6 @@ #include "init-mod.h" -#define MAIN #include "portab.h" #include "globals.h" @@ -39,6 +38,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.12 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -169,14 +171,14 @@ extern BYTE FAR * lpBase; extern BYTE FAR * upBase; INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); -VOID FAR init_call_WritePCClock(ULONG); -VOID FAR reloc_call_WritePCClock(ULONG); +VOID WritePCClock(ULONG); INIT VOID configDone(VOID); INIT static void InitIO(void); INIT static COUNT BcdToByte(COUNT); -INIT static COUNT BcdToDay(BYTE *); +/** INIT static COUNT BcdToDay(BYTE *);*/ +INIT static VOID update_dcb(struct dhdr FAR *); INIT static VOID init_kernel(VOID); INIT static VOID signon(VOID); INIT VOID kernel(VOID); @@ -226,26 +228,28 @@ INIT VOID main(void) at least one known utility (norton DE) seems to access them directly. ok, so we access for all drives, that the stuff gets build */ - -void InitializeAllBPBs() +/* + should not be necessary anymore (see DosSelectDrv in dosfns.c) +void InitializeAllBPBs(VOID) { static char filename[] = "A:-@JUNK@-.TMP"; int drive,fileno; for (drive = 'Z'; drive >= 'C'; drive--) { filename[0] = drive; - if ((fileno = dos_open((BYTE FAR *) filename, O_RDONLY)) >= 0) - dos_close(fileno); + if ((fileno = init_DosOpen(filename, O_RDONLY)) >= 0) + init_DosClose(fileno); } } - +*/ INIT void init_kernel(void) { COUNT i; + os_major = MAJOR_RELEASE; os_minor = MINOR_RELEASE; - cu_psp = DOS_PSP; + nblkdev = 0; maxbksize = 0x200; switchar = '/'; @@ -294,10 +298,13 @@ INIT void init_kernel(void) scr_pos = 0; break_ena = TRUE; + init_PSPInit(DOS_PSP); + /* Do first initialization of system variable buffers so that */ /* we can read config.sys later. */ lastdrive = Config.cfgLastdrive; PreConfig(); + init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); /* Now config the temporary file system */ FsConfig(); @@ -305,11 +312,12 @@ INIT void init_kernel(void) #ifndef KDB /* Now process CONFIG.SYS */ DoConfig(); - /* and do final buffer allocation. */ PostConfig(); + nblkdev = 0; + update_dcb(&blk_dev); - /* Init the file system on emore time */ + /* Init the file system one more time */ FsConfig(); /* and process CONFIG.SYS one last time to load device drivers. */ @@ -326,20 +334,12 @@ INIT void init_kernel(void) InDOS = 0; pDirFileNode = 0; dosidle_flag = 0; - - InitializeAllBPBs(); - } INIT VOID FsConfig(VOID) { REG COUNT i; - date Date; - time Time; - - /* Get the start-up date and time */ - Date = dos_getdate(); - Time = dos_gettime(); + struct dpb FAR *dpb; /* Initialize the file tables */ for (i = 0; i < Config.cfgFiles; i++) @@ -351,84 +351,36 @@ 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; } /* 0 is /dev/con (stdin) */ - sfthead->sftt_table[0].sft_count = 1; - sfthead->sftt_table[0].sft_mode = SFT_MREAD; - sfthead->sftt_table[0].sft_attrib = 0; - sfthead->sftt_table[0].sft_flags = - ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; - sfthead->sftt_table[0].sft_psp = DOS_PSP; - sfthead->sftt_table[0].sft_date = Date; - sfthead->sftt_table[0].sft_time = Time; - fbcopy( - (VOID FAR *) "CON ", - (VOID FAR *) sfthead->sftt_table[0].sft_name, 11); - sfthead->sftt_table[0].sft_dev = (struct dhdr FAR *)&con_dev; + init_DosOpen("CON", SFT_MREAD); + sfthead->sftt_table[0].sft_flags |= SFT_FCONIN | SFT_FCONOUT; /* 1 is /dev/con (stdout) */ - sfthead->sftt_table[1].sft_count = 1; - sfthead->sftt_table[1].sft_mode = SFT_MWRITE; - sfthead->sftt_table[1].sft_attrib = 0; - sfthead->sftt_table[1].sft_flags = - ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; - sfthead->sftt_table[1].sft_psp = DOS_PSP; - sfthead->sftt_table[1].sft_date = Date; - sfthead->sftt_table[1].sft_time = Time; - fbcopy( - (VOID FAR *) "CON ", - (VOID FAR *) sfthead->sftt_table[1].sft_name, 11); - sfthead->sftt_table[1].sft_dev = (struct dhdr FAR *)&con_dev; + init_DosOpen("CON", SFT_MWRITE); + sfthead->sftt_table[1].sft_flags |= SFT_FCONIN | SFT_FCONOUT; /* 2 is /dev/con (stderr) */ - sfthead->sftt_table[2].sft_count = 1; - sfthead->sftt_table[2].sft_mode = SFT_MWRITE; - sfthead->sftt_table[2].sft_attrib = 0; - sfthead->sftt_table[2].sft_flags = - ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; - sfthead->sftt_table[2].sft_psp = DOS_PSP; - sfthead->sftt_table[2].sft_date = Date; - sfthead->sftt_table[2].sft_time = Time; - fbcopy( - (VOID FAR *) "CON ", - (VOID FAR *) sfthead->sftt_table[2].sft_name, 11); - sfthead->sftt_table[2].sft_dev = (struct dhdr FAR *)&con_dev; + init_DosOpen("CON", SFT_MWRITE); + sfthead->sftt_table[2].sft_flags |= SFT_FCONIN | SFT_FCONOUT; /* 3 is /dev/aux */ - sfthead->sftt_table[3].sft_count = 1; - sfthead->sftt_table[3].sft_mode = SFT_MRDWR; - sfthead->sftt_table[3].sft_attrib = 0; - sfthead->sftt_table[3].sft_flags = - ((aux_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE; - sfthead->sftt_table[3].sft_psp = DOS_PSP; - sfthead->sftt_table[3].sft_date = Date; - sfthead->sftt_table[3].sft_time = Time; - fbcopy( - (VOID FAR *) "AUX ", - (VOID FAR *) sfthead->sftt_table[3].sft_name, 11); - sfthead->sftt_table[3].sft_dev = (struct dhdr FAR *)&aux_dev; + init_DosOpen("AUX", SFT_MRDWR); + sfthead->sftt_table[3].sft_flags &= ~SFT_FEOF; /* 4 is /dev/prn */ - sfthead->sftt_table[4].sft_count = 1; - sfthead->sftt_table[4].sft_mode = SFT_MWRITE; - sfthead->sftt_table[4].sft_attrib = 0; - sfthead->sftt_table[4].sft_flags = - ((prn_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE; - sfthead->sftt_table[4].sft_psp = DOS_PSP; - sfthead->sftt_table[4].sft_date = Date; - sfthead->sftt_table[4].sft_time = Time; - fbcopy( - (VOID FAR *) "PRN ", - (VOID FAR *) sfthead->sftt_table[4].sft_name, 11); - sfthead->sftt_table[4].sft_dev = (struct dhdr FAR *)&prn_dev; + init_DosOpen("PRN", SFT_MWRITE); + sfthead->sftt_table[4].sft_flags &= ~SFT_FEOF; /* Log-in the default drive. */ /* Get the boot drive from the ipl and use it for default. */ default_drive = BootDrive - 1; + dpb = DPBp; - /* Initialzie the current directory structures */ + /* Initialize the current directory structures */ for (i = 0; i < lastdrive ; i++) { struct cds FAR *pcds_table = &CDSp->cds_table[i]; @@ -438,10 +390,11 @@ INIT VOID FsConfig(VOID) pcds_table->cdsCurrentPath[0] += i; - if (i < nblkdev) + if (i < nblkdev && (ULONG)dpb != 0xffffffffl) { - pcds_table->cdsDpb = &blk_devices[i]; + pcds_table->cdsDpb = dpb; pcds_table->cdsFlags = CDSPHYSDRV; + dpb = dpb->dpb_next; } else { @@ -453,7 +406,7 @@ INIT VOID FsConfig(VOID) pcds_table->cdsJoinOffset = 2; } - /* Initialze the disk buffer management functions */ + /* Initialize the disk buffer management functions */ /* init_call_init_buffers(); done from CONFIG.C */ } @@ -495,21 +448,55 @@ INIT void kernel() ep += sizeof(int); #endif RootPsp = ~0; - - init_call_p_0(); + p_0(); } +/* check for a block device and update device control block */ +static VOID update_dcb(struct dhdr FAR * dhp) +{ + REG COUNT Index; + COUNT nunits = dhp->dh_name[0]; + struct dpb FAR *dpb; + + if (nblkdev==0) + dpb = DPBp; + else { + for (dpb = DPBp; (ULONG)dpb->dpb_next != 0xffffffffl; dpb = dpb->dpb_next) + ; + dpb = dpb->dpb_next = (struct dpb FAR *)KernelAlloc(nunits*sizeof(struct dpb)); + } + + for(Index = 0; Index < nunits; Index++) + { + dpb->dpb_next = dpb+1; + dpb->dpb_unit = nblkdev; + dpb->dpb_subunit = Index; + dpb->dpb_device = dhp; + dpb->dpb_flags = M_CHANGED; + if ((CDSp != 0) && (nblkdev < lastdrive)) + { + CDSp->cds_table[nblkdev].cdsDpb = dpb; + CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; + } + ++dpb; + ++nblkdev; + } + (dpb-1)->dpb_next = (void FAR *)0xFFFFFFFFl; +} + + /* If cmdLine is NULL, this is an internal driver */ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_top) { request rq; - ULONG memtop = ((ULONG) r_top) << 10; - ULONG maxmem = memtop - ((ULONG) FP_SEG(dhp) << 4); + UCOUNT maxmem = ((UCOUNT)r_top << 6) - FP_SEG(dhp); - if (maxmem >= 0x10000) + if (maxmem >= 0x1000) maxmem = 0xFFFF; + else + maxmem <<= 4; rq.r_unit = 0; rq.r_status = 0; @@ -519,7 +506,6 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); rq.r_firstunit = nblkdev; - execrh((request FAR *) & rq, dhp); /* @@ -535,32 +521,11 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ lpBase = rq.r_endaddr; } -/* check for a block device and update device control block */ - if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) - { - REG COUNT Index; - - for (Index = 0; Index < rq.r_nunits; Index++) - { - struct dpb *pblk_devices = &blk_devices[nblkdev]; - - if (nblkdev) - (pblk_devices-1)->dpb_next = pblk_devices; - - pblk_devices->dpb_next = (void FAR *)0xFFFFFFFF; - pblk_devices->dpb_unit = nblkdev; - pblk_devices->dpb_subunit = Index; - pblk_devices->dpb_device = dhp; - pblk_devices->dpb_flags = M_CHANGED; - if ((CDSp != 0) && (nblkdev < lastdrive)) - { - CDSp->cds_table[nblkdev].cdsDpb = pblk_devices; - CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; - } - ++nblkdev; - } + if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { + dhp->dh_name[0] = rq.r_nunits; + update_dcb(dhp); } - DPBp = &blk_devices[0]; + return FALSE; } @@ -579,7 +544,6 @@ INIT static void InitIO(void) setvec(0x29, int29_handler); /* Requires Fast Con Driver */ init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top); - init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 3e881fd..cd0bcb0 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.11 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -166,9 +169,12 @@ seg far2para(VOID FAR * p) return FP_SEG(p) + (FP_OFF(p) >> 4); } -seg long2para(LONG size) +seg long2para(ULONG size) { - return ((size + 0x0f) >> 4); + UWORD high = size>>16; + if ((UWORD)size > 0xfff0) + high++; + return (((UWORD)size + 0x0f) >> 4) + (high << 12); } /* @@ -176,11 +182,14 @@ seg long2para(LONG size) */ VOID FAR *add_far(VOID FAR * fp, ULONG off) { - if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + off; + UWORD off2; + + if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + FP_OFF(off); off += FP_OFF(fp); + off2 = ((off >> 16) << 12) + ((UWORD)off >> 4); - return MK_FP(FP_SEG(fp) + (UWORD) (off >> 4), (UWORD) off & 0xf); + return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); } /* @@ -199,7 +208,7 @@ VOID FAR *adjust_far(VOID FAR * fp) #undef REG #define REG -#ifdef KERNEL +#if 1 /* #ifdef KERNEL KERNEL */ /* Allocate a new memory area. *para is assigned to the segment of the MCB rather then the segment of the data portion */ /* If mode == LARGEST, asize MUST be != NULL and will always recieve the @@ -234,7 +243,7 @@ searchAgain: /* check for corruption */ if (!mcbValid(p)) return DE_MCBDESTRY; - + if (mcbFree(p)) { /* unused block, check if it applies to the rule */ if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ @@ -347,11 +356,6 @@ stopIt: /* reached from FIRST_FIT on match */ return SUCCESS; } -COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) -{ - return DosMemAlloc(size, mode, para, asize); -} - /* * Unlike the name and the original prototype could suggest, this function * is used to return the _size_ of the largest available block rather than @@ -363,7 +367,6 @@ COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FA COUNT DosMemLargest(UWORD FAR * size) { REG mcb FAR *p; - COUNT found; /* Initialize */ p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root) @@ -550,7 +553,7 @@ COUNT DosMemCheck(void) COUNT FreeProcessMem(UWORD ps) { - mcb FAR *p, FAR *u; + mcb FAR *p; COUNT x = 0; /* Initialize */ @@ -574,7 +577,7 @@ COUNT FreeProcessMem(UWORD ps) return DE_MCBDESTRY; } -#if 0 +#if 0 /* seems to be superceeded by DosMemLargest -- 1999/04/21 ska */ COUNT DosGetLargestBlock(UWORD FAR * block) @@ -621,14 +624,12 @@ VOID show_chain(void) p = nxtMCB(p); } } -#endif VOID mcb_print(mcb FAR * mcbp) { static BYTE buff[9]; - VOID _fmemcpy(); - _fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); + fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); buff[8] = '\0'; printf("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n", FP_SEG(mcbp), @@ -638,14 +639,8 @@ VOID mcb_print(mcb FAR * mcbp) mcbp->m_psp, mcbp->m_size); } -/* -VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) -{ - while (n--) - *d++ = *s++; +#endif -} -*/ VOID DosUmbLink(BYTE n) { REG mcb FAR *p; @@ -688,4 +683,58 @@ VOID DosUmbLink(BYTE n) DUL_exit: return; } + +/* + if we arrive here the first time, it's just + before jumping to COMMAND.COM + + so we are done initializing, and can claim the IMIT_DATA segment, + as these data/strings/buffers are no longer in use. + + we carve a free memory block out of it and hope that + it will be useful (maybe for storing environments) + +*/ + +BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ +extern BYTE _INIT_DATA_START[], _INIT_DATA_END[]; + +VOID ClaimINITDataSegment() +{ + unsigned ilow,ihigh; + VOID FAR * p; + + if (INITDataSegmentClaimed) + return; + INITDataSegmentClaimed = 1; + + + ilow = (unsigned)_INIT_DATA_START; + ilow = (ilow+0x0f) & ~0x000f; + ihigh = (unsigned)_INIT_DATA_END; + ihigh = ((ihigh + 0x0f) & ~0x000f) - 0x20; + + if (ilow +0x10 < ihigh) + { + printf("CLAIMING INIT_DATA memory - %u bytes\n",ihigh - ilow); + } + + + ((mcb*)ilow)->m_type = MCB_NORMAL; /* 'M' */ + ((mcb*)ilow)->m_psp = FREE_PSP; /* '0' */ + ((mcb*)ilow)->m_size = (ihigh-ilow-0x10)>>4; /* '0' */ + + ((mcb*)ihigh)->m_type = MCB_NORMAL; /* 'M' */ + ((mcb*)ihigh)->m_psp = 0x0008; /* system */ + + p = (void FAR*)(void*)ihigh; + + ((mcb*)ihigh)->m_size = first_mcb -1 - FP_SEG(p) - (FP_OFF(p) >> 4); + + p = (void FAR*)(void*)ilow; + + first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); + +} + #endif diff --git a/kernel/misc.c b/kernel/misc.c index 2593a3b..fa26a11 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -34,6 +34,9 @@ static BYTE *miscRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -98,11 +101,6 @@ VOID scopy(REG BYTE * s, REG BYTE * d) *d = '\0'; } -VOID FAR init_call_scopy(REG BYTE * s, REG BYTE * d) -{ - scopy(s, d); -} - VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d) { while (*s) @@ -117,7 +115,6 @@ VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n) *d = '\0'; } -#ifndef ASMSUPT VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n) { while (n--) @@ -137,16 +134,3 @@ VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) } #endif - -VOID FAR init_call_fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n) -{ - fbcopy(s, d, n); -} - -VOID fmemset(VOID FAR *, int, COUNT); - -VOID FAR init_call_fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) -{ - fmemset(s, ch, n); -} -#endif diff --git a/kernel/network.c b/kernel/network.c index 75db9da..0c5f763 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.10 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -86,7 +89,7 @@ static BYTE *RcsId = "$Id$"; */ UWORD get_machine_name(BYTE FAR * netname) { - fmemcpy(netname, &net_name, 15); + fmemcpy(netname, &net_name, 16); return (NetBios); } @@ -124,8 +127,8 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e */ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) { - COUNT i, x; - char FAR *p, FAR *q; + COUNT i; + char FAR *p; VOID FAR * test; struct dirent FAR *SDp = (struct dirent FAR *) &SearchDir; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 8bb0a92..497b697 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.10 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -152,10 +155,10 @@ int SetJFTSize(UWORD nHandles) return SUCCESS; } +/* this is the same, is shorter (~170)and slightly easier to understand TE*/ int DosMkTmp(BYTE FAR * pathname, UWORD attr) { /* create filename from current date and time */ - static const char tokens[] = "0123456789ABCDEF"; char FAR *ptmp = pathname; BYTE wd, month, @@ -167,6 +170,8 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) WORD sh; WORD year; int rc; + char name83[13]; + int loop; while (*ptmp) ptmp++; @@ -179,61 +184,46 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) sh = s * 100 + hund; - ptmp[0] = tokens[year & 0xf]; - ptmp[1] = tokens[month]; - ptmp[2] = tokens[day & 0xf]; - ptmp[3] = tokens[h & 0xf]; - ptmp[4] = tokens[m & 0xf]; - ptmp[5] = tokens[(sh >> 8) & 0xf]; - ptmp[6] = tokens[(sh >> 4) & 0xf]; - ptmp[7] = tokens[sh & 0xf]; - ptmp[8] = '.'; - ptmp[9] = 'A'; - ptmp[10] = 'A'; - ptmp[11] = 'A'; - ptmp[12] = 0; + for ( loop = 0; loop < 0xfff; loop++) + { + sprintf(name83,"%x%x%x%x%x%03x.%03x", - while ((rc = DosOpen(pathname, 0)) >= 0) - { - DosClose(rc); + year & 0xf,month & 0xf, day & 0xf,h & 0xf,m & 0xf, sh&0xfff, + loop & 0xfff); - if (++ptmp[11] > 'Z') + fmemcpy(ptmp, name83, 13); + + if ((rc = DosOpen(pathname, 0)) < 0 && + rc != DE_ACCESS /* subdirectory ?? */ + /* todo: sharing collision on + network drive + */ + ) + break; + + if (rc >= 0) DosClose(rc); + } + + if (rc == DE_FILENOTFND) { - if (++ptmp[10] > 'Z') - { - if (++ptmp[9] > 'Z') - return DE_TOOMANY; - - ptmp[10] = 'A'; - } - ptmp[11] = 'A'; + rc = DosCreat(pathname, attr); } - } - - if (rc == DE_FILENOTFND) - { - rc = DosCreat(pathname, attr); - } - return rc; + return rc; } COUNT get_verify_drive(char FAR *src) { - COUNT drive; - /* First, adjust the source pointer */ - src = adjust_far(src); + UBYTE drive; /* Do we have a drive? */ if (src[1] == ':') - { - drive = (src[0] | 0x20) - 'a'; - } + drive = ((src[0]-1) | 0x20) - ('a'-1); else - drive = default_drive; - if ((drive < 0) || (drive >= lastdrive)) { - drive = DE_INVLDDRV; - } - return drive; + return default_drive; + if (drive < lastdrive && CDSp->cds_table[drive].cdsFlags & CDSVALID) + return drive; + else + return DE_INVLDDRV; } /* @@ -271,21 +261,19 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) dest[0] = '\0'; + i = get_verify_drive(src); + if (i < 0) + return DE_INVLDDRV; + + buf[0] = i + 'A'; + buf[1] = ':'; /* Just to be sure */ + /* First, adjust the source pointer */ src = adjust_far(src); /* Do we have a drive? */ if (src[1] == ':') - { - buf[0] = (src[0] | 0x20) + 'A' - 'a'; - - if (buf[0] >= lastdrive + 'A') /* BUG:should be: drive exists */ - return DE_INVLDDRV; - src += 2; - } - else - buf[0] = default_drive + 'A'; /* /// Added to adjust for filenames which begin with ".\" The problem was manifesting itself in the inability @@ -297,7 +285,6 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) /* /// Changed to "while" from "if". - Ron Cemer */ while ( (src[0] == '.') && (src[1] == '\\') ) src += 2; - i = buf[0] - 'A'; /* Code repoff from dosfns.c MSD returns X:/CON for truename con. Not X:\CON diff --git a/kernel/nls.c b/kernel/nls.c index 5e60ce4..31a3177 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.5 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -256,7 +259,7 @@ static COUNT cpyBuf(VOID FAR *dst, UWORD dstlen , VOID FAR *src, UWORD srclen) { if(srclen <= dstlen) { - _fmemcpy(dst, src, srclen); + fmemcpy(dst, src, srclen); return SUCCESS; } return DE_INVLDFUNC; /* buffer too small */ diff --git a/kernel/prf.c b/kernel/prf.c index 1c04d1b..8be3991 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,12 +28,18 @@ #include "portab.h" +COUNT strlen (BYTE * s); /* don't want globals.h, sorry */ + + #ifdef VERSION_STRINGS static BYTE *prfRcsId = "$Id$"; #endif /* * $Log$ + * Revision 1.7 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.6 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -44,6 +50,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.7 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.6 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -166,7 +175,7 @@ BYTE * p = q = s; do { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[u % base]; + *p++ = "0123456789abcdef"[(UWORD)(u % base)]; } while ((u /= base) > 0); @@ -185,11 +194,10 @@ BYTE * #define RIGHT 1 /* printf -- short version of printf to conserve space */ -WORD FAR - init_call_printf(CONST BYTE * fmt, BYTE * args) +WORD printf(CONST BYTE * fmt, ...) { charp = 0; - return do_printf(fmt, &args); + return do_printf(fmt, (BYTE **)&fmt + 1); } WORD @@ -216,8 +224,7 @@ COUNT { int base; BYTE s[11], - *p, - *ltob(); + *p; int c, flag, size, diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index e3cd198..d5402b3 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.5 2001/03/24 22:13:05 bartoldeman ; See history.txt: dsk.c changes, warning removal and int21 entry handling. ; @@ -94,16 +97,14 @@ extern _api_ss:wrt DGROUP ; switching extern _usr_sp:wrt DGROUP ; user stacks extern _usr_ss:wrt DGROUP - - extern _kstackp:wrt TGROUP ; kernel stack - extern _ustackp:wrt TGROUP ; new task stack + extern _lpUserStack:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag extern _int21_handler:wrt TGROUP ; far call system services %include "stacks.inc" -segment _TEXT +segment _TEXT extern _DGROUP_:wrt TGROUP @@ -149,6 +150,7 @@ _got_cbreak: pop ds iret +segment HMA_TEXT ; ; Special call for switching processes during break handling @@ -191,8 +193,23 @@ _spawn_int23: ; restore to user stack cli ;; Pre-8086 don't disable INT autom. - mov ss,[_usr_ss] - mov sp,[_usr_sp] +;*TE PATCH +; CtrlC at DosInput (like C:>DATE does) +; Nukes the Kernel. +; +; it looks like ENTRY.ASM+PROCSUPT.ASM +; got out of sync. +; +; spawn_int() assumes a stack layout at +; usr_ss:usr:sp. but usr:ss currently contains 0 +; +; this patch helps FreeDos to survive CtrlC, +; but should clearly be done somehow else. + mov ss, [_lpUserStack+2] + mov sp, [_lpUserStack] + +; mov ss,[_usr_ss] +; mov sp,[_usr_sp] sti ; get all the user registers back @@ -307,13 +324,8 @@ _spawn_int23: ??int23_respawn: pop bp ;; Restore the original register - jmp _int21_handler + jmp far _int21_handler - - global _init_call_spawn_int23 -_init_call_spawn_int23: - call _spawn_int23 - retf ; ; interrupt enable and disable routines ; diff --git a/kernel/proto.h b/kernel/proto.h index 590c5d7..8b5495a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.12 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -162,18 +165,7 @@ static BYTE *Proto_hRcsId = "$Id$"; #define INIT -#ifdef IN_INIT_MOD -#define __FAR_WRAPPER(ret, name, proto) \ - ret FAR name proto; /* will be expanded to `init_call_' */ -#else -#define __FAR_WRAPPER(ret, name, proto) \ - ret name proto; \ - ret FAR init_call_##name proto; \ - ret FAR reloc_call_##name proto; -#endif - /* blockio.c */ -VOID FAR init_call_init_buffers(COUNT anzBuffers); ULONG getblkno(struct buffer FAR *); VOID setblkno(struct buffer FAR *, ULONG); struct buffer FAR *getblock(ULONG blkno, COUNT dsk); @@ -198,7 +190,7 @@ BOOL con_break(void); BOOL StdinBusy(void); VOID KbdFlush(void); VOID Do_DosIdle_loop(void); -__FAR_WRAPPER(VOID, sti, (keyboard FAR * kp)) +VOID sti(keyboard FAR * kp); sft FAR *get_sft(COUNT); @@ -214,6 +206,7 @@ INIT COUNT tolower(COUNT c); INIT COUNT toupper(COUNT c); INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); +INIT BYTE FAR *KernelAlloc(WORD nBytes); /* dosfns.c */ BYTE FAR *get_root(BYTE FAR *); @@ -231,8 +224,8 @@ COUNT DosDup(COUNT Handle); COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); COUNT DosOpen(BYTE FAR * fname, COUNT mode); COUNT DosClose(COUNT hndl); -VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); -COUNT DosGetCuDir(COUNT drive, BYTE FAR * s); +VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); +COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); @@ -240,14 +233,15 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp); COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp); -BYTE DosSelectDrv(BYTE drv); +UBYTE DosSelectDrv(UBYTE drv); COUNT DosDelete(BYTE FAR *path); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); struct dhdr FAR * IsDevice(BYTE FAR * FileName); -/* extern sft FAR *get_free_sft(WORD FAR * sft_idx); - #define FcbGetFreeSft(sft_idx) get_free_sft(sft_idx) */ +BOOL IsShareInstalled(void); +COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); +sft FAR *get_free_sft(WORD FAR * sft_idx); /*dosidle.asm */ VOID DosIdle_int(void); @@ -258,12 +252,12 @@ COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); /* dsk.c */ -COUNT FAR init_call_blk_driver(rqptr rp); +COUNT FAR blk_driver(rqptr rp); /* error.c */ VOID dump(void); VOID panic(BYTE * s); -__FAR_WRAPPER(VOID, fatal, (BYTE * err_msg)) +VOID fatal(BYTE * err_msg); COUNT char_error(request * rq, struct dhdr FAR * lpDevice); COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); @@ -277,17 +271,17 @@ COUNT dos_findnext(void); void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); /* fatfs.c */ -__FAR_WRAPPER(COUNT, dos_open, (BYTE FAR * path, COUNT flag)) +COUNT dos_open(BYTE FAR * path, COUNT flag); BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n); BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); VOID touc(BYTE FAR * s, COUNT n); -__FAR_WRAPPER(COUNT, dos_close, (COUNT fd)) +COUNT dos_close(COUNT fd); COUNT dos_creat(BYTE FAR * path, COUNT attrib); COUNT dos_delete(BYTE FAR * path); COUNT dos_rmdir(BYTE FAR * path); COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2); -__FAR_WRAPPER(date, dos_getdate, (void)) -__FAR_WRAPPER(time, dos_gettime, (void)) +date dos_getdate(void); +time dos_gettime(void); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp); LONG dos_getcufsize(COUNT fd); @@ -298,10 +292,10 @@ BOOL last_link(struct f_node FAR * fnp); COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode); UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); -__FAR_WRAPPER(COUNT, dos_read, (COUNT fd, VOID FAR * buffer, UCOUNT count)) +COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); -UWORD dos_free(struct dpb *dpbp); +UWORD dos_free(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s); @@ -312,18 +306,19 @@ VOID release_f_node(struct f_node FAR * fnp); VOID dos_setdta(BYTE FAR * newdta); COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp); COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp); -COUNT media_check(REG struct dpb *dpbp); +COUNT media_check(REG struct dpb FAR *dpbp); struct f_node FAR *xlt_fd(COUNT fd); COUNT xlt_fnp(struct f_node FAR * fnp); struct dhdr FAR *select_unit(COUNT drive); +VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp); /* fattab.c */ -UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); -UCOUNT link_fat16(struct dpb *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UCOUNT link_fat12(struct dpb *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UWORD next_cluster(struct dpb *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl16(struct dpb *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl12(struct dpb *dpbp, REG UCOUNT ClusterNum); +UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); +UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); +UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); +UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); +UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); +UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); /* fcbfns.c */ VOID DosOutputString(BYTE FAR * s); @@ -345,8 +340,8 @@ BOOL FcbSetRandom(xfcb FAR * lpXfcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb); BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); -BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode); -BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode); +BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, + BOOL (*FcbFunc)(xfcb FAR *, COUNT *)); BOOL FcbCreate(xfcb FAR * lpXfcb); void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); BOOL FcbOpen(xfcb FAR * lpXfcb); @@ -384,8 +379,17 @@ VOID INRPT FAR int2f_handler(void); VOID INRPT FAR empty_handler(void); VOID INRPT FAR int0_handler(void); +/* intr.asm */ +/* void init_call_intr(int nr, iregs *rp); */ +INIT COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n); +INIT COUNT init_DosOpen(BYTE *fname, COUNT mode); +INIT COUNT init_DosClose(COUNT hndl); +INIT VOID init_PSPInit(seg psp_seg); +INIT VOID keycheck(VOID); + /* ioctl.c */ -COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); +COUNT DosDevIOctl(iregs FAR * r); + /* main.c */ INIT VOID main(void); @@ -393,11 +397,10 @@ INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COU /* memmgr.c */ seg far2para(VOID FAR * p); -seg long2para(LONG size); +seg long2para(ULONG size); VOID FAR *add_far(VOID FAR * fp, ULONG off); VOID FAR *adjust_far(VOID FAR * fp); -__FAR_WRAPPER(COUNT, DosMemAlloc, - (UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize)) +COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize); COUNT DosMemLargest(UWORD FAR * size); COUNT DosMemFree(UWORD para); COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize); @@ -410,16 +413,15 @@ VOID mcb_print(mcb FAR * mcbp); /* misc.c */ /* -__FAR_WRAPPER(VOID, scopy, (REG BYTE * s, REG BYTE * d)) +VOID scopy(REG BYTE * s, REG BYTE * d); #define strcpy(d, s) scopy(s, d) -__FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n)) +VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n); */ -__FAR_WRAPPER(VOID, strcpy, (REG BYTE * d, REG BYTE * s)) +VOID strcpy(REG BYTE * d, REG BYTE * s); #define scopy(s, d) strcpy(d,s) -__FAR_WRAPPER(VOID, fmemcpy, (REG VOID FAR * d, REG VOID FAR * s, REG COUNT n)) +VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); #define fbcopy(s, d, n) fmemcpy(d,s,n) -void FAR _reloc_call_fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); /*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/ @@ -432,8 +434,8 @@ VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); void memcpy(REG BYTE * d, REG BYTE * s, REG COUNT n); #define bcopy(s,d,n) memcpy(d,s,n) -__FAR_WRAPPER(void, fmemset,(REG VOID FAR * s, REG int ch, REG COUNT n)) -__FAR_WRAPPER(void, memset ,(REG VOID * s, REG int ch, REG COUNT n)) +void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); +void memset(REG VOID * s, REG int ch, REG COUNT n); /* nls.c */ @@ -460,16 +462,16 @@ UWORD syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); -__FAR_WRAPPER(WORD, printf, (CONST BYTE * fmt,...)) +WORD printf(CONST BYTE * fmt,...); WORD sprintf(BYTE * buff, CONST BYTE * fmt,...); VOID hexd(char *title,VOID FAR *p,COUNT numBytes); /* strings.c */ -__FAR_WRAPPER(COUNT, strlen, (REG BYTE * s)) +COUNT strlen(REG BYTE * s); COUNT fstrlen(REG BYTE FAR * s); VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l); -__FAR_WRAPPER(COUNT, strcmp, (REG BYTE * d, REG BYTE * s)) +COUNT strcmp(REG BYTE * d, REG BYTE * s); COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l); @@ -483,7 +485,7 @@ void fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); BYTE *strchr(BYTE * s, BYTE c); /* sysclk.c */ -WORD FAR init_call_clk_driver(rqptr rp); +WORD FAR clk_driver(rqptr rp); COUNT BcdToByte(COUNT x); COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); COUNT ByteToBcd(COUNT x); @@ -505,7 +507,7 @@ VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); WORD *is_leap_year_monthdays(int year); -__FAR_WRAPPER(WORD,DaysFromYearMonthDay,(WORD Year, WORD Month, WORD DayOfMonth)) +WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth); @@ -513,10 +515,9 @@ __FAR_WRAPPER(WORD,DaysFromYearMonthDay,(WORD Year, WORD Month, WORD DayOfMonth) COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname); VOID new_psp(psp FAR * p, int psize); VOID return_user(void); -__FAR_WRAPPER(COUNT, DosExec, (COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)) -__FAR_WRAPPER(VOID, InitPSP, (VOID)) - -VOID FAR init_call_p_0(VOID); +COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); +VOID InitPSP(VOID); +VOID p_0(VOID); /* irqstack.asm */ VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); diff --git a/kernel/segs.inc b/kernel/segs.inc index 992212d..6f88f73 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -58,7 +61,7 @@ ; group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSS _BSSEND +group DGROUP _FIXED_DATA _DATA _BSS _BSSEND ID_B ID ID_E group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END @@ -67,11 +70,14 @@ segment _IO_TEXT class=CODE segment _IO_FIXED_DATA class=CODE align=2 segment _FIXED_DATA class=DATA align=16 segment _DATA class=DATA align=2 -segment _BSSSTART class=BSS align=2 +segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS +segment ID_B class=ID align=2 +segment ID class=ID align=2 +segment ID_E class=ID align=2 segment HMA_TEXT_START class=HMA -segment HMA_TEXT class=HMA +segment HMA_TEXT class=HMA segment HMA_TEXT_END class=HMA segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT diff --git a/kernel/strings.c b/kernel/strings.c index c97ca2b..c9a89ee 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,6 +34,9 @@ static BYTE *stringsRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -104,11 +107,6 @@ COUNT strlen(REG BYTE * s) return cnt; } -COUNT FAR init_call_strlen(REG BYTE * s) -{ - return strlen(s); -} - COUNT fstrlen(REG BYTE FAR * s) { REG WORD cnt = 0; @@ -145,11 +143,6 @@ COUNT strcmp(REG BYTE * d, REG BYTE * s) return *d - *s; } -COUNT FAR init_call_strcmp(REG BYTE * d, REG BYTE * s) -{ - return strcmp(d, s); -} - COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s) { while (*s != '\0' && *d != '\0') diff --git a/kernel/sysclk.c b/kernel/sysclk.c index c3188b3..f13710c 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -121,17 +124,16 @@ static UWORD Month, Year; static BYTE bcdMinutes; static BYTE bcdHours; -static BYTE bcdHundredths; +/** static BYTE bcdHundredths;*/ static BYTE bcdSeconds; static ULONG Ticks; UWORD DaysSinceEpoch = 0; -WORD FAR init_call_clk_driver(rqptr rp) +WORD FAR clk_driver(rqptr rp) { COUNT c; - int FAR *cp; WORD *pdays; switch (rp->r_command) @@ -337,9 +339,3 @@ VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr) x[3] = ByteToBcd(*yr / 100); x[2] = ByteToBcd(*yr % 100); } - -/* Used by `main.c'. */ -VOID FAR init_call_WritePCClock(ULONG ticks) -{ - WritePCClock(ticks); -} diff --git a/kernel/systime.c b/kernel/systime.c index 0bb740f..5bc13d2 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,6 +37,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -133,11 +136,6 @@ WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) + ((Year - 1980 + 3) / 4); } -WORD FAR init_call_DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) -{ - return DaysFromYearMonthDay(Year,Month,DayOfMonth); -} - /* common - call the clock driver */ void ExecuteClockDriverRequest(BYTE command) diff --git a/kernel/task.c b/kernel/task.c index 4c3243f..c7702a9 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.9 2001/03/31 20:54:52 bartoldeman * Made SHELLHIGH behave more like LOADHIGH. * @@ -149,6 +152,8 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ +extern VOID ClaimINITDataSegment(VOID); + #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) #define LOADNGO 0 @@ -160,7 +165,7 @@ static BYTE *RcsId = "$Id$"; static exe_header header; #define CHUNK 32256 -#define MAXENV 32768 +#define MAXENV 32768u #define ENV_KEEPFREE 83 /* keep unallocated by environment variables */ /* The '65' added to nEnvSize does not cover the additional stuff: + 2 bytes: number of strings @@ -311,12 +316,10 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) VOID new_psp(psp FAR * p, int psize) { REG COUNT i; - BYTE FAR *lpPspBuffer; psp FAR *q = MK_FP(cu_psp, 0); /* Clear out new psp first */ - for (lpPspBuffer = (BYTE FAR *) p, i = 0; i < sizeof(psp); ++i) - *lpPspBuffer = 0; + fmemset(p, 0, sizeof(psp)); /* initialize all entries and exits */ /* CP/M-like exit point */ @@ -364,7 +367,7 @@ VOID new_psp(psp FAR * p, int psize) p->ps_filetab = p->ps_files; /* clone the file table */ - if (InDOS > 0) + if (p!=q) { REG COUNT i; @@ -376,15 +379,6 @@ VOID new_psp(psp FAR * p, int psize) p->ps_filetab[i] = 0xff; } } - else - { - /* initialize stdin, stdout, etc */ - p->ps_files[STDIN] = 0; /* stdin */ - p->ps_files[STDOUT] = 1; /* stdout */ - p->ps_files[STDERR] = 2; /* stderr */ - p->ps_files[STDAUX] = 3; /* stdaux */ - p->ps_files[STDPRN] = 4; /* stdprn */ - } /* first command line argument */ p->ps_fcb1.fcb_drive = 0; @@ -540,14 +534,16 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) sp = MK_FP(mem, 0); else { /* test the filesize against the allocated memory */ + UWORD tmp = 16; + sp = MK_FP(mem, sizeof(psp)); /* This is a potential problem, what to do with .COM files larger than the allocated memory? MS DOS always only loads the very first 64KB - sizeof(psp) bytes. -- 1999/04/21 ska */ - if (com_size > (LONG) asize << 4) /* less memory than the .COM file has */ - com_size = (LONG) asize << 4; + if ((ULONG)com_size > (ULONG)asize * tmp) /* less memory than the .COM file has */ + (ULONG)com_size = (ULONG)asize * tmp; /* << 4 */ } do { @@ -597,6 +593,14 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { cu_psp = mem; dta = p->ps_dta; + + /* if that's the first time, we arrive here + now we 1 microsecond from COMMAND.COM + now we claim the ID = INIT_DATA segment, + which should no longer be used + */ + ClaimINITDataSegment(); + if (InDOS) --InDOS; exec_user(irp); @@ -693,13 +697,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) mem = exp->load.load_seg; /* compute image offset from the header */ - image_offset = (ULONG) header.exHeaderSize * 16l; + asize = 16; + image_offset = (ULONG)header.exHeaderSize * asize; /* compute image size by removing the offset from the */ /* number pages scaled to bytes plus the remainder and */ /* the psp */ /* First scale the size */ - image_size = (ULONG) (header.exPages) * 512l; + asize = 512; + image_size = (ULONG)header.exPages * asize; /* remove the offset */ image_size -= image_offset; @@ -777,7 +783,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) asize = exe_size; #ifdef DEBUG - printf("loading %s at %04x\n", (char*)namep,mem); +{ COUNT i = 0; + printf("loading '"); + while (namep[i]!=0) + { + cso(namep[i]); + i++; + } + printf("' at %04x\n", mem); +} #endif /* /// Added open curly brace and "else" clause. We should not attempt @@ -844,6 +858,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (exe_size > 0) { + UCOUNT tmp = 16; + sp = MK_FP(start_seg, 0x0); if (mode != OVERLAY) @@ -851,7 +867,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) { sp = MK_FP(start_seg + mp->m_size - - (image_size + 15) / 16, 0); + - (image_size + 15) / tmp, 0); } } @@ -928,6 +944,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) case LOADNGO: cu_psp = mem; dta = p->ps_dta; + + + /* if that's the first time, we arrive here + now we 1 microsecond from COMMAND.COM + now we claim the ID = INIT_DATA segment, + which should no longer be used + */ + ClaimINITDataSegment(); + if (InDOS) --InDOS; exec_user(irp); @@ -954,15 +979,14 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) { COUNT rc, err; - exec_blk leb = *ep; + exec_blk leb; + /* BYTE FAR *cp;*/ BOOL bIsCom = FALSE; + fmemcpy(&leb, ep, sizeof(exec_blk)); /* If file not found - free ram and return error */ - if (cu_psp == DOS_PSP) - InitPSP(); - if ((rc = DosOpen(lp, 0)) < 0) { return DE_FILENOTFND; @@ -985,43 +1009,22 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) rc = DosExeLoader(lp, &leb, mode); } if (mode == LOAD && rc == SUCCESS) - *ep = leb; + fmemcpy(ep, &leb, sizeof(exec_blk)); return rc; } -COUNT FAR init_call_DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) -{ - return DosExec(mode, ep, lp); -} - -VOID InitPSP(VOID) -{ - psp FAR *p = MK_FP(DOS_PSP, 0); -/* - Fixed Device Driver Print output. - */ - if(p->ps_exit == 0x000020cd) - return; - new_psp(p, 0); -} - -UBYTE P_0_startmode = 0; - /* process 0 */ -VOID FAR reloc_call_p_0(VOID) +VOID p_0(VOID) { exec_blk exb; CommandTail Cmd; BYTE FAR *szfInitialPrgm = (BYTE FAR *) Config.cfgInit; int rc; -/* init a fake psp file at seg 50:0000 */ - psp FAR *p = MK_FP(cu_psp, 0); - new_psp(p, 0); /* Execute command.com /P from the drive we just booted from */ exb.exec.env_seg = master_env; - strcpy(Cmd.ctBuffer, Config.cfgInitTail); + fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1); for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') diff --git a/sys/sys.mak b/sys/sys.mak index d48f402..9f5e0bb 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.7 2001/04/15 03:21:50 bartoldeman +# See history.txt for the list of fixes. +# # Revision 1.6 2001/03/25 04:33:56 bartoldeman # Fix compilation of sys.com. Now a proper .com file once again. # @@ -43,7 +46,7 @@ !include "..\config.mak" CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO -zAHMA -zCHMA_TEXT -zPDGROUP + -DI86;PROTO # *Implicit Rules* .c.obj: @@ -54,11 +57,11 @@ CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ # *List Macros* -LIBS = ..\lib\device.lib +LIBS = floppy.obj EXE_dependencies = \ sys.obj \ - $(LIBS) + floppy.obj # *Explicit Rules* production: ..\bin\sys.com @@ -72,9 +75,12 @@ b_fat12.h: ..\boot\b_fat12.bin bin2c.com b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 +floppy.obj: ..\drivers\floppy.asm + $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj + sys.com: $(EXE_dependencies) - $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ - $(LIBS)+$(CLIB); + $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj+$(LIBS),sys,,\ + $(CLIB); clobber: clean $(RM) sys.com b_fat12.h b_fat16.h @@ -84,3 +90,8 @@ clean: # *Individual File Dependencies* sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h + +# RULES (DEPENDENCIES) +# ---------------- +.asm.obj : + $(NASM) -f obj -DSYS=1 $< \ No newline at end of file