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$ # $Id$
# #
!include "../mkfiles/generic.mak" !include "../mkfiles/generic.mak"
production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin ########################################################################
fat12com.bin: boot.asm all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin
$(NASM) -dISFAT12 boot.asm -ofat12com.bin
fat16com.bin: boot.asm fat12.bin: boot.asm $(DEPENDS)
$(NASM) -dISFAT16 boot.asm -ofat16com.bin $(NASM) -DISFAT12 boot.asm -o$*.bin
fat32chs.bin: boot32.asm fat16.bin: boot.asm $(DEPENDS)
$(NASM) boot32.asm -ofat32chs.bin $(NASM) -DISFAT16 boot.asm -o$*.bin
fat32lba.bin: boot32lb.asm fat32chs.bin: boot32.asm $(DEPENDS)
$(NASM) boot32lb.asm -ofat32lba.bin $(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 clobber: clean
-$(RM) *.bin status.me -$(RM) *.bin status.me
clean:
-$(RM) *.lst *.map *.bak *.obj

View File

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

View File

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

View File

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

View File

@ -1,38 +1 @@
@echo off @clean clobber
:- 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

175
config.b
View File

@ -1,119 +1,128 @@
:- @echo off
:- batch file that is included in all other batch files for configuration :- 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)
:-**************************************************************** set LAST=
:- NOTICE! You must edit and rename this file to CONFIG.BAT! *
:-****************************************************************
:-********************************************************************* :-----------------------------------------------------------------------
:- determine your compiler settings :- define NASM executable. It should not be protected mode DJGPP
:- :- version if you're using Windows NT/2k/XP to compile. also:
:- you have to :- NASM/DJGPP crashes when using protected mode Borland's make.
:- 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
:-
:-*********************************************************************
:-********************************************************************** set NASM=c:\bin\nasm16
:-- 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 XNASM=c:\bin\nasm16 :-----------------------------------------------------------------------
:- define COMPILER name here, pick one of them.
:**********************************************************************
:- define your COMPILER type here, pick one of them
:**********************************************************************
:- Turbo C 2.01 :- Turbo C 2.01
set COMPILER=TC2 set COMPILER=TC
:- Turbo C++ 1.01 :- Turbo C++ 1.01
:- set COMPILER=TURBOCPP ::set COMPILER=TCPP
:- Turbo C 3.0 :- Turbo C++ 3.0
:- set COMPILER=TC3 ::set COMPILER=TCPP3
:- Borland C :- Borland C
:- set COMPILER=BC5 ::set COMPILER=BC
:- Microsoft C :- Microsoft C
:- set COMPILER=MSCL8 ::set COMPILER=MSC
:- Watcom C :- 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 TC_BASE=c:\tc
:- set TP1_BASE=c:\tcpp ::set TCPP_BASE=c:\tcpp
:- set TC3_BASE=c:\tc3 ::set TCPP3_BASE=c:\tcpp3
:- set BC5_BASE=c:\bc5 ::set BC_BASE=c:\bc
:- set MS_BASE=c:\msvc ::set MSC_BASE=c:\msc
::set WATCOM=c:\watcom
:- if WATCOM maybe you need to set your WATCOM environment variables :-----------------------------------------------------------------------
:- and path :- When compiling executable, compilers search linker through PATH;
:- if not \%WATCOM% == \ goto watcom_defined :- if some linker not in PATH, uncomment OLDPATH and required SETs PATH.
:- set WATCOM=c:\watcom
:- set PATH=%PATH%;%WATCOM%\binw
:watcom_defined
:-********************************************************************** ::set OLDPATH=%PATH%
:- where is UPX and which options to use? ::set PATH=%TC_BASE%;%PATH%
:-********************************************************************** ::set PATH=%TCPP_BASE%\bin;%PATH%
set XUPX=upx --8086 --best ::set PATH=%TCPP3_BASE%\bin;%PATH%
:- or use set XUPX= ::set PATH=%BC_BASE%\bin;%PATH%
:- if you don't want to use it ::set PATH=%MSC_BASE%\bin;%PATH%
::set PATH=%WATCOM%\binw;%PATH%
:-********************************************************************** :- MSC searches libraries only through LIB variable.
:- (optionally) which linker to use: ::set LIB=%MSC_BASE%\lib
:- (otherwise will be determined automatically)
:- :-----------------------------------------------------------------------
:- WARNING TLINK needs to be in your PATH! :- define which linker to use OR it will be determined AUTOMATICALLY.
:-**********************************************************************
:- Turbo Link :- Turbo Link
:- set XLINK=tlink /m/c/s/l ::set LINK=tlink /c/m/s/l
:- Microsoft Link :- Microsoft Link
:- set XLINK=d:\qb\link /ma ::set LINK=link /ONERROR:NOEXE /nologo
:- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
:- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink) :- 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% :- define which librarian to use OR it will be determined AUTOMATICALLY.
:- set PATH=%PATH%;%TC2_BASE%
:********************************************************************** :- Turbo Lib
:* optionally define your MAKE type here, if not then ::set LIBUTIL=tlib
:* it will be automatically determined, pick one of them ::set LIBTERM=
:* use MS nmake if you want to compile with MSCL :- 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 :- Borland MAKE
:- set MAKE=%TC2_BASE%\make ::set MAKE=make
::set MAKE=maker -S
:- Watcom MAKE in MS mode :- Watcom MAKE in MS mode
:- set MAKE=%WATCOM%\binw\wmake /ms ::set MAKE=wmake /ms
:- Microsoft MAKE :- 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 XUPX=upx --8086 --best
:- set XCPU=186
:- set XCPU=386
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 :- Give extra compiler DEFINE flags here
:- such as -DDEBUG : extra DEBUG output :- such as -DDEBUG : extra DEBUG output
:- -DDOSEMU : printf output goes to dosemu log :- -DDOSEMU : printf output goes to dosemu log
:- set ALLCFLAGS=-DDEBUG ::set ALLCFLAGS=-DDEBUG
:-----------------------------------------------------------------------
:- set LAST=1
:- $Id$ 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 segment HMA_TEXT
; ;
; BOOL ASMPASCAL fl_reset(WORD drive); ; int ASMPASCAL fl_reset(UBYTE drive);
; ;
; Reset both the diskette and hard disk system. ; Reset both the diskette and hard disk system.
; returns TRUE if successful. ; returns TRUE if successful.
@ -41,129 +41,116 @@ segment HMA_TEXT
global FL_RESET global FL_RESET
FL_RESET: FL_RESET:
pop ax ; return address pop ax ; return address
pop dx ; drive (DL only) pop dx ; drive
push ax ; restore address push ax ; restore address
mov ah,0 ; BIOS reset diskette & fixed disk mov ah,0 ; reset disk
int 13h int 13h
sbb ax,ax ; CF=1: error
sbb ax,ax ; carry set indicates error, AX=-CF={-1,0}
inc ax ; ...return TRUE (1) on success, 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. ; 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 global FL_DISKCHANGED
FL_DISKCHANGED: FL_DISKCHANGED:
pop ax ; return address pop ax ; return address
pop dx ; drive (DL only, 00h-7Fh) pop dx ; drive
push ax ; restore stack push ax ; restore stack
push si ; preserve value push si
mov ah,16h ; read change status type mov ah,16h ; read change status type
xor si,si ; RBIL: avoid crash on AT&T 6300 xor si,si ; RBIL: avoid crash on AT&T 6300
int 13h int 13h
pop si ; restore pop si
sbb al,al ; AL=-CF={-1,0} where 0==no change sbb al,al ; CF=0 (disk has not changed)
jnc fl_dc ; carry set on error or disk change jnc ret_AH_0 ; ...return 0
cmp ah,6 ; if AH==6 then disk change, else error cmp ah,6 ; ah!=6 (error)
jne fl_dc ; if error, return -1 jne ret_AH_0 ; ...return 0xFF
mov al, 1 ; set change occurred mov al,1 ; ah=6 (disk has changed)
fl_dc: cbw ; extend AL into AX, AX={1,0,-1} jmp short ret_AH_0 ; ...return 1
ret ; note: AH=0 on no change, AL set above
; ;
; 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). ; 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 global FL_FORMAT
FL_FORMAT: FL_FORMAT:
mov ah,5 ; format track mov ah,5 ; format track
jmp short fl_common jmp short fl_common
global FL_READ
FL_READ:
mov ah,2 ; read sector(s)
jmp short fl_common
global FL_VERIFY global FL_VERIFY
FL_VERIFY: FL_VERIFY:
mov ah,4 ; verify sector(s) mov ah,4 ; verify sector(s)
jmp short fl_common jmp short fl_common
global FL_READ
FL_READ:
mov ah,2 ; read sector(s)
jmp short fl_common
global FL_WRITE global FL_WRITE
FL_WRITE: FL_WRITE:
mov ah,3 ; write sector(s) mov ah,3 ; write sector(s)
fl_common: fl_common:
push bp ; setup stack frame push bp
mov bp,sp 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 xchg ch,cl ; ch=low 8 bits of cylinder number
cmp ch,3 ; this code can't write above 3FFh=1023 mov dh,[bp+14] ; head number
ja fl_error ; as cylinder # is limited to 10 bits.
xchg ch,cl ; ch=low 8 bits of cyl number
ror cl,1 ; bits 8-9 of cylinder number... ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; ...to bits 6-7 in CL ror cl,1 ; ...to bits 6-7 in CL
or cl,[bp+0Ah] ; or in the sector number (bits 0-5) or cl,[bp+10] ; 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
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 int 13h ; process sectors
sbb al,al ; carry: al=ff, else al=0 sbb al,al ; carry: al=ff, else al=0
and al,ah ; carry: error code, else 0 and al,ah ; carry: error code, else 0
fl_error: fl_error:
mov ah,0 ; extend AL into AX without sign extension mov ah,0
pop bp pop bp
ret 14 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. ; Returns 0 if successful, error code otherwise.
; ;
global FL_LBA_READWRITE global FL_LBA_READWRITE
FL_LBA_READWRITE: FL_LBA_READWRITE:
push bp ; setup stack frame push bp
mov bp,sp mov bp,sp
push si
push ds push ds
push si ; wasn't in kernel < KE2024Bo6!! mov dl,[bp+10] ; drive (if or'ed 80h its hard drive)
mov ax,[bp+8] ; command
mov dl,[bp+10] ; drive (if or'ed with 80h a hard drive) lds si,[bp+4] ; far dap pointer
mov ax,[bp+8] ; get the command int 13h ; process sectors
lds si,[bp+4] ; get far dap pointer
int 13h ; read from/write to drive
pop si
pop ds pop ds
pop si
pop bp pop bp
mov al,ah ; place error code into al
mov al,ah ; place any error code into al mov ah,0
mov ah,0 ; zero out ah
ret 8 ret 8
; ;
@ -171,48 +158,48 @@ FL_LBA_READWRITE:
; ;
global FL_READKEY global FL_READKEY
FL_READKEY: xor ah, ah FL_READKEY:
mov ah,0
int 16h int 16h
ret ret
; ;
; COUNT ASMPASCAL fl_setdisktype (WORD drive, WORD type); ; int ASMPASCAL fl_setdisktype (UBYTE drive, WORD type);
; ;
global FL_SETDISKTYPE global FL_SETDISKTYPE
FL_SETDISKTYPE: FL_SETDISKTYPE:
pop bx ; return address pop bx ; return address
pop ax ; disk format type (al) pop ax ; disk type
pop dx ; drive number (dl) pop dx ; drive
push bx ; restore stack push bx ; restore stack
mov ah,17h ; floppy set disk type for format mov ah,17h ; set disk type for format
int 13h int 13h
ret_AH: ret_AH:
mov al,ah ; place any error code into al mov al,ah ; place error code into al
mov ah,0 ; zero out ah ret_AH_0:
mov ah,0
ret ret
; ;
; COUNT ASMPASCAL fl_setmediatype (WORD drive, WORD tracks, WORD sectors); ; int ASMPASCAL fl_setmediatype (UBYTE drive, WORD tracks, WORD sectors);
; ;
global FL_SETMEDIATYPE global FL_SETMEDIATYPE
FL_SETMEDIATYPE: FL_SETMEDIATYPE:
pop ax ; return address pop ax ; return address
pop bx ; sectors/track pop bx ; sectors/track
pop cx ; number of tracks pop cx ; number of tracks
pop dx ; drive number pop dx ; drive
push ax ; restore stack push ax ; restore stack
push di 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 xchg ch,cl ; CH=low 8 bits of last cyl number
ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; extract bits 8-9 of cylinder number... ror cl,1 ; ...to bits 6-7 in CL
ror cl,1 ; ...into cl bit 6-7 or cl,bl ; sectors/track (bits 0-5)
mov ah,18h ; set media type for format
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
int 13h int 13h
jc skipint1e jc skipint1e
@ -220,10 +207,9 @@ FL_SETMEDIATYPE:
xor dx,dx xor dx,dx
mov es,dx mov es,dx
cli cli
pop word [es:0x1e*4+2] ; set int 0x1e table to es:di
mov [es:0x1e*4],di mov [es:0x1e*4],di
pop word [es:0x1e*4+2] ; set int 0x1e table to es:di
sti sti
skipint1e: skipint1e:
pop di pop di
jmp short ret_AH jmp short ret_AH

View File

@ -4,46 +4,25 @@
# $Id$ # $Id$
# #
!include "../mkfiles/generic.mak" !include "../mkfiles/generic.mak"
# MICROSOFT C
# -----------
#MODEL = s
#CFLAGS = /c /Gs /A$(MODEL)
#AFLAGS = /Mx /Dmem$(MODEL)=1
#TERM = ;
# BORLAND C
# -----------
#MODEL = s
#CFLAGS = -c -m$(MODEL)
#AFLAGS = /Mx /Dmem$(MODEL)=1
#LIBFLAGS = /c
OBJS=floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj OBJS=floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj
LIBOBJS=+floppy +rdpcclk +wrpcclk +wratclk LIBOBJS=+floppy +rdpcclk +wrpcclk +wratclk
# Build the LIBRARY ####################################################
all: ..\lib\device.lib
# Build the LIBRARY ..\lib\device.lib: $(OBJS)
# ----------------- -$(RM) $*.lib
all: production $(LIBUTIL) $(LIBFLAGS) $* $(LIBOBJS) $(LIBTERM)
production: ..\lib\device.lib $(OBJS): $(DEPENDS)
..\lib\device.lib: device.lib ########################################################################
copy device.lib ..\lib
clobber: clean
-$(RM) device.lib status.me ..\lib\device.lib
clean: clean:
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
device.lib : $(OBJS)
-$(RM) device.lib
$(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM)
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
#endif #endif
#include <limits.h>
/****************************************************************/ /****************************************************************/
/* */ /* */
/* Machine dependant portable types. Note that this section is */ /* Machine dependant portable types. Note that this section is */
@ -256,55 +258,105 @@ typedef signed long LONG;
#define LONG long #define LONG long
#endif #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 */ /* General far pointer macros */
#ifdef I86 #ifdef I86
#ifndef MK_FP #ifndef MK_FP
#if defined(__WATCOMC__) #if defined __WATCOMC__
#define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) #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)) #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs))
#else #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 #endif
#define pokeb(seg, ofs, b) (*((unsigned char far *)MK_FP(seg,ofs)) = b) #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 poke(seg, ofs, w) (*(unsigned far *)MK_FP(seg,ofs) = (w))
#define pokew poke #define pokew poke
#define pokel(seg, ofs, l) (*((unsigned long far *)MK_FP(seg,ofs)) = l) #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 peekb(seg, ofs) (*(unsigned char far *)MK_FP(seg,ofs))
#define peek(seg, ofs) (*((unsigned far *)MK_FP(seg,ofs))) #define peek(seg, ofs) (*(unsigned far *)MK_FP(seg,ofs))
#define peekw peek #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)) #define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp))
#else #else
#define FP_SEG(fp) ((unsigned)((ULONG)(VOID FAR *)(fp)>>16)) #define FP_SEG(fp) hiword ((ULONG)(VOID FAR *)(fp))
#endif #endif
#define FP_OFF(fp) ((unsigned)(fp)) #define FP_OFF(fp) loword (fp)
#endif #endif
#endif #endif
#ifdef MC68K #ifdef MC68K
#define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(size_t)(seg))[(ofs)]))) #define MK_FP(seg,ofs) ((VOID *)&(((BYTE *)(size_t)(seg))[ofs]))
#define FP_SEG(fp) (0) #define FP_SEG(fp) 0
#define FP_OFF(fp) ((size_t)(fp)) #define FP_OFF(fp) ((size_t)(fp))
#endif #endif
typedef VOID (FAR ASMCFUNC * intvec) (void); 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 this suppresses the warning
unreferenced parameter 'x' unreferenced parameter 'x'
and (hopefully) generates no code and (hopefully) generates no code
*/ */
#define UNREFERENCED_PARAMETER(x) (void)x; #define UNREFERENCED_PARAMETER(x) (void)(x)
#ifdef I86 /* commandline overflow - removing /DPROTO TE */ #ifdef I86 /* commandline overflow - removing /DPROTO TE */
#define PROTO #define PROTO
#endif #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 %else
push eax push eax
pop ax pop ax
%ifdef MSCL8 %ifdef MSC
push ecx push ecx
pop cx pop cx
%else ;BC5 %else ;BC
push ebx push ebx
pop bx pop bx
%endif %endif
@ -170,10 +170,10 @@ irp_hi equ 26
%else %else
push dx push dx
pop edx pop edx
%ifdef MSCL8 %ifdef MSC
push cx push cx
pop ecx pop ecx
%else ;BC5 %else ;BC
push bx push bx
pop ebx pop ebx
%endif %endif

View File

@ -48,7 +48,7 @@ static BYTE *date_hRcsId =
#define REVISION_MAJOR 1 #define REVISION_MAJOR 1
#define REVISION_MINOR 1 #define REVISION_MINOR 1
#define REVISION_SEQ 35 #define REVISION_SEQ 35
#define BUILD "2035" #define BUILD "2035a"
#define SUB_BUILD "a" #define SUB_BUILD ""
#define KERNEL_VERSION_STRING "1.1.35" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ #define KERNEL_VERSION_STRING "1.1.35a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */
#define KERNEL_BUILD_STRING "2035a" /*#BUILD SUB_BUILD */ #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 check_handle_break(struct dhdr FAR **pdev)
{ {
unsigned char c = CTL_C; unsigned char c;
if (!ctrl_break_pressed()) if (ctrl_break_pressed() ||
c = (unsigned char)ndread(&syscon); (c = (unsigned char)ndread(&syscon)) == CTL_C ||
if (c != CTL_C && *pdev != syscon) *pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C)
c = (unsigned char)ndread(pdev); {
if (c == CTL_C)
handle_break(pdev, -1); handle_break(pdev, -1);
}
return c; 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 */ 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 cfgFilesHigh;
UBYTE cfgFcbs; /* number of available FCBs */ UBYTE cfgFcbs; /* number of available FCBs */
UBYTE cfgProtFcbs; /* number of protected FCBs */ UBYTE cfgProtFcbs; /* number of protected FCBs */
BYTE *cfgInit; /* init of command.com */ char cfgShell[256]; /* SHELL= line */
BYTE *cfgInitTail; /* command.com's tail */
UBYTE cfgLastdrive; /* last drive */ UBYTE cfgLastdrive; /* last drive */
UBYTE cfgLastdriveHigh; UBYTE cfgLastdriveHigh;
BYTE cfgStacks; /* number of stacks */ BYTE cfgStacks; /* number of stacks */
BYTE cfgStacksHigh; BYTE cfgStacksHigh;
UWORD cfgStackSize; /* stacks size for each stack */ 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 */ UBYTE cfgP_0_startmode; /* load command.com high or not */
unsigned ebda2move; /* value for switches=/E:nnnn */ 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 or ah,ah
jz int21_3 jz int21_3
cmp ah,0ch cmp ah,0ch
jle int21_normalentry jbe int21_normalentry
int21_3: int21_3:
call dos_crit_sect 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 UWORD ASM NetBios;
extern BYTE * ASM net_name; extern BYTE * ASM net_name;
extern BYTE ASM net_set_count; 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 */ extern UWORD ASM first_mcb, /* Start of user memory */
ASM uppermem_root; /* Start of umb chain (usually 9fff) */ 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. */ /* Process related functions - not under automatic generation. */
/* Typically, these are in ".asm" files. */ /* Typically, these are in ".asm" files. */
VOID ASMCFUNC FAR cpm_entry(VOID) VOID ASMCFUNC FAR cpm_entry(VOID);
/*INRPT FAR handle_break(VOID) */ ;
COUNT ASMCFUNC COUNT ASMCFUNC
CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError,
struct dhdr FAR * lpDevice); struct dhdr FAR * lpDevice);
@ -371,7 +370,6 @@ VOID ASMCFUNC FAR CharMapSrvc(VOID);
VOID ASMCFUNC FAR set_stack(VOID); VOID ASMCFUNC FAR set_stack(VOID);
VOID ASMCFUNC FAR restore_stack(VOID); VOID ASMCFUNC FAR restore_stack(VOID);
#endif #endif
/*VOID INRPT FAR handle_break(VOID); */
ULONG ASMPASCAL ReadPCClock(VOID); ULONG ASMPASCAL ReadPCClock(VOID);
VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE); VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE);

View File

@ -124,36 +124,32 @@ intvec getvec(unsigned char intno);
/* config.c */ /* config.c */
extern struct config Config; extern struct config Config;
VOID PreConfig(VOID); VOID PreConfig(VOID);
VOID PreConfig2(VOID); void DoConfig(void);
VOID DoConfig(int pass);
VOID PostConfig(VOID); VOID PostConfig(VOID);
VOID configDone(VOID); VOID configDone(VOID);
VOID FAR * KernelAlloc(size_t nBytes, char type, int mode); #ifdef I86
void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode); void _seg * alignNextPara(CVFP);
char *strcat(char * d, const char * s); #else
BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); #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); void DoInstall(void);
UWORD GetBiosKey(int timeout); unsigned GetBiosKey(int timeout);
/* diskinit.c */ /* diskinit.c */
COUNT dsk_init(VOID); COUNT dsk_init(VOID);
/* int2f.asm */ /* int2f.asm */
COUNT ASMPASCAL Umb_Test(void);
COUNT ASMPASCAL UMB_get_largest(void FAR * driverAddress, int ASMPASCAL UMB_get_largest(CVFP driverAddress, seg_t *, size_t *);
UCOUNT * seg, UCOUNT * size);
#ifdef __WATCOMC__ #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 #endif
/* inithma.c */ /* inithma.c */
int MoveKernelToHMA(void); int MoveKernelToHMA(void);
VOID FAR * HMAalloc(COUNT bytesToAllocate); VFP HMAalloc(COUNT bytesToAllocate);
/* initoem.c */
unsigned init_oem(void);
void movebda(size_t bytes, unsigned new_seg);
unsigned ebdasize(void);
/* intr.asm */ /* intr.asm */
@ -164,7 +160,7 @@ int ASMPASCAL close(int fd);
int ASMPASCAL dup2(int oldfd, int newfd); int ASMPASCAL dup2(int oldfd, int newfd);
seg ASMPASCAL allocmem(UWORD size); seg ASMPASCAL allocmem(UWORD size);
void ASMPASCAL init_PSPSet(seg psp_seg); 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_setdrive(int drive);
int ASMPASCAL init_switchar(int chr); int ASMPASCAL init_switchar(int chr);
void ASMPASCAL keycheck(void); void ASMPASCAL keycheck(void);
@ -208,15 +204,22 @@ VOID ASMCFUNC FAR int2f_handler(void);
VOID ASMCFUNC FAR cpm_entry(void); VOID ASMCFUNC FAR cpm_entry(void);
/* kernel.asm */ /* 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 */ /* main.c */
VOID ASMCFUNC FreeDOSmain(void);
BOOL init_device(struct dhdr FAR * dhp, char * cmdLine, void ASMCFUNC FreeDOSmain(void);
COUNT mode, char FAR **top); BOOL init_device(struct dhdr FAR *, PCStr cmdLine, int mode, VFP *top);
VOID init_fatal(BYTE * err_msg); #ifdef __WATCOMC__
# pragma aux (cdecl) FreeDOSmain aborts
#endif
/* prf.c */ /* prf.c */
int VA_CDECL init_printf(const char * fmt, ...); int VA_CDECL init_printf(const char * fmt, ...);
int VA_CDECL init_sprintf(char * buff, 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 unsigned CurrentKernelSegment;
extern struct _KernelConfig FAR ASM LowKernelConfig; extern struct _KernelConfig FAR ASM LowKernelConfig;
extern WORD days[2][13]; extern WORD days[2][13];
extern BYTE FAR *lpTop; extern VFP lpTop;
extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[];
extern UWORD ram_top; /* How much ram in Kbytes */
extern char singleStep; enum { ASK_ASK = 0x01, /* ?device= device?= */
extern char SkipAllConfig; ASK_NOASK = 0x02, /* !files= */
extern char master_env[128]; ASK_TRACE = 0x04, /* F8 processing */
ASK_SKIPALL = 0x08, /* F5 processing */
ASK_YESALL = 0x10, /* Esc while trace */
};
extern UBYTE askCommand;
extern struct lol FAR *LoL; 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 DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */
ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */
#endif #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 mov di, _Dyn+2
jmp short Int2f?iret jmp short Int2f?iret
;**********************************************************************
;*********************************************************** ; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C
; internal doscalls INT2F/11xx - handled through C ;**********************************************************************
;***********************************************************
IntDosCal: IntDosCal:
; set up register frame ; set up register frame
;struct int2f12regs ;struct int2f12regs

View File

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

View File

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

View File

@ -56,17 +56,124 @@ static BYTE *RcsId =
COUNT DosDevIOctl(lregs * r) COUNT DosDevIOctl(lregs * r)
{ {
sft FAR *s; static UBYTE cmds [] = {
struct dpb FAR *dpbp; 0, 0,
COUNT nMode; /* 0x02 */ C_IOCTLIN,
unsigned attr; /* 0x03 */ C_IOCTLOUT,
unsigned char al = r->AL; /* 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; return DE_INVLDFUNC;
/* commonly used, shouldn't harm to do front up */ /* 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_cat = r->CH; /* category (major) code */
CharReqHdr.r_fun = r->CL; /* function (minor) code */ CharReqHdr.r_fun = r->CL; /* function (minor) code */
@ -80,49 +187,18 @@ COUNT DosDevIOctl(lregs * r)
CharReqHdr.r_length = sizeof(request); CharReqHdr.r_length = sizeof(request);
CharReqHdr.r_status = 0; 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) switch (r->AL)
{ {
case 0x00: case 0x00:
/* Get the flags from the SFT */ /* Get the flags from the SFT */
r->DX = flags;
if (flags & SFT_FDEVICE) if (flags & SFT_FDEVICE)
r->AX = (attr & 0xff00) | (flags & 0xff); r->DH = attr >> 8;
else
r->AX = flags;
/* Undocumented result, Ax = Dx seen using Pcwatch */ /* Undocumented result, Ax = Dx seen using Pcwatch */
r->DX = r->AX; r->AX = r->DX;
break; break;
case 0x01: case 0x01:
/* sft_flags is a file, return an error because you */
/* can't set the status of a file. */ /* can't set the status of a file. */
if (!(flags & SFT_FDEVICE)) if (!(flags & SFT_FDEVICE))
return DE_INVLDFUNC; return DE_INVLDFUNC;
@ -132,205 +208,95 @@ COUNT DosDevIOctl(lregs * r)
if (r->DH != 0) if (r->DH != 0)
return DE_INVLDDATA; 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 */ /* Set it to what we got in the DL register from the */
/* user. */ /* user. */
s->sft_flags_lo = SFT_FDEVICE | r->DL; s->sft_flags_lo = SFT_FDEVICE | r->DL;
break; /* Undocumented: AL should get the old value */
r->AL = (UBYTE)flags;
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;
break; break;
case 0x0a: case 0x0a:
r->DX = flags; r->DX = flags;
r->AX = 0; r->AX = 0; /* ??? RBIL doesn't says that AX changed --avb */
break; 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: case 0x0c:
nMode = C_GENIOCTL; case 0x10:
goto IoCharCommon; if (!(flags & SFT_FDEVICE))
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;
}
return DE_INVLDFUNC; return DE_INVLDFUNC;
} CharReqHdr.r_unit = 0; /* ??? not used for devices --avb */
break; 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: case 0x09:
{ {
struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit); const struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit);
r->AX = S_DONE | S_BUSY; if (cdsp == NULL)
if (cdsp != NULL && dpbp == NULL)
{
r->DX = ATTR_REMOTE;
}
else
{
if (!dpbp)
{
return DE_INVLDDRV; return DE_INVLDDRV;
}
r->DX = attr;
}
if (cdsp->cdsFlags & CDSSUBST) if (cdsp->cdsFlags & CDSSUBST)
{ attr |= ATTR_SUBST;
r->DX |= 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; break;
} }
case 0x0d: case 0x0d:
nMode = C_GENIOCTL; if ((r->CX & ~0x4021) == 0x084A)
goto IoBlockCommon;
case 0x11:
nMode = C_IOCTLQRY;
IoBlockCommon:
if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A)
{ /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */
r->AX = 0; /* (lock/unlock logical/physical volume) */ r->AX = 0; /* (lock/unlock logical/physical volume) */
break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */
} }
if ((r->AL <= 0x05 && !(attr & ATTR_IOCTL)) /* fall through */
|| (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);
case 0x04:
case 0x05:
case 0x08:
case 0x11:
execrequest:
execrh(&CharReqHdr, dev);
if (CharReqHdr.r_status & S_ERROR) if (CharReqHdr.r_status & S_ERROR)
{ {
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
return DE_DEVICE; return DE_DEVICE;
} }
if (r->AL <= 0x05)
if (r->AL <= 0x05) /* 0x02, 0x03, 0x04, 0x05 */
r->AX = CharReqHdr.r_count; r->AX = CharReqHdr.r_count;
else if (r->AL == 0x08) else if (r->AL <= 0x07) /* 0x06, 0x07 */
r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; r->AX = (CharReqHdr.r_status & S_BUSY) ? 0000 : 0x00ff;
else /* 0x0d or 0x11 */ else if (r->AL == 0x08) /* 0x08 */
r->AX = (CharReqHdr.r_status / S_BUSY) & 1u;
else /* 0x0c, 0x0d, 0x10, 0x11 */
r->AX = CharReqHdr.r_status; r->AX = CharReqHdr.r_status;
break; break;
case 0x0e: case 0x0e:
nMode = C_GETLDEV;
goto IoLogCommon;
default: /* 0x0f */ default: /* 0x0f */
nMode = C_SETLDEV; execrh(&CharReqHdr, dev);
IoLogCommon:
if (attr & ATTR_GENIOCTL)
{
CharReqHdr.r_command = nMode;
execrh((request FAR *) & CharReqHdr, dpbp->dpb_device);
if (CharReqHdr.r_status & S_ERROR) if (CharReqHdr.r_status & S_ERROR)
{ {
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
return DE_ACCESS; return DE_ACCESS;
} }
else
{
r->AL = CharReqHdr.r_unit; r->AL = CharReqHdr.r_unit;
} /* switch */
return SUCCESS; return SUCCESS;
} }
}
return DE_INVLDFUNC;
}
break;
}
return SUCCESS;
}

View File

@ -45,12 +45,12 @@ static char copyright[] =
struct _KernelConfig InitKernelConfig BSS_INIT({0}); 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 update_dcb(struct dhdr FAR *);
STATIC VOID init_kernel(VOID); STATIC VOID init_kernel(VOID);
STATIC VOID signon(VOID); STATIC VOID signon(VOID);
STATIC VOID kernel(VOID); STATIC VOID init_shell(VOID);
STATIC VOID FsConfig(VOID); STATIC VOID FsConfig(VOID);
STATIC VOID InitPrinters(VOID); STATIC VOID InitPrinters(VOID);
STATIC VOID InitSerialPorts(VOID); STATIC VOID InitSerialPorts(VOID);
@ -69,11 +69,8 @@ __segment DosTextSeg = 0;
struct lol FAR *LoL = &DATASTART; struct lol FAR *LoL = &DATASTART;
VOID ASMCFUNC FreeDOSmain(void) void ASMCFUNC FreeDOSmain(void)
{ {
unsigned char drv;
unsigned char FAR *p;
#ifdef _MSC_VER #ifdef _MSC_VER
extern FAR prn_dev; extern FAR prn_dev;
DosDataSeg = (__segment) & DATASTART; DosDataSeg = (__segment) & DATASTART;
@ -89,47 +86,40 @@ VOID ASMCFUNC FreeDOSmain(void)
at 50:e0 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)); UBYTE drv;
UBYTE FAR *p = MK_PTR(UBYTE, 0, 0x5e2);
drv = *p + 1; if (fmemcmp(p, "CONFIG", 6) == 0) /* UPXed */
*(DWORD FAR *)(p+2) = 0; drv = p[-2]; /* boot drive was stored there by stub from exeflat.c */
}
else else
{ {
*p = drv - 1; drv = LoL->BootDrive;
fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); p[-2] = drv; /* used by initdisk.c:ReadAllPartitionTables() */
p = (UBYTE FAR*)&LowKernelConfig;
} }
if (drv >= 0x80) drv++;
if (drv > 0x80)
drv = 3; /* C: */ drv = 3; /* C: */
LoL->BootDrive = drv; LoL->BootDrive = drv;
fmemcpy(&InitKernelConfig, p, sizeof InitKernelConfig);
}
setup_int_vectors(); setup_int_vectors();
CheckContinueBootFromHarddisk(); CheckContinueBootFromHarddisk();
signon(); signon();
init_kernel(); init_kernel();
init_shell();
#ifdef DEBUG init_call_p_0(&Config); /* execute process 0 (the shell) */
/* Non-portable message kludge alert! */
printf("KERNEL: Boot drive = %c\n", 'A' + LoL->BootDrive - 1);
#endif
DoInstall();
kernel();
} }
/* /*
InitializeAllBPBs() InitializeAllBPBs()
or MakeNortonDiskEditorHappy() or MakeNortonDiskEditorHappy()
it has been determined, that FDOS's BPB tables are initialized, it has been determined, that FDOS's BPB tables are initialized,
only when used (like DIR H:). only when used (like DIR H:).
at least one known utility (norton DE) seems to access them directly. at least one known utility (norton DE) seems to access them directly.
@ -149,62 +139,47 @@ void InitializeAllBPBs(VOID)
STATIC void PSPInit(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)); /* Clear out new psp first */
fmemset(p, 0, sizeof(psp));
/* initialize all entries and exits */ /* initialize all entries and exits */
/* CP/M-like exit point */ p->ps_exit = 0x20cd; /* CP/M-like exit point: */
p->ps_exit = 0x20cd; /* INT 20 opcode */
/* CP/M-like entry point: */
/* CP/M-like entry point - call far to special entry */ p->ps_farcall = 0x9a; /* FAR CALL opcode... */
p->ps_farcall = 0x9a; p->ps_reentry = MK_FP(0, 0x30 * 4); /* ...entry address */
p->ps_reentry = MK_FP(0, 0x30 * 4); p->ps_unix[0] = 0xcd; /* unix style call: */
/* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ p->ps_unix[1] = 0x21; /* INT 21/RETF opcodes */
p->ps_unix[0] = 0xcd;
p->ps_unix[1] = 0x21;
p->ps_unix[2] = 0xcb; p->ps_unix[2] = 0xcb;
/* Now for parent-child relationships */ /* parent-child relationships */
/* parent psp segment */ /*p->ps_parent = 0;*/ /* parent psp segment */
p->ps_parent = FP_SEG(p); p->ps_prevpsp = (VFP)-1l; /* previous psp address */
/* previous psp pointer */
p->ps_prevpsp = MK_FP(0xffff,0xffff);
/* Environment and memory useage parameters */ /* Environment and memory useage parameters */
/* memory size in paragraphs */ /*p->ps_size = 0;*/ /* segment of memory beyond */
/* p->ps_size = 0; clear from above */ /* memory allocated to program */
/* environment paragraph */ /*p->ps_environ = 0;*/ /* 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);
/* user stack pointer - int 21 */ /*p->ps_isv22 = NULL;*/ /* terminate handler */
/* p->ps_stack = NULL; clear from above */ /*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 */ /* File System parameters */
/* maximum open files */ p->ps_maxfiles = sizeof p->ps_files; /* size of file table */
p->ps_maxfiles = 20; fmemset(p->ps_filetab = p->ps_files, 0xff, sizeof p->ps_files);
fmemset(p->ps_files, 0xff, 20);
/* open file table pointer */ /*p->ps_fcb1.fcb_drive = 0;*/ /* 1st command line argument */
p->ps_filetab = p->ps_files; /*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 */ /* this area reused for master environment */
/* p->ps_fcb1.fcb_drive = 0; already set */ /*p->ps_cmd.ctCount = 0;*/ /* local command line */
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /*p->ps_cmd.ctBuffer[0] = '\r';*/ /* command tail */
/* 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 */
} }
#ifndef __WATCOMC__ #ifndef __WATCOMC__
@ -255,7 +230,7 @@ STATIC void setup_int_vectors(void)
for (i = 0x23; i <= 0x3f; i++) for (i = 0x23; i <= 0x3f; i++)
setvec(i, empty_handler); 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)); setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
pokeb(0, 0x30 * 4, 0xea); pokeb(0, 0x30 * 4, 0xea);
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); 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_major = LoL->os_major = MAJOR_RELEASE;
LoL->os_setver_minor = LoL->os_minor = MINOR_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 */ /* move kernel to high conventional RAM, just below the init code */
#ifdef __WATCOMC__ #ifdef __WATCOMC__
lpTop = MK_FP(_CS, 0); lpTop = MK_FP(_CS, 0);
@ -283,16 +255,17 @@ STATIC void init_kernel(void)
#endif #endif
MoveKernel(FP_SEG(lpTop)); MoveKernel(FP_SEG(lpTop));
/* lpTop should be para-aligned */
lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0);
/* Initialize IO subsystem */ /* Initialize IO subsystem */
InitIO(); init_internal_devices();
InitPrinters(); InitPrinters();
InitSerialPorts(); InitSerialPorts();
init_PSPSet(DOS_PSP);
set_DTA(MK_FP(DOS_PSP, 0x80)); set_DTA(MK_FP(DOS_PSP, 0x80));
PSPInit(); PSPInit();
init_PSPSet(DOS_PSP);
Init_clk_driver(); Init_clk_driver();
@ -300,7 +273,6 @@ STATIC void init_kernel(void)
/* we can read config.sys later. */ /* we can read config.sys later. */
LoL->lastdrive = Config.cfgLastdrive; LoL->lastdrive = Config.cfgLastdrive;
/* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, &ram_top); */
blk_dev.dh_name[0] = dsk_init(); blk_dev.dh_name[0] = dsk_init();
PreConfig(); PreConfig();
@ -313,14 +285,7 @@ STATIC void init_kernel(void)
FsConfig(); FsConfig();
/* Now process CONFIG.SYS */ /* Now process CONFIG.SYS */
DoConfig(0); DoConfig();
DoConfig(1);
/* initialize near data and MCBs */
PreConfig2();
/* and process CONFIG.SYS one last time for device drivers */
DoConfig(2);
/* Close all (device) files */ /* Close all (device) files */
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
@ -335,6 +300,8 @@ STATIC void init_kernel(void)
configDone(); configDone();
InitializeAllBPBs(); InitializeAllBPBs();
DoInstall();
} }
STATIC VOID FsConfig(VOID) STATIC VOID FsConfig(VOID)
@ -346,21 +313,15 @@ STATIC VOID FsConfig(VOID)
for (i = 0; i < LoL->lastdrive; i++) for (i = 0; i < LoL->lastdrive; i++)
{ {
struct cds FAR *pcds_table = &LoL->CDSp[i]; struct cds FAR *pcds_table = &LoL->CDSp[i];
fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4);
pcds_table->cdsCurrentPath[0] += i; pcds_table->cdsCurrentPath[0] += i;
pcds_table->cdsFlags = 0;
if (i < LoL->nblkdev && (ULONG) dpb != 0xffffffffl) if (i < LoL->nblkdev && (LONG) dpb != -1l)
{ {
pcds_table->cdsDpb = dpb; pcds_table->cdsDpb = dpb;
pcds_table->cdsFlags = CDSPHYSDRV; pcds_table->cdsFlags = CDSPHYSDRV;
dpb = dpb->dpb_next; dpb = dpb->dpb_next;
} }
else
{
pcds_table->cdsFlags = 0;
}
pcds_table->cdsStrtClst = 0xffff; pcds_table->cdsStrtClst = 0xffff;
pcds_table->cdsParam = 0xffff; pcds_table->cdsParam = 0xffff;
pcds_table->cdsStoreUData = 0xffff; pcds_table->cdsStoreUData = 0xffff;
@ -428,135 +389,89 @@ STATIC VOID signon()
MAJOR_RELEASE, MINOR_RELEASE, copyright); 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 */ /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */
/* (insert /D, /Y as first argument) */
/* 3 for string + 2 for "\r\n" */ if (askCommand & (ASK_TRACE | ASK_SKIPALL))
if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 5)
{ {
char *insertString = NULL; PStr p = Config.cfgShell - 1; /* find end of command name */
if (singleStep) /* too long line -> truncate it to make space for "/Y \0" */
insertString = " /Y"; /* single step AUTOEXEC */ Config.cfgShell[sizeof Config.cfgShell - 4] = '\0';
if (SkipAllConfig) do p++; while ((UBYTE)*p > ' ' && *p != '/');
insertString = " /D"; /* disable AUTOEXEC */
if (*p == ' ' || *p == '\t')
p++; /* place option after space */
if (insertString)
{ {
PStr q = p;
/* insert /D, /Y as first argument */ while (*q++); /* find end of command line */
char *p, *q; /* shift tail to right by 3 to make room for option */
do
for (p = Cmd.ctBuffer; p < &Cmd.ctBuffer[Cmd.ctCount]; p++)
{ {
if (*p == ' ' || *p == '\t' || *p == '\r') q--;
{
for (q = &Cmd.ctBuffer[Cmd.ctCount + 1]; q >= p; q--)
q[3] = q[0]; q[3] = q[0];
memcpy(p, insertString, 3); } while (q > p);
break;
} }
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 */ /* check for a block device and update device control block */
STATIC VOID update_dcb(struct dhdr FAR * dhp) STATIC VOID update_dcb(struct dhdr FAR * dhp)
{ {
REG COUNT Index; int nunits = dhp->dh_name[0];
COUNT nunits = dhp->dh_name[0]; struct dpb FAR *dpb = LoL->DPBp;
struct dpb FAR *dpb;
if (LoL->nblkdev == 0) if (LoL->nblkdev)
dpb = LoL->DPBp;
else
{ {
for (dpb = LoL->DPBp; (ULONG) dpb->dpb_next != 0xffffffffl; while ((LONG) dpb->dpb_next != -1l)
dpb = dpb->dpb_next) dpb = dpb->dpb_next;
;
dpb = dpb->dpb_next = dpb = dpb->dpb_next =
KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb); 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_next = dpb + 1;
dpb->dpb_unit = LoL->nblkdev; dpb->dpb_unit = LoL->nblkdev;
dpb->dpb_subunit = Index; if (LoL->nblkdev < LoL->lastdrive && LoL->CDSp)
dpb->dpb_device = dhp;
dpb->dpb_flags = M_CHANGED;
if ((LoL->CDSp != 0) && (LoL->nblkdev < LoL->lastdrive))
{ {
LoL->CDSp[LoL->nblkdev].cdsDpb = dpb; LoL->CDSp[LoL->nblkdev].cdsDpb = dpb;
LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV; 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 */ /* If r_top is NULL, this is an internal driver */
BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top)
BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode,
char FAR **r_top)
{ {
request rq; 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_unit = 0;
rq.r_status = 0; rq.r_status = 0;
rq.r_command = C_INIT; rq.r_command = C_INIT;
rq.r_length = sizeof(request); rq.r_length = sizeof(request);
rq.r_endaddr = *r_top; rq.r_endaddr = r_top ? *r_top : lpTop;
rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); rq.r_bpbptr = (VFP)cmdLine;
rq.r_firstunit = LoL->nblkdev; rq.r_firstunit = LoL->nblkdev;
execrh((request FAR *) & rq, dhp); execrh(&rq, dhp);
/* /*
* Added needed Error handle * 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) if ((rq.r_status & (S_ERROR | S_DONE)) == S_ERROR)
return TRUE; return TRUE;
if (cmdLine) if (r_top)
{ {
/* Don't link in device drivers which do not take up memory */ /* Don't link in device drivers which do not take up memory */
if (rq.r_endaddr == (BYTE FAR *) dhp) 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) if (FP_OFF(dhp->dh_next) == 0xffff)
{ {
KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16 char name[8];
- FP_SEG(dhp), 'D', name, mode); 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: */ /* 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 */ /* last INIT call which will then be passed as the end address */
/* for the next INIT call. */ /* 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)) 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; return FALSE;
} }
STATIC void InitIO(void) STATIC void init_internal_devices(void)
{ {
struct dhdr far *device = &LoL->nul_dev; struct dhdr far *device = &LoL->nul_dev;
/* Initialize driver chain */ /* Initialize driver chain */
do { 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; device = device->dh_next;
} }
while (FP_OFF(device) != 0xffff); 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 Initialize all printers
this should work. IMHO, this might also be done on first use 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 of printer, as I never liked the noise by a resetting printer, and
I usually much more often reset my system, then I print :-) I usually much more often reset my system, then I print :-)
@ -678,46 +613,39 @@ STATIC VOID InitSerialPorts(VOID)
booted from HD booted from HD
*/ */
EmulatedDriveStatus(int drive,char statusOnly) static int EmulatedDriveStatus(int drive,char statusOnly)
{ {
iregs r; iregs r;
char buffer[0x13]; char buffer[0x13];
buffer[0] = 0x13; buffer[0] = 0x13;
r.a.b.h = 0x4b; /* bootable CDROM - get status */ r.AH = 0x4b; /* bootable CDROM - get status */
r.a.b.l = statusOnly; r.AL = statusOnly;
r.d.b.l = (char)drive; r.DL = (char)drive;
r.si = (int)buffer; r.SI = (int)buffer;
init_call_intr(0x13, &r); init_call_intr(0x13, &r);
return r.FLAGS & 1; /* carry flag */
if (r.flags & 1)
return FALSE;
return TRUE;
} }
STATIC void CheckContinueBootFromHarddisk(void) STATIC void CheckContinueBootFromHarddisk(void)
{ {
char *bootedFrom = "Floppy/CD"; char *bootedFrom = "Floppy/CD";
iregs r;
int key;
if (InitKernelConfig.BootHarddiskSeconds == 0) if (InitKernelConfig.BootHarddiskSeconds <= 0)
return; return;
if (LoL->BootDrive >= 3) if (LoL->BootDrive >= 3)
{ {
#if 0 #if 0
if (!EmulatedDriveStatus(0x80,1)) if (EmulatedDriveStatus(0x80,1))
#endif #endif
{
/* already booted from HD */ /* already booted from HD */
return; return;
} }
} else
else { {
#if 0 #if 0
if (!EmulatedDriveStatus(0x00,1)) if (EmulatedDriveStatus(0x00,1))
#endif #endif
bootedFrom = "Floppy"; bootedFrom = "Floppy";
} }
@ -729,15 +657,13 @@ STATIC void CheckContinueBootFromHarddisk(void)
" Hit 'H' or wait %d seconds to boot from Harddisk\n", " Hit 'H' or wait %d seconds to boot from Harddisk\n",
InitKernelConfig.BootHarddiskSeconds, InitKernelConfig.BootHarddiskSeconds,
bootedFrom, bootedFrom,
InitKernelConfig.BootHarddiskSeconds InitKernelConfig.BootHarddiskSeconds);
);
key = GetBiosKey(InitKernelConfig.BootHarddiskSeconds); if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds))
if (key != -1 && (key & 0xff) != 'h' && (key & 0xff) != 'H')
{ {
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 */ /* user has hit a key, continue to boot from floppy/CD */
printf("\n");
return; return;
} }
@ -745,18 +671,16 @@ STATIC void CheckContinueBootFromHarddisk(void)
EmulatedDriveStatus(0x00,0); EmulatedDriveStatus(0x00,0);
EmulatedDriveStatus(0x80,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); iregs r;
r.AX = 0x0201;
r.CX = 0x0001;
r.DX = 0x0080;
r.BX = 0x7c00;
r.ES = 0;
init_call_intr(0x13, &r);
}
(*reboot)(); /* 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$ # $Id$
# #
@ -9,10 +9,12 @@
LIBS=..\lib\device.lib ..\lib\libm.lib LIBS=..\lib\device.lib ..\lib\libm.lib
HDR=../hdr/ HDR=../hdr/
# *List Macros* # List Macros ##########################################################
# Only 8 files per definition; this is limitation of DOS batch # Only 8 files per definition; this is limitation of DOS batch
# files (only 9 directly accessible parameters). # 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 \ OBJS1=kernel.obj entry.obj io.obj console.obj serial.obj printer.obj dsk.obj \
sysclk.obj sysclk.obj
OBJS2=asmsupt.obj execrh.obj nlssupt.obj procsupt.obj dosidle.obj int2f.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 initdisk.obj initclk.obj
OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) 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 ..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe
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)
$(LINK) @$(TARGET).lnk; $(LINK) @$(TARGET).lnk;
$(XUPX) kernel.exe
clobber: clean ..\utils\exeflat kernel.exe $*.sys 0x60 -S0x10 -S0x8B $(UPXOPT)
-$(RM) kernel.exe kernel.sys status.me copy $*.sys ..\bin\kernel.sys
clean:
-$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk
# XXX: This is a very ugly way of linking the kernel, forced upon us by the # 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 ECHOTO=..\utils\echoto
$(TARGET).lnk: turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).mak $(TARGET).lnk: $(DEPENDS) *.cfg
-$(RM) *.lnk -$(RM) *.lnk *.obj
$(ECHOTO) $(TARGET).lnk $(OBJS1)+ $(ECHOTO) $*.lnk $(OBJS1)+
$(ECHOTO) $(TARGET).lnk $(OBJS2)+ $(ECHOTO) $*.lnk $(OBJS2)+
$(ECHOTO) $(TARGET).lnk $(OBJS3)+ $(ECHOTO) $*.lnk $(OBJS3)+
$(ECHOTO) $(TARGET).lnk $(OBJS4)+ $(ECHOTO) $*.lnk $(OBJS4)+
$(ECHOTO) $(TARGET).lnk $(OBJS5)+ $(ECHOTO) $*.lnk $(OBJS5)+
$(ECHOTO) $(TARGET).lnk $(OBJS6)+ $(ECHOTO) $*.lnk $(OBJS6)+
$(ECHOTO) $(TARGET).lnk $(OBJS7) $(ECHOTO) $*.lnk $(OBJS7)
$(ECHOTO) $(TARGET).lnk kernel.exe $(ECHOTO) $*.lnk kernel
$(ECHOTO) $(TARGET).lnk kernel.map $(ECHOTO) $*.lnk ..\bin\$*
$(ECHOTO) $(TARGET).lnk $(LIBS) $(ECHOTO) $*.lnk $(LIBS)
# *Individual File Dependencies* # Individual File Dependencies #########################################
apisupt.obj: apisupt.asm segs.inc $(TARGET).lnk
asmsupt.obj: asmsupt.asm segs.inc $(TARGET).lnk apisupt.obj: apisupt.asm segs.inc
console.obj: console.asm io.inc $(TARGET).lnk asmsupt.obj: asmsupt.asm segs.inc
dosidle.obj: dosidle.asm segs.inc $(TARGET).lnk console.obj: console.asm io.inc
entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk dosidle.obj: dosidle.asm segs.inc
execrh.obj: execrh.asm segs.inc $(TARGET).lnk entry.obj: entry.asm segs.inc $(HDR)stacks.inc
int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk execrh.obj: execrh.asm segs.inc
intr.obj: intr.asm segs.inc $(TARGET).lnk int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc
io.obj: io.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk intr.obj: intr.asm segs.inc
irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk io.obj: io.asm segs.inc $(HDR)stacks.inc
kernel.obj: kernel.asm segs.inc ludivmul.inc $(TARGET).lnk irqstack.obj: irqstack.asm segs.inc
nls_hc.obj: nls_hc.asm segs.inc $(TARGET).lnk kernel.obj: kernel.asm segs.inc ludivmul.inc
nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk nls_hc.obj: nls_hc.asm segs.inc
printer.obj: printer.asm io.inc $(TARGET).lnk nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc
procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk printer.obj: printer.asm io.inc
serial.obj: serial.asm io.inc $(TARGET).lnk procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc
serial.obj: serial.asm io.inc
HDRS=\ HDRS=\
$(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \
@ -94,31 +85,31 @@ HDRS=\
HEADERS=$(HDRS) globals.h proto.h HEADERS=$(HDRS) globals.h proto.h
INITHEADERS=$(HDRS) init-mod.h init-dat.h INITHEADERS=$(HDRS) init-mod.h init-dat.h
blockio.obj: blockio.c $(HEADERS) $(TARGET).lnk blockio.obj: blockio.c $(HEADERS)
break.obj: break.c $(HEADERS) $(TARGET).lnk break.obj: break.c $(HEADERS)
chario.obj: chario.c $(HEADERS) $(TARGET).lnk chario.obj: chario.c $(HEADERS)
dosfns.obj: dosfns.c $(HEADERS) $(TARGET).lnk dosfns.obj: dosfns.c $(HEADERS)
dosnames.obj: dosnames.c $(HEADERS) $(TARGET).lnk dosnames.obj: dosnames.c $(HEADERS)
dsk.obj: dsk.c $(HEADERS) $(TARGET).lnk dsk.obj: dsk.c $(HEADERS)
error.obj: error.c $(HEADERS) $(TARGET).lnk error.obj: error.c $(HEADERS)
fatdir.obj: fatdir.c $(HEADERS) $(TARGET).lnk fatdir.obj: fatdir.c $(HEADERS)
fatfs.obj: fatfs.c $(HEADERS) $(TARGET).lnk fatfs.obj: fatfs.c $(HEADERS)
fattab.obj: fattab.c $(HEADERS) $(TARGET).lnk fattab.obj: fattab.c $(HEADERS)
fcbfns.obj: fcbfns.c $(HEADERS) $(TARGET).lnk fcbfns.obj: fcbfns.c $(HEADERS)
inthndlr.obj: inthndlr.c $(HEADERS) $(TARGET).lnk inthndlr.obj: inthndlr.c $(HEADERS)
ioctl.obj: ioctl.c $(HEADERS) $(TARGET).lnk ioctl.obj: ioctl.c $(HEADERS)
memmgr.obj: memmgr.c $(HEADERS) $(TARGET).lnk lfnapi.obj: lfnapi.c $(HEADERS)
misc.obj: misc.c $(HEADERS) $(TARGET).lnk memmgr.obj: memmgr.c $(HEADERS)
lfnapi.obj: lfnapi.c $(HEADERS) $(TARGET).lnk misc.obj: misc.c $(HEADERS)
newstuff.obj: newstuff.c $(HEADERS) $(TARGET).lnk network.obj: network.c $(HEADERS)
network.obj: network.c $(HEADERS) $(TARGET).lnk newstuff.obj: newstuff.c $(HEADERS)
nls.obj: nls.c $(HEADERS) $(TARGET).lnk nls.obj: nls.c $(HEADERS)
prf.obj: prf.c $(HDR)portab.h $(TARGET).lnk prf.obj: prf.c $(HDR)portab.h
strings.obj: strings.c $(TARGET).lnk strings.obj: strings.c
sysclk.obj: sysclk.c $(HEADERS) $(TARGET).lnk sysclk.obj: sysclk.c $(HEADERS)
syspack.obj: syspack.c $(HEADERS) $(TARGET).lnk syspack.obj: syspack.c $(HEADERS)
systime.obj: systime.c $(HEADERS) $(TARGET).lnk systime.obj: systime.c $(HEADERS)
task.obj: task.c $(HEADERS) $(TARGET).lnk task.obj: task.c $(HEADERS)
# now the funny stuff :-) # now the funny stuff :-)
# Files in the INIT segment # 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 # XXX: Special handling for initialization modules -- this is required because
# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 # 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 $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
initoem.obj: initoem.c $(INITHEADERS) $(TARGET).lnk dyninit.obj: dyninit.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
main.obj: main.c $(INITHEADERS) $(TARGET).lnk initclk.obj: initclk.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
inithma.obj: inithma.c $(INITHEADERS) $(TARGET).lnk initdisk.obj: initdisk.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
dyninit.obj: dyninit.c $(INITHEADERS) $(TARGET).lnk inithma.obj: inithma.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
initdisk.obj: initdisk.c $(INITHEADERS) $(TARGET).lnk initoem.obj: initoem.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
initclk.obj: initclk.c $(INITHEADERS) $(TARGET).lnk main.obj: main.c $(INITHEADERS)
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(INITPATCH) $*.obj
# the string functions for INIT_TEXT # 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 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 # 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
iprf.obj: iprf.c prf.c $(HDR)portab.h
$(CC) $(INITCFLAGS) $*.c $(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj $(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; return DE_INVLDFUNC;
/* nls := NLS package of cntry/codepage */ /* nls := NLS package of cntry/codepage */
if ((nls = searchPackage(cp, cntry)) == NULL if ((nls = searchPackage(cp, cntry)) != NULL)
|| (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0)
{ {
/* If the NLS pkg is not loaded into memory or the /* matching NLS package found */
direct-access flag is disabled, the request must if (nls->flags & NLS_FLAG_DIRECT_GETDATA)
be passed through MUX */
return (subfct == NLS_DOS_38)
? mux38(nls->cp, nls->cntry, bufsize, buf)
: mux65(subfct, nls->cp, nls->cntry, bufsize, buf);
}
/* Direct access to the data */ /* Direct access to the data */
return nlsGetData(nls, subfct, buf, bufsize); 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 global _exec_user
_exec_user: _exec_user:
%ifndef WATCOM
; PUSH$ALL ; exec_user declared with attribute `aborts'
; mov ds,[_DGROUP_]
; cld
;
;
;
pop ax ; return address (unused) pop ax ; return address (unused)
%endif
pop ax ; irp (user ss:sp) pop ax ; irp (user ss:sp)
pop dx pop dx
pop cx ; disable A20? pop cx ; disable A20?
@ -282,8 +277,11 @@ _spawn_int23:
global reloc_call_p_0 global reloc_call_p_0
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 ; return address (32-bit, unused)
pop ax pop ax
%endif
pop ax ; fetch parameter 0 (32-bit) from the old stack pop ax ; fetch parameter 0 (32-bit) from the old stack
pop dx pop dx
mov ds,[cs:_DGROUP_] mov ds,[cs:_DGROUP_]
@ -293,4 +291,9 @@ reloc_call_p_0:
sti sti
push dx ; pass parameter 0 onto the new stack push dx ; pass parameter 0 onto the new stack
push ax push ax
%ifndef WATCOM
call _P_0 ; no return, allow parameter fetch from C 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); int ParseDosName(const char *, char *, BOOL);
/* error.c */ /* error.c */
VOID dump(void); VOID dump(void);
VOID panic(BYTE * s); VOID panic(BYTE * s);
VOID fatal(BYTE * err_msg); VOID fatal(BYTE * err_msg);
#ifdef __WATCOMC__
# pragma aux panic aborts
# pragma aux fatal aborts
#endif
/* fatdir.c */ /* fatdir.c */
VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart); VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart);
@ -225,8 +230,9 @@ void FcbCloseAll(void);
UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First); UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First);
/* intr.asm */ /* 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__ #ifdef __WATCOMC__
# pragma aux (pascal) res_DosExec modify exact [ax bx dx es] # 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_read modify exact [ax bx cx dx]
@ -236,10 +242,8 @@ UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
COUNT DosDevIOctl(lregs * r); COUNT DosDevIOctl(lregs * r);
/* memmgr.c */ /* memmgr.c */
seg far2para(VOID FAR * p);
seg long2para(ULONG size); VFP adjust_far(CVFP);
void FAR *add_far(void FAR * fp, unsigned off);
VOID FAR *adjust_far(const void FAR * fp);
COUNT DosMemAlloc(UWORD size, COUNT mode, seg * para, UWORD * asize); COUNT DosMemAlloc(UWORD size, COUNT mode, seg * para, UWORD * asize);
COUNT DosMemLargest(UWORD * size); COUNT DosMemLargest(UWORD * size);
COUNT DosMemFree(UWORD para); COUNT DosMemFree(UWORD para);
@ -364,12 +368,16 @@ const UWORD *is_leap_year_monthdays(UWORD year);
UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth);
/* task.c */ /* task.c */
VOID new_psp(seg para, seg cur_psp);
VOID child_psp(seg para, seg cur_psp, int psize); void new_psp(seg_t para, seg_t cur_psp);
VOID return_user(void); 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); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
ULONG SftGetFsize(int sft_idx); ULONG SftGetFsize(int sft_idx);
VOID InitPSP(VOID); VOID InitPSP(VOID);
#ifdef __WATCOMC__
# pragma aux return_user aborts
#endif
/* newstuff.c */ /* newstuff.c */
int SetJFTSize(UWORD nHandles); 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); VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
/* procsupt.asm */ /* 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 */ /* 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) 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 _BSS class=BSS align=2
segment _DATA class=DATA align=2 segment _DATA class=DATA align=2
segment _DATAEND class=DATA align=1 segment _DATAEND class=DATA align=1
;for WATCOM %ifdef MSC
segment CONST class=CONST align=2
%else
segment CONST class=DATA align=2 segment CONST class=DATA align=2
%endif
;for WATCOM
segment CONST2 class=DATA align=2 segment CONST2 class=DATA align=2
;for MSC ;for MSC
segment DCONST class=DCONST align=2 segment DCONST class=DCONST align=2

View File

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

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 -d
-f-
-k- -k-
-vi- -O -Z
-wpro
-weas
-wpre
-w
-g1
-I..\hdr
-p -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$ # $Id$
# #
!include "../mkfiles/generic.mak" !include "../mkfiles/generic.mak"
########################################################################
libm.lib: $(CLIB) all: libm.lib
-$(RM) libm.lib
libm.lib: $(CLIB) $(DEPENDS)
-$(RM) $*.lib
$(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM)
$(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i $(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i
$(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) $(LIBUTIL) $* $(MATH_INSERT) $(LIBTERM)
-$(RM) *.OBJ -$(RM) *.obj
########################################################################
clobber: clean
-$(RM) status.me
clean: 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++ # BC5.MAK - kernel copiler options for Borland C++
# #
# Use these for Borland C++ !include "..\mkfiles\turbocpp.mak"
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
TARGET=KBC TARGET=KBC
# used for building the library CC=$(BINPATH)\bcc -c
CL=$(BINPATH)\bcc
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)

View File

@ -1,43 +1,67 @@
# These are generic definitions # These are generic definitions
#********************************************************************** # TARGET : we create a $(TARGET).sys file
#* TARGET : we create a %TARGET%.sys file
#* TARGETOPT : options, handled down to the compiler
#**********************************************************************
TARGETOPT=-1-
!if $(XCPU)0 == 0
XCPU=86
!endif
CPUOPT=
!if $(XCPU) == 186 !if $(XCPU) == 186
TARGETOPT=-1 CPUOPT=-1
!endif !endif
!if $(XCPU) == 386 !if $(XCPU) == 386
TARGETOPT=-3 CPUOPT=-3
!endif !endif
!if $(XFAT)0 == 0
XFAT=32
!endif
!if $(XFAT) == 32 !if $(XFAT) == 32
ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32 ALLCFLAGS=-DWITHFAT32 $(ALLCFLAGS)
NASMFLAGS=$(NASMFLAGS) -DWITHFAT32 NASMFLAGS=-DWITHFAT32 $(NASMFLAGS)
!endif !endif
NASM=$(XNASM) NASMFLAGS=-fobj -i../hdr/ -D$(COMPILER) -DXCPU=$(XCPU) $(NASMFLAGS)
NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU)
LINK=$(XLINK)
BINPATH=$(BASE)\bin
INCLUDEPATH=$(BASE)\include
LIBPATH=$(BASE)\lib
INITPATCH=@rem 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" !include "..\mkfiles\$(COMPILER).mak"
TARGET=$(TARGET)$(XCPU)$(XFAT) TARGET=$(TARGET)$(XCPU)$(XFAT)
INITCFLAGS=$(INITCFLAGS) $(ALLCFLAGS)
CFLAGS=$(CFLAGS) $(ALLCFLAGS)
RM=..\utils\rmfiles RM=..\utils\rmfiles
DEPENDS=makefile ..\*.bat ..\mkfiles\*.*
# Implicit Rules #######################################################
.asm.obj: .asm.obj:
$(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm $(NASM) $(NASMFLAGS) $<
# *Implicit Rules*
.c.obj: .c.obj:
$(CC) $(CFLAGS) $*.c $(CC) $(CFLAGS) $<
.cpp.obj: .cpp.obj:
$(CC) $(CFLAGS) $*.cpp $(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

@ -2,46 +2,30 @@
# MSCL8.MAK - kernel copiler options for MS CL8 = MS VC 1.52 # MSCL8.MAK - kernel copiler options for MS CL8 = MS VC 1.52
# #
# Use these for MSCV 1.52 TARGET=KMS
COMPILERPATH=$(MS_BASE)
COMPILERBIN=$(COMPILERPATH)\bin CC=$(BINPATH)\cl -batch -nologo -c
INCLUDEPATH=$(COMPILERPATH)\include CL=$(BINPATH)\cl -batch -nologo
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 # used for building the library
CLIB=$(COMPILERPATH)\lib\slibce.lib CLIB=$(LIBPATH)\slibce.lib
MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv *aFNaulsh
MATH_INSERT= +aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv MATH_INSERT =+aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +aFNaulsh
TARGETOPT=
!if $(XCPU) == 186
TARGETOPT=-G1
!endif
!if $(XCPU) == 386
TARGETOPT=-G3
!endif
TARGET=KMS
# #
# 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
INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT CFLAGS =-NTHMA_TEXT
CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT
INITPATCH=..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC 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) !include "..\mkfiles\turbocpp.mak"
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
TARGET=KTC TARGET=KTC
# used for building the library
CLIB=$(COMPILERPATH)\lib\cs.lib
MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH
MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH
# # TCC 2.0 doesn't support responce file
# 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"
# INITCFLAGS=-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP
# 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)

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 !include "..\mkfiles\turbocpp.mak"
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
TARGET=KT3 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 TARGET=KTP
CC=$(BINPATH)\tcc -c
CL=$(BINPATH)\tcc
# used for building the library # 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_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 options for Turbo/Borland C
# Compiler and Options for Borland C++
# ------------------------------------ # ------------------------------------
# #
# -zAname ¦ ¦ Code class # -zAname ¦ ¦ Code class
@ -46,8 +32,12 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL
# -zX ¦«¦ Use default name for "X" # -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 ALLCFLAGS=-I..\hdr;$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS)
CFLAGS=$(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 TARGET=KWC
BINPATH=$(BASE)\binw
INCLUDEPATH=$(BASE)\h
LIBPATH=$(BASE)\lib286
CC=$(BINPATH)\wcc
CL=$(BINPATH)\wcl
# used for building the library # used for building the library
CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib CLIB=$(LIBPATH)\dos\clibm.lib
# we use our own ones, which override these ones when linking.
#
MATH_EXTRACT=*i4m 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 # -e=<num> set limit on number of error messages
# -ms small memory model (small code/small data) # -w=<num> set warning level number
# -we treat all warnings as errors
# -zq operate quietly
#
# -j change char default from unsigned to signed # -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}
#
# -3 optimization for 386 - given in $(CPUOPT)
# -g=<id> set code group name
# -nc=<id> set code class name # -nc=<id> set code class name
# -nd=<id> set data segment name # -nd=<id> set data segment name
# -nm=<file> set module name # -nm=<file> set module name
# -nt=<id> set name of text segment # -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
# -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
# #
ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r ALLCFLAGS=-I$(INCLUDEPATH) $(CPUOPT)$(ALLCFLAGS)
INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI INITCFLAGS=@wci.cfg
CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT 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 #define FAR far
#include "kconfig.h" #include "kconfig.h"
KernelConfig cfg = { 0 }; KernelConfig cfg; /* static memory zeroed automatically */
typedef unsigned char byte; typedef unsigned char byte;
typedef signed char sbyte; typedef signed char sbyte;

View File

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

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

View File

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

View File

@ -7,4 +7,3 @@ shift
goto loop_commandline goto loop_commandline
:done_with_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 @echo off
ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk %BASE%\binw\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9>kernel.lnk
echo op map,statics,verbose >> kernel.lnk echo op map,statics,verbose,eliminate,vfremoval>>kernel.lnk
call wlink @kernel.lnk %BASE%\binw\wlink @kernel.lnk