diff --git a/build.bat b/build.bat index e5fe55f..e647488 100644 --- a/build.bat +++ b/build.bat @@ -64,17 +64,13 @@ if \%COMPILER% == \ goto end @if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c @if \%COMPILER% == \TC3 set XLINK=%TC3_BASE%\bin\tlink /m/c @if \%COMPILER% == \BC5 set XLINK=%BC5_BASE%\bin\tlink /m/c -@if \%COMPILER% == \WATCOM goto watcom_problem +@if \%COMPILER% == \WATCOM set XLINK=..\utils\wlinker /ma/nologo @if \%COMPILER% == \MSCL8 set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo goto link_set -:watcom_problem -@echo you MUST set XLINK for Watcom in config.bat as WLINK is not suitable -goto end - :link_set -echo linker ist %XLINK% +echo linker is %XLINK% @if not "%XUPX%" == "" goto upx_set @set XUPX=@rem @@ -150,6 +146,8 @@ set XERROR=1 @set MS_BASE= @set XNASM= @set XERROR= +@set XUPX= +@set UPXOPT= :- Log: build.bat,v :- diff --git a/config.b b/config.b index 1ec4f1d..c2c28da 100644 --- a/config.b +++ b/config.b @@ -38,8 +38,7 @@ set COMPILER=TC2 :- set COMPILER=BC5 :- Microsoft C :- set COMPILER=MSCL8 - -:- warning: watcom can compile but the result does not work yet. +:- Watcom C :- set COMPILER=WATCOM :-********************************************************************** @@ -63,26 +62,23 @@ set TC2_BASE=c:\tc201 :- where is UPX and which options to use? :-********************************************************************** set XUPX=upx --8086 -:- or use set XUPX= +:- or use set XUPX= :- if you don't want to use it :-********************************************************************** :- (optionally) which linker to use: :- (otherwise will be determined automatically) -:- WATCOM wlink is not (yet) suitable for linking -:- (the map file and syntax are not compatible) -:- Turbo C 2.01 TLINK 2.0 can't link WATCOM (but can link TC2) -:- Turbo C++ 1.01 and higher TLINK 3.01+ are ok -:- or get TLINK 4 (creates nice map file) from simtel at -:- ftp://ftp.simtel.net/pub/simtelnet/msdos/borland/tlink4.zip :- :- WARNING TLINK needs to be in your PATH! :-********************************************************************** :- Turbo Link -:- set XLINK=%TC2_BASE%\tlink /m/c +:- set XLINK=tlink /m/c/s/l :- Microsoft Link +:- set XLINK=d:\qb\link /ma :- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo +:- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink) +:- set XLINK=..\utils\wlinker /ma /nologo :- set path for Turbo Link - use OLDPATH to restore normal path :- set OLDPATH=%PATH% diff --git a/docs/build.txt b/docs/build.txt index e8752e3..3de6f96 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -3,17 +3,14 @@ to make life easier. This file is in the FDKERNEL directory of the distribution. In addition, there is a corresponding batch file (CLEAN.BAT) to clean up the source directories. -There is a CONFIG.M file that specifies all the paths and names of +There is a CONFIG.B file that specifies all the paths and names of the compiler, assembler, etc. that you want to use. You MUST copy -it to CONFIG.MAK first, then edit it to reflect your setup. - -Likewise, there is a CONFIG.B file that should be copied to -CONFIG.BAT, and then edited to reflect your setup. +it to CONFIG.BAT first, then edit it to reflect your setup. The reason for this copying of files is that when new releases of the kernel come out, you can extract them over your previous source, and not have to worry about resetting up your configuration because your -CONFIG.BAT and CONFIG.MAK files will not get replaced! +CONFIG.BAT file will not get replaced! You will also need to download the latest version of NASM and Turbo C 2.01. Install Turbo C and NASM somewhere (it doesn't really matter @@ -32,8 +29,7 @@ or a mirror of ftp.kernel.org. This program will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers and Microsoft C as well. Watcom C can compile -it but the result does not work yet. +other Borland compilers, Microsoft C and Watcom C. If you feel hardy, read on to understand the directory structure. A more complete description of the build environment is contained in a diff --git a/docs/history.txt b/docs/history.txt index 682f986..df9ea83 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,7 +1,7 @@ 2002 Feb xx - Build 2026test -------- Bart Oldeman (bart@dosemu.org) + Changes Tom - * FCB clean-ups and fixes + * FCB clean-ups and fixes (CYRUS CHESS, bug #1014) * initial config.sys menus (see config.txt) * execrh * make kernel UPX-able @@ -24,14 +24,19 @@ * implement lock/unlock for remote drives * implement commit file (int21/ah=68,6a) * implement ioctl get/set logical drive map (int21/ax=440E--F) - * implement get drive data table (int2f/ax=0803) - * fix "get SDA" (int21/ax=5d06) + * implement get address of drive data table (int2f/ax=0803) + * fix "get address of SDA" (int21/ax=5d06) * do not use CHS if the root extended partition of the relevant - logical partition is labelled LBA + logical partition is labelled LBA (bug #1011) + * hopefully avoid format problem (bug #1030) by not setting drive + to "non-accessible" while reading the bpb. * boot sector fixes: enable booting beyond cylinder x where x * number of heads >= 65536. still uses CHS to boot (not able to boot beyond cylinder 1023) - recognize FF8-FFF as FAT12 ending (was only FFF) + recognize FF8-FFF as FAT12 ending (was only FFF) (bug #1021) + * avoid using LIB when linking the kernel by echo-ing to a linker + resource file. Use a batch file to bypass Borlands Make 2.0 + unwillingness to redirect stdout. 2001 Nov 18 - Build 2025c -------- Bart Oldeman (bart@dosemu.org) + Changes Bart diff --git a/drivers/makefile b/drivers/makefile index 50fe8b3..e71bf45 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -22,10 +22,10 @@ #AFLAGS = /Mx /Dmem$(MODEL)=1 #LIBFLAGS = /c -OBJS = devend.obj floppy.obj getvec.obj rdpcclk.obj rdatclk.obj \ +OBJS = floppy.obj getvec.obj rdpcclk.obj rdatclk.obj \ wrpcclk.obj wratclk.obj -LIBOBJS= +devend +floppy +getvec +rdpcclk +rdatclk +wrpcclk +wratclk +LIBOBJS= +floppy +getvec +rdpcclk +rdatclk +wrpcclk +wratclk diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index 113828f..e51d21e 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -29,13 +29,14 @@ %include "segs.inc" +segment HMA_TEXT +%if 0 + extern _api_sp:wrt DGROUP ; api stacks - for context extern _api_ss:wrt DGROUP ; switching extern _usr_sp:wrt DGROUP ; user stacks extern _usr_ss:wrt DGROUP -segment HMA_TEXT -%if 0 global _set_stack ; ; void set_stack(void) - diff --git a/kernel/fatfs.c b/kernel/fatfs.c index fb6750f..7e757d5 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1626,7 +1626,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Compute the block within the cluster and the offset */ /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset & (secsize - 1); + fnp->f_boff = fnp->f_offset % secsize; currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; @@ -1780,7 +1780,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) /* Compute the block within the cluster and the offset */ /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset & (secsize - 1); + fnp->f_boff = fnp->f_offset % secsize; #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", @@ -1966,7 +1966,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Compute the block within the cluster and the offset */ /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset & (secsize - 1); + fnp->f_boff = fnp->f_offset % secsize; #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", @@ -2253,6 +2253,10 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) ULONG size; REG UWORD shftcnt; + for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) + ; + dpbp->dpb_shftcnt = shftcnt; + dpbp->dpb_mdb = bpbp->bpb_mdesc; dpbp->dpb_secsize = bpbp->bpb_nbyte; dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; @@ -2261,14 +2265,11 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_dirents = bpbp->bpb_ndirent; size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize; dpbp->dpb_fatsize = bpbp->bpb_nfsect; - dpbp->dpb_dirstrt = dpbp->dpb_fatstrt - + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; dpbp->dpb_data = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * (ULONG) 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_dirents + dpbp->dpb_secsize/DIRENT_SIZE - 1) / + (dpbp->dpb_secsize/DIRENT_SIZE); + dpbp->dpb_size = ((size - dpbp->dpb_data) >> shftcnt) + 1; dpbp->dpb_flags = 0; dpbp->dpb_cluster = UNKNCLUSTER; /* number of free clusters */ @@ -2299,17 +2300,12 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_size = 0; dpbp->dpb_xdata = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize; - dpbp->dpb_xsize = - ((size - dpbp->dpb_xdata) / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_xsize = ((size - dpbp->dpb_xdata) >> shftcnt) + 1; dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; read_fsinfo(dpbp); } } #endif - - for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) - ; - dpbp->dpb_shftcnt = shftcnt; } COUNT media_check(REG struct dpb FAR * dpbp) diff --git a/kernel/globals.h b/kernel/globals.h index 98a21bb..54bedec 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -335,8 +335,8 @@ extern BYTE ASM TempBuffer[], /* Temporary general purpose buffer */ FAR ASM swap_indos[], /* " " */ ASM tsr, /* true if program is TSR */ ASM break_flg, /* true if break was detected */ - ASM break_ena, /* break enabled flag */ - FAR * ASM dta; /* Disk transfer area (kludge) */ + ASM break_ena; /* break enabled flag */ +extern BYTE FAR * ASM dta; /* Disk transfer area (kludge) */ extern seg ASM cu_psp; /* current psp segment */ extern iregs FAR * ASM user_r; /* User registers for int 21h call */ @@ -381,10 +381,6 @@ GLOBAL f_node_ptr f_nodes; /* pointer to the array */ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ -/*!! GLOBAL iregs - FAR * ustackp, /* user stack */ -/*!! FAR * kstackp; *//* kernel stack */ - /* */ /* Function prototypes - automatically generated */ /* */ diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 8ca501f..082b82e 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -603,7 +603,6 @@ _VirtOpen db 0 ;782 - virtual open flag ; controlled variables end at offset 78Ch so pad to end times (78ch - ($ - _internal_data)) db 0 -_swap_indos: ; ; end of controlled variables @@ -643,7 +642,7 @@ init_tos: __init_end: init_end: -segment _BSSEND +segment _DATA ; blockdev private stack global blk_stk_top times 192 dw 0 @@ -654,21 +653,22 @@ blk_stk_top: 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 __bssend -__bssend: - ; Dynamic data: ; member of the DOS DATA GROUP ; and marks definitive end of all used data in kernel data segment ; +segment _DATAEND + +_swap_indos: +; we don't know precisely what needs to be swapped before this, so set it here. +; this is just after FIXED_DATA+BSS+DATA and before (D)CONST+BSS +; probably, the clock and block stacks and disktransferbuffer should go past +; _swap_indos but only if int2a ah=80/81 (critical section start/end) +; are called upon entry and exit of the device drivers + segment DYN_DATA + global _Dyn _Dyn: DynAllocated dw 0 diff --git a/kernel/ludivmul.inc b/kernel/ludivmul.inc index fd60406..decf779 100644 --- a/kernel/ludivmul.inc +++ b/kernel/ludivmul.inc @@ -1,19 +1,19 @@ -; these are adapted from elks, http://elks.sourceforge.net +; this one adapted from elks, http://elks.sourceforge.net ; multiply cx:bx * dx:ax, result in dx:ax %macro LMULU 0 push si push cx - mov si,ax ; save _ax in si - mov ax,bx ; cx:ax = _cx:_bx - mul dx ; dx:ax = _bx*_dx (forget dx) - xchg cx,ax ; cx = low(_dx*_bx) - mul si ; dx:ax = _cx*_ax (forget dx) - add cx,ax ; cx = low(_cx*_ax + _dx*_bx) - mov ax,si ; restore _ax - mul bx ; dx:ax = _bx*_ax - add dx,cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) + mov si, ax ; save _ax in si + mov ax, bx ; cx:ax = _cx:_bx + mul dx ; dx:ax = _bx*_dx (forget dx) + xchg cx, ax ; cx = low(_dx*_bx) + mul si ; dx:ax = _cx*_ax (forget dx) + add cx, ax ; cx = low(_cx*_ax + _dx*_bx) + mov ax, si ; restore _ax + mul bx ; dx:ax = _bx*_ax + add dx, cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) pop cx pop si ret @@ -23,122 +23,88 @@ ; divide dx:ax / cx:bx, quotient in dx:ax, remainder in cx:bx %macro LDIVMODU 0 -; ldivmod.s - 32 over 32 to 32 bit division and remainder for 8086 +; this one is adapted from an assembly gem: +; gem writer: Norbert Juffa, norbert.juffa@amd.com -; ludivmod( dividend bx:ax, divisor di:cx ) [ unsigned quot di:cx, rem bx:ax ] +; Dividing 64-bit unsigned integers Assembler / 80386 -; dx is not preserved +; Here is a division routine for dividing two 64-bit unsigned integers. +; I derived it by modifying some old +; 16-bit code for dividing 32-bit integers that I did several years ago for a +; Turbo-Pascal replacement library. +; If a 64-bit signed integer division is needed, appropriate shell code for +; this routine can easily be written. +; +; (adapted back to 32-bit by Bart Oldeman ;-)) +; +; __U4D divides two unsigned long numbers, the dividend and the divisor +; resulting in a quotient and a remainder. +; +; input: +; dx:ax = dividend +; cx:bx = divisor +; +; output: +; dx:ax = quotient of division of dividend by divisor +; cx:bx = remainder of division of dividend by divisor +; +; destroys: +; flags +; + + test cx, cx ; divisor > 2^32-1 ? + jnz %%big_divisor ; yes, divisor > 32^32-1 + cmp dx, bx ; only one division needed ? (ecx = 0) + jb %%one_div ; yes, one division sufficient -; NB negatives are handled correctly, unlike by the processor -; divison by zero does not trap - - -; let dividend = a, divisor = b, quotient = q, remainder = r -; a = b * q + r mod 2^32 -; where: - -; if b = 0, q = 0 and r = a - -; otherwise, q and r are uniquely determined by the requirements: -; r has the same sign as b and absolute value smaller than that of b, i.e. -; 0 <= r < b - - push di - mov di,cx - mov cx,bx - mov bx,dx - - push bp - push si - mov bp,sp - push di ; remember b - push cx - -%assign b0 -4 -%assign b16 -2 - - test di,di - jne %%divlarge - test cx,cx - je %%return ; divzero: return q = 0 and r = a - cmp bx,cx - jae %%divlarge ; would overflow - mov dx,bx ; a in dx:ax - div cx - xchg cx,ax ; q in di:cx, junk in ax - xchg ax,dx ; r in ax, junk in dx - mov bx,di ; r in bx:ax - jmp %%return - -%%divlarge: - mov si,di ; w in si:dx, initially b from di:cx - mov dx,cx - xor cx,cx ; q in di:cx, initially 0 - mov di,cx - -; r in bx:ax, initially a -; use di:cx rather than dx:cx in order to -; have dx free for a byte pair later - - cmp si,bx - jb %%loop1 - ja %%return ; finished if b > r - cmp dx,ax - ja %%return - -; rotate w (= b) to greatest dyadic multiple of b <= r - -%%loop1: - shl dx,1 ; w = 2*w - rcl si,1 - jc %%loop1_exit ; w was > r counting overflow (unsigned) - cmp si,bx ; while w <= r (unsigned) - jb %%loop1 - ja %%loop1_exit - cmp dx,ax - jbe %%loop1 ; else exit with carry clear for rcr - -%%loop1_exit: - rcr si,1 - rcr dx,1 - -%%loop2: - shl cx,1 ; q = 2*q - rcl di,1 - cmp si,bx ; if w <= r - jb %%loop2_over - ja %%loop2_test - cmp dx,ax - ja %%loop2_test - -%%loop2_over: - add cx,1 ; q++ - adc di,0 - sub ax,dx ; r = r-w - sbb bx,si - -%%loop2_test: - shr si,1 ; w = w/2 - rcr dx,1 - cmp si,[bp+b16] ; while w >= b - ja %%loop2 - jb %%return - cmp dx,[bp+b0] - jae %%loop2 - -%%return: - mov sp,bp - pop si - pop bp - - mov dx,bx - mov bx,ax - mov ax,cx - mov cx,dx - mov dx,di - pop di + xchg cx, ax ; save dividend-lo in cx, ax=0 + xchg ax, dx ; get dividend-hi in ax, dx=0 + div bx ; quotient-hi in eax + xchg ax, cx ; cx = quotient-hi, ax =dividend-lo +%%one_div: + div bx ; ax = quotient-lo + mov bx, dx ; bx = remainder-lo + mov dx, cx ; dx = quotient-hi(quotient in dx:ax) + xor cx, cx ; cx = remainder-hi (rem. in cx:bx) ret -%endmacro \ No newline at end of file +%%big_divisor: + push si ; save temp + push di ; variables + push dx ; save + push ax ; dividend + mov si, bx ; divisor now in + mov di, cx ; di:bx and cx:si +%%shift_loop: + shr dx, 1 ; shift both + rcr ax, 1 ; divisor and + shr di, 1 ; and dividend + rcr bx, 1 ; right by 1 bit + jnz %%shift_loop ; loop if di non-zero (rcr does not touch ZF) + mov di, cx ; restore original divisor (di:si) + div bx ; compute quotient + pop bx ; get dividend lo-word + mov cx, ax ; save quotient + mul di ; quotient * divisor hi-word (low only) + xchg ax, di ; save in di + mov ax, cx ; ax=quotient + mul si ; quotient * divisor lo-word + add dx, di ; dx:ax = quotient * divisor + sub bx, ax ; dividend-lo - (quot.*divisor)-lo + mov ax, cx ; get quotient + pop cx ; restore dividend hi-word + sbb cx, dx ; subtract divisor * quot. from dividend + sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh + and si, dx ; nothing to add + and di, dx ; back if remainder positive + add bx, si ; correct remaider + adc cx, di ; and quotient if + add ax, dx ; necessary + xor dx, dx ; clear hi-word of quot (ax<=FFFFFFFFh) + pop di ; restore temp + pop si ; variables + ret + +%endmacro \ No newline at end of file diff --git a/kernel/makefile b/kernel/makefile index 3fd7224..636ebfd 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -104,21 +104,24 @@ clean: # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 kernel.exe: $(EXE_dependencies) $(LIBS) - -$(RM) kernel.lib - $(LIBUTIL) kernel.lib $(LIBPLUS)entry.obj $(LIBPLUS)io.obj $(LIBPLUS)blockio.obj $(LIBPLUS)chario.obj $(LIBPLUS)dosfns.obj $(LIBPLUS)console.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)printer.obj $(LIBPLUS)serial.obj $(LIBPLUS)dsk.obj $(LIBPLUS)initdisk.obj $(LIBPLUS)error.obj $(LIBPLUS)fatdir.obj $(LIBPLUS)fatfs.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)fattab.obj $(LIBPLUS)fcbfns.obj $(LIBPLUS)initoem.obj $(LIBPLUS)initHMA.obj $(LIBPLUS)inthndlr.obj $(LIBPLUS)ioctl.obj $(LIBPLUS)nls_hc.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)main.obj $(LIBPLUS)config.obj $(LIBPLUS)memmgr.obj $(LIBPLUS)misc.obj $(LIBPLUS)newstuff.obj $(LIBPLUS)nls.obj $(LIBPLUS)intr.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)dosnames.obj $(LIBPLUS)prf.obj $(LIBPLUS)strings.obj $(LIBPLUS)network.obj $(LIBPLUS)sysclk.obj $(LIBPLUS)syspack.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)systime.obj $(LIBPLUS)task.obj $(LIBPLUS)int2f.obj $(LIBPLUS)irqstack.obj $(LIBPLUS)apisupt.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)asmsupt.obj $(LIBPLUS)execrh.obj $(LIBPLUS)nlssupt.obj $(LIBPLUS)procsupt.obj $(LIBPLUS)break.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)lfnapi.obj $(LIBTERM) - -$(RM) kernel.bak - $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS)+..\lib\libm.lib; - -$(RM) kernel.lib + -$(RM) kernel.res + ..\utils\echoto kernel.res kernel.obj iprf.obj+ + ..\utils\echoto kernel.res entry.obj io.obj blockio.obj chario.obj dosfns.obj console.obj+ + ..\utils\echoto kernel.res printer.obj serial.obj dsk.obj initdisk.obj error.obj fatdir.obj fatfs.obj+ + ..\utils\echoto kernel.res fattab.obj fcbfns.obj initoem.obj initHMA.obj inthndlr.obj ioctl.obj nls_hc.obj+ + ..\utils\echoto kernel.res main.obj config.obj memmgr.obj misc.obj newstuff.obj nls.obj intr.obj+ + ..\utils\echoto kernel.res dosnames.obj prf.obj strings.obj network.obj sysclk.obj syspack.obj+ + ..\utils\echoto kernel.res systime.obj task.obj int2f.obj irqstack.obj apisupt.obj+ + ..\utils\echoto kernel.res asmsupt.obj execrh.obj nlssupt.obj procsupt.obj break.obj+ + ..\utils\echoto kernel.res dosidle.obj dyninit.obj lfnapi.obj + ..\utils\echoto kernel.res kernel.exe + ..\utils\echoto kernel.res kernel.map + ..\utils\echoto kernel.res ..\lib\libm.lib ..\lib\device.lib + $(LINK) @kernel.res; + -$(RM) kernel.res # *Individual File Dependencies* -kernel.obj: kernel.asm segs.inc +kernel.obj: kernel.asm segs.inc ludivmul.inc console.obj: console.asm io.inc diff --git a/kernel/segs.inc b/kernel/segs.inc index a3599d3..9fdeee2 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,7 +29,7 @@ group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA DCONST +group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA I_BSS IB_B IB IB_E group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END @@ -37,11 +37,13 @@ segment PSP class=PSP segment _TEXT class=CODE 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 _FIXED_DATA class=FDATA align=16 segment _BSS class=BSS align=2 -segment _BSSEND class=BSS +segment _DATA class=DATA align=2 +segment _DATAEND class=DATA align=1 +;for WATCOM +segment CONST class=DATA align=2 +segment CONST2 class=DATA align=2 ;for MSC segment DCONST class=DCONST align=2 segment DYN_DATA class=DYN_DATA diff --git a/kernel/sysclk.c b/kernel/sysclk.c index f2f73c7..fb6b084 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -111,7 +111,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) BcdToByte(bcd_seconds)) * 19663ul / 1080ul; WritePCClock(Ticks); } - rp->r_endaddr = device_end(); + /* rp->r_endaddr = device_end(); not needed - bart */ rp->r_nunits = 0; return S_DONE; diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 23729ab..05f5f2a 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -21,8 +21,8 @@ LIBUTIL=$(COMPILERBIN)\wlib LIBPLUS= LIBTERM= -CFLAGST=-zp=1 -mt -CFLAGSC=-zp=1 -mc +CFLAGST=-zp=1 -mt -os -s -we -e=3 -w=2 +CFLAGSC=-zp=1 -mc -os -s -we -e=3 -w=2 TARGET=KWC @@ -30,13 +30,6 @@ TARGET=KWC CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib -# -#MATH_EXTRACT=*i4d *i4m -#MATH_INSERT= +i4d +i4m -# -# these are NOT usable, as they are called NEAR, and are in TEXT segment. -# so we can't use them, when moving the kernel. called ~15 times -# # we use our own ones, which override these ones when linking. # diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 21f2d65..b2d4471 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -20,11 +20,14 @@ char PROGRAM[] = "SYS CONFIG"; char KERNEL[] = "KERNEL.SYS"; #include -#include #include #include #include +#include "portab.h" +extern WORD CDECL printf(CONST BYTE * fmt, ...); +extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); + #define FAR far #include "kconfig.h" @@ -85,10 +88,6 @@ void showUsage(void) */ int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg) { - int ch; - int configBlkFound; - word cfgSize; - /* Seek to start of kernel file */ if (lseek(kfile, 2, SEEK_SET) != 2) printf("can't seek to offset 2\n"), exit(1); diff --git a/sys/sys.c b/sys/sys.c index ca2cae6..3480691 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -51,10 +51,13 @@ #include #endif #include +#ifdef __TURBOC__ #include +#endif #define SYS_MAXPATH 260 #include "portab.h" extern WORD CDECL printf(CONST BYTE * fmt, ...); +extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #include "b_fat12.h" #include "b_fat16.h" @@ -71,7 +74,7 @@ COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 -#define COPY_SIZE 24576u +#define COPY_SIZE 32768u #ifdef _MSC_VER #pragma pack(1) @@ -159,7 +162,7 @@ int main(int argc, char **argv) COUNT drive; /* destination drive */ COUNT drivearg = 0; /* drive argument position */ BYTE *bsFile = NULL; /* user specified destination boot sector */ - COUNT srcDrive; /* source drive */ + unsigned srcDrive; /* source drive */ BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */ BYTE rootPath[4]; /* alternate source path to try if not '\0' */ WORD slen; @@ -221,7 +224,7 @@ int main(int argc, char **argv) else /* src doesn't specify drive, so assume current drive */ { #ifdef __TURBOC__ - srcDrive = getdisk(); + srcDrive = (unsigned) getdisk(); #else _dos_getdrive(&srcDrive); #endif @@ -309,7 +312,6 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned short count; void far *address; } diskReadPacket; - int retval; union REGS regs; diskReadPacket.sectorNumber = sector; @@ -342,9 +344,6 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) { - COUNT i, z; - WORD head, track, sector, ret; - WORD count; ULONG temp; struct bootsectortype *bs; #ifdef WITHFAT32 @@ -599,7 +598,6 @@ BYTE copybuffer[COPY_SIZE]; BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) { BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH]; - COUNT ifd, ofd; unsigned ret; int fdin, fdout; ULONG copied = 0; @@ -660,6 +658,13 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) setftime(fdout, &ftime); } #endif +#ifdef __WATCOMC__ + { + unsigned short date, time; + _dos_getftime(fdin, &date, &time); + _dos_setftime(fdout, date, time); + } +#endif close(fdin); close(fdout); diff --git a/utils/echoto.bat b/utils/echoto.bat new file mode 100755 index 0000000..31758d9 --- /dev/null +++ b/utils/echoto.bat @@ -0,0 +1 @@ +@echo %2 %3 %4 %5 %6 %7 %8 %9 >> %1 \ No newline at end of file diff --git a/utils/patchobj.c b/utils/patchobj.c index 4c1200d..c811852 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -55,8 +55,6 @@ void define_replace(char *sin) int main(int argc, char *argv[]) { char *argptr; - int argloop; - int cont; FILE *fd, *fdo; char *inname = 0, *outname = "~patchob.tmp"; diff --git a/utils/wlinker.bat b/utils/wlinker.bat new file mode 100755 index 0000000..47a065c --- /dev/null +++ b/utils/wlinker.bat @@ -0,0 +1 @@ +@ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, | wlink \ No newline at end of file