Lucho's kernel with Arkady's changes, initial unstable branch

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@988 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2004-07-09 02:16:31 +00:00
parent 38bcefb6e8
commit 9c94426d7a
61 changed files with 3474 additions and 4379 deletions

View File

@ -4,26 +4,28 @@
# $Id$
#
!include "../mkfiles/generic.mak"
production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin
########################################################################
fat12com.bin: boot.asm
$(NASM) -dISFAT12 boot.asm -ofat12com.bin
all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin
fat16com.bin: boot.asm
$(NASM) -dISFAT16 boot.asm -ofat16com.bin
fat12.bin: boot.asm $(DEPENDS)
$(NASM) -DISFAT12 boot.asm -o$*.bin
fat32chs.bin: boot32.asm
$(NASM) boot32.asm -ofat32chs.bin
fat16.bin: boot.asm $(DEPENDS)
$(NASM) -DISFAT16 boot.asm -o$*.bin
fat32lba.bin: boot32lb.asm
$(NASM) boot32lb.asm -ofat32lba.bin
fat32chs.bin: boot32.asm $(DEPENDS)
$(NASM) boot32.asm -o$*.bin
fat32lba.bin: boot32lb.asm $(DEPENDS)
$(NASM) boot32lb.asm -o$*.bin
########################################################################
clean:
-$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) *.bin status.me
clean:
-$(RM) *.lst *.map *.bak *.obj

View File

@ -3,18 +3,22 @@
:- batch file to build everything
:- $Id$
:-----------------------------------------------------------------------
:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386]
:- option case is significant !!
:-----------------------------------------------------------------------
set XERROR=1
if "%XERROR%" == "" goto noenv
if "%1" == "-r" call clobber.bat
if "%1" == "-r" shift
set XERROR=
if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup!
if not exist config.bat goto abort
call config.bat
if "%LAST%" == "" goto noenv
:-----------------------------------------------------------------------
:- following is command line handling
@ -26,10 +30,10 @@ call config.bat
if "%1" == "fat32" set XFAT=32
if "%1" == "fat16" set XFAT=16
if "%1" == "msc" set COMPILER=MSCL8
if "%1" == "msc" set COMPILER=MSC
if "%1" == "wc" set COMPILER=WATCOM
if "%1" == "tc" set COMPILER=TC2
if "%1" == "tcpp" set COMPILER=TURBOCPP
if "%1" == "tc" set COMPILER=TC
if "%1" == "tcpp" set COMPILER=TCPP
if "%1" == "86" set XCPU=86
if "%1" == "186" set XCPU=186
@ -41,7 +45,8 @@ if not "%1" == "" goto loop_commandline
if "%COMPILER%" == "" echo you MUST define a COMPILER variable in CONFIG.BAT
if "%COMPILER%" == "" goto abort
call default.bat
call defaults.bat
if "%LAST%" == "" goto noenv
:-----------------------------------------------------------------------
:- finally - we are going to compile
@ -51,50 +56,51 @@ echo.
echo Process UTILS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd utils
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process LIB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\lib
%MAKE%
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process DRIVERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\drivers
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process BOOT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\boot
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process SYS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\sys
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process KERNEL +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\kernel
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
cd ..
:- if you like, put some finalizing commands (like copy to floppy)
:- into build2.bat
:- if you like, put finalizing commands (like copy to floppy) into build2.bat
if exist build2.bat call build2
set XERROR=
if exist build2.bat call build2.bat
echo.
echo Processing is done.
@ -104,9 +110,9 @@ goto end
:abort-cd
cd ..
:noenv
:abort
echo Compilation was aborted!
set XERROR=1
:end
default.bat clearset
defaults.bat clearset

View File

@ -9,56 +9,48 @@
if "%1" == "$SUMMARY" goto summary
set onerror=if not "%XERROR%" == "" goto daswarwohlnix
:***** MSCL kernels
call config.bat
if "%LAST%" == "" goto end
if "%MS_BASE%" == "" goto no_ms
call build -r msc 386 fat16
%ONERROR%
call build -r msc 186 fat16
%ONERROR%
call build -r msc 86 fat16
%ONERROR%
call build -r msc 386 fat32
%ONERROR%
call build -r msc 186 fat32
%ONERROR%
call build -r msc 86 fat32
%ONERROR%
:***** MSVC kernels
if "%MSC_BASE%" == "" goto no_ms
call build.bat -r msc 386 fat16
if "%XERROR%" == "" call build.bat -r msc 186 fat16
if "%XERROR%" == "" call build.bat -r msc 86 fat16
if "%XERROR%" == "" call build.bat -r msc 386 fat32
if "%XERROR%" == "" call build.bat -r msc 186 fat32
if "%XERROR%" == "" call build.bat -r msc 86 fat32
if not "%XERROR%" == "" goto daswarwohlnix
:no_ms
:***** TC 2.01 kernels
if "%TC2_BASE%" == "" goto no_tc
call build -r tc 186 fat16
%ONERROR%
call build -r tc 86 fat16
%ONERROR%
call build -r tc 186 fat32
%ONERROR%
call build -r tc 86 fat32
%ONERROR%
if "%TC_BASE%" == "" goto no_tc
call build.bat -r tc 186 fat16
if "%XERROR%" == "" call build.bat -r tc 86 fat16
if "%XERROR%" == "" call build.bat -r tc 186 fat32
if "%XERROR%" == "" call build.bat -r tc 86 fat32
if not "%XERROR%" == "" goto daswarwohlnix
:no_tc
:***** (Open) Watcom kernels
if "%WATCOM%" == "" goto no_wc
call build -r wc 386 fat32
%ONERROR%
call build -r wc 386 fat16
%ONERROR%
call build -r wc 86 fat32
%ONERROR%
call build -r wc 86 fat16
%ONERROR%
call build.bat -r wc 386 fat32
if "%XERROR%" == "" call build.bat -r wc 386 fat16
if "%XERROR%" == "" call build.bat -r wc 86 fat32
if "%XERROR%" == "" call build.bat -r wc 86 fat16
if not "%XERROR%" == "" goto daswarwohlnix
:no_wc
:***** now rebuild the default kernel
call build -r
call build.bat -r
if not "%XERROR%" == "" goto daswarwohlnix
:**************************************************************
:* now we build a summary of all kernels HMA size + total size
@ -74,20 +66,20 @@ set TempSumfile=bin\tsummary.txt
:****echo.|time >>%TempSumfile%
:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i
if exist %Sumfile% del %Sumfile%
if exist %TempSumfile% del %TempSumfile%
if exist %Sumfile% del %Sumfile%>nul
if exist %TempSumfile% del %TempSumfile%>nul
>ktemp.bat
for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat
sort <ktemp.bat >ktemps.bat
call ktemps.bat
del ktemp.bat
del ktemps.bat
del ktemp.bat>nul
del ktemps.bat>nul
echo >>%Sumfile% Summary of all kernels build
echo.|date >>%Sumfile%
echo.|time >>%Sumfile%
find <%TempSumfile% "H" >>%Sumfile%
del %TempSumfile%
del %TempSumfile%>nul
set TempSumfile=
set Sumfile=
@ -103,6 +95,5 @@ goto end
:daswarwohlnix
echo Sorry, something didn't work as expected :-(
set ONERROR=
:end

View File

@ -1,37 +1,45 @@
@echo off
:- batch file to clean everything
:- batch file to clean and clobber everything
:- $Id$
if "%1" == "" %0 clean
goto %1
goto end
:clean
:clobber
if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup!
if not exist config.bat goto end
call config.bat
call default.bat
if not "%LAST%" == "" call defaults.bat
if "%LAST%" == "" goto end
cd utils
%MAKE% clean
call %MAKE% %1
cd ..\lib
%MAKE% clean
call %MAKE% %1
cd ..\drivers
%MAKE% clean
call %MAKE% %1
cd ..\boot
%MAKE% clean
call %MAKE% %1
cd ..\sys
%MAKE% clean
call %MAKE% %1
cd ..\kernel
%MAKE% clean
call %MAKE% %1
cd ..\hdr
if exist *.bak del *.bak
if exist *.bak del *.bak>nul
cd ..
if exist *.bak del *.bak
if exist *.bak del *.bak>nul
if "%1"=="clobber" if exist status.me del status.me>nul
:end
default.bat clearset
defaults.bat clearset

View File

@ -1,38 +1 @@
@echo off
:- batch file to clobber everything
:- $Id$
if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup!
if not exist config.bat goto end
call config.bat
call default.bat
cd utils
%MAKE% clobber
cd ..\lib
%MAKE% clobber
cd ..\drivers
%MAKE% clobber
cd ..\boot
%MAKE% clobber
cd ..\sys
%MAKE% clobber
cd ..\kernel
%MAKE% clobber
cd ..\hdr
if exist *.bak del *.bak
cd ..
if exist *.bak del *.bak
if exist status.me del status.me
:end
default.bat clearset
@clean clobber

175
config.b
View File

@ -1,119 +1,128 @@
:-
@echo off
:- batch file that is included in all other batch files for configuration
:- $Id$
:-----------------------------------------------------------------------
:- NOTICE! You must edit and rename this file to CONFIG.BAT!
:-----------------------------------------------------------------------
:- determine compiler(s) settings.
:-
:- you REQUIRED to
:- search for NASM - and set the path to NASM
:- search for COMPILER - and set the default compiler name
:- search for ??_BASE - and set the path to (all) compiler(s)
:-****************************************************************
:- NOTICE! You must edit and rename this file to CONFIG.BAT! *
:-****************************************************************
set LAST=
:-*********************************************************************
:- determine your compiler settings
:-
:- you have to
:- search for XNASM - and set the path for NASM
:- search for COMPILER - and set your compiler
:- search for ??_BASE - and set the path to your compiler
:-
:-*********************************************************************
:-----------------------------------------------------------------------
:- define NASM executable. It should not be protected mode DJGPP
:- version if you're using Windows NT/2k/XP to compile. also:
:- NASM/DJGPP crashes when using protected mode Borland's make.
:-**********************************************************************
:-- define NASM executable - remember - it should not be protected
:- mode DJGPP version if you're using Windows NT/2k/XP to compile
:- also: DJGPP-nasm crashes when using protected mode Borland's make
:-**********************************************************************
set NASM=c:\bin\nasm16
set XNASM=c:\bin\nasm16
:**********************************************************************
:- define your COMPILER type here, pick one of them
:**********************************************************************
:-----------------------------------------------------------------------
:- define COMPILER name here, pick one of them.
:- Turbo C 2.01
set COMPILER=TC2
set COMPILER=TC
:- Turbo C++ 1.01
:- set COMPILER=TURBOCPP
:- Turbo C 3.0
:- set COMPILER=TC3
::set COMPILER=TCPP
:- Turbo C++ 3.0
::set COMPILER=TCPP3
:- Borland C
:- set COMPILER=BC5
::set COMPILER=BC
:- Microsoft C
:- set COMPILER=MSCL8
::set COMPILER=MSC
:- Watcom C
:- set COMPILER=WATCOM
::set COMPILER=WATCOM
:-**********************************************************************
:-- where is the BASE dir of your compiler(s) ??
:-**********************************************************************
:-----------------------------------------------------------------------
:- define BASE dir of compiler;
:- may be defined for all installed compilers.
set TC2_BASE=c:\tc201
:- set TP1_BASE=c:\tcpp
:- set TC3_BASE=c:\tc3
:- set BC5_BASE=c:\bc5
:- set MS_BASE=c:\msvc
set TC_BASE=c:\tc
::set TCPP_BASE=c:\tcpp
::set TCPP3_BASE=c:\tcpp3
::set BC_BASE=c:\bc
::set MSC_BASE=c:\msc
::set WATCOM=c:\watcom
:- if WATCOM maybe you need to set your WATCOM environment variables
:- and path
:- if not \%WATCOM% == \ goto watcom_defined
:- set WATCOM=c:\watcom
:- set PATH=%PATH%;%WATCOM%\binw
:watcom_defined
:-----------------------------------------------------------------------
:- When compiling executable, compilers search linker through PATH;
:- if some linker not in PATH, uncomment OLDPATH and required SETs PATH.
:-**********************************************************************
:- where is UPX and which options to use?
:-**********************************************************************
set XUPX=upx --8086 --best
:- or use set XUPX=
:- if you don't want to use it
::set OLDPATH=%PATH%
::set PATH=%TC_BASE%;%PATH%
::set PATH=%TCPP_BASE%\bin;%PATH%
::set PATH=%TCPP3_BASE%\bin;%PATH%
::set PATH=%BC_BASE%\bin;%PATH%
::set PATH=%MSC_BASE%\bin;%PATH%
::set PATH=%WATCOM%\binw;%PATH%
:-**********************************************************************
:- (optionally) which linker to use:
:- (otherwise will be determined automatically)
:-
:- WARNING TLINK needs to be in your PATH!
:-**********************************************************************
:- MSC searches libraries only through LIB variable.
::set LIB=%MSC_BASE%\lib
:-----------------------------------------------------------------------
:- define which linker to use OR it will be determined AUTOMATICALLY.
:- Turbo Link
:- set XLINK=tlink /m/c/s/l
::set LINK=tlink /c/m/s/l
:- Microsoft Link
:- set XLINK=d:\qb\link /ma
:- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
::set LINK=link /ONERROR:NOEXE /nologo
:- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink)
:- set XLINK=..\utils\wlinker /ma /nologo
::set LINK=..\utils\wlinker /nologo
:- set path for Turbo Link - use OLDPATH to restore normal path
:- set OLDPATH=%PATH%
:- set PATH=%PATH%;%TC2_BASE%
:-----------------------------------------------------------------------
:- define which librarian to use OR it will be determined AUTOMATICALLY.
:**********************************************************************
:* optionally define your MAKE type here, if not then
:* it will be automatically determined, pick one of them
:* use MS nmake if you want to compile with MSCL
:**********************************************************************
:- Turbo Lib
::set LIBUTIL=tlib
::set LIBTERM=
:- Microsoft Lib
::set LIBUTIL=lib /nologo
::set LIBTERM=;
:- WATCOM Lib
::set LIBUTIL=wlib -q
::set LIBTERM=
:-----------------------------------------------------------------------
:- define which MAKE to use OR it will be determined AUTOMATICALLY.
:- Borland MAKE
:- set MAKE=%TC2_BASE%\make
::set MAKE=make
::set MAKE=maker -S
:- Watcom MAKE in MS mode
:- set MAKE=%WATCOM%\binw\wmake /ms
::set MAKE=wmake /ms
:- Microsoft MAKE
:- set MAKE=%MS_BASE%\bin\nmake /nologo
::set MAKE=nmake /nologo
::set MAKE=nmaker /nologo
:**********************************************************************
:* select your default target: required CPU and what FAT system to support
:**********************************************************************
:-----------------------------------------------------------------------
:- where is UPX and which options to use
:- (comment this out if you don't want to use it)
set XCPU=86
:- set XCPU=186
:- set XCPU=386
set XUPX=upx --8086 --best
set XFAT=16
:- set XFAT=32
:-----------------------------------------------------------------------
:- select default target: CPU type (default is 86) and
:- what FAT system (default is 32) to support
::set XCPU=86
::set XCPU=186
::set XCPU=386
::set XFAT=16
::set XFAT=32
:- Give extra compiler DEFINE flags here
:- such as -DDEBUG : extra DEBUG output
:- -DDOSEMU : printf output goes to dosemu log
:- set ALLCFLAGS=-DDEBUG
::set ALLCFLAGS=-DDEBUG
:-----------------------------------------------------------------------
:-
:- $Id$
:-
set LAST=1
if not "%LAST%" == "1" defaults.bat clearset

View File

@ -1,66 +0,0 @@
@echo off
:- $Id$
if "%1" == "clearset" goto clearset
:-----------------------------------------------------------------------
if not "%MAKE%" == "" goto skip_make
if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make
if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make
if "%COMPILER%" == "TC3" set MAKE=%TC3_BASE%\bin\make
if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make
if "%COMPILER%" == "WATCOM" set MAKE=wmake /ms /h
if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake /nologo
echo Make is %MAKE%.
:skip_make
:-----------------------------------------------------------------------
if not "%XLINK%" == "" goto skip_xlink
if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c
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" set XLINK=..\utils\wlinker /ma/nologo
if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
echo Linker is %XLINK%.
:skip_xlink
:-----------------------------------------------------------------------
if not "%XUPX%" == "" set UPXOPT=-U
if "%XUPX%" == "" set UPXOPT=
if "%XUPX%" == "" set XUPX=@rem
goto end
:-----------------------------------------------------------------------
:clearset
if not "%OLDPATH%" == "" set PATH=%OLDPATH%
if not "%OLDPATH%" == "" set OLDPATH=
set MAKE=
set COMPILER=
set XCPU=
set XFAT=
set XLINK=
set TC2_BASE=
set TP1_BASE=
set TC3_BASE=
set BC5_BASE=
set MS_BASE=
set XNASM=
set XUPX=
set UPXOPT=
:end

87
defaults.bat Normal file
View File

@ -0,0 +1,87 @@
@echo off
:- $Id$
set LAST=
if "%1" == "clearset" goto clearset
:-----------------------------------------------------------------------
if "%COMPILER%" == "TC" set BASE=%TC_BASE%
if "%COMPILER%" == "TCPP" set BASE=%TCPP_BASE%
if "%COMPILER%" == "TCPP3" set BASE=%TCPP3_BASE%
if "%COMPILER%" == "BC" set BASE=%BC_BASE%
if "%COMPILER%" == "WATCOM" set BASE=%WATCOM%
if "%COMPILER%" == "MSC" set BASE=%MSC_BASE%
if "%BASE%" == "" goto clearset
:-----------------------------------------------------------------------
if not "%LINK%" == "" goto skip_link
set LINK=%BASE%\bin\tlink /c/m
if "%COMPILER%" == "TC" set LINK=%BASE%\tlink /c/m
if "%COMPILER%" == "WATCOM" set LINK=..\utils\wlinker /nologo
if "%COMPILER%" == "MSC" set LINK=%BASE%\bin\link /ONERROR:NOEXE /batch
echo Linker is %LINK%
:skip_link
:-----------------------------------------------------------------------
if not "%LIBUTIL%" == "" goto skip_lib
set LIBUTIL=%BASE%\bin\tlib
set LIBTERM=
if "%COMPILER%" == "TC" set LIBUTIL=%BASE%\tlib
if "%COMPILER%" == "WATCOM" set LIBUTIL=%BASE%\binw\wlib -q
if "%COMPILER%" == "MSC" set LIBUTIL=%BASE%\bin\lib /nologo
if "%COMPILER%" == "MSC" set LIBTERM=;
echo Librarian is %LIBUTIL%
:skip_lib
:-----------------------------------------------------------------------
if not "%MAKE%" == "" goto skip_make
set MAKE=%BASE%\bin\make
if "%COMPILER%" == "TC" set MAKE=%BASE%\make
if "%COMPILER%" == "WATCOM" set MAKE=%BASE%\binw\wmake /ms /h
if "%COMPILER%" == "MSC" set MAKE=%BASE%\bin\nmake /nologo
echo Make is %MAKE%
:skip_make
:-----------------------------------------------------------------------
set LAST=1
if "%LAST%" == "1" goto end
:-----------------------------------------------------------------------
:clearset
set NASM=
set COMPILER=
set BASE=
set TC_BASE=
set TCPP_BASE=
set TCPP3_BASE=
set BC_BASE=
set MSC_BASE=
set LINK=
set LIBUTIL=
set LIBTERM=
set MAKE=
set XUPX=
set XCPU=
set XFAT=
if not "%OLDPATH%" == "" set PATH=%OLDPATH%
set OLDPATH=
:end

View File

@ -32,7 +32,7 @@
segment HMA_TEXT
;
; BOOL ASMPASCAL fl_reset(WORD drive);
; int ASMPASCAL fl_reset(UBYTE drive);
;
; Reset both the diskette and hard disk system.
; returns TRUE if successful.
@ -41,129 +41,116 @@ segment HMA_TEXT
global FL_RESET
FL_RESET:
pop ax ; return address
pop dx ; drive (DL only)
pop dx ; drive
push ax ; restore address
mov ah,0 ; BIOS reset diskette & fixed disk
mov ah,0 ; reset disk
int 13h
sbb ax,ax ; carry set indicates error, AX=-CF={-1,0}
sbb ax,ax ; CF=1: error
inc ax ; ...return TRUE (1) on success,
ret ; else FALSE (0) on failure
ret ; FALSE (0) on error
;
; COUNT ASMPASCAL fl_diskchanged(WORD drive);
; int ASMPASCAL fl_diskchanged(UBYTE drive);
;
; Read disk change line status.
; returns 1 if disk has changed, 0 if not, 0xFFFF if error.
; returns 1 if disk has changed, 0 if not, 0xFF if error.
;
global FL_DISKCHANGED
FL_DISKCHANGED:
pop ax ; return address
pop dx ; drive (DL only, 00h-7Fh)
pop dx ; drive
push ax ; restore stack
push si ; preserve value
push si
mov ah,16h ; read change status type
xor si,si ; RBIL: avoid crash on AT&T 6300
int 13h
pop si ; restore
pop si
sbb al,al ; AL=-CF={-1,0} where 0==no change
jnc fl_dc ; carry set on error or disk change
cmp ah,6 ; if AH==6 then disk change, else error
jne fl_dc ; if error, return -1
mov al, 1 ; set change occurred
fl_dc: cbw ; extend AL into AX, AX={1,0,-1}
ret ; note: AH=0 on no change, AL set above
sbb al,al ; CF=0 (disk has not changed)
jnc ret_AH_0 ; ...return 0
cmp ah,6 ; ah!=6 (error)
jne ret_AH_0 ; ...return 0xFF
mov al,1 ; ah=6 (disk has changed)
jmp short ret_AH_0 ; ...return 1
;
; int ASMPASCAL fl_read (UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer);
; int ASMPASCAL fl_write (UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer);
; int ASMPASCAL fl_verify(UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer);
; int ASMPASCAL fl_format(UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer);
;
; Format tracks (sector should be 0).
; COUNT ASMPASCAL fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
; Reads one or more sectors.
; COUNT ASMPASCAL fl_read (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
; Writes one or more sectors.
; COUNT ASMPASCAL fl_write (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
; COUNT ASMPASCAL fl_verify(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer);
;
; Returns 0 if successful, error code otherwise.
;
global FL_FORMAT
FL_FORMAT:
mov ah,5 ; format track
jmp short fl_common
global FL_READ
FL_READ:
mov ah,2 ; read sector(s)
jmp short fl_common
global FL_VERIFY
FL_VERIFY:
mov ah,4 ; verify sector(s)
jmp short fl_common
global FL_READ
FL_READ:
mov ah,2 ; read sector(s)
jmp short fl_common
global FL_WRITE
FL_WRITE:
mov ah,3 ; write sector(s)
fl_common:
push bp ; setup stack frame
push bp
mov bp,sp
mov cx,[bp+0Ch] ; cylinder number
mov cx,[bp+12] ; cylinder number
mov al,1 ; error code
cmp ch,3
ja fl_error ; can't write above 3FFh=1023
mov al,1 ; this should be an error code
cmp ch,3 ; this code can't write above 3FFh=1023
ja fl_error ; as cylinder # is limited to 10 bits.
xchg ch,cl ; ch=low 8 bits of cyl number
xchg ch,cl ; ch=low 8 bits of cylinder number
mov dh,[bp+14] ; head number
ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; ...to bits 6-7 in CL
or cl,[bp+0Ah] ; or in the sector number (bits 0-5)
mov al,[bp+08h] ; count of sectors to read/write/...
les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX
mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive)
mov dh,[bp+0Eh] ; get the head number
or cl,[bp+10] ; sector number (bits 0-5)
mov al,[bp+8] ; number of sectors
les bx,[bp+4] ; 32-bit buffer ptr
mov dl,[bp+16] ; drive (if or'ed 80h its hard drive)
int 13h ; process sectors
sbb al,al ; carry: al=ff, else al=0
and al,ah ; carry: error code, else 0
fl_error:
mov ah,0 ; extend AL into AX without sign extension
mov ah,0
pop bp
ret 14
;
; COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode, void FAR * dap_p);
; int ASMPASCAL fl_lba_ReadWrite(UBYTE drive, WORD mode, void FAR * dap);
;
; Returns 0 if successful, error code otherwise.
;
global FL_LBA_READWRITE
FL_LBA_READWRITE:
push bp ; setup stack frame
push bp
mov bp,sp
push si
push ds
push si ; wasn't in kernel < KE2024Bo6!!
mov dl,[bp+10] ; drive (if or'ed with 80h a hard drive)
mov ax,[bp+8] ; get the command
lds si,[bp+4] ; get far dap pointer
int 13h ; read from/write to drive
pop si
mov dl,[bp+10] ; drive (if or'ed 80h its hard drive)
mov ax,[bp+8] ; command
lds si,[bp+4] ; far dap pointer
int 13h ; process sectors
pop ds
pop si
pop bp
mov al,ah ; place any error code into al
mov ah,0 ; zero out ah
mov al,ah ; place error code into al
mov ah,0
ret 8
;
@ -171,48 +158,48 @@ FL_LBA_READWRITE:
;
global FL_READKEY
FL_READKEY: xor ah, ah
FL_READKEY:
mov ah,0
int 16h
ret
;
; COUNT ASMPASCAL fl_setdisktype (WORD drive, WORD type);
; int ASMPASCAL fl_setdisktype (UBYTE drive, WORD type);
;
global FL_SETDISKTYPE
FL_SETDISKTYPE:
pop bx ; return address
pop ax ; disk format type (al)
pop dx ; drive number (dl)
pop ax ; disk type
pop dx ; drive
push bx ; restore stack
mov ah,17h ; floppy set disk type for format
mov ah,17h ; set disk type for format
int 13h
ret_AH:
mov al,ah ; place any error code into al
mov ah,0 ; zero out ah
mov al,ah ; place error code into al
ret_AH_0:
mov ah,0
ret
;
; COUNT ASMPASCAL fl_setmediatype (WORD drive, WORD tracks, WORD sectors);
; int ASMPASCAL fl_setmediatype (UBYTE drive, WORD tracks, WORD sectors);
;
global FL_SETMEDIATYPE
FL_SETMEDIATYPE:
pop ax ; return address
pop bx ; sectors/track
pop cx ; number of tracks
pop dx ; drive number
pop dx ; drive
push ax ; restore stack
push di
dec cx ; number of cylinders - 1 (last cyl number)
dec cx ; last cylinder number
xchg ch,cl ; CH=low 8 bits of last cyl number
ror cl,1 ; extract bits 8-9 of cylinder number...
ror cl,1 ; ...into cl bit 6-7
or cl,bl ; sectors/track (bits 0-5) or'd with high cyl bits 7-6
mov ah,18h ; disk set media type for format
ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; ...to bits 6-7 in CL
or cl,bl ; sectors/track (bits 0-5)
mov ah,18h ; set media type for format
int 13h
jc skipint1e
@ -220,10 +207,9 @@ FL_SETMEDIATYPE:
xor dx,dx
mov es,dx
cli
mov [es:0x1e*4],di
pop word [es:0x1e*4+2] ; set int 0x1e table to es:di
mov [es:0x1e*4 ], di
sti
skipint1e:
pop di
jmp short ret_AH

View File

@ -4,46 +4,25 @@
# $Id$
#
!include "../mkfiles/generic.mak"
OBJS=floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj
LIBOBJS=+floppy +rdpcclk +wrpcclk +wratclk
# MICROSOFT C
# -----------
#MODEL = s
#CFLAGS = /c /Gs /A$(MODEL)
#AFLAGS = /Mx /Dmem$(MODEL)=1
#TERM = ;
# Build the LIBRARY ####################################################
# BORLAND C
# -----------
#MODEL = s
#CFLAGS = -c -m$(MODEL)
#AFLAGS = /Mx /Dmem$(MODEL)=1
#LIBFLAGS = /c
all: ..\lib\device.lib
OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj
..\lib\device.lib: $(OBJS)
-$(RM) $*.lib
$(LIBUTIL) $(LIBFLAGS) $* $(LIBOBJS) $(LIBTERM)
LIBOBJS= +floppy +rdpcclk +wrpcclk +wratclk
$(OBJS): $(DEPENDS)
# Build the LIBRARY
# -----------------
all: production
production: ..\lib\device.lib
..\lib\device.lib: device.lib
copy device.lib ..\lib
clobber: clean
-$(RM) device.lib status.me ..\lib\device.lib
########################################################################
clean:
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err
device.lib : $(OBJS)
-$(RM) device.lib
$(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM)
-$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) ..\lib\device.lib status.me

155
filelist
View File

@ -1,155 +0,0 @@
*/*/build.bat
*/*/buildall.bat
*/*/clean.bat
*/*/clobber.bat
*/*/config.b
*/*/filelist
*/*/default.bat
*/*/makefile
*/*/bin/autoexec.bat
*/*/bin/config.sys
*/*/bin/install.bat
*/*/boot/boot.asm
*/*/boot/boot32.asm
*/*/boot/boot32lb.asm
*/*/boot/makefile
*/*/docs/bugs.txt
*/*/docs/build.txt
*/*/docs/config.txt
*/*/docs/contrib.txt
*/*/docs/copying
*/*/docs/fdkernel.lsm
*/*/docs/history.txt
*/*/docs/intfns.txt
*/*/docs/lfnapi.txt
*/*/docs/mkboot.txt
*/*/docs/nls.txt
*/*/docs/readme.cvs
*/*/docs/readme.txt
*/*/docs/sys.txt
*/*/drivers/floppy.asm
*/*/drivers/makefile
*/*/drivers/rdpcclk.asm
*/*/drivers/wratclk.asm
*/*/drivers/wrpcclk.asm
*/*/hdr/algnbyte.h
*/*/hdr/algndflt.h
*/*/hdr/buffer.h
*/*/hdr/cds.h
*/*/hdr/clock.h
*/*/hdr/date.h
*/*/hdr/dcb.h
*/*/hdr/device.h
*/*/hdr/dirmatch.h
*/*/hdr/error.h
*/*/hdr/exe.h
*/*/hdr/fat.h
*/*/hdr/fcb.h
*/*/hdr/file.h
*/*/hdr/fnode.h
*/*/hdr/kbd.h
*/*/hdr/kconfig.h
*/*/hdr/lol.h
*/*/hdr/mcb.h
*/*/hdr/network.h
*/*/hdr/nls.h
*/*/hdr/pcb.h
*/*/hdr/portab.h
*/*/hdr/process.h
*/*/hdr/sft.h
*/*/hdr/stacks.inc
*/*/hdr/tail.h
*/*/hdr/time.h
*/*/hdr/version.h
*/*/hdr/xstructs.h
*/*/kernel/nls/001-437.hc
*/*/kernel/nls/001-437.unf
*/*/kernel/nls/001-437.up
*/*/kernel/nls/049-850.hc
*/*/kernel/nls/049-850.unf
*/*/kernel/nls/049-850.up
*/*/kernel/nls/files
*/*/kernel/apisupt.asm
*/*/kernel/asmsupt.asm
*/*/kernel/blockio.c
*/*/kernel/break.c
*/*/kernel/chario.c
*/*/kernel/config.c
*/*/kernel/config.h
*/*/kernel/console.asm
*/*/kernel/dosfns.c
*/*/kernel/dosidle.asm
*/*/kernel/dosnames.c
*/*/kernel/dsk.c
*/*/kernel/dyndata.h
*/*/kernel/dyninit.c
*/*/kernel/entry.asm
*/*/kernel/error.c
*/*/kernel/execrh.asm
*/*/kernel/fatdir.c
*/*/kernel/fatfs.c
*/*/kernel/fattab.c
*/*/kernel/fcbfns.c
*/*/kernel/globals.h
*/*/kernel/init-dat.h
*/*/kernel/init-mod.h
*/*/kernel/initclk.c
*/*/kernel/initdisk.c
*/*/kernel/inithma.c
*/*/kernel/initoem.c
*/*/kernel/int2f.asm
*/*/kernel/inthndlr.c
*/*/kernel/intr.asm
*/*/kernel/makefile
*/*/kernel/io.asm
*/*/kernel/io.inc
*/*/kernel/ioctl.c
*/*/kernel/iprf.c
*/*/kernel/irqstack.asm
*/*/kernel/kernel.asm
*/*/kernel/kernel.cfg
*/*/kernel/lfnapi.c
*/*/kernel/ludivmul.inc
*/*/kernel/main.c
*/*/kernel/memmgr.c
*/*/kernel/misc.c
*/*/kernel/network.c
*/*/kernel/newstuff.c
*/*/kernel/nls.c
*/*/kernel/nls_hc.asm
*/*/kernel/nls_load.c
*/*/kernel/nlssupt.asm
*/*/kernel/prf.c
*/*/kernel/printer.asm
*/*/kernel/procsupt.asm
*/*/kernel/proto.h
*/*/kernel/segs.inc
*/*/kernel/serial.asm
*/*/kernel/strings.c
*/*/kernel/sysclk.c
*/*/kernel/syspack.c
*/*/kernel/systime.c
*/*/kernel/task.c
*/*/kernel/turboc.cfg
*/*/lib/makefile
*/*/mkfiles/generic.mak
*/*/mkfiles/bc5.mak
*/*/mkfiles/mscl8.mak
*/*/mkfiles/tc2.mak
*/*/mkfiles/tc3.mak
*/*/mkfiles/turbocpp.mak
*/*/mkfiles/watcom.mak
*/*/sys/fdkrncfg.c
*/*/sys/bin2c.c
*/*/sys/makefile
*/*/sys/sys.c
*/*/sys/talloc.c
*/*/utils/echoto.bat
*/*/utils/exeflat.c
*/*/utils/indent.ini
*/*/utils/makefile
*/*/utils/patchobj.c
*/*/utils/proto.bat
*/*/utils/relocinf.c
*/*/utils/rmfiles.bat
*/*/utils/wlinker.bat

View File

@ -35,6 +35,8 @@ static char *portab_hRcsId =
#endif
#endif
#include <limits.h>
/****************************************************************/
/* */
/* Machine dependant portable types. Note that this section is */
@ -256,55 +258,105 @@ typedef signed long LONG;
#define LONG long
#endif
typedef UWORD ofs_t;
typedef UWORD seg_t;
#define lonibble(v) (0x0f & (v))
#define hinibble(v) (0xf0 & (v))
#if CHAR_BIT == 8
# define lobyte(v) ((UBYTE)(v))
#else
# define lobyte(v) ((UBYTE)(0xff & (v)))
#endif
#define hibyte(v) lobyte ((UWORD)(v) >> 8u)
#if USHRT_MAX == 0xFFFF
# define loword(v) ((unsigned short)(v))
#else
# define loword(v) (0xFFFF & (unsigned)(v))
#endif
#define hiword(v) loword ((v) >> 16u)
#define MK_UWORD(hib,lob) (((UWORD)(hib) << 8u) | (UBYTE)(lob))
#define MK_ULONG(hiw,low) (((ULONG)(hiw) << 16u) | (UWORD)(low))
/* General far pointer macros */
#ifdef I86
#ifndef MK_FP
#if defined(__WATCOMC__)
#if defined __WATCOMC__
#define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs)))
#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
#elif __TURBOC__ > 0x202
#define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs))
#else
#define MK_FP(seg,ofs) ((void FAR *)(((ULONG)(seg)<<16)|(UWORD)(ofs)))
#define MK_FP(seg,ofs) ((void FAR *)MK_ULONG(seg, ofs))
#endif
#define pokeb(seg, ofs, b) (*((unsigned char far *)MK_FP(seg,ofs)) = b)
#define poke(seg, ofs, w) (*((unsigned far *)MK_FP(seg,ofs)) = w)
#define pokeb(seg, ofs, b) (*(unsigned char far *)MK_FP(seg,ofs) = (b))
#define poke(seg, ofs, w) (*(unsigned far *)MK_FP(seg,ofs) = (w))
#define pokew poke
#define pokel(seg, ofs, l) (*((unsigned long far *)MK_FP(seg,ofs)) = l)
#define peekb(seg, ofs) (*((unsigned char far *)MK_FP(seg,ofs)))
#define peek(seg, ofs) (*((unsigned far *)MK_FP(seg,ofs)))
#define pokel(seg, ofs, l) (*(unsigned long far *)MK_FP(seg,ofs) = (l))
#define peekb(seg, ofs) (*(unsigned char far *)MK_FP(seg,ofs))
#define peek(seg, ofs) (*(unsigned far *)MK_FP(seg,ofs))
#define peekw peek
#define peekl(seg, ofs) (*((unsigned long far *)MK_FP(seg,ofs)))
#define peekl(seg, ofs) (*(unsigned long far *)MK_FP(seg,ofs))
#if defined(__TURBOC__) && (__TURBOC__ > 0x202)
#if __TURBOC__ > 0x202
#define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp))
#else
#define FP_SEG(fp) ((unsigned)((ULONG)(VOID FAR *)(fp)>>16))
#define FP_SEG(fp) hiword ((ULONG)(VOID FAR *)(fp))
#endif
#define FP_OFF(fp) ((unsigned)(fp))
#define FP_OFF(fp) loword (fp)
#endif
#endif
#ifdef MC68K
#define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(size_t)(seg))[(ofs)])))
#define FP_SEG(fp) (0)
#define MK_FP(seg,ofs) ((VOID *)&(((BYTE *)(size_t)(seg))[ofs]))
#define FP_SEG(fp) 0
#define FP_OFF(fp) ((size_t)(fp))
#endif
typedef VOID (FAR ASMCFUNC * intvec) (void);
#define MK_PTR(type,seg,ofs) ((type FAR*) MK_FP (seg, ofs))
#if __TURBOC__ > 0x202
# define MK_SEG_PTR(type,seg) ((type _seg*) (seg))
#else
# define _seg FAR
# define MK_SEG_PTR(type,seg) MK_PTR (type, seg, 0)
#endif
/*
this suppresses the warning
unreferenced parameter 'x'
and (hopefully) generates no code
*/
#define UNREFERENCED_PARAMETER(x) (void)x;
#define UNREFERENCED_PARAMETER(x) (void)(x)
#ifdef I86 /* commandline overflow - removing /DPROTO TE */
#define PROTO
#endif
#define LENGTH(x) (sizeof(x)/sizeof(x[0]))
typedef const char CStr[], *PCStr;
typedef char Str[], *PStr;
typedef const void *CVP;
typedef const void FAR *CVFP;
typedef void FAR *VFP;
#define LENGTH(x) (sizeof (x)/sizeof *(x))
#define ENDOF(x) ((x) + LENGTH (x))
/* (unsigned) modulo arithmetics trick: a<=b<=c equal to b-a<=c-a */
#define inrange(type,v,lo,hi) ((type)((v) - (lo)) <= (type)((hi) - (lo)))
#define _isdigit(c) inrange(UBYTE, c, '0', '9')
#define _islower(c) inrange(UBYTE, c, 'a', 'z')
#define _isupper(c) inrange(UBYTE, c, 'A', 'Z')
/* Fast ASCII tolower/toupper */
#define _fast_lower(ch) ((ch) | 0x20)
#define _fast_dolower(var) ((var) |= 0x20)
#define _fast_upper(ch) ((ch) & ~0x20)
#define _fast_doupper(var) ((var) &= ~0x20)

View File

@ -149,10 +149,10 @@ irp_hi equ 26
%else
push eax
pop ax
%ifdef MSCL8
%ifdef MSC
push ecx
pop cx
%else ;BC5
%else ;BC
push ebx
pop bx
%endif
@ -170,10 +170,10 @@ irp_hi equ 26
%else
push dx
pop edx
%ifdef MSCL8
%ifdef MSC
push cx
pop ecx
%else ;BC5
%else ;BC
push bx
pop ebx
%endif

View File

@ -48,7 +48,7 @@ static BYTE *date_hRcsId =
#define REVISION_MAJOR 1
#define REVISION_MINOR 1
#define REVISION_SEQ 35
#define BUILD "2035"
#define SUB_BUILD "a"
#define KERNEL_VERSION_STRING "1.1.35" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */
#define BUILD "2035a"
#define SUB_BUILD ""
#define KERNEL_VERSION_STRING "1.1.35a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */
#define KERNEL_BUILD_STRING "2035a" /*#BUILD SUB_BUILD */

View File

@ -53,13 +53,13 @@ unsigned char ctrl_break_pressed(void)
unsigned char check_handle_break(struct dhdr FAR **pdev)
{
unsigned char c = CTL_C;
if (!ctrl_break_pressed())
c = (unsigned char)ndread(&syscon);
if (c != CTL_C && *pdev != syscon)
c = (unsigned char)ndread(pdev);
if (c == CTL_C)
unsigned char c;
if (ctrl_break_pressed() ||
(c = (unsigned char)ndread(&syscon)) == CTL_C ||
*pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C)
{
handle_break(pdev, -1);
}
return c;
}
@ -90,4 +90,3 @@ void handle_break(struct dhdr FAR **pdev, int sft_out)
spawn_int23(); /* invoke user INT-23 and never come back */
}

File diff suppressed because it is too large Load Diff

View File

@ -34,21 +34,12 @@ struct config { /* Configuration variables */
UBYTE cfgFilesHigh;
UBYTE cfgFcbs; /* number of available FCBs */
UBYTE cfgProtFcbs; /* number of protected FCBs */
BYTE *cfgInit; /* init of command.com */
BYTE *cfgInitTail; /* command.com's tail */
char cfgShell[256]; /* SHELL= line */
UBYTE cfgLastdrive; /* last drive */
UBYTE cfgLastdriveHigh;
BYTE cfgStacks; /* number of stacks */
BYTE cfgStacksHigh;
UWORD cfgStackSize; /* stacks size for each stack */
/* COUNTRY=
* In Pass #1 these information is collected and in PostConfig()
* the NLS package is loaded into memory. -- 2000/06/11 ska
*/
WORD cfgCSYS_cntry; /* country ID to be loaded */
UWORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */
WORD cfgCSYS_memory; /* # of bytes required for the NLS pkg; 0 if none */
VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */
UBYTE cfgP_0_startmode; /* load command.com high or not */
unsigned ebda2move; /* value for switches=/E:nnnn */
};

File diff suppressed because it is too large Load Diff

View File

@ -314,7 +314,7 @@ int21_2: inc byte [_InDOS]
or ah,ah
jz int21_3
cmp ah,0ch
jle int21_normalentry
jbe int21_normalentry
int21_3:
call dos_crit_sect

View File

@ -235,7 +235,7 @@ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\
extern UWORD ASM NetBios;
extern BYTE * ASM net_name;
extern BYTE ASM net_set_count;
extern BYTE ASM NetDelay, ASM NetRetry;
extern UWORD ASM NetDelay, ASM NetRetry;
extern UWORD ASM first_mcb, /* Start of user memory */
ASM uppermem_root; /* Start of umb chain (usually 9fff) */
@ -360,8 +360,7 @@ extern UWORD ASM f_nodes_cnt; /* number of allocated f_nodes */
/* Process related functions - not under automatic generation. */
/* Typically, these are in ".asm" files. */
VOID ASMCFUNC FAR cpm_entry(VOID)
/*INRPT FAR handle_break(VOID) */ ;
VOID ASMCFUNC FAR cpm_entry(VOID);
COUNT ASMCFUNC
CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError,
struct dhdr FAR * lpDevice);
@ -371,7 +370,6 @@ VOID ASMCFUNC FAR CharMapSrvc(VOID);
VOID ASMCFUNC FAR set_stack(VOID);
VOID ASMCFUNC FAR restore_stack(VOID);
#endif
/*VOID INRPT FAR handle_break(VOID); */
ULONG ASMPASCAL ReadPCClock(VOID);
VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE);

View File

@ -124,36 +124,32 @@ intvec getvec(unsigned char intno);
/* config.c */
extern struct config Config;
VOID PreConfig(VOID);
VOID PreConfig2(VOID);
VOID DoConfig(int pass);
void DoConfig(void);
VOID PostConfig(VOID);
VOID configDone(VOID);
VOID FAR * KernelAlloc(size_t nBytes, char type, int mode);
void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode);
char *strcat(char * d, const char * s);
BYTE * GetStringArg(BYTE * pLine, BYTE * pszString);
#ifdef I86
void _seg * alignNextPara(CVFP);
#else
#define alignNextPara(x) ((const VOID *)x)
#endif
void _seg * KernelAlloc(size_t nBytes, UBYTE type, int mode);
void _seg * KernelAllocPara(size_t nPara, UBYTE type, CStr name, int mode);
void DoInstall(void);
UWORD GetBiosKey(int timeout);
unsigned GetBiosKey(int timeout);
/* diskinit.c */
COUNT dsk_init(VOID);
/* int2f.asm */
COUNT ASMPASCAL Umb_Test(void);
COUNT ASMPASCAL UMB_get_largest(void FAR * driverAddress,
UCOUNT * seg, UCOUNT * size);
int ASMPASCAL UMB_get_largest(CVFP driverAddress, seg_t *, size_t *);
#ifdef __WATCOMC__
#pragma aux (pascal) UMB_get_largest modify exact [ax bx cx dx]
# pragma aux (pascal) UMB_get_largest modify exact [ax bx cx dx]
#endif
/* inithma.c */
int MoveKernelToHMA(void);
VOID FAR * HMAalloc(COUNT bytesToAllocate);
/* initoem.c */
unsigned init_oem(void);
void movebda(size_t bytes, unsigned new_seg);
unsigned ebdasize(void);
VFP HMAalloc(COUNT bytesToAllocate);
/* intr.asm */
@ -164,7 +160,7 @@ int ASMPASCAL close(int fd);
int ASMPASCAL dup2(int oldfd, int newfd);
seg ASMPASCAL allocmem(UWORD size);
void ASMPASCAL init_PSPSet(seg psp_seg);
int ASMPASCAL init_DosExec(int mode, exec_blk * ep, char * lp);
int ASMPASCAL init_DosExec(int mode, exec_blk *, CStr);
int ASMPASCAL init_setdrive(int drive);
int ASMPASCAL init_switchar(int chr);
void ASMPASCAL keycheck(void);
@ -208,15 +204,22 @@ VOID ASMCFUNC FAR int2f_handler(void);
VOID ASMCFUNC FAR cpm_entry(void);
/* kernel.asm */
VOID ASMCFUNC FAR init_call_p_0(struct config FAR *Config); /* P_0, actually */
void ASMCFUNC FAR init_call_p_0(const struct config FAR *); /* P_0, actually */
#ifdef __WATCOMC__
# pragma aux (cdecl) init_call_p_0 aborts
#endif
/* main.c */
VOID ASMCFUNC FreeDOSmain(void);
BOOL init_device(struct dhdr FAR * dhp, char * cmdLine,
COUNT mode, char FAR **top);
VOID init_fatal(BYTE * err_msg);
void ASMCFUNC FreeDOSmain(void);
BOOL init_device(struct dhdr FAR *, PCStr cmdLine, int mode, VFP *top);
#ifdef __WATCOMC__
# pragma aux (cdecl) FreeDOSmain aborts
#endif
/* prf.c */
int VA_CDECL init_printf(const char * fmt, ...);
int VA_CDECL init_sprintf(char * buff, const char * fmt, ...);
@ -231,12 +234,17 @@ extern UWORD HMAFree; /* first byte in HMA not yet used */
extern unsigned CurrentKernelSegment;
extern struct _KernelConfig FAR ASM LowKernelConfig;
extern WORD days[2][13];
extern BYTE FAR *lpTop;
extern VFP lpTop;
extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[];
extern UWORD ram_top; /* How much ram in Kbytes */
extern char singleStep;
extern char SkipAllConfig;
extern char master_env[128];
enum { ASK_ASK = 0x01, /* ?device= device?= */
ASK_NOASK = 0x02, /* !files= */
ASK_TRACE = 0x04, /* F8 processing */
ASK_SKIPALL = 0x08, /* F5 processing */
ASK_YESALL = 0x10, /* Esc while trace */
};
extern UBYTE askCommand;
extern struct lol FAR *LoL;
@ -312,4 +320,3 @@ ULONG ASMCFUNC FAR MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULo
ULONG ASMCFUNC FAR DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */
ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */
#endif

View File

@ -1,72 +0,0 @@
/****************************************************************/
/* */
/* initoem.c */
/* */
/* OEM Initializattion Functions */
/* */
/* Copyright (c) 1995 */
/* Pasquale J. Villani */
/* All Rights Reserved */
/* */
/* This file is part of DOS-C. */
/* */
/* DOS-C is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version */
/* 2, or (at your option) any later version. */
/* */
/* DOS-C is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
/* the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with DOS-C; see the file COPYING. If not, */
/* write to the Free Software Foundation, 675 Mass Ave, */
/* Cambridge, MA 02139, USA. */
/* */
/****************************************************************/
#include "portab.h"
#include "init-mod.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId =
"$Id$";
#endif
#define EBDASEG 0x40e
#define RAMSIZE 0x413
unsigned init_oem(void)
{
iregs r;
init_call_intr(0x12, &r);
return r.a.x;
}
void movebda(size_t bytes, unsigned new_seg)
{
unsigned old_seg = peek(0, EBDASEG);
fmemcpy(MK_FP(new_seg, 0), MK_FP(old_seg, 0), bytes);
poke(0, EBDASEG, new_seg);
poke(0, RAMSIZE, ram_top);
}
unsigned ebdasize(void)
{
unsigned ebdaseg = peek(0, EBDASEG);
unsigned ramsize = ram_top;
if (ramsize * 64 == ebdaseg && ramsize < 640 && peek(0, RAMSIZE) == ramsize)
{
unsigned ebdasz = peekb(ebdaseg, 0);
/* sanity check: is there really no more than 63 KB?
* must be at 640k (all other values never seen and are untested)
*/
if (ebdasz <= 63 && ramsize + ebdasz == 640)
return ebdasz * 1024U;
}
return 0;
}

View File

@ -106,10 +106,9 @@ DriverSysCal:
mov di, _Dyn+2
jmp short Int2f?iret
;***********************************************************
; internal doscalls INT2F/11xx - handled through C
;***********************************************************
;**********************************************************************
; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C
;**********************************************************************
IntDosCal:
; set up register frame
;struct int2f12regs

View File

@ -1240,13 +1240,12 @@ dispatch:
case 0x5f:
if (lr.AL == 7 || lr.AL == 8)
{
struct cds FAR *cdsp;
if (lr.DL >= lastdrive)
struct cds FAR *cdsp = &CDSp[lr.DL];
if (lr.DL >= lastdrive || FP_OFF(cdsp->cdsDpb) == 0)
{
rc = DE_INVLDDRV;
goto error_exit;
}
cdsp = &CDSp[lr.DL];
if (lr.AL == 7)
cdsp->cdsFlags |= CDSPHYSDRV;
else

View File

@ -94,7 +94,9 @@
segment HMA_TEXT
;; COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
;
; int ASMPASCAL res_DosExec(int mode, exec_blk * ep, const char * lp);
;
global RES_DOSEXEC
RES_DOSEXEC:
pop es ; ret address
@ -106,12 +108,13 @@ RES_DOSEXEC:
push ds
pop es ; es = ds
int 21h
jc short no_exec_error
xor ax, ax
no_exec_error:
sbb dx,dx ; CF=0?
and ax,dx ; then ax=0, else ax=error code
ret
;; UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
;
; unsigned ASMPASCAL res_read(int fd, void *buf, unsigned count);
;
global RES_READ
RES_READ:
pop ax ; ret address
@ -121,23 +124,20 @@ RES_READ:
push ax ; ret address
mov ah, 3fh
int 21h
jnc no_read_error
mov ax, -1
no_read_error:
sbb dx,dx ; CF=1?
or ax,dx ; then ax=-1, else ax=bytes read
ret
segment INIT_TEXT
;
; void init_call_intr(nr, rp)
; REG int nr
; REG struct REGPACK *rp
; unsigned ASMPASCAL init_call_intr(int nr, iregs * rp);
;
global INIT_CALL_INTR
INIT_CALL_INTR:
INTR
;
; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX)
; int ASMPASCAL init_call_XMScall(void FAR * driverAddress, UWORD ax, UWORD dx);
;
; this calls HIMEM.SYS
;
@ -155,7 +155,9 @@ INIT_CALL_XMSCALL:
push cx
retf
; void FAR *DetectXMSDriver(VOID)
;
; void FAR * ASMPASCAL DetectXMSDriver(VOID);
;
global DETECTXMSDRIVER
DETECTXMSDRIVER:
mov ax, 4300h
@ -163,8 +165,8 @@ DETECTXMSDRIVER:
cmp al, 80h
je detected
xor ax, ax
xor dx, dx
xor ax,ax
cwd
ret
detected:
@ -179,13 +181,18 @@ detected:
pop es
ret
;
; void ASMPASCAL keycheck(void);
;
global KEYCHECK
KEYCHECK:
mov ah, 1
int 16h
ret
;; int open(const char *pathname, int flags);
;
; int ASMPASCAL open(const char *pathname, int flags);
;
global INIT_DOSOPEN
INIT_DOSOPEN:
;; init calling DOS through ints:
@ -198,12 +205,14 @@ INIT_DOSOPEN:
common_int21:
int 21h
jnc common_no_error
mov ax, -1
common_no_error:
jnc common_ret ; CF=1?
sbb ax,ax ; then ax=-1, else ax unchanged
common_ret:
ret
;; int close(int fd);
;
; int ASMPASCAL close(int fd);
;
global CLOSE
CLOSE:
pop ax ; ret address
@ -212,7 +221,9 @@ CLOSE:
mov ah, 3eh
jmp short common_int21
;; UCOUNT read(int fd, void *buf, UCOUNT count);
;
; unsigned ASMPASCAL read(int fd, void *buf, unsigned count);
;
global READ
READ:
pop ax ; ret address
@ -223,7 +234,9 @@ READ:
mov ah, 3fh
jmp short common_int21
;; int dup2(int oldfd, int newfd);
;
; int ASMPASCAL dup2(int oldfd, int newfd);
;
global DUP2
DUP2:
pop ax ; ret address
@ -233,7 +246,9 @@ DUP2:
mov ah, 46h
jmp short common_int21
;; VOID init_PSPSet(seg psp_seg)
;
; void ASMPASCAL init_PSPSet(seg psp_seg);
;
global INIT_PSPSET
INIT_PSPSET:
pop ax ; ret address
@ -243,7 +258,9 @@ INIT_PSPSET:
int 21h
ret
;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
;
; int ASMPASCAL init_DosExec(int mode, exec_blk * ep, const char * lp);
;
global INIT_DOSEXEC
INIT_DOSEXEC:
pop es ; ret address
@ -255,12 +272,13 @@ INIT_DOSEXEC:
push ds
pop es ; es = ds
int 21h
jc short exec_no_error
xor ax, ax
exec_no_error:
sbb dx,dx ; CF=0?
and ax,dx ; then ax=0, else ax=error code
ret
;; int init_setdrive(int drive)
;
; int ASMPASCAL init_setdrive(int drive);
;
global INIT_SETDRIVE
INIT_SETDRIVE:
mov ah, 0x0e
@ -271,7 +289,9 @@ common_dl_int21:
int 21h
ret
;; int init_switchar(int char)
;
; int ASMPASCAL init_switchar(int chr);
;
global INIT_SWITCHAR
INIT_SWITCHAR:
mov ax, 0x3701
@ -287,11 +307,13 @@ ALLOCMEM:
push ax ; ret address
mov ah, 48h
int 21h
sbb bx, bx ; carry=1 -> ax=-1
or ax, bx ; segment
sbb bx,bx ; CF=1?
or ax,bx ; then ax=-1, else ax=segment
ret
;; void set_DTA(void far *dta)
;
; void ASMPASCAL set_DTA(void far *dta);
;
global SET_DTA
SET_DTA:
pop ax ; ret address

View File

@ -56,17 +56,124 @@ static BYTE *RcsId =
COUNT DosDevIOctl(lregs * r)
{
sft FAR *s;
struct dpb FAR *dpbp;
COUNT nMode;
unsigned attr;
unsigned char al = r->AL;
static UBYTE cmds [] = {
0, 0,
/* 0x02 */ C_IOCTLIN,
/* 0x03 */ C_IOCTLOUT,
/* 0x04 */ C_IOCTLIN,
/* 0x05 */ C_IOCTLOUT,
/* 0x06 */ C_ISTAT,
/* 0x07 */ C_OSTAT,
/* 0x08 */ C_REMMEDIA,
0, 0, 0,
/* 0x0c */ C_GENIOCTL,
/* 0x0d */ C_GENIOCTL,
/* 0x0e */ C_GETLDEV,
/* 0x0f */ C_SETLDEV,
/* 0x10 */ C_IOCTLQRY,
/* 0x11 */ C_IOCTLQRY,
};
static UWORD required_attr [] = {
0, 0,
/* 0x02 */ ATTR_IOCTL,
/* 0x03 */ ATTR_IOCTL,
/* 0x04 */ ATTR_IOCTL,
/* 0x05 */ ATTR_IOCTL,
0, 0,
/* 0x08 */ ATTR_EXCALLS,
0, 0, 0,
/* 0x0c */ ATTR_GENIOCTL,
/* 0x0d */ ATTR_GENIOCTL,
/* 0x0e */ ATTR_GENIOCTL,
/* 0x0f */ ATTR_GENIOCTL,
/* 0x10 */ ATTR_QRYIOCTL,
/* 0x11 */ ATTR_QRYIOCTL,
};
if (al > 0x11)
sft FAR *s;
struct dhdr FAR *dev;
unsigned attr, flags;
UBYTE cmd;
switch (r->AL)
{
default: /* 0x12+ */
return DE_INVLDFUNC;
case 0x0b:
if (r->DX) /* skip, it's a special case */
NetRetry = r->DX;
NetDelay = r->CX;
return SUCCESS;
case 0x00:
case 0x01:
case 0x02:
case 0x03:
case 0x06:
case 0x07:
case 0x0a:
case 0x0c:
case 0x10:
/* Test that the handle is valid and */
/* get the SFT block that contains the SFT */
if ((s = get_sft(r->BX)) == (sft FAR *)-1)
return DE_INVLDHNDL;
flags = s->sft_flags;
dev = s->sft_dev;
attr = dev->dh_attr;
break;
case 0x04:
case 0x05:
case 0x08:
case 0x09:
case 0x0d:
case 0x0e:
case 0x0f:
case 0x11:
{
struct dpb FAR *dpbp;
/*
Line below previously returned the deviceheader at r->bl. But,
DOS numbers its drives starting at 1, not 0. A=1, B=2, and so
on. Changed this line so it is now zero-based. --SRM
*/
/* changed to use default drive if drive=0. --JPP */
/* Fixed it. --JT */
#define NDN_HACK
#ifdef NDN_HACK
/* NDN feeds the actual ASCII drive letter to this function */
UBYTE unit = (r->BL & 0x1f) - 1;
#else
UBYTE unit = r->BL - 1;
#endif
if (unit == 0xff)
unit = default_drive;
CharReqHdr.r_unit = unit;
if ((dpbp = get_dpb(unit)) == NULL)
{
if (r->AL != 0x09)
return DE_INVLDDRV;
attr = ATTR_REMOTE;
}
else
{
dev = dpbp->dpb_device;
attr = dev->dh_attr;
}
}
} /* switch */
/* required_attr[] may be zero and in this case attr ignored */
if (~attr & required_attr [r->AL])
return DE_INVLDFUNC;
/* commonly used, shouldn't harm to do front up */
if (al == 0x0C || al == 0x0D || al >= 0x10) /* generic or query */
CharReqHdr.r_command = cmd = cmds [r->AL];
if (cmd == C_GENIOCTL || cmd == C_IOCTLQRY)
{
CharReqHdr.r_cat = r->CH; /* category (major) code */
CharReqHdr.r_fun = r->CL; /* function (minor) code */
@ -80,49 +187,18 @@ COUNT DosDevIOctl(lregs * r)
CharReqHdr.r_length = sizeof(request);
CharReqHdr.r_status = 0;
switch (r->AL)
{
case 0x0b:
/* skip, it's a special case. */
NetDelay = r->CX;
if (r->DX)
NetRetry = r->DX;
break;
case 0x00:
case 0x01:
case 0x02:
case 0x03:
case 0x06:
case 0x07:
case 0x0a:
case 0x0c:
case 0x10:
{
unsigned flags;
/* Test that the handle is valid and */
/* get the SFT block that contains the SFT */
if ((s = get_sft(r->BX)) == (sft FAR *) - 1)
return DE_INVLDHNDL;
attr = s->sft_dev->dh_attr;
flags = s->sft_flags;
switch (r->AL)
{
case 0x00:
/* Get the flags from the SFT */
r->DX = flags;
if (flags & SFT_FDEVICE)
r->AX = (attr & 0xff00) | (flags & 0xff);
else
r->AX = flags;
r->DH = attr >> 8;
/* Undocumented result, Ax = Dx seen using Pcwatch */
r->DX = r->AX;
r->AX = r->DX;
break;
case 0x01:
/* sft_flags is a file, return an error because you */
/* can't set the status of a file. */
if (!(flags & SFT_FDEVICE))
return DE_INVLDFUNC;
@ -132,205 +208,95 @@ COUNT DosDevIOctl(lregs * r)
if (r->DH != 0)
return DE_INVLDDATA;
/* Undocumented: AL should get the old value */
r->AL = s->sft_flags_lo;
/* Set it to what we got in the DL register from the */
/* user. */
s->sft_flags_lo = SFT_FDEVICE | r->DL;
break;
case 0x02:
nMode = C_IOCTLIN;
goto IoCharCommon;
case 0x03:
nMode = C_IOCTLOUT;
goto IoCharCommon;
case 0x06:
if (flags & SFT_FDEVICE)
{
nMode = C_ISTAT;
goto IoCharCommon;
}
r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF;
break;
case 0x07:
if (flags & SFT_FDEVICE)
{
nMode = C_OSTAT;
goto IoCharCommon;
}
r->AL = 0;
/* Undocumented: AL should get the old value */
r->AL = (UBYTE)flags;
break;
case 0x0a:
r->DX = flags;
r->AX = 0;
r->AX = 0; /* ??? RBIL doesn't says that AX changed --avb */
break;
case 0x06:
if (!(flags & SFT_FDEVICE))
{
r->AL = s->sft_posit >= s->sft_size ? (UBYTE)0 : (UBYTE)0xFF;
break;
}
/* fall through */
case 0x07:
if (!(flags & SFT_FDEVICE))
{
r->AL = 0;
break;
}
/* fall through */
case 0x02:
case 0x03:
case 0x0c:
nMode = C_GENIOCTL;
goto IoCharCommon;
default: /* 0x10 */
nMode = C_IOCTLQRY;
IoCharCommon:
if ((flags & SFT_FDEVICE) &&
( (r->AL <= 0x03 && (attr & ATTR_IOCTL))
|| r->AL == 0x06 || r->AL == 0x07
|| (r->AL == 0x10 && (attr & ATTR_QRYIOCTL))
|| (r->AL == 0x0c && (attr & ATTR_GENIOCTL))))
{
CharReqHdr.r_unit = 0;
CharReqHdr.r_command = nMode;
execrh((request FAR *) & CharReqHdr, s->sft_dev);
if (CharReqHdr.r_status & S_ERROR)
{
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
return DE_DEVICE;
}
if (r->AL <= 0x03)
r->AX = CharReqHdr.r_count;
else if (r->AL <= 0x07)
r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff;
else /* 0x0c or 0x10 */
r->AX = CharReqHdr.r_status;
break;
}
case 0x10:
if (!(flags & SFT_FDEVICE))
return DE_INVLDFUNC;
}
break;
}
CharReqHdr.r_unit = 0; /* ??? not used for devices --avb */
goto execrequest;
default: /* block IOCTL: 4, 5, 8, 9, d, e, f, 11 */
/*
This line previously returned the deviceheader at r->bl. But,
DOS numbers its drives starting at 1, not 0. A=1, B=2, and so
on. Changed this line so it is now zero-based.
-SRM
*/
/* JPP - changed to use default drive if drive=0 */
/* JT Fixed it */
#define NDN_HACK
/* NDN feeds the actual ASCII drive letter to this function */
#ifdef NDN_HACK
CharReqHdr.r_unit = ((r->BL & 0x1f) == 0 ? default_drive :
(r->BL & 0x1f) - 1);
#else
CharReqHdr.r_unit = (r->BL == 0 ? default_drive : r->BL - 1);
#endif
dpbp = get_dpb(CharReqHdr.r_unit);
if (dpbp)
attr = dpbp->dpb_device->dh_attr;
else if (r->AL != 9)
return DE_INVLDDRV;
switch (r->AL)
{
case 0x04:
nMode = C_IOCTLIN;
goto IoBlockCommon;
case 0x05:
nMode = C_IOCTLOUT;
goto IoBlockCommon;
case 0x08:
if (attr & ATTR_EXCALLS)
{
nMode = C_REMMEDIA;
goto IoBlockCommon;
}
return DE_INVLDFUNC;
case 0x09:
{
struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit);
r->AX = S_DONE | S_BUSY;
if (cdsp != NULL && dpbp == NULL)
{
r->DX = ATTR_REMOTE;
}
else
{
if (!dpbp)
{
const struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit);
if (cdsp == NULL)
return DE_INVLDDRV;
}
r->DX = attr;
}
if (cdsp->cdsFlags & CDSSUBST)
{
r->DX |= ATTR_SUBST;
}
attr |= ATTR_SUBST;
r->DX = attr;
r->AX = S_DONE | S_BUSY; /* ??? S_* values only for driver interface;
RBIL doesn't says that AX changed --avb */
break;
}
case 0x0d:
nMode = C_GENIOCTL;
goto IoBlockCommon;
case 0x11:
nMode = C_IOCTLQRY;
IoBlockCommon:
if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A)
if ((r->CX & ~0x4021) == 0x084A)
{ /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */
r->AX = 0; /* (lock/unlock logical/physical volume) */
break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */
}
if ((r->AL <= 0x05 && !(attr & ATTR_IOCTL))
|| (r->AL == 0x11 && !(attr & ATTR_QRYIOCTL))
|| (r->AL == 0x0d && !(attr & ATTR_GENIOCTL)))
{
return DE_INVLDFUNC;
}
CharReqHdr.r_command = nMode;
execrh((request FAR *) & CharReqHdr, dpbp->dpb_device);
/* fall through */
case 0x04:
case 0x05:
case 0x08:
case 0x11:
execrequest:
execrh(&CharReqHdr, dev);
if (CharReqHdr.r_status & S_ERROR)
{
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
return DE_DEVICE;
}
if (r->AL <= 0x05)
if (r->AL <= 0x05) /* 0x02, 0x03, 0x04, 0x05 */
r->AX = CharReqHdr.r_count;
else if (r->AL == 0x08)
r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0;
else /* 0x0d or 0x11 */
else if (r->AL <= 0x07) /* 0x06, 0x07 */
r->AX = (CharReqHdr.r_status & S_BUSY) ? 0000 : 0x00ff;
else if (r->AL == 0x08) /* 0x08 */
r->AX = (CharReqHdr.r_status / S_BUSY) & 1u;
else /* 0x0c, 0x0d, 0x10, 0x11 */
r->AX = CharReqHdr.r_status;
break;
case 0x0e:
nMode = C_GETLDEV;
goto IoLogCommon;
default: /* 0x0f */
nMode = C_SETLDEV;
IoLogCommon:
if (attr & ATTR_GENIOCTL)
{
CharReqHdr.r_command = nMode;
execrh((request FAR *) & CharReqHdr, dpbp->dpb_device);
execrh(&CharReqHdr, dev);
if (CharReqHdr.r_status & S_ERROR)
{
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
return DE_ACCESS;
}
else
{
r->AL = CharReqHdr.r_unit;
return SUCCESS;
}
}
return DE_INVLDFUNC;
}
break;
}
} /* switch */
return SUCCESS;
}

View File

@ -45,12 +45,12 @@ static char copyright[] =
struct _KernelConfig InitKernelConfig BSS_INIT({0});
STATIC VOID InitIO(void);
STATIC VOID init_internal_devices(void);
STATIC VOID update_dcb(struct dhdr FAR *);
STATIC VOID init_kernel(VOID);
STATIC VOID signon(VOID);
STATIC VOID kernel(VOID);
STATIC VOID init_shell(VOID);
STATIC VOID FsConfig(VOID);
STATIC VOID InitPrinters(VOID);
STATIC VOID InitSerialPorts(VOID);
@ -69,11 +69,8 @@ __segment DosTextSeg = 0;
struct lol FAR *LoL = &DATASTART;
VOID ASMCFUNC FreeDOSmain(void)
void ASMCFUNC FreeDOSmain(void)
{
unsigned char drv;
unsigned char FAR *p;
#ifdef _MSC_VER
extern FAR prn_dev;
DosDataSeg = (__segment) & DATASTART;
@ -89,47 +86,40 @@ VOID ASMCFUNC FreeDOSmain(void)
at 50:e0
*/
drv = LoL->BootDrive + 1;
p = MK_FP(0, 0x5e0);
if (fmemcmp(p+2,"CONFIG",6) == 0) /* UPX */
{
fmemcpy(&InitKernelConfig, p+2, sizeof(InitKernelConfig));
drv = *p + 1;
*(DWORD FAR *)(p+2) = 0;
}
UBYTE drv;
UBYTE FAR *p = MK_PTR(UBYTE, 0, 0x5e2);
if (fmemcmp(p, "CONFIG", 6) == 0) /* UPXed */
drv = p[-2]; /* boot drive was stored there by stub from exeflat.c */
else
{
*p = drv - 1;
fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig));
drv = LoL->BootDrive;
p[-2] = drv; /* used by initdisk.c:ReadAllPartitionTables() */
p = (UBYTE FAR*)&LowKernelConfig;
}
if (drv >= 0x80)
drv++;
if (drv > 0x80)
drv = 3; /* C: */
LoL->BootDrive = drv;
fmemcpy(&InitKernelConfig, p, sizeof InitKernelConfig);
}
setup_int_vectors();
CheckContinueBootFromHarddisk();
signon();
init_kernel();
init_shell();
#ifdef DEBUG
/* Non-portable message kludge alert! */
printf("KERNEL: Boot drive = %c\n", 'A' + LoL->BootDrive - 1);
#endif
DoInstall();
kernel();
init_call_p_0(&Config); /* execute process 0 (the shell) */
}
/*
InitializeAllBPBs()
or MakeNortonDiskEditorHappy()
it has been determined, that FDOS's BPB tables are initialized,
only when used (like DIR H:).
at least one known utility (norton DE) seems to access them directly.
@ -149,62 +139,47 @@ void InitializeAllBPBs(VOID)
STATIC void PSPInit(void)
{
psp far *p = MK_FP(DOS_PSP, 0);
psp _seg *p = MK_SEG_PTR(psp, DOS_PSP);
/* Clear out new psp first */
fmemset(p, 0, sizeof(psp));
fmemset(p, 0, sizeof(psp)); /* Clear out new psp first */
/* initialize all entries and exits */
/* CP/M-like exit point */
p->ps_exit = 0x20cd;
/* CP/M-like entry point - call far to special entry */
p->ps_farcall = 0x9a;
p->ps_reentry = MK_FP(0, 0x30 * 4);
/* unix style call - 0xcd 0x21 0xcb (int 21, retf) */
p->ps_unix[0] = 0xcd;
p->ps_unix[1] = 0x21;
p->ps_exit = 0x20cd; /* CP/M-like exit point: */
/* INT 20 opcode */
/* CP/M-like entry point: */
p->ps_farcall = 0x9a; /* FAR CALL opcode... */
p->ps_reentry = MK_FP(0, 0x30 * 4); /* ...entry address */
p->ps_unix[0] = 0xcd; /* unix style call: */
p->ps_unix[1] = 0x21; /* INT 21/RETF opcodes */
p->ps_unix[2] = 0xcb;
/* Now for parent-child relationships */
/* parent psp segment */
p->ps_parent = FP_SEG(p);
/* previous psp pointer */
p->ps_prevpsp = MK_FP(0xffff,0xffff);
/* parent-child relationships */
/*p->ps_parent = 0;*/ /* parent psp segment */
p->ps_prevpsp = (VFP)-1l; /* previous psp address */
/* Environment and memory useage parameters */
/* memory size in paragraphs */
/* p->ps_size = 0; clear from above */
/* environment paragraph */
p->ps_environ = DOS_PSP + 8;
/* terminate address */
p->ps_isv22 = getvec(0x22);
/* break address */
p->ps_isv23 = getvec(0x23);
/* critical error address */
p->ps_isv24 = getvec(0x24);
/*p->ps_size = 0;*/ /* segment of memory beyond */
/* memory allocated to program */
/*p->ps_environ = 0;*/ /* environment paragraph */
/* user stack pointer - int 21 */
/* p->ps_stack = NULL; clear from above */
/*p->ps_isv22 = NULL;*/ /* terminate handler */
/*p->ps_isv23 = NULL;*/ /* break handler */
/*p->ps_isv24 = NULL;*/ /* critical error handler */
/*p->ps_stack = NULL;*/ /* user stack pointer - int 21 */
/* File System parameters */
/* maximum open files */
p->ps_maxfiles = 20;
fmemset(p->ps_files, 0xff, 20);
p->ps_maxfiles = sizeof p->ps_files; /* size of file table */
fmemset(p->ps_filetab = p->ps_files, 0xff, sizeof p->ps_files);
/* open file table pointer */
p->ps_filetab = p->ps_files;
/*p->ps_fcb1.fcb_drive = 0;*/ /* 1st command line argument */
/*fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);*/
/*p->ps_fcb2.fcb_drive = 0;*/ /* 2nd command line argument */
/*fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);*/
/* first command line argument */
/* p->ps_fcb1.fcb_drive = 0; already set */
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* second command line argument */
/* p->ps_fcb2.fcb_drive = 0; already set */
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* local command line */
/* p->ps_cmd.ctCount = 0; command tail, already set */
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
/* this area reused for master environment */
/*p->ps_cmd.ctCount = 0;*/ /* local command line */
/*p->ps_cmd.ctBuffer[0] = '\r';*/ /* command tail */
}
#ifndef __WATCOMC__
@ -255,7 +230,7 @@ STATIC void setup_int_vectors(void)
for (i = 0x23; i <= 0x3f; i++)
setvec(i, empty_handler);
for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++)
for (pvec = vectors; pvec < ENDOF(vectors); pvec++)
setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
pokeb(0, 0x30 * 4, 0xea);
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry);
@ -272,9 +247,6 @@ STATIC void init_kernel(void)
LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE;
LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE;
/* Init oem hook - returns memory size in KB */
ram_top = init_oem();
/* move kernel to high conventional RAM, just below the init code */
#ifdef __WATCOMC__
lpTop = MK_FP(_CS, 0);
@ -283,16 +255,17 @@ STATIC void init_kernel(void)
#endif
MoveKernel(FP_SEG(lpTop));
/* lpTop should be para-aligned */
lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0);
/* Initialize IO subsystem */
InitIO();
init_internal_devices();
InitPrinters();
InitSerialPorts();
init_PSPSet(DOS_PSP);
set_DTA(MK_FP(DOS_PSP, 0x80));
PSPInit();
init_PSPSet(DOS_PSP);
Init_clk_driver();
@ -300,7 +273,6 @@ STATIC void init_kernel(void)
/* we can read config.sys later. */
LoL->lastdrive = Config.cfgLastdrive;
/* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, &ram_top); */
blk_dev.dh_name[0] = dsk_init();
PreConfig();
@ -313,14 +285,7 @@ STATIC void init_kernel(void)
FsConfig();
/* Now process CONFIG.SYS */
DoConfig(0);
DoConfig(1);
/* initialize near data and MCBs */
PreConfig2();
/* and process CONFIG.SYS one last time for device drivers */
DoConfig(2);
DoConfig();
/* Close all (device) files */
for (i = 0; i < 20; i++)
@ -335,6 +300,8 @@ STATIC void init_kernel(void)
configDone();
InitializeAllBPBs();
DoInstall();
}
STATIC VOID FsConfig(VOID)
@ -346,21 +313,15 @@ STATIC VOID FsConfig(VOID)
for (i = 0; i < LoL->lastdrive; i++)
{
struct cds FAR *pcds_table = &LoL->CDSp[i];
fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4);
pcds_table->cdsCurrentPath[0] += i;
if (i < LoL->nblkdev && (ULONG) dpb != 0xffffffffl)
pcds_table->cdsFlags = 0;
if (i < LoL->nblkdev && (LONG) dpb != -1l)
{
pcds_table->cdsDpb = dpb;
pcds_table->cdsFlags = CDSPHYSDRV;
dpb = dpb->dpb_next;
}
else
{
pcds_table->cdsFlags = 0;
}
pcds_table->cdsStrtClst = 0xffff;
pcds_table->cdsParam = 0xffff;
pcds_table->cdsStoreUData = 0xffff;
@ -428,135 +389,89 @@ STATIC VOID signon()
MAJOR_RELEASE, MINOR_RELEASE, copyright);
}
STATIC void kernel()
STATIC void init_shell()
{
CommandTail Cmd;
if (master_env[0] == '\0') /* some shells panic on empty master env. */
strcpy(master_env, "PATH=.");
fmemcpy(MK_FP(DOS_PSP + 8, 0), master_env, sizeof(master_env));
/* process 0 */
/* Execute command.com from the drive we just booted from */
memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer));
strcpy(Cmd.ctBuffer, Config.cfgInitTail);
for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++)
if (Cmd.ctBuffer[Cmd.ctCount] == '\r')
break;
/* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */
/* 3 for string + 2 for "\r\n" */
if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 5)
/* (insert /D, /Y as first argument) */
if (askCommand & (ASK_TRACE | ASK_SKIPALL))
{
char *insertString = NULL;
PStr p = Config.cfgShell - 1; /* find end of command name */
if (singleStep)
insertString = " /Y"; /* single step AUTOEXEC */
/* too long line -> truncate it to make space for "/Y \0" */
Config.cfgShell[sizeof Config.cfgShell - 4] = '\0';
if (SkipAllConfig)
insertString = " /D"; /* disable AUTOEXEC */
do p++; while ((UBYTE)*p > ' ' && *p != '/');
if (*p == ' ' || *p == '\t')
p++; /* place option after space */
if (insertString)
{
/* insert /D, /Y as first argument */
char *p, *q;
for (p = Cmd.ctBuffer; p < &Cmd.ctBuffer[Cmd.ctCount]; p++)
PStr q = p;
while (*q++); /* find end of command line */
/* shift tail to right by 3 to make room for option */
do
{
if (*p == ' ' || *p == '\t' || *p == '\r')
{
for (q = &Cmd.ctBuffer[Cmd.ctCount + 1]; q >= p; q--)
q--;
q[3] = q[0];
memcpy(p, insertString, 3);
break;
} while (q > p);
}
p[0] = '/', p[1] = 'Y', p[2] = ' '; /* single step AUTOEXEC */
if (askCommand & ASK_SKIPALL)
p[1] = 'D'; /* disable AUTOEXEC */
}
/* save buffer -- on the stack it's fine here */
Config.cfgInitTail = Cmd.ctBuffer;
}
}
init_call_p_0(&Config); /* go execute process 0 (the shell) */
}
/* 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;
int nunits = dhp->dh_name[0];
struct dpb FAR *dpb = LoL->DPBp;
if (LoL->nblkdev == 0)
dpb = LoL->DPBp;
else
if (LoL->nblkdev)
{
for (dpb = LoL->DPBp; (ULONG) dpb->dpb_next != 0xffffffffl;
dpb = dpb->dpb_next)
;
while ((LONG) dpb->dpb_next != -1l)
dpb = dpb->dpb_next;
dpb = dpb->dpb_next =
KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb);
}
for (Index = 0; Index < nunits; Index++)
{
int i = 0;
do
{
dpb->dpb_next = dpb + 1;
dpb->dpb_unit = LoL->nblkdev;
dpb->dpb_subunit = Index;
dpb->dpb_device = dhp;
dpb->dpb_flags = M_CHANGED;
if ((LoL->CDSp != 0) && (LoL->nblkdev < LoL->lastdrive))
if (LoL->nblkdev < LoL->lastdrive && LoL->CDSp)
{
LoL->CDSp[LoL->nblkdev].cdsDpb = dpb;
LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV;
}
++dpb;
++LoL->nblkdev;
LoL->nblkdev++;
dpb->dpb_subunit = i;
dpb->dpb_device = dhp;
dpb->dpb_flags = M_CHANGED;
dpb++;
i++;
} while (i < nunits);
}
(dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl;
(dpb - 1)->dpb_next = (VFP)-1l;
}
/* If cmdLine is NULL, this is an internal driver */
BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
char FAR **r_top)
/* If r_top is NULL, this is an internal driver */
BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top)
{
request rq;
char name[8];
if (cmdLine) {
char *p, *q, ch;
int i;
p = q = cmdLine;
for (;;)
{
ch = *p;
if (ch == '\0' || ch == ' ' || ch == '\t')
break;
p++;
if (ch == '\\' || ch == '/' || ch == ':')
q = p; /* remember position after path */
}
for (i = 0; i < 8; i++) {
ch = '\0';
if (p != q && *q != '.')
ch = *q++;
/* copy name, without extension */
name[i] = ch;
}
}
rq.r_unit = 0;
rq.r_status = 0;
rq.r_command = C_INIT;
rq.r_length = sizeof(request);
rq.r_endaddr = *r_top;
rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n");
rq.r_endaddr = r_top ? *r_top : lpTop;
rq.r_bpbptr = (VFP)cmdLine;
rq.r_firstunit = LoL->nblkdev;
execrh((request FAR *) & rq, dhp);
execrh(&rq, dhp);
/*
* Added needed Error handle
@ -564,7 +479,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
if ((rq.r_status & (S_ERROR | S_DONE)) == S_ERROR)
return TRUE;
if (cmdLine)
if (r_top)
{
/* Don't link in device drivers which do not take up memory */
if (rq.r_endaddr == (BYTE FAR *) dhp)
@ -578,8 +493,35 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
if (FP_OFF(dhp->dh_next) == 0xffff)
{
KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16
- FP_SEG(dhp), 'D', name, mode);
char name[8];
PCStr q;
{
UBYTE ch;
PCStr p = cmdLine;
q = p; /* position after path */
do /* find driver name after path */
{
ch = *p;
p++;
if (ch == ':' || ch == '\\' || ch == '/')
q = p;
} while (ch > ' ');
}
{
int i = 0;
do /* extract driver name */
{
UBYTE ch = *q;
if (ch <= ' ' || ch == '.')
ch = '\0'; /* copy name, without extension */
name[i] = ch;
if (ch == '\0')
break;
i++, q++;
} while (i < sizeof name);
}
KernelAllocPara(FP_SEG(alignNextPara(rq.r_endaddr)) - FP_SEG(dhp),
'D', name, mode);
}
/* Another fix for multisegmented device drivers: */
@ -589,7 +531,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
/* last INIT call which will then be passed as the end address */
/* for the next INIT call. */
*r_top = (char FAR *)rq.r_endaddr;
*r_top = rq.r_endaddr;
}
if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0))
@ -606,28 +548,21 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
return FALSE;
}
STATIC void InitIO(void)
STATIC void init_internal_devices(void)
{
struct dhdr far *device = &LoL->nul_dev;
/* Initialize driver chain */
do {
init_device(device, NULL, 0, &lpTop);
/* ??? is cmdLine "\n" for internal devices required? --avb */
init_device(device, "\n", 0, NULL);
device = device->dh_next;
}
while (FP_OFF(device) != 0xffff);
}
/* issue an internal error message */
VOID init_fatal(BYTE * err_msg)
{
printf("\nInternal kernel error - %s\nSystem halted\n", err_msg);
for (;;) ;
}
/*
Initialize all printers
this should work. IMHO, this might also be done on first use
of printer, as I never liked the noise by a resetting printer, and
I usually much more often reset my system, then I print :-)
@ -678,46 +613,39 @@ STATIC VOID InitSerialPorts(VOID)
booted from HD
*/
EmulatedDriveStatus(int drive,char statusOnly)
static int EmulatedDriveStatus(int drive,char statusOnly)
{
iregs r;
char buffer[0x13];
buffer[0] = 0x13;
r.a.b.h = 0x4b; /* bootable CDROM - get status */
r.a.b.l = statusOnly;
r.d.b.l = (char)drive;
r.si = (int)buffer;
r.AH = 0x4b; /* bootable CDROM - get status */
r.AL = statusOnly;
r.DL = (char)drive;
r.SI = (int)buffer;
init_call_intr(0x13, &r);
if (r.flags & 1)
return FALSE;
return TRUE;
return r.FLAGS & 1; /* carry flag */
}
STATIC void CheckContinueBootFromHarddisk(void)
{
char *bootedFrom = "Floppy/CD";
iregs r;
int key;
if (InitKernelConfig.BootHarddiskSeconds == 0)
if (InitKernelConfig.BootHarddiskSeconds <= 0)
return;
if (LoL->BootDrive >= 3)
{
#if 0
if (!EmulatedDriveStatus(0x80,1))
if (EmulatedDriveStatus(0x80,1))
#endif
{
/* already booted from HD */
return;
}
}
else {
else
{
#if 0
if (!EmulatedDriveStatus(0x00,1))
if (EmulatedDriveStatus(0x00,1))
#endif
bootedFrom = "Floppy";
}
@ -729,15 +657,13 @@ STATIC void CheckContinueBootFromHarddisk(void)
" Hit 'H' or wait %d seconds to boot from Harddisk\n",
InitKernelConfig.BootHarddiskSeconds,
bootedFrom,
InitKernelConfig.BootHarddiskSeconds
);
InitKernelConfig.BootHarddiskSeconds);
key = GetBiosKey(InitKernelConfig.BootHarddiskSeconds);
if (key != -1 && (key & 0xff) != 'h' && (key & 0xff) != 'H')
if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds))
{
unsigned key = GetBiosKey(-1); /* remove key from buffer */
if ((UBYTE)key != 'h' && (UBYTE)key != 'H')
/* user has hit a key, continue to boot from floppy/CD */
printf("\n");
return;
}
@ -745,18 +671,16 @@ STATIC void CheckContinueBootFromHarddisk(void)
EmulatedDriveStatus(0x00,0);
EmulatedDriveStatus(0x80,0);
/* now jump and run */
r.a.x = 0x0201;
r.c.x = 0x0001;
r.d.x = 0x0080;
r.b.x = 0x7c00;
r.es = 0;
init_call_intr(0x13, &r);
{
void (far *reboot)(void) = (void (far*)(void)) MK_FP(0x0,0x7c00);
(*reboot)();
iregs r;
r.AX = 0x0201;
r.CX = 0x0001;
r.DX = 0x0080;
r.BX = 0x7c00;
r.ES = 0;
init_call_intr(0x13, &r);
}
/* now jump and run */
((void (far*)(void)) MK_FP(0,0x7c00))(); /* jump to boot sector */
}

View File

@ -1,5 +1,5 @@
#
# Makefile for Borland C++ 3.1 for kernel.sys
# makefile for kernel.sys
#
# $Id$
#
@ -9,10 +9,12 @@
LIBS=..\lib\device.lib ..\lib\libm.lib
HDR=../hdr/
# *List Macros*
# List Macros ##########################################################
# Only 8 files per definition; this is limitation of DOS batch
# files (only 9 directly accessible parameters).
# Order of linking is important: first kernel.asm, last INIT code.
OBJS1=kernel.obj entry.obj io.obj console.obj serial.obj printer.obj dsk.obj \
sysclk.obj
OBJS2=asmsupt.obj execrh.obj nlssupt.obj procsupt.obj dosidle.obj int2f.obj \
@ -27,63 +29,52 @@ OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \
initdisk.obj initclk.obj
OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7)
# *Explicit Rules*
# Explicit Rules #######################################################
production: ..\bin\$(TARGET).sys
all: ..\bin\$(TARGET).sys
..\bin\$(TARGET).sys: kernel.sys
copy kernel.sys ..\bin
copy kernel.sys ..\bin\$(TARGET).sys
copy kernel.map ..\bin\$(TARGET).map
kernel.sys: kernel.exe ..\utils\exeflat.exe
$(XUPX) kernel.exe
..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B $(UPXOPT)
kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS)
..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe
$(LINK) @$(TARGET).lnk;
clobber: clean
-$(RM) kernel.exe kernel.sys status.me
clean:
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk
$(XUPX) kernel.exe
..\utils\exeflat kernel.exe $*.sys 0x60 -S0x10 -S0x8B $(UPXOPT)
copy $*.sys ..\bin\kernel.sys
# 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
# inability of Turbo `make' 2.0 to perform command line redirection. --ror4
ECHOTO=..\utils\echoto
$(TARGET).lnk: turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).mak
-$(RM) *.lnk
$(ECHOTO) $(TARGET).lnk $(OBJS1)+
$(ECHOTO) $(TARGET).lnk $(OBJS2)+
$(ECHOTO) $(TARGET).lnk $(OBJS3)+
$(ECHOTO) $(TARGET).lnk $(OBJS4)+
$(ECHOTO) $(TARGET).lnk $(OBJS5)+
$(ECHOTO) $(TARGET).lnk $(OBJS6)+
$(ECHOTO) $(TARGET).lnk $(OBJS7)
$(ECHOTO) $(TARGET).lnk kernel.exe
$(ECHOTO) $(TARGET).lnk kernel.map
$(ECHOTO) $(TARGET).lnk $(LIBS)
$(TARGET).lnk: $(DEPENDS) *.cfg
-$(RM) *.lnk *.obj
$(ECHOTO) $*.lnk $(OBJS1)+
$(ECHOTO) $*.lnk $(OBJS2)+
$(ECHOTO) $*.lnk $(OBJS3)+
$(ECHOTO) $*.lnk $(OBJS4)+
$(ECHOTO) $*.lnk $(OBJS5)+
$(ECHOTO) $*.lnk $(OBJS6)+
$(ECHOTO) $*.lnk $(OBJS7)
$(ECHOTO) $*.lnk kernel
$(ECHOTO) $*.lnk ..\bin\$*
$(ECHOTO) $*.lnk $(LIBS)
# *Individual File Dependencies*
apisupt.obj: apisupt.asm segs.inc $(TARGET).lnk
asmsupt.obj: asmsupt.asm segs.inc $(TARGET).lnk
console.obj: console.asm io.inc $(TARGET).lnk
dosidle.obj: dosidle.asm segs.inc $(TARGET).lnk
entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
execrh.obj: execrh.asm segs.inc $(TARGET).lnk
int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
intr.obj: intr.asm segs.inc $(TARGET).lnk
io.obj: io.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk
kernel.obj: kernel.asm segs.inc ludivmul.inc $(TARGET).lnk
nls_hc.obj: nls_hc.asm segs.inc $(TARGET).lnk
nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
printer.obj: printer.asm io.inc $(TARGET).lnk
procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk
serial.obj: serial.asm io.inc $(TARGET).lnk
# Individual File Dependencies #########################################
apisupt.obj: apisupt.asm segs.inc
asmsupt.obj: asmsupt.asm segs.inc
console.obj: console.asm io.inc
dosidle.obj: dosidle.asm segs.inc
entry.obj: entry.asm segs.inc $(HDR)stacks.inc
execrh.obj: execrh.asm segs.inc
int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc
intr.obj: intr.asm segs.inc
io.obj: io.asm segs.inc $(HDR)stacks.inc
irqstack.obj: irqstack.asm segs.inc
kernel.obj: kernel.asm segs.inc ludivmul.inc
nls_hc.obj: nls_hc.asm segs.inc
nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc
printer.obj: printer.asm io.inc
procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc
serial.obj: serial.asm io.inc
HDRS=\
$(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \
@ -94,31 +85,31 @@ HDRS=\
HEADERS=$(HDRS) globals.h proto.h
INITHEADERS=$(HDRS) init-mod.h init-dat.h
blockio.obj: blockio.c $(HEADERS) $(TARGET).lnk
break.obj: break.c $(HEADERS) $(TARGET).lnk
chario.obj: chario.c $(HEADERS) $(TARGET).lnk
dosfns.obj: dosfns.c $(HEADERS) $(TARGET).lnk
dosnames.obj: dosnames.c $(HEADERS) $(TARGET).lnk
dsk.obj: dsk.c $(HEADERS) $(TARGET).lnk
error.obj: error.c $(HEADERS) $(TARGET).lnk
fatdir.obj: fatdir.c $(HEADERS) $(TARGET).lnk
fatfs.obj: fatfs.c $(HEADERS) $(TARGET).lnk
fattab.obj: fattab.c $(HEADERS) $(TARGET).lnk
fcbfns.obj: fcbfns.c $(HEADERS) $(TARGET).lnk
inthndlr.obj: inthndlr.c $(HEADERS) $(TARGET).lnk
ioctl.obj: ioctl.c $(HEADERS) $(TARGET).lnk
memmgr.obj: memmgr.c $(HEADERS) $(TARGET).lnk
misc.obj: misc.c $(HEADERS) $(TARGET).lnk
lfnapi.obj: lfnapi.c $(HEADERS) $(TARGET).lnk
newstuff.obj: newstuff.c $(HEADERS) $(TARGET).lnk
network.obj: network.c $(HEADERS) $(TARGET).lnk
nls.obj: nls.c $(HEADERS) $(TARGET).lnk
prf.obj: prf.c $(HDR)portab.h $(TARGET).lnk
strings.obj: strings.c $(TARGET).lnk
sysclk.obj: sysclk.c $(HEADERS) $(TARGET).lnk
syspack.obj: syspack.c $(HEADERS) $(TARGET).lnk
systime.obj: systime.c $(HEADERS) $(TARGET).lnk
task.obj: task.c $(HEADERS) $(TARGET).lnk
blockio.obj: blockio.c $(HEADERS)
break.obj: break.c $(HEADERS)
chario.obj: chario.c $(HEADERS)
dosfns.obj: dosfns.c $(HEADERS)
dosnames.obj: dosnames.c $(HEADERS)
dsk.obj: dsk.c $(HEADERS)
error.obj: error.c $(HEADERS)
fatdir.obj: fatdir.c $(HEADERS)
fatfs.obj: fatfs.c $(HEADERS)
fattab.obj: fattab.c $(HEADERS)
fcbfns.obj: fcbfns.c $(HEADERS)
inthndlr.obj: inthndlr.c $(HEADERS)
ioctl.obj: ioctl.c $(HEADERS)
lfnapi.obj: lfnapi.c $(HEADERS)
memmgr.obj: memmgr.c $(HEADERS)
misc.obj: misc.c $(HEADERS)
network.obj: network.c $(HEADERS)
newstuff.obj: newstuff.c $(HEADERS)
nls.obj: nls.c $(HEADERS)
prf.obj: prf.c $(HDR)portab.h
strings.obj: strings.c
sysclk.obj: sysclk.c $(HEADERS)
syspack.obj: syspack.c $(HEADERS)
systime.obj: systime.c $(HEADERS)
task.obj: task.c $(HEADERS)
# now the funny stuff :-)
# Files in the INIT segment
@ -126,39 +117,49 @@ task.obj: task.c $(HEADERS) $(TARGET).lnk
# XXX: Special handling for initialization modules -- this is required because
# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4
config.obj: config.c $(INITHEADERS) $(TARGET).lnk
config.obj: config.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
initoem.obj: initoem.c $(INITHEADERS) $(TARGET).lnk
dyninit.obj: dyninit.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
main.obj: main.c $(INITHEADERS) $(TARGET).lnk
initclk.obj: initclk.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
inithma.obj: inithma.c $(INITHEADERS) $(TARGET).lnk
initdisk.obj: initdisk.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
dyninit.obj: dyninit.c $(INITHEADERS) $(TARGET).lnk
inithma.obj: inithma.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
initdisk.obj: initdisk.c $(INITHEADERS) $(TARGET).lnk
initoem.obj: initoem.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
initclk.obj: initclk.c $(INITHEADERS) $(TARGET).lnk
main.obj: main.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
#the string functions for INIT_TEXT
iasmsupt.obj: asmsupt.asm $(TARGET).lnk
$(NASM) -D$(COMPILER) -D_INIT $(NASMFLAGS) -f obj -o iasmsupt.obj asmsupt.asm
# the string functions for INIT_TEXT
#the printf for INIT_TEXT - yet another special case, this file includes prf.c
iprf.obj: iprf.c prf.c $(HDR)portab.h $(TARGET).lnk
iasmsupt.obj: asmsupt.asm
$(NASM) $(NASMFLAGS) -D_INIT asmsupt.asm -o$*.obj
# the printf for INIT_TEXT - yet another special case, this file includes prf.c
iprf.obj: iprf.c prf.c $(HDR)portab.h
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
########################################################################
clean:
-$(RM) *.bak *.cod *.crf *.err *.lnk *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) kernel.exe status.me

5
kernel/msc.cfg Normal file
View File

@ -0,0 +1,5 @@
-batch -nologo -WX
-Zlp1
-f- -Osb1V4e -Gsry
-Fc
-I..\hdr

View File

@ -513,19 +513,21 @@ COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize,
return DE_INVLDFUNC;
/* nls := NLS package of cntry/codepage */
if ((nls = searchPackage(cp, cntry)) == NULL
|| (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0)
if ((nls = searchPackage(cp, cntry)) != NULL)
{
/* If the NLS pkg is not loaded into memory or the
direct-access flag is disabled, the request must
be passed through MUX */
return (subfct == NLS_DOS_38)
? mux38(nls->cp, nls->cntry, bufsize, buf)
: mux65(subfct, nls->cp, nls->cntry, bufsize, buf);
}
/* matching NLS package found */
if (nls->flags & NLS_FLAG_DIRECT_GETDATA)
/* Direct access to the data */
return nlsGetData(nls, subfct, buf, bufsize);
cp = nls->cp;
cntry = nls->cntry;
}
/* If the NLS pkg is not loaded into memory or the direct-access
flag is disabled, the request must be passed through MUX */
return (subfct == NLS_DOS_38)
? mux38(cp, cntry, bufsize, buf)
: mux65(subfct, cp, cntry, bufsize, buf);
}
/*

View File

@ -49,15 +49,10 @@ segment HMA_TEXT
;
global _exec_user
_exec_user:
; PUSH$ALL
; mov ds,[_DGROUP_]
; cld
;
;
;
%ifndef WATCOM
; exec_user declared with attribute `aborts'
pop ax ; return address (unused)
%endif
pop ax ; irp (user ss:sp)
pop dx
pop cx ; disable A20?
@ -282,8 +277,11 @@ _spawn_int23:
global reloc_call_p_0
reloc_call_p_0:
%ifndef WATCOM
; reloc_call_p_0 declared with attribute `aborts'
pop ax ; return address (32-bit, unused)
pop ax
%endif
pop ax ; fetch parameter 0 (32-bit) from the old stack
pop dx
mov ds,[cs:_DGROUP_]
@ -293,4 +291,9 @@ reloc_call_p_0:
sti
push dx ; pass parameter 0 onto the new stack
push ax
%ifndef WATCOM
call _P_0 ; no return, allow parameter fetch from C
%else
; P_0 declared with attribute `aborts'
jmp _P_0 ; no return, allow parameter fetch from C
%endif

View File

@ -132,9 +132,14 @@ VOID ASMCFUNC DosIdle_int(void);
int ParseDosName(const char *, char *, BOOL);
/* error.c */
VOID dump(void);
VOID panic(BYTE * s);
VOID fatal(BYTE * err_msg);
#ifdef __WATCOMC__
# pragma aux panic aborts
# pragma aux fatal aborts
#endif
/* fatdir.c */
VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart);
@ -225,21 +230,20 @@ void FcbCloseAll(void);
UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First);
/* intr.asm */
COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
int ASMPASCAL res_DosExec(int mode, exec_blk *, PCStr);
unsigned ASMPASCAL res_read(int fd, void *buf, unsigned count);
#ifdef __WATCOMC__
#pragma aux (pascal) res_DosExec modify exact [ax bx dx es]
#pragma aux (pascal) res_read modify exact [ax bx cx dx]
# pragma aux (pascal) res_DosExec modify exact [ax bx dx es]
# pragma aux (pascal) res_read modify exact [ax bx cx dx]
#endif
/* ioctl.c */
COUNT DosDevIOctl(lregs * r);
/* memmgr.c */
seg far2para(VOID FAR * p);
seg long2para(ULONG size);
void FAR *add_far(void FAR * fp, unsigned off);
VOID FAR *adjust_far(const void FAR * fp);
VFP adjust_far(CVFP);
COUNT DosMemAlloc(UWORD size, COUNT mode, seg * para, UWORD * asize);
COUNT DosMemLargest(UWORD * size);
COUNT DosMemFree(UWORD para);
@ -364,12 +368,16 @@ const UWORD *is_leap_year_monthdays(UWORD year);
UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth);
/* task.c */
VOID new_psp(seg para, seg cur_psp);
VOID child_psp(seg para, seg cur_psp, int psize);
VOID return_user(void);
void new_psp(seg_t para, seg_t cur_psp);
void child_psp(seg_t para, seg_t cur_psp, seg_t beyond);
void return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
ULONG SftGetFsize(int sft_idx);
VOID InitPSP(VOID);
#ifdef __WATCOMC__
# pragma aux return_user aborts
#endif
/* newstuff.c */
int SetJFTSize(UWORD nHandles);
@ -391,7 +399,11 @@ UWORD get_machine_name(BYTE FAR * netname);
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
/* procsupt.asm */
VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20);
void ASMCFUNC exec_user(iregs FAR *, int disable_a20);
#ifdef __WATCOMC__
# pragma aux (cdecl) exec_user aborts
#endif
/* new by TE */
@ -403,5 +415,4 @@ VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20);
ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8)
*/
#define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; }
#define ASSERT_CONST(x) { typedef struct { char _[(x) ? 1 : -1]; } _; }

View File

@ -59,8 +59,12 @@ segment _FIXED_DATA class=FDATA align=16
segment _BSS class=BSS align=2
segment _DATA class=DATA align=2
segment _DATAEND class=DATA align=1
;for WATCOM
%ifdef MSC
segment CONST class=CONST align=2
%else
segment CONST class=DATA align=2
%endif
;for WATCOM
segment CONST2 class=DATA align=2
;for MSC
segment DCONST class=DCONST align=2

View File

@ -34,8 +34,6 @@ static BYTE *RcsId =
"$Id$";
#endif
#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c))
#define LOADNGO 0
#define LOAD 1
#define OVERLAY 3
@ -49,6 +47,7 @@ static BYTE *RcsId =
#define ExeHeader (*(exe_header *)(SecPathName + 0))
#define TempExeBlock (*(exec_blk *)(SecPathName + sizeof(exe_header)))
#define Shell (SecPathName + sizeof(exe_header) + sizeof(exec_blk))
#define sizeofShell (sizeof SecPathName - sizeof(exe_header) - sizeof(exec_blk))
#ifdef __TURBOC__ /* this is a Borlandism and doesn't work elsewhere */
#if sizeof(SecPathName) < sizeof(exe_header) + sizeof(exec_blk) + NAMEMAX
@ -56,20 +55,17 @@ static BYTE *RcsId =
#endif
#endif
#define CHUNK 32256
#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
+ 80 bytes: maximum absolute filename
+ 1 byte: '\0'
-- 1999/04/21 ska */
#define CHUNK 32256u /* =8000h-512; this value allows to combine
in one int value negative error codes
and positive read counters
*/
#define MAXENV 32768u /* maximum environment size */
intvec getvec(unsigned char intno)
{
intvec iv;
disable();
iv = *(intvec FAR *)MK_FP(0,4 * (intno));
iv = *MK_PTR(intvec, 0, 4 * intno);
enable();
return iv;
}
@ -77,13 +73,13 @@ intvec getvec(unsigned char intno)
void setvec(unsigned char intno, intvec vector)
{
disable();
*(intvec FAR *)MK_FP(0,4 * intno) = vector;
*MK_PTR(intvec, 0, 4 * intno) = vector;
enable();
}
ULONG SftGetFsize(int sft_idx)
{
sft FAR *s = idx_to_sft(sft_idx);
const sft FAR *s = idx_to_sft(sft_idx);
/* Get the SFT block that contains the SFT */
if (FP_OFF(s) == (size_t) -1)
@ -99,244 +95,229 @@ ULONG SftGetFsize(int sft_idx)
return dos_getfsize(s->sft_status);
}
STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
/* create a new environment for the process */
STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path)
{
BYTE FAR *pSrc;
BYTE FAR *pDest;
UWORD nEnvSize;
COUNT RetCode;
/* UWORD MaxEnvSize; not used -- 1999/04/21 ska */
psp FAR *ppsp = MK_FP(cu_psp, 0);
size_t env_sz, path_sz;
int rc;
/* create a new environment for the process */
/* copy parent's environment if exec.env_seg == 0 */
pSrc = exp->exec.env_seg ?
MK_FP(exp->exec.env_seg, 0) : MK_FP(ppsp->ps_environ, 0);
#if 0
/* Every process requires an environment because of argv[0]
-- 1999/04/21 ska */
*/if (!pSrc) /* no environment to copy */
{
*pChildEnvSeg = 0;
return SUCCESS;
}
#endif
-- 1999/04/21 ska
*/
nEnvSize = 1;
/* This loop had not counted the very last '\0'
-- 1999/04/21 ska */
if (pSrc)
{ /* if no environment is available, one byte is required */
/* make complete pathname */
if ((rc = truename(path, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS)
return rc;
for (nEnvSize = 0;; nEnvSize++)
/* get parent's environment if exec.env_seg == 0 */
if (env_seg == 0)
env_seg = MK_SEG_PTR(const psp, cu_psp)->ps_environ;
/* count size of environment */
path_sz = strlen(PriPathName) + 5;
env_sz = 0;
if (env_seg && *MK_PTR(const char, env_seg, 0))
{
/* Test env size and abort if greater than max */
if (nEnvSize >= MAXENV - ENV_KEEPFREE)
do
{
env_sz++;
if (env_sz + path_sz > MAXENV)
return DE_INVLDENV;
if (*(UWORD FAR *) (pSrc + nEnvSize) == 0)
break;
}
nEnvSize += 2; /* account for trailing \0\0 */
} while (*MK_PTR(const UWORD, env_seg, env_sz));
}
/* allocate enough space for env + path */
if ((RetCode = DosMemAlloc((nEnvSize + ENV_KEEPFREE + 15)/16,
mem_access_mode, pChildEnvSeg,
NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0)
return RetCode;
pDest = MK_FP(*pChildEnvSeg + 1, 0);
/* fill the new env and inform the process of its */
/* location throught the psp */
/* copy the environment */
if (pSrc)
/* allocate space for env + path */
{
fmemcpy(pDest, pSrc, nEnvSize);
pDest += nEnvSize;
UWORD tmp;
if ((rc = DosMemAlloc((env_sz + path_sz + 15) / 16,
mem_access_mode, penv_seg, &tmp)) != SUCCESS)
return rc;
}
else
*pDest++ = '\0'; /* create an empty environment */
/* initialize 'extra strings' count */
*((UWORD FAR *) pDest) = 1;
pDest += sizeof(UWORD) / sizeof(BYTE);
/* copy complete pathname */
if ((RetCode = truename(pathname, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS)
{
return RetCode;
seg_t dst_seg = *penv_seg + 1;
/* enviornment contains:
- 0 or more ASCIIZ strings (with variable definitions);
- empty ASCIIZ string (one null character);
- 16-bit counter (usually 1);
- ASCIIZ string with path.
*/
/* UNDOCUMENTED: with none variables before empty ASCIIZ string,
environment should get additional null character (ie. empty
environment contains two null characters). --avb
*/
fmemcpy(MK_SEG_PTR(char, dst_seg), MK_SEG_PTR(const char, env_seg), env_sz);
*MK_PTR(UWORD, dst_seg, env_sz) = 0;
*MK_PTR(UWORD, dst_seg, env_sz + 2) = 1;
fstrcpy(MK_PTR(char, dst_seg, env_sz + 4), PriPathName);
}
fstrcpy(pDest, PriPathName);
/* Theoretically one could either:
+ resize the already allocated block to best-fit behind the pathname, or
+ generate the filename into a temporary buffer to allocate only the
minimum required environment -- 1999/04/21 ska */
return SUCCESS;
}
/* The following code is 8086 dependant */
void new_psp(seg para, seg cur_psp)
void new_psp(seg_t para, seg_t cur_psp)
{
psp FAR *p = MK_FP(para, 0);
psp _seg *p = MK_SEG_PTR(psp, para);
fmemcpy(p, MK_FP(cur_psp, 0), sizeof(psp));
fmemcpy(p, MK_SEG_PTR(psp, cur_psp), sizeof(psp));
/* terminate address */
p->ps_isv22 = getvec(0x22);
/* break address */
p->ps_isv23 = getvec(0x23);
/* critical error address */
p->ps_isv24 = getvec(0x24);
/* parent psp segment set to 0 (see RBIL int21/ah=26) */
p->ps_parent = 0;
}
/* initialize all entries and exits */
p->ps_exit = 0x20cd; /* CP/M-like exit point: */
/* INT 20 opcode */
/* CP/M-like entry point: */
p->ps_farcall = 0x9a; /* FAR CALL opcode... */
p->ps_reentry = MK_FP(0xf01d,0xfef0); /* ...entry address */
void child_psp(seg para, seg cur_psp, int psize)
{
psp FAR *p = MK_FP(para, 0);
psp FAR *q = MK_FP(cur_psp, 0);
int i;
/* entry address should point to 0:c0 (INT 30 vector), but
low word of ps_reentry should also contain "size of first
segment for .COM file" while preserving the far call;
in MS-DOS this is F01D:FEF0 --avb */
new_psp(para, cur_psp);
p->ps_unix[0] = 0xcd; /* unix style call: */
p->ps_unix[1] = 0x21; /* INT 21/RETF opcodes */
p->ps_unix[2] = 0xcb;
/* Now for parent-child relationships */
/* parent psp segment */
p->ps_parent = cu_psp;
/* previous psp pointer */
p->ps_prevpsp = q;
/* parent-child relationships */
p->ps_prevpsp = (VFP)-1l; /* previous psp address */
/* Environment and memory useage parameters */
/* memory size in paragraphs */
p->ps_size = psize;
p->ps_isv22 = getvec(0x22); /* terminate handler */
p->ps_isv23 = getvec(0x23); /* break handler */
p->ps_isv24 = getvec(0x24); /* critical error handler */
/* File System parameters */
/* maximum open files */
p->ps_maxfiles = 20;
fmemset(p->ps_files, 0xff, 20);
/* open file table pointer */
p->ps_filetab = p->ps_files;
/* clone the file table -- 0xff is unused */
for (i = 0; i < 20; i++)
if (CloneHandle(i) >= 0)
p->ps_files[i] = q->ps_filetab[i];
/* first command line argument */
p->ps_fcb1.fcb_drive = 0;
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* second command line argument */
p->ps_fcb2.fcb_drive = 0;
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* local command line */
p->ps_cmd.ctCount = 0;
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
p->ps_maxfiles = sizeof p->ps_files; /* size of file table */
p->ps_filetab = p->ps_files; /* file table address */
}
STATIC UBYTE chkdrv(unsigned drive) /* from FCB: 0 = default, 1 = A:, ... */
/* !!! cur_psp always equal to cu_psp --avb */
void child_psp(seg_t para, seg_t cur_psp, seg_t beyond)
{
if (drive)
drive--; /* 0 = A:, 1 = B:, ... */
else
drive = default_drive;
return get_cds(drive) ? 0 : 0xff; /* return 0 if drive is valid, else 0xff */
}
psp _seg *p;
STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb,
BYTE FAR * fnam)
{
psp FAR *psp;
mcb FAR *pspmcb;
int i;
BYTE FAR *np;
new_psp(para, cur_psp);
p = MK_SEG_PTR(psp, para);
pspmcb = MK_FP(pspseg, 0);
++pspseg;
psp = MK_FP(pspseg, 0);
/* parent-child relationships */
p->ps_parent = cu_psp; /* parent psp segment */
/* complete the psp by adding the command line and FCBs */
fmemcpy(&psp->ps_cmd, exb->exec.cmd_line, sizeof(CommandTail));
if (FP_OFF(exb->exec.fcb_1) != 0xffff)
/* Environment and memory useage parameters */
p->ps_size = beyond; /* segment of memory beyond */
/* memory allocated to program */
/* File System parameters */
{
fmemcpy(&psp->ps_fcb1, exb->exec.fcb_1, 16);
fmemcpy(&psp->ps_fcb2, exb->exec.fcb_2, 16);
psp _seg *q = MK_SEG_PTR(psp, cur_psp);
int i;
/* clone the file table, 0xff=unused */
for (i = 0; i < sizeof p->ps_files; i++)
p->ps_files[i] = CloneHandle(i) != SUCCESS ? 0xff : q->ps_filetab[i];
}
}
struct cds FAR *get_cds1(unsigned drv)
{
if (drv-- == 0) /* 0 = A:, 1 = B:, ... */
drv = default_drive;
return get_cds(drv);
}
STATIC void makePSP(seg_t pspseg, seg_t envseg, size_t asize, const char FAR * path)
{
psp _seg *p = MK_SEG_PTR(psp, pspseg);
mcb _seg *pspmcb = MK_SEG_PTR(mcb, FP_SEG(p) - 1);
/* identify the mcb as this functions' */
pspmcb->m_psp = pspseg;
/* Patch in environment segment, if present, also adjust its MCB */
pspmcb->m_psp = FP_SEG(p);
/* copy the file name less extension into MCB */
{
const char FAR *np;
int i;
for (np = path;;) /* find program name after path */
{
char ch = *path;
if (ch == '\0')
break;
path++;
if (ch == ':' || ch == '\\' || ch == '/')
np = path; /* remember position after path */
}
i = 0;
do /* extract program name */
{
UBYTE ch = *np;
if (ch == '.' || ch == '\0')
{
pspmcb->m_name[i] = '\0';
break;
}
if (ch >= 'a' && ch <= 'z')
ch -= (UBYTE)('a' - 'A');
pspmcb->m_name[i] = ch; /* copy name, without extension */
i++, np++;
} while (i < 8);
}
setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP));
child_psp(FP_SEG(p), cu_psp, FP_SEG(p) + asize);
/* Patch in env segment, if present, also adjust its MCB */
if (envseg)
{
((mcb FAR *) MK_FP(envseg, 0))->m_psp = pspseg;
MK_SEG_PTR(mcb, envseg)->m_psp = FP_SEG(p);
envseg++;
}
psp->ps_environ = envseg;
/* use the file name less extension - left adjusted and */
np = fnam;
for (;;)
{
switch (*fnam++)
{
case '\0':
goto set_name;
case ':':
case '/':
case '\\':
np = fnam;
}
}
set_name:
for (i = 0; i < 8 && np[i] != '.' && np[i] != '\0'; i++)
{
pspmcb->m_name[i] = toupper(np[i]);
}
if (i < 8)
pspmcb->m_name[i] = '\0';
/* return value: AX value to be passed based on FCB values */
return chkdrv(psp->ps_fcb1.fcb_drive) |
(chkdrv(psp->ps_fcb2.fcb_drive) << 8);
p->ps_environ = envseg;
}
int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode)
static void load_transfer(seg_t ds, exec_blk *ep, int mode)
{
psp FAR *p = MK_FP(ds, 0);
psp FAR *q = MK_FP(cu_psp, 0);
/* Transfer control to the executable */
p->ps_parent = cu_psp;
UWORD fcbcode;
psp _seg *p = MK_SEG_PTR(psp, ds);
{
psp _seg *q = MK_SEG_PTR(psp, cu_psp);
p->ps_parent = FP_SEG(q);
p->ps_prevpsp = q;
q->ps_stack = (BYTE FAR *)user_r;
}
user_r->FLAGS &= ~FLG_CARRY;
cu_psp = ds;
cu_psp = FP_SEG(p);
/* process dta */
dta = &p->ps_cmd;
/* complete the psp by adding the command line and FCBs */
/* UNDOCUMENTED: MS-DOS copies sizeof(CommandTail) bytes without
checking memory contents and fixing wrong (>7Fh) length field;
FCBs also copied without checking address validness --avb
*/
fmemcpy(&p->ps_fcb1, ep->exec.fcb_1, 12); /* drive+name+ext */
fmemcpy(&p->ps_fcb2, ep->exec.fcb_2, 12);
fmemcpy(&p->ps_cmd, ep->exec.cmd_line, sizeof(CommandTail));
/* AX value to be passed based on FCB values */
fcbcode = (get_cds1(p->ps_fcb1.fcb_drive) ? 0 : 0xff) |
(get_cds1(p->ps_fcb2.fcb_drive) ? 0 : 0xff00);
/* Transfer control to the executable */
if (mode == LOADNGO)
{
iregs FAR *irp;
/* build the user area on the stack */
irp = (iregs FAR *)(exp->exec.stack - sizeof(iregs));
iregs FAR *irp = (iregs FAR *)(ep->exec.stack - sizeof(iregs));
/* start allocating REGs (as in MS-DOS - some demos expect them so --LG) */
/* see http://www.beroset.com/asm/showregs.asm */
irp->DX = irp->ES = irp->DS = ds;
irp->CS = FP_SEG(exp->exec.start_addr);
irp->SI = irp->IP = FP_OFF(exp->exec.start_addr);
irp->DI = FP_OFF(exp->exec.stack);
irp->AX =
irp->BX = fcbcode;
irp->DX =
irp->ES =
irp->DS = FP_SEG(p);
irp->CS = FP_SEG(ep->exec.start_addr);
irp->SI =
irp->IP = FP_OFF(ep->exec.start_addr);
irp->DI = FP_OFF(ep->exec.stack);
irp->BP = 0x91e; /* this is more or less random but some programs
expect 0x9 in the high byte of BP!! */
irp->AX = irp->BX = fcbcode;
irp->CX = 0xFF;
irp->FLAGS = 0x200;
@ -345,12 +326,12 @@ int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode)
exec_user(irp, 1);
/* We should never be here
fatal("KERNEL RETURNED!!!"); */
panic("KERNEL RETURNED!!!"); */
}
/* mode == LOAD */
exp->exec.stack -= 2;
*((UWORD FAR *)(exp->exec.stack)) = fcbcode;
return SUCCESS;
ep->exec.stack -= sizeof(UWORD);
*(UWORD FAR *)ep->exec.stack = fcbcode;
}
/* Now find out how many paragraphs are available
@ -413,9 +394,7 @@ STATIC int ExecMemAlloc(UWORD size, seg *para, UWORD *asize)
COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
{
UWORD mem;
UWORD env, asize = 0;
{
UWORD env, asize;
UWORD com_size;
{
ULONG com_size_long = SftGetFsize(fd);
@ -436,20 +415,15 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
DosUmbLink(1); /* link in UMB's */
}
rc = ChildEnv(exp, &env, namep);
/* COMFILES will always be loaded in largest area. is that true TE */
/* yes, see RBIL, int21/ah=48 -- Bart */
if (rc == SUCCESS)
rc = ExecMemLargest(&asize, com_size);
if (rc == SUCCESS)
if ((rc = ChildEnv(exp->exec.env_seg, &env, namep)) == SUCCESS)
{
if ((rc = ExecMemLargest(&asize, com_size)) != SUCCESS ||
/* Allocate our memory and pass back any errors */
rc = ExecMemAlloc(asize, &mem, &asize);
if (rc != SUCCESS)
(rc = ExecMemAlloc(asize, &mem, &asize)) != SUCCESS)
DosMemFree(env);
}
if (mode & 0x80)
{
@ -461,46 +435,27 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
if (rc != SUCCESS)
return rc;
++mem;
}
else
mem = exp->load.load_seg;
}
#ifdef DEBUG
printf("DosComLoader. Loading '%S' at %04x\n", namep, mem);
#endif
/* Now load the executable */
{
BYTE FAR *sp;
if (mode == OVERLAY) /* memory already allocated */
sp = MK_FP(mem, 0);
else /* test the filesize against the allocated memory */
sp = MK_FP(mem, sizeof(psp));
/* MS DOS always only loads the very first 64KB - sizeof(psp) bytes.
-- 1999/04/21 ska */
/* rewind to start */
SftSeek(fd, 0, 0);
/* read everything, but at most 64K - sizeof(PSP) */
DosRWSft(fd, 0xff00, sp, XFR_READ);
DosCloseSft(fd, FALSE);
++mem;
}
if (mode == OVERLAY)
return SUCCESS;
/* Now load the executable */
/* rewind to start */
SftSeek(fd, 0, 0);
/* MS DOS always only loads the very first 64KB - sizeof(psp) bytes.
-- 1999/04/21 ska */
/* read everything, but at most 64K - sizeof(PSP) */
/* !!! should be added check for reading success --avb */
DosRWSft(fd, 0xff00, mode == OVERLAY /* memory already allocated */
? MK_FP(exp->load.load_seg, 0)
: MK_FP(mem, sizeof(psp)), XFR_READ);
DosCloseSft(fd, FALSE);
if (mode != OVERLAY)
{
UWORD fcbcode;
psp FAR *p;
/* point to the PSP so we can build it */
setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP));
child_psp(mem, cu_psp, mem + asize);
fcbcode = patchPSP(mem - 1, env, exp, namep);
makePSP(mem, env, asize, namep);
/* set asize to end of segment */
if (asize > 0x1000)
asize = 0x1000;
@ -510,27 +465,21 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
/* CP/M compatibility--size of first segment for .COM files
while preserving the far call to 0:00c0 +
copy in HMA at ffff:00d0 */
p = MK_FP(mem, 0);
p->ps_reentry = MK_FP(0xc - asize, asize << 4);
MK_SEG_PTR(psp, mem)->ps_reentry = MK_FP(0xc - asize, asize << 4);
asize <<= 4;
asize += 0x10e;
exp->exec.stack = MK_FP(mem, asize);
exp->exec.start_addr = MK_FP(mem, 0x100);
*((UWORD FAR *) MK_FP(mem, asize)) = (UWORD) 0;
load_transfer(mem, exp, fcbcode, mode);
*MK_PTR(UWORD, mem, asize) = 0;
load_transfer(mem, exp, mode);
}
return SUCCESS;
}
VOID return_user(void)
void return_user(void)
{
psp FAR *p, FAR * q;
REG COUNT i;
iregs FAR *irp;
/* long j;*/
/* restore parent */
p = MK_FP(cu_psp, 0);
psp _seg *p = MK_SEG_PTR(psp, cu_psp);
/* When process returns - restore the isv */
setvec(0x22, p->ps_isv22);
@ -544,33 +493,30 @@ VOID return_user(void)
if (!tsr)
{
REG COUNT i;
network_redirector(REM_CLOSEALL);
for (i = 0; i < p->ps_maxfiles; i++)
{
DosClose(i);
}
FcbCloseAll();
FreeProcessMem(cu_psp);
FreeProcessMem(FP_SEG(p));
}
cu_psp = p->ps_parent;
q = MK_FP(cu_psp, 0);
irp = (iregs FAR *) q->ps_stack;
{
iregs FAR *irp = (iregs FAR *)MK_SEG_PTR(psp, cu_psp = p->ps_parent)->ps_stack;
irp->CS = FP_SEG(p->ps_isv22);
irp->IP = FP_OFF(p->ps_isv22);
if (InDOS)
--InDOS;
exec_user((iregs FAR *) q->ps_stack, 0);
exec_user(irp, 0);
}
}
COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
{
UWORD mem, env, start_seg, asize = 0;
UWORD exe_size;
{
UWORD mem, env, start_seg, asize;
UWORD image_size;
/* compute image size by removing the offset from the */
@ -581,10 +527,11 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
return DE_INVLDDATA; /* we're not able to get >=1MB in dos memory */
image_size = ExeHeader.exPages * 32 - ExeHeader.exHeaderSize;
/* We should not attempt to allocate
memory if we are overlaying the current process, because the new
process will simply re-use the block we already have allocated.
Jun 11, 2000 - rbc */
/* We should not attempt to allocate memory if we are overlaying
the current process, because the new process will simply re-use
the block we already have allocated. This was causing execl() to
fail in applications which use it to overlay (replace) the current
exe file with a new one. Jun 11, 2000 --rbc */
if ((mode & 0x7f) != OVERLAY)
{
@ -592,10 +539,6 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
UBYTE orig_mem_access = mem_access_mode;
COUNT rc;
/* and finally add in the psp size */
image_size += sizeof(psp) / 16; /*TE 03/20/01 */
exe_size = image_size + ExeHeader.exMinAlloc;
/* Clone the environement and create a memory arena */
if (mode & 0x80)
{
@ -603,38 +546,35 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
mem_access_mode |= 0x80;
}
rc = ChildEnv(exp, &env, namep);
if (rc == SUCCESS)
if ((rc = ChildEnv(exp->exec.env_seg, &env, namep)) == SUCCESS)
{
image_size += sizeof(psp) / 16; /*TE 03/20/01 */
/* Now find out how many paragraphs are available */
rc = ExecMemLargest(&asize, exe_size);
exe_size = image_size + ExeHeader.exMaxAlloc;
if ((rc = ExecMemLargest(&asize, image_size + ExeHeader.exMinAlloc)) == SUCCESS)
{
unsigned max_size = image_size + ExeHeader.exMaxAlloc;
/* second test is for overflow (avoiding longs) --
exMaxAlloc can be high */
if (exe_size > asize || exe_size < image_size)
exe_size = asize;
if (max_size > asize || max_size < image_size ||
/* TE if ExeHeader.exMinAlloc == ExeHeader.exMaxAlloc == 0,
DOS will allocate the largest possible memory area
and load the image as high as possible into it.
discovered (and after that found in RBIL), when testing NET */
if ((ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0)
exe_size = asize;
(ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0)
max_size = asize;
/* Allocate our memory and pass back any errors */
if (rc == SUCCESS)
rc = ExecMemAlloc(exe_size, &mem, &asize);
rc = ExecMemAlloc(max_size, &mem, &asize);
}
if (rc != SUCCESS)
DosMemFree(env);
}
if (mode & 0x80)
{
mem_access_mode = orig_mem_access; /* restore old situation */
DosUmbLink(UMBstate); /* restore link state */
}
if (rc != SUCCESS)
return rc;
@ -643,20 +583,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
#ifdef DEBUG
printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem);
#endif
/* memory found large enough - continue processing */
++mem;
/* /// Added open curly brace and "else" clause. We should not attempt
to allocate memory if we are overlaying the current process, because
the new process will simply re-use the block we already have allocated.
This was causing execl() to fail in applications which use it to
overlay (replace) the current exe file with a new one.
Jun 11, 2000 - rbc */
}
else /* !!OVERLAY */
{
mem = exp->load.load_seg;
}
/* Now load the executable */
@ -665,75 +592,57 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
{
if (mode != OVERLAY)
{
DosMemFree(--mem);
DosMemFree(mem);
DosMemFree(env);
}
return DE_INVLDDATA;
}
/* create the start seg for later computations */
start_seg = mem;
exe_size = image_size;
start_seg = exp->load.load_seg;
if (mode != OVERLAY)
{
exe_size -= sizeof(psp) / 16;
start_seg += sizeof(psp) / 16;
if (exe_size > 0 && (ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0)
{
mcb FAR *mp = MK_FP(mem - 1, 0);
start_seg = mem + 1 + sizeof(psp) / 16;
if ((ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0)
/* then the image should be placed as high as possible */
start_seg += mp->m_size - image_size;
}
}
start_seg += MK_SEG_PTR(const mcb, mem)->m_size - image_size;
image_size -= sizeof(psp) / 16;
}
/* read in the image in 32256 chunks */
{
int nBytesRead, toRead = CHUNK;
seg sp = start_seg;
while (1)
seg_t sp = start_seg;
do
{
if (exe_size < CHUNK/16)
toRead = exe_size*16;
nBytesRead = (int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ);
if (nBytesRead < toRead || exe_size <= CHUNK/16)
int toRead = CHUNK;
if (image_size < CHUNK/16)
{
toRead = image_size*16;
image_size = CHUNK/16;
}
if ((int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ) < toRead)
break;
sp += CHUNK/16;
exe_size -= CHUNK/16;
}
} while (image_size -= CHUNK/16);
}
{ /* relocate the image for new segment */
COUNT i;
UWORD reloc[2];
seg FAR *spot;
/* relocate the image for new segment */
SftSeek(fd, ExeHeader.exRelocTable, 0);
for (i = 0; i < ExeHeader.exRelocItems; i++)
{
if (DosRWSft
(fd, sizeof(reloc), (VOID FAR *) & reloc[0], XFR_READ) != sizeof(reloc))
unsigned i;
for (i = ExeHeader.exRelocItems; i; i--)
{
UWORD reloc[2];
if (DosRWSft(fd, sizeof reloc, reloc, XFR_READ) != sizeof reloc)
{
if (mode != OVERLAY)
{
DosMemFree(--mem);
DosMemFree(mem);
DosMemFree(env);
}
return DE_INVLDDATA;
}
if (mode == OVERLAY)
{
spot = MK_FP(reloc[1] + mem, reloc[0]);
*spot += exp->load.reloc;
}
else
{
/* spot = MK_FP(reloc[1] + mem + 0x10, reloc[0]); */
spot = MK_FP(reloc[1] + start_seg, reloc[0]);
*spot += start_seg;
}
*MK_PTR(seg_t, reloc[1] + start_seg, reloc[0]) += start_seg;
}
}
@ -741,24 +650,17 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
DosCloseSft(fd, FALSE);
/* exit here for overlay */
if (mode == OVERLAY)
return SUCCESS;
if (mode != OVERLAY)
{
UWORD fcbcode;
/* point to the PSP so we can build it */
setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP));
child_psp(mem, cu_psp, mem + asize);
fcbcode = patchPSP(mem - 1, env, exp, namep);
mem++;
makePSP(mem, env, asize, namep);
exp->exec.stack =
MK_FP(ExeHeader.exInitSS + start_seg, ExeHeader.exInitSP);
exp->exec.start_addr =
MK_FP(ExeHeader.exInitCS + start_seg, ExeHeader.exInitIP);
/* Transfer control to the executable */
load_transfer(mem, exp, fcbcode, mode);
load_transfer(mem, exp, mode);
}
return SUCCESS;
}
@ -786,7 +688,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
return DE_FILENOTFND;
}
rc = (int)DosRWSft(fd, sizeof(exe_header), (BYTE FAR *)&ExeHeader, XFR_READ);
rc = (int)DosRWSft(fd, sizeof(exe_header), &ExeHeader, XFR_READ);
if (rc == sizeof(exe_header) &&
(ExeHeader.exSignature == MAGIC || ExeHeader.exSignature == OLD_MAGIC))
@ -809,44 +711,65 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)
#include "config.h" /* config structure definition */
/* start process 0 (the shell) */
VOID ASMCFUNC P_0(struct config FAR *Config)
void ASMCFUNC P_0(const struct config FAR *);
#ifdef __WATCOMC__
# pragma aux (cdecl) P_0 aborts
#endif
void ASMCFUNC P_0(const struct config FAR *Config)
{
BYTE *tailp, *endp;
exec_blk exb;
UBYTE mode = Config->cfgP_0_startmode;
int mode = Config->cfgP_0_startmode;
/* build exec block and save all parameters here as init part will vanish! */
exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *)-1L;
exb.exec.env_seg = DOS_PSP + 8;
fstrcpy(Shell, MK_FP(FP_SEG(Config), Config->cfgInit));
/* join name and tail */
fstrcpy(Shell + strlen(Shell), MK_FP(FP_SEG(Config), Config->cfgInitTail));
endp = Shell + strlen(Shell);
const char FAR *p = MK_PTR(const char, FP_SEG(Config), Config->cfgShell);
PStr endp = Shell;
while ((*endp = *p++) != '\0' &&
++endp < Shell + sizeofShell - 4); /* 4 for 0,ctCount and "\r\0" */
for ( ; ; ) /* endless shell load loop - reboot or shut down to exit it! */
for (;;) /* endless shell load loop - reboot or shut down to exit it! */
{
BYTE *p;
/* if there are no parameters, point to end without "\r\n" */
if((tailp = strchr(Shell,'\t')) == NULL &&
(tailp = strchr(Shell, ' ')) == NULL)
tailp = endp - 2;
/* shift tail to right by 2 to make room for '\0', ctCount */
for (p = endp - 1; p >= tailp; p--)
*(p + 2) = *p;
/* terminate name and tail */
*tailp = *(endp + 2) = '\0';
/* ctCount: just past '\0' do not count the "\r\n" */
exb.exec.cmd_line = (CommandTail *)(tailp + 1);
exb.exec.cmd_line->ctCount = endp - tailp - 2;
PStr tailp = Shell - 1;
*endp = '\r', endp[1] = '\0'; /* terminate command line */
endp += 2;
/* find end of command name */
do tailp++; while ((UBYTE)*tailp > ' ' && *tailp != '/');
/* shift tail to right by 2 to make room for '\0' and ctCount */
{
PStr p = endp;
do
{
p--;
p[2] = p[0];
} while (p > tailp);
}
/* terminate name */
*tailp = '\0';
/* init length of command line tail (ctCount field) */
tailp++;
*tailp = (UBYTE)(endp - tailp - 1); /* without "\r\0" */
{
exec_blk exb;
exb.exec.env_seg = DOS_PSP + 8;
exb.exec.cmd_line = (CommandTail *)tailp;
/*exb.exec.fcb_1 = exb.exec.fcb_2 = NULL;*/ /* unimportant */
#ifdef DEBUG
printf("Process 0 starting: %s%s\n\n", Shell, tailp + 2);
printf("Process 0 starting: %s%s\n\n", Shell, tailp + 1);
#endif
res_DosExec(mode, &exb, Shell);
put_string("Bad or missing Command Interpreter: "); /* failure _or_ exit */
}
/* failure or exit */
put_string("\nBad or missing Command Interpreter\n"
"Enter the full shell command line:\n");
put_string(Shell);
put_string(tailp + 2);
put_string(" Enter the full shell command line: ");
endp = Shell + res_read(STDIN, Shell, NAMEMAX);
*endp = '\0'; /* terminate string for strchr */
*endp = '\n'; /* replace "\r\0" by "\n\0" */
put_string(++tailp);
endp = Shell + res_read(STDIN, Shell, sizeofShell) - 2; /* exclude "\r\n" */
}
}

7
kernel/tci.cfg Normal file
View File

@ -0,0 +1,7 @@
-zCINIT_TEXT
-zRID
-zTID
-zSI_GROUP
-zDIB
-zBIB
-zGI_GROUP

View File

@ -1,15 +1,11 @@
-f-
-ff-
-O
-Z
-d
-f-
-k-
-vi-
-wpro
-weas
-wpre
-w
-g1
-I..\hdr
-O -Z
-p
-v- -I. -D__STDC__=0 -DKERNEL -DI86 -DPROTO -DASMSUPT
-v-
-w -g1
-I..\hdr
-DI86
-zCHMA_TEXT

5
kernel/vc.cfg Normal file
View File

@ -0,0 +1,5 @@
-batch -nologo -WX
-Zlp1
-f- -Osb1V4e -Gsry
-Fc
-I..\hdr

9
kernel/wc.cfg Normal file
View File

@ -0,0 +1,9 @@
-e5 -we -wx
-j
-os -s
-r -zgf -zff
-zq -zl -zp1
-d1
-I..\hdr
-ntHMA_TEXT

11
kernel/wci.cfg Normal file
View File

@ -0,0 +1,11 @@
-e5 -we -wx
-j
-os -s
-r -zgf -zff
-zq -zl -zp1
-d1
-I..\hdr
-ntINIT_TEXT
-gTGROUP
-ndI

View File

@ -4,21 +4,23 @@
# $Id$
#
!include "../mkfiles/generic.mak"
########################################################################
libm.lib: $(CLIB)
-$(RM) libm.lib
all: libm.lib
libm.lib: $(CLIB) $(DEPENDS)
-$(RM) $*.lib
$(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM)
$(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i
$(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM)
-$(RM) *.OBJ
$(LIBUTIL) $* $(MATH_INSERT) $(LIBTERM)
-$(RM) *.obj
clobber: clean
-$(RM) status.me
########################################################################
clean:
-$(RM) *.obj *.bak libm.lib
-$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) libm.lib status.me

10
mkfiles/bc.mak Normal file
View File

@ -0,0 +1,10 @@
#
# BC.MAK - kernel copiler options for Borland C++
#
!include "..\mkfiles\tcpp.mak"
TARGET=KBC
CC=$(BINPATH)\bcc -c
CL=$(BINPATH)\bcc

View File

@ -2,52 +2,9 @@
# BC5.MAK - kernel copiler options for Borland C++
#
# Use these for Borland C++
COMPILERPATH=$(BC5_BASE)
COMPILERBIN=$(COMPILERPATH)\bin
CC=$(COMPILERBIN)\bcc -c
CL=$(COMPILERBIN)\bcc
INCLUDEPATH=$(COMPILERPATH)\include
LIBUTIL=$(COMPILERBIN)\tlib
LIBPATH=$(COMPILERPATH)\lib
LIBTERM=
LIBPLUS=+
TINY=-lt
CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d
CFLAGSC=-L$(LIBPATH) -a- -mc
!include "..\mkfiles\turbocpp.mak"
TARGET=KBC
# used for building the library
CLIB=$(COMPILERPATH)\lib\cs.lib
MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL
MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
#
# heavy stuff - building the kernel
# Compiler and Options for Borland C++
# ------------------------------------
#
# -zAname ¦ ¦ Code class
# -zBname ¦ ¦ BSS class
# -zCname ¦ ¦ Code segment
# -zDname ¦ ¦ BSS segment
# -zEname ¦ ¦ Far segment
# -zFname ¦ ¦ Far class
# -zGname ¦ ¦ BSS group
# -zHname ¦ ¦ Far group
# -zPname ¦ ¦ Code group
# -zRname ¦ ¦ Data segment
# -zSname ¦ ¦ Data group
# -zTname ¦ ¦ Data class
# -zX ¦«¦ Use default name for "X"
#
# ALLCFLAGS specified by turbo.cfg and config.mak
#
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
CC=$(BINPATH)\bcc -c
CL=$(BINPATH)\bcc

View File

@ -1,43 +1,67 @@
# These are generic definitions
#**********************************************************************
#* TARGET : we create a %TARGET%.sys file
#* TARGETOPT : options, handled down to the compiler
#**********************************************************************
TARGETOPT=-1-
# TARGET : we create a $(TARGET).sys file
!if $(XCPU)0 == 0
XCPU=86
!endif
CPUOPT=
!if $(XCPU) == 186
TARGETOPT=-1
CPUOPT=-1
!endif
!if $(XCPU) == 386
TARGETOPT=-3
CPUOPT=-3
!endif
!if $(XFAT)0 == 0
XFAT=32
!endif
!if $(XFAT) == 32
ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32
NASMFLAGS=$(NASMFLAGS) -DWITHFAT32
ALLCFLAGS=-DWITHFAT32 $(ALLCFLAGS)
NASMFLAGS=-DWITHFAT32 $(NASMFLAGS)
!endif
NASM=$(XNASM)
NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU)
LINK=$(XLINK)
NASMFLAGS=-fobj -i../hdr/ -D$(COMPILER) -DXCPU=$(XCPU) $(NASMFLAGS)
BINPATH=$(BASE)\bin
INCLUDEPATH=$(BASE)\include
LIBPATH=$(BASE)\lib
INITPATCH=@rem
UPXOPT=-U
!if $(__MAKE__)0 == 0 # NMAKE/WMAKE
!if "$(XUPX)" == "" # TC doesn't supports this
XUPX=rem # NMAKE doesn't supports @ in macro
UPXOPT=
!endif
!else # TC/BC MAKE
!if !$d(XUPX) # NMAKE/WMAKE doesn't supports $d()
XUPX=@rem
UPXOPT=
!endif
!endif
!include "..\mkfiles\$(COMPILER).mak"
TARGET=$(TARGET)$(XCPU)$(XFAT)
INITCFLAGS=$(INITCFLAGS) $(ALLCFLAGS)
CFLAGS=$(CFLAGS) $(ALLCFLAGS)
RM=..\utils\rmfiles
DEPENDS=makefile ..\*.bat ..\mkfiles\*.*
.asm.obj :
$(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm
# Implicit Rules #######################################################
# *Implicit Rules*
.c.obj :
$(CC) $(CFLAGS) $*.c
.asm.obj:
$(NASM) $(NASMFLAGS) $<
.cpp.obj :
$(CC) $(CFLAGS) $*.cpp
.c.obj:
$(CC) $(CFLAGS) $<
.cpp.obj:
$(CC) $(CFLAGS) $<
.c.com:
$(CL) $(CFLAGST) $<
.c.exe:
$(CL) $(CFLAGSC) $<

31
mkfiles/msc.mak Normal file
View File

@ -0,0 +1,31 @@
#
# MSC.MAK - kernel copiler options for MS VC 1.5x (MS CL 8.x)
#
TARGET=KMS
CC=$(BINPATH)\cl -batch -nologo -c
CL=$(BINPATH)\cl -batch -nologo
# used for building the library
CLIB=$(LIBPATH)\slibce.lib
MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv *aFNaulsh
MATH_INSERT =+aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +aFNaulsh
#
!if $(XCPU) == 186
CPUOPT=-G1
!endif
!if $(XCPU) == 386
CPUOPT=-G3
!endif
ALLCFLAGS=@msc.cfg -I$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS)
INITCFLAGS=-NTINIT_TEXT
CFLAGS =-NTHMA_TEXT
INITPATCH=..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC
CFLAGST=-I..\hdr -I$(INCLUDEPATH) /Fm /AT /Os /Zp1
CFLAGSC=-I..\hdr -I$(INCLUDEPATH) /Fm /AL /Os /Zp1

View File

@ -1,47 +1,31 @@
#
# MSCL8.MAK - kernel copiler options for MS CL8 = MSVC1.52
# MSCL8.MAK - kernel copiler options for MS CL8 = MS VC 1.52
#
# Use these for MSCV 1.52
COMPILERPATH=$(MS_BASE)
COMPILERBIN=$(COMPILERPATH)\bin
INCLUDEPATH=$(COMPILERPATH)\include
CC=$(COMPILERBIN)\cl -c
CL=$(COMPILERBIN)\cl
TINY=
CFLAGST=/Fm /AT /Os /Zp1
CFLAGSC=/Fm /AL /Os /Zp1
LIBPATH=$(COMPILERPATH)\lib
LIB=$(COMPILERPATH)\lib
INCLUDE=$(COMPILERPATH)\include
LIBUTIL=$(COMPILERBIN)\lib /nologo
LIBPLUS=+
LIBTERM=;
INCLUDE=$(COMPILERPATH)\include
LIB=$(COMPILERPATH)\lib
# used for building the library
CLIB=$(COMPILERPATH)\lib\slibce.lib
MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv
MATH_INSERT= +aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv
TARGETOPT=
!if $(XCPU) == 186
TARGETOPT=-G1
!endif
!if $(XCPU) == 386
TARGETOPT=-G3
!endif
TARGET=KMS
CC=$(BINPATH)\cl -batch -nologo -c
CL=$(BINPATH)\cl -batch -nologo
# used for building the library
CLIB=$(LIBPATH)\slibce.lib
MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv *aFNaulsh
MATH_INSERT =+aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +aFNaulsh
#
# heavy stuff - building
!if $(XCPU) == 186
CPUOPT=-G1
!endif
!if $(XCPU) == 386
CPUOPT=-G3
!endif
ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1
ALLCFLAGS=@vc.cfg -I$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS)
INITCFLAGS=-NTINIT_TEXT
CFLAGS =-NTHMA_TEXT
INITPATCH=..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC
INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT
CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT
INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC
CFLAGST=-I..\hdr -I$(INCLUDEPATH) /Fm /AT /Os /Zp1
CFLAGSC=-I..\hdr -I$(INCLUDEPATH) /Fm /AL /Os /Zp1

16
mkfiles/tc.mak Normal file
View File

@ -0,0 +1,16 @@
#
# TC.MAK - kernel copiler options for Turbo C 2.01
#
BINPATH=$(BASE)
!include "..\mkfiles\tcpp.mak"
TARGET=KTC
MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH
MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH
# TCC doesn't support responce file
INITCFLAGS=-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP

View File

@ -1,53 +1,16 @@
#
# TURBOC.MAK - kernel copiler options for TURBOC
# TC2.MAK - kernel copiler options for Turbo C 2.01
#
# Use these for Turbo C 2.01
BINPATH=$(BASE)
COMPILERPATH=$(TC2_BASE)
COMPILERBIN=$(COMPILERPATH)
CC=$(COMPILERBIN)\tcc -c
CL=$(COMPILERBIN)\tcc
INCLUDEPATH=$(COMPILERPATH)\include
LIBUTIL=$(COMPILERBIN)\tlib
LIBPATH=$(COMPILERPATH)\lib
LIBTERM=
LIBPLUS=+
TINY=-lt
CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d -w
CFLAGSC=-L$(LIBPATH) -a- -mc
!include "..\mkfiles\turbocpp.mak"
TARGET=KTC
# used for building the library
CLIB=$(COMPILERPATH)\lib\cs.lib
MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH
MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH
MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH
#
# heavy stuff - building the kernel
# Compiler and Options for Borland C++
# ------------------------------------
#
# -zAname ¦ ¦ Code class
# -zBname ¦ ¦ BSS class
# -zCname ¦ ¦ Code segment
# -zDname ¦ ¦ BSS segment
# -zEname ¦ ¦ Far segment
# -zFname ¦ ¦ Far class
# -zGname ¦ ¦ BSS group
# -zHname ¦ ¦ Far group
# -zPname ¦ ¦ Code group
# -zRname ¦ ¦ Data segment
# -zSname ¦ ¦ Data group
# -zTname ¦ ¦ Data class
# -zX ¦«¦ Use default name for "X"
# TCC 2.0 doesn't support responce file
#
# ALLCFLAGS specified by turbo.cfg and config.mak
#
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
INITCFLAGS=-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP

View File

@ -1,53 +1,7 @@
#
# TC3.MAK - kernel copiler options for Turbo C 3.0
# TC3.MAK - kernel copiler options for Turbo C++ 3.0
#
# Use these for Turbo C 3.0
COMPILERPATH=$(TC3_BASE)
COMPILERBIN=$(COMPILERPATH)\bin
CC=$(COMPILERBIN)\tcc -c
CL=$(COMPILERBIN)\tcc
INCLUDEPATH=$(COMPILERPATH)\include
LIBUTIL=$(COMPILERBIN)\tlib
LIBPATH=$(COMPILERPATH)\lib
LIBTERM=
LIBPLUS=+
TINY=-lt
CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d
CFLAGSC=-L$(LIBPATH) -a- -mc
!include "..\mkfiles\turbocpp.mak"
TARGET=KT3
# used for building the library
CLIB=$(COMPILERPATH)\lib\cs.lib
MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL
MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
#
# heavy stuff - building the kernel
# Compiler and Options for Borland C++
# ------------------------------------
#
# -zAname ¦ ¦ Code class
# -zBname ¦ ¦ BSS class
# -zCname ¦ ¦ Code segment
# -zDname ¦ ¦ BSS segment
# -zEname ¦ ¦ Far segment
# -zFname ¦ ¦ Far class
# -zGname ¦ ¦ BSS group
# -zHname ¦ ¦ Far group
# -zPname ¦ ¦ Code group
# -zRname ¦ ¦ Data segment
# -zSname ¦ ¦ Data group
# -zTname ¦ ¦ Data class
# -zX ¦«¦ Use default name for "X"
#
# ALLCFLAGS specified by turbo.cfg and config.mak
#
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)

42
mkfiles/tcpp.mak Normal file
View File

@ -0,0 +1,42 @@
#
# TCPP.MAK - kernel copiler options for Turbo C++ 1.01
#
TARGET=KTP
CC=$(BINPATH)\tcc -c
CL=$(BINPATH)\tcc
# used for building the library
CLIB=$(LIBPATH)\cs.lib
MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL
MATH_INSERT =+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
#
# Compiler options for Turbo/Borland C
# ------------------------------------
#
# -zAname ¦ ¦ Code class
# -zBname ¦ ¦ BSS class
# -zCname ¦ ¦ Code segment
# -zDname ¦ ¦ BSS segment
# -zEname ¦ ¦ Far segment
# -zFname ¦ ¦ Far class
# -zGname ¦ ¦ BSS group
# -zHname ¦ ¦ Far group
# -zPname ¦ ¦ Code group
# -zRname ¦ ¦ Data segment
# -zSname ¦ ¦ Data group
# -zTname ¦ ¦ Data class
# -zX ¦«¦ Use default name for "X"
#
# Common options specified in turboc.cfg instead ALLCFLAGS
#
ALLCFLAGS=-I..\hdr;$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS)
INITCFLAGS=@tci.cfg
CFLAGST=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mt -lt
CFLAGSC=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mc

7
mkfiles/tcpp3.mak Normal file
View File

@ -0,0 +1,7 @@
#
# TCPP3.MAK - kernel copiler options for Turbo C++ 3.0
#
!include "..\mkfiles\tcpp.mak"
TARGET=KT3

View File

@ -1,34 +1,20 @@
#
# TURBOCPP.MAK - kernel copiler options for TCPP 1.01
# TURBOCPP.MAK - kernel copiler options for Turbo C++ 1.01
#
# Use these for Turbo CPP 1.01
COMPILERPATH=$(TP1_BASE)
COMPILERBIN=$(COMPILERPATH)\bin
CC=$(COMPILERBIN)\tcc -c
CL=$(COMPILERBIN)\tcc
INCLUDEPATH=$(COMPILERPATH)\include
LIBUTIL=$(COMPILERBIN)\tlib
LIBPATH=$(COMPILERPATH)\lib
LIBTERM=
LIBPLUS=+
TINY=-lt
CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d
CFLAGSC=-L$(LIBPATH) -a- -mc
TARGET=KTP
CC=$(BINPATH)\tcc -c
CL=$(BINPATH)\tcc
# used for building the library
CLIB=$(COMPILERPATH)\lib\cs.lib
CLIB=$(LIBPATH)\cs.lib
MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL
MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
MATH_INSERT =+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
#
# heavy stuff - building the kernel
# Compiler and Options for Borland C++
# Compiler options for Turbo/Borland C
# ------------------------------------
#
# -zAname ¦ ¦ Code class
@ -46,8 +32,12 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
# -zX ¦«¦ Use default name for "X"
#
# ALLCFLAGS specified by turbo.cfg and config.mak
# Common options specified in turboc.cfg instead ALLCFLAGS
#
ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP
CFLAGS=$(ALLCFLAGS)
ALLCFLAGS=-I..\hdr;$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS)
INITCFLAGS=@..\mkfiles\tci.cfg
CFLAGS =-zCHMA_TEXT
CFLAGST=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mt -lt # -ff-
CFLAGSC=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mc

View File

@ -1,67 +1,50 @@
#
# WATCOM.MAK - kernel copiler options for WATCOM C 11.0c
# WATCOM.MAK - kernel copiler options for WATCOM C/OpenWatcom
#
# Use these for WATCOM 11.0c
COMPILERPATH=$(WATCOM)
CC=*wcc
CL=wcl
INCLUDEPATH=$(COMPILERPATH)\H
INCLUDE=$(COMPILERPATH)\h
EDPATH=$(COMPILERPATH)\EDDAT
!if $(XCPU) != 186
!if $(XCPU) != 386
TARGETOPT=-0
!endif
!endif
LIBPATH=$(COMPILERPATH)\lib286
LIBUTIL=wlib -q
LIBPLUS=
LIBTERM=
TINY=-mt
CFLAGST=-zq-zp1-os-s-we-e3-wx
CFLAGSC=-mc-zq-zp1-os-s-we-e3-wx
TARGET=KWC
BINPATH=$(BASE)\binw
INCLUDEPATH=$(BASE)\h
LIBPATH=$(BASE)\lib286
CC=$(BINPATH)\wcc
CL=$(BINPATH)\wcl
# used for building the library
CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib
# we use our own ones, which override these ones when linking.
#
CLIB=$(LIBPATH)\dos\clibm.lib
MATH_EXTRACT=*i4m
MATH_INSERT=+i4m
MATH_INSERT =+i4m
#
# heavy stuff - building
# Compiler options for Watcom
# ---------------------------
#
# -e=<num> set limit on number of error messages
# -ms small memory model (small code/small data)
# -j change char default from unsigned to signed
#-nc=<id> set code class name
#-nd=<id> set data segment name
#-nm=<file> set module name
#-nt=<id> set name of text segment
# -g=<id> set code group name
# -os -> favor code size over execution time in optimizations
# -s remove stack overflow checks
# -w=<num> set warning level number
# -we treat all warnings as errors
# -zq operate quietly
#
# -j change char default from unsigned to signed
# -ms small memory model (small code/small data)
# -os -> favor code size over execution time in optimizations
# -s remove stack overflow checks
# -ze enable extensions (i.e., near, far, export, etc.)
# -zl remove default library information
# -zp=<num> pack structure members with alignment {1,2,4,8,16}
# -zq operate quietly
#
# -3 optimization for 386 - given in CONFIG.MAK, not here
# -3 optimization for 386 - given in $(CPUOPT)
# -g=<id> set code group name
# -nc=<id> set code class name
# -nd=<id> set data segment name
# -nm=<file> set module name
# -nt=<id> set name of text segment
#
ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r
INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI
CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT
ALLCFLAGS=-I$(INCLUDEPATH) $(CPUOPT)$(ALLCFLAGS)
INITCFLAGS=@wci.cfg
CFLAGS =@wc.cfg
CFLAGST=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-mt
CFLAGSC=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-mc

View File

@ -50,7 +50,7 @@ unsigned long lseek(int fildes, unsigned long offset, int whence);
#define FAR far
#include "kconfig.h"
KernelConfig cfg = { 0 };
KernelConfig cfg; /* static memory zeroed automatically */
typedef unsigned char byte;
typedef signed char sbyte;

View File

@ -6,55 +6,36 @@
!include "../mkfiles/generic.mak"
CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST)
NASMFLAGS = -DSYS=1
SYS_C=sys.c fdkrncfg.c ..\kernel\prf.c talloc.c
DEPENDS=$(DEPENDS) *.cfg
# *List Macros*
########################################################################
SYS_EXE_dependencies = \
sys.obj \
fdkrncfg.obj \
prf.obj \
talloc.obj
all: bin2c.com ..\bin\sys.com
# *Explicit Rules*
production: bin2c.com ..\bin\sys.com
bin2c.com: bin2c.c $(DEPENDS)
bin2c.com: bin2c.c
$(CL) $(CFLAGS) $(TINY) bin2c.c
fat12com.h: ..\boot\fat12.bin bin2c.com
bin2c ..\boot\fat12.bin $*.h $*
..\bin\sys.com: sys.com
copy sys.com ..\bin
fat12com.h: ..\boot\fat12com.bin bin2c.com
.\bin2c ..\boot\fat12com.bin fat12com.h fat12com
fat16com.h: ..\boot\fat16com.bin bin2c.com
.\bin2c ..\boot\fat16com.bin fat16com.h fat16com
fat16com.h: ..\boot\fat16.bin bin2c.com
bin2c ..\boot\fat16.bin $*.h $*
fat32chs.h: ..\boot\fat32chs.bin bin2c.com
.\bin2c ..\boot\fat32chs.bin fat32chs.h fat32chs
bin2c ..\boot\$*.bin $*.h $*
fat32lba.h: ..\boot\fat32lba.bin bin2c.com
.\bin2c ..\boot\fat32lba.bin fat32lba.h fat32lba
bin2c ..\boot\$*.bin $*.h $*
prf.obj: ..\kernel\prf.c
$(CC) $(CFLAGS) ..\kernel\prf.c
..\bin\sys.com: $(SYS_C) ..\hdr\*.h fat12com.h fat16com.h fat32chs.h fat32lba.h
$(CL) $(CFLAGST) -DFORSYS -DWITHFAT32 $(SYS_C)
copy sys.com ..\bin
del sys.com
fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h
talloc.obj: talloc.c
sys.com: $(SYS_EXE_dependencies)
$(CL) $(CFLAGST) $(TINY) $(SYS_EXE_dependencies)
clobber: clean
-$(RM) bin2c.com sys.com fat*.h
########################################################################
clean:
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me
# *Individual File Dependencies*
sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h fat12com.h fat16com.h fat32chs.h fat32lba.h
$(CC) $(CFLAGS) $*.c
-$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) bin2c.com fat*.h status.me

7
sys/turboc.cfg Normal file
View File

@ -0,0 +1,7 @@
-d
-f-
-k-
-O -Z
-v-
-w -g1
-I..\hdr

View File

@ -1 +1 @@
@echo %2 %3 %4 %5 %6 %7 %8 %9 >> %1
@echo %2 %3 %4 %5 %6 %7 %8 %9>>%1

View File

@ -52,8 +52,6 @@ large portions copied from task.c
#define BUFSIZE 32768u
#define LENGTH(x) (sizeof(x)/sizeof(x[0]))
typedef struct {
UWORD off, seg;
} farptr;
@ -260,7 +258,7 @@ int main(int argc, char **argv)
}
/* this assumes <= 0xfe00 code in kernel */
*(short *)&JumpBehindCode[0x1e] += size;
*(short *)&JumpBehindCode[0x1e] += (short)size;
fwrite(JumpBehindCode, 1, 0x20, dest);
}
@ -283,30 +281,32 @@ int main(int argc, char **argv)
{
/* UPX trailer */
/* hand assembled - so this remains ANSI C ;-) */
static char trailer[] = { /* shift down everything by sizeof JumpBehindCode */
0xE8, 0x00, 0x00, /* call 103 */
0x59, /* pop cx */
0x0E, /* push cs */
0x1F, /* pop ds */
0x8c, 0xc8, /* mov ax,cs */
0x48, /* dec ax */
0x48, /* dec ax */
0x8e, 0xc0, /* mov es,ax */
0x31, 0xFF, /* xor di,di */
0xBE, 0x00, 0x00, /* mov si,0x00 */
0xFC, /* cld */
0xF3, 0xA4, /* rep movsb */
0x26, 0x88, 0x1e, 0x00, 0x00, /* mov es:[0],bl */
0xB8, 0x00, 0x00, /* mov ax,0000h */
0x8E, 0xD0, /* mov ss,ax */
0xBC, 0x00, 0x00, /* mov sp,0000h */
0x31, 0xC0, /* xor ax,ax */
0x50, /* push ax */
0xC3 /* ret */
/* move kernel down to place CONFIG-block, which added above,
at 0x5e:0 instead 0x60:0 and store there boot drive number
from BL; kernel.asm will then check presence of additional
CONFIG-block at this address. */
static char trailer[] = {
0x0E, /* 0 push cs */
0x1F, /* 1 pop ds ; =0x60 */
0xBF,0x5E,0x00, /* 2 mov di,0x5E */
0x8E,0xC7, /* 5 mov es,di */
0xFC, /* 7 cld */
0x33,0xFF, /* 8 xor di,di */
0x93, /* 10 xchg ax,bx ; mov al,bl */
0xAA, /* 11 stosb ; mov [es:0],al */
0x8B,0xF7, /* 12 mov si,di */
0xB9,0x00,0x00, /* 14 mov cx,offset trailer */
0xF3,0xA4, /* 17 rep movsb */
0xBF,0x00,0x00, /* 19 mov di,... */
0x8E,0xD7, /* 22 mov ss,di */
0xBC,0x00,0x00, /* 24 mov sp,... */
0x33,0xFF, /* 27 xor di,di */
0xFF,0xE7, /* 29 jmp di ; jmp 0 */
};
*(short *)&trailer[26] = start_seg + header.exInitSS;
*(short *)&trailer[31] = header.exInitSP;
fwrite(trailer, 1, sizeof(trailer), dest);
*(short *)&trailer[15] = (short)size + 0x20;
*(short *)&trailer[20] = start_seg + header.exInitSS;
*(short *)&trailer[25] = header.exInitSP;
fwrite(trailer, 1, sizeof trailer, dest);
}
fclose(dest);
printf("\nProcessed %d relocations, %d not shown\n",

View File

@ -1,19 +1,19 @@
!include "../mkfiles/generic.mak"
CFLAGS = -I$(INCLUDEPATH) -I..\hdr
DEPENDS=$(DEPENDS) *.cfg
production: patchobj.com exeflat.exe
########################################################################
patchobj.com: patchobj.c
$(CL) $(CFLAGST) $(TINY) $(CFLAGS) patchobj.c
all: patchobj.com exeflat.exe
exeflat.exe: exeflat.c ../hdr/exe.h
$(CL) $(CFLAGSC) $(CFLAGS) exeflat.c
patchobj.com: patchobj.c $(DEPENDS)
exeflat.exe: exeflat.c ../hdr/exe.h $(DEPENDS)
clobber: clean
########################################################################
clean:
$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me
$(RM) exeflat.exe patchobj.com
-$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) patchobj.com exeflat.exe status.me

View File

@ -7,4 +7,3 @@ shift
goto loop_commandline
:done_with_commandline

7
utils/turboc.cfg Normal file
View File

@ -0,0 +1,7 @@
-d
-f-
-k-
-O -Z
-v-
-w -g1
-I..\hdr

View File

@ -1,4 +1,4 @@
@echo off
ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk
echo op map,statics,verbose >> kernel.lnk
call wlink @kernel.lnk
%BASE%\binw\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9>kernel.lnk
echo op map,statics,verbose,eliminate,vfremoval>>kernel.lnk
%BASE%\binw\wlink @kernel.lnk