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
clobber: clean fat32lba.bin: boot32lb.asm $(DEPENDS)
-$(RM) *.bin status.me $(NASM) boot32lb.asm -o$*.bin
########################################################################
clean: clean:
-$(RM) *.lst *.map *.bak *.obj -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) *.bin status.me

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
@ -70,30 +62,30 @@ set Sumfile=bin\ksummary.txt
set TempSumfile=bin\tsummary.txt set TempSumfile=bin\tsummary.txt
:****echo >%TempSumfile% Summary of all kernels build :****echo >%TempSumfile% Summary of all kernels build
:****echo.|date >>%TempSumfile% :****echo.|date >>%TempSumfile%
:****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=
goto end goto end
:summary :summary
echo H************************************************* %2 >>%TempSumfile% echo H************************************************* %2 >>%TempSumfile%
find<%2 " HMA_TEXT"|find/V "HMA_TEXT_START"|find/V "HMA_TEXT_END">>%TempSumfile% find<%2 " HMA_TEXT"|find/V "HMA_TEXT_START"|find/V "HMA_TEXT_END">>%TempSumfile%
find<%2 " STACK">>%TempSumfile% find<%2 " STACK">>%TempSumfile%
@ -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

177
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 TP1_BASE=c:\tcpp
:- set TC3_BASE=c:\tc3
:- set BC5_BASE=c:\bc5
:- set MS_BASE=c:\msvc
:- if WATCOM maybe you need to set your WATCOM environment variables set TC_BASE=c:\tc
:- and path ::set TCPP_BASE=c:\tcpp
:- if not \%WATCOM% == \ goto watcom_defined ::set TCPP3_BASE=c:\tcpp3
:- set WATCOM=c:\watcom ::set BC_BASE=c:\bc
:- set PATH=%PATH%;%WATCOM%\binw ::set MSC_BASE=c:\msc
:watcom_defined ::set WATCOM=c:\watcom
:-********************************************************************** :-----------------------------------------------------------------------
:- where is UPX and which options to use? :- When compiling executable, compilers search linker through PATH;
:-********************************************************************** :- if some linker not in PATH, uncomment OLDPATH and required SETs PATH.
set XUPX=upx --8086 --best
:- or use set XUPX=
:- if you don't want to use it
:-********************************************************************** ::set OLDPATH=%PATH%
:- (optionally) which linker to use: ::set PATH=%TC_BASE%;%PATH%
:- (otherwise will be determined automatically) ::set PATH=%TCPP_BASE%\bin;%PATH%
:- ::set PATH=%TCPP3_BASE%\bin;%PATH%
:- WARNING TLINK needs to be in your PATH! ::set PATH=%BC_BASE%\bin;%PATH%
:-********************************************************************** ::set PATH=%MSC_BASE%\bin;%PATH%
::set PATH=%WATCOM%\binw;%PATH%
:- MSC searches libraries only through LIB variable.
::set LIB=%MSC_BASE%\lib
:-----------------------------------------------------------------------
:- define which linker to use OR it will be determined AUTOMATICALLY.
:- Turbo Link :- 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,189 +41,175 @@ 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_VERIFY
FL_VERIFY:
mov ah,4 ; verify sector(s)
jmp short fl_common
global FL_READ global FL_READ
FL_READ: FL_READ:
mov ah,2 ; read sector(s) mov ah,2 ; read sector(s)
jmp short fl_common jmp short fl_common
global FL_VERIFY
FL_VERIFY:
mov ah,4 ; verify 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. ror cl,1 ; bits 8-9 of cylinder number...
ror cl,1 ; ...to bits 6-7 in CL
or cl,[bp+10] ; sector number (bits 0-5)
xchg ch,cl ; ch=low 8 bits of cyl number mov al,[bp+8] ; number of sectors
ror cl,1 ; bits 8-9 of cylinder number... les bx,[bp+4] ; 32-bit buffer ptr
ror cl,1 ; ...to bits 6-7 in CL mov dl,[bp+16] ; drive (if or'ed 80h its hard drive)
or cl,[bp+0Ah] ; or in the sector number (bits 0-5) int 13h ; process sectors
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
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 pop ds
int 13h ; read from/write to drive pop si
pop bp
pop si mov al,ah ; place error code into al
pop ds mov ah,0
ret 8
pop bp
mov al,ah ; place any error code into al
mov ah,0 ; zero out ah
ret 8
; ;
; void ASMPASCAL fl_readkey (void); ; void ASMPASCAL fl_readkey (void);
; ;
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
push es push es
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"
OBJS=floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj
LIBOBJS=+floppy +rdpcclk +wrpcclk +wratclk
# MICROSOFT C # Build the LIBRARY ####################################################
# -----------
#MODEL = s
#CFLAGS = /c /Gs /A$(MODEL)
#AFLAGS = /Mx /Dmem$(MODEL)=1
#TERM = ;
# BORLAND C all: ..\lib\device.lib
# -----------
#MODEL = s
#CFLAGS = -c -m$(MODEL)
#AFLAGS = /Mx /Dmem$(MODEL)=1
#LIBFLAGS = /c
OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj ..\lib\device.lib: $(OBJS)
-$(RM) $*.lib
$(LIBUTIL) $(LIBFLAGS) $* $(LIBOBJS) $(LIBTERM)
LIBOBJS= +floppy +rdpcclk +wrpcclk +wratclk $(OBJS): $(DEPENDS)
########################################################################
# Build the LIBRARY
# -----------------
all: production
production: ..\lib\device.lib
..\lib\device.lib: device.lib
copy device.lib ..\lib
clobber: clean
-$(RM) device.lib status.me ..\lib\device.lib
clean: 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

@ -29,26 +29,17 @@
struct config { /* Configuration variables */ struct config { /* Configuration variables */
UBYTE cfgDosDataUmb; UBYTE cfgDosDataUmb;
BYTE cfgBuffers; /* number of buffers in the system */ BYTE cfgBuffers; /* number of buffers in the system */
UBYTE cfgFiles; /* number of available files */ UBYTE cfgFiles; /* number of available files */
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
; ;
@ -154,8 +154,10 @@ INIT_CALL_XMSCALL:
push es ; driver address ("jmp es:cx") push es ; driver address ("jmp es:cx")
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
@ -163,8 +165,8 @@ 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 */
@ -82,47 +189,16 @@ COUNT DosDevIOctl(lregs * r)
switch (r->AL) switch (r->AL)
{ {
case 0x0b:
/* skip, it's a special case. */
NetDelay = r->CX;
if (r->DX)
NetRetry = r->DX;
break;
case 0x00: case 0x00:
case 0x01:
case 0x02:
case 0x03:
case 0x06:
case 0x07:
case 0x0a:
case 0x0c:
case 0x10:
{
unsigned flags;
/* Test that the handle is valid and */
/* get the SFT block that contains the SFT */
if ((s = get_sft(r->BX)) == (sft FAR *) - 1)
return DE_INVLDHNDL;
attr = s->sft_dev->dh_attr;
flags = s->sft_flags;
switch (r->AL)
{
case 0x00:
/* Get the flags from the SFT */ /* 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;
/* Undocumented: AL should get the old value */
r->AL = (UBYTE)flags;
break; break;
case 0x02: case 0x0a:
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;
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 0x0c: case 0x06:
nMode = C_GENIOCTL; if (!(flags & SFT_FDEVICE))
goto IoCharCommon;
default: /* 0x10 */
nMode = C_IOCTLQRY;
IoCharCommon:
if ((flags & SFT_FDEVICE) &&
( (r->AL <= 0x03 && (attr & ATTR_IOCTL))
|| r->AL == 0x06 || r->AL == 0x07
|| (r->AL == 0x10 && (attr & ATTR_QRYIOCTL))
|| (r->AL == 0x0c && (attr & ATTR_GENIOCTL))))
{ {
CharReqHdr.r_unit = 0; r->AL = s->sft_posit >= s->sft_size ? (UBYTE)0 : (UBYTE)0xFF;
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; break;
} }
return DE_INVLDFUNC; /* fall through */
}
break;
}
default: /* block IOCTL: 4, 5, 8, 9, d, e, f, 11 */ case 0x07:
if (!(flags & SFT_FDEVICE))
/*
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; r->AL = 0;
goto IoBlockCommon; break;
} }
return DE_INVLDFUNC; /* fall through */
case 0x09:
case 0x02:
case 0x03:
case 0x0c:
case 0x10:
if (!(flags & SFT_FDEVICE))
return DE_INVLDFUNC;
CharReqHdr.r_unit = 0; /* ??? not used for devices --avb */
goto execrequest;
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) return DE_INVLDDRV;
{
r->DX = ATTR_REMOTE;
}
else
{
if (!dpbp)
{
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:
nMode = C_GENIOCTL; case 0x0d:
goto IoBlockCommon; if ((r->CX & ~0x4021) == 0x084A)
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; default: /* 0x0f */
goto IoLogCommon; execrh(&CharReqHdr, dev);
default: /* 0x0f */ if (CharReqHdr.r_status & S_ERROR)
nMode = C_SETLDEV;
IoLogCommon:
if (attr & ATTR_GENIOCTL)
{ {
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
CharReqHdr.r_command = nMode; return DE_ACCESS;
execrh((request FAR *) & CharReqHdr, dpbp->dpb_device);
if (CharReqHdr.r_status & S_ERROR)
{
CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13;
return DE_ACCESS;
}
else
{
r->AL = CharReqHdr.r_unit;
return SUCCESS;
}
} }
return DE_INVLDFUNC; r->AL = CharReqHdr.r_unit;
} } /* switch */
break;
}
return SUCCESS; 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,24 +86,25 @@ 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);
if (fmemcmp(p, "CONFIG", 6) == 0) /* UPXed */
drv = p[-2]; /* boot drive was stored there by stub from exeflat.c */
else
{
drv = LoL->BootDrive;
p[-2] = drv; /* used by initdisk.c:ReadAllPartitionTables() */
p = (UBYTE FAR*)&LowKernelConfig;
}
drv = *p + 1; drv++;
*(DWORD FAR *)(p+2) = 0; if (drv > 0x80)
} drv = 3; /* C: */
else LoL->BootDrive = drv;
{
*p = drv - 1;
fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig));
}
if (drv >= 0x80) fmemcpy(&InitKernelConfig, p, sizeof InitKernelConfig);
drv = 3; /* C: */ }
LoL->BootDrive = drv;
setup_int_vectors(); setup_int_vectors();
@ -114,22 +112,14 @@ VOID ASMCFUNC FreeDOSmain(void)
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 */
/* File System parameters */ /*p->ps_stack = NULL;*/ /* user stack pointer - int 21 */
/* maximum open files */
p->ps_maxfiles = 20;
fmemset(p->ps_files, 0xff, 20);
/* open file table pointer */ /* File System parameters */
p->ps_filetab = p->ps_files; p->ps_maxfiles = sizeof p->ps_files; /* size of file table */
fmemset(p->ps_filetab = p->ps_files, 0xff, sizeof p->ps_files);
/* first command line argument */ /*p->ps_fcb1.fcb_drive = 0;*/ /* 1st command line argument */
/* p->ps_fcb1.fcb_drive = 0; already set */ /*fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);*/
fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /*p->ps_fcb2.fcb_drive = 0;*/ /* 2nd command line argument */
/* second command line argument */ /*fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);*/
/* p->ps_fcb2.fcb_drive = 0; already set */
fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);
/* local command line */ /* this area reused for master environment */
/* p->ps_cmd.ctCount = 0; command tail, already set */ /*p->ps_cmd.ctCount = 0;*/ /* local command line */
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ /*p->ps_cmd.ctBuffer[0] = '\r';*/ /* 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++)
@ -331,10 +296,12 @@ STATIC void init_kernel(void)
/* Init the file system one more time */ /* Init the file system one more time */
FsConfig(); FsConfig();
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 stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */
/* (insert /D, /Y as first argument) */
if (master_env[0] == '\0') /* some shells panic on empty master env. */ if (askCommand & (ASK_TRACE | ASK_SKIPALL))
strcpy(master_env, "PATH=.");
fmemcpy(MK_FP(DOS_PSP + 8, 0), master_env, sizeof(master_env));
/* process 0 */
/* Execute command.com from the drive we just booted from */
memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer));
strcpy(Cmd.ctBuffer, Config.cfgInitTail);
for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++)
if (Cmd.ctBuffer[Cmd.ctCount] == '\r')
break;
/* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */
/* 3 for string + 2 for "\r\n" */
if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 5)
{ {
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--;
{ q[3] = q[0];
for (q = &Cmd.ctBuffer[Cmd.ctCount + 1]; q >= p; q--) } while (q > p);
q[3] = q[0];
memcpy(p, insertString, 3);
break;
}
}
/* save buffer -- on the stack it's fine here */
Config.cfgInitTail = Cmd.ctBuffer;
} }
p[0] = '/', p[1] = 'Y', p[2] = ' '; /* single step AUTOEXEC */
if (askCommand & ASK_SKIPALL)
p[1] = 'D'; /* disable AUTOEXEC */
} }
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++)
{ {
dpb->dpb_next = dpb + 1; int i = 0;
dpb->dpb_unit = LoL->nblkdev; do
dpb->dpb_subunit = Index;
dpb->dpb_device = dhp;
dpb->dpb_flags = M_CHANGED;
if ((LoL->CDSp != 0) && (LoL->nblkdev < LoL->lastdrive))
{ {
LoL->CDSp[LoL->nblkdev].cdsDpb = dpb; dpb->dpb_next = dpb + 1;
LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV; dpb->dpb_unit = LoL->nblkdev;
} if (LoL->nblkdev < LoL->lastdrive && LoL->CDSp)
++dpb; {
++LoL->nblkdev; LoL->CDSp[LoL->nblkdev].cdsDpb = dpb;
LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV;
}
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 :-)
@ -674,50 +609,43 @@ STATIC VOID InitSerialPorts(VOID)
remove the floppy/bootable CD from the drive. remove the floppy/bootable CD from the drive.
user has some seconds to hit ANY key to continue user has some seconds to hit ANY key to continue
to boot from floppy/cd, else the system is to boot from floppy/cd, else the system is
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,34 +657,30 @@ 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')
{ {
/* user has hit a key, continue to boot from floppy/CD */ unsigned key = GetBiosKey(-1); /* remove key from buffer */
printf("\n"); if ((UBYTE)key != 'h' && (UBYTE)key != 'H')
return; /* user has hit a key, continue to boot from floppy/CD */
return;
} }
/* reboot from harddisk */ /* reboot from harddisk */
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;
(*reboot)(); r.CX = 0x0001;
r.DX = 0x0080;
r.BX = 0x7c00;
r.ES = 0;
init_call_intr(0x13, &r);
} }
/* now jump and run */
((void (far*)(void)) MK_FP(0,0x7c00))(); /* jump to boot sector */
} }

View File

@ -1,5 +1,5 @@
# #
# Makefile for Borland C++ 3.1 for kernel.sys # makefile for kernel.sys
# #
# $Id$ # $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,98 +29,87 @@ 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 \
$(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \
$(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \
$(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \
$(HDR)version.h dyndata.h $(HDR)version.h dyndata.h
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
#the printf for INIT_TEXT - yet another special case, this file includes prf.c iasmsupt.obj: asmsupt.asm
iprf.obj: iprf.c prf.c $(HDR)portab.h $(TARGET).lnk $(NASM) $(NASMFLAGS) -D_INIT asmsupt.asm -o$*.obj
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj # the printf for INIT_TEXT - yet another special case, this file includes prf.c
iprf.obj: iprf.c prf.c $(HDR)portab.h
$(CC) $(INITCFLAGS) $*.c
$(INITPATCH) $*.obj
########################################################################
clean:
-$(RM) *.bak *.cod *.crf *.err *.lnk *.lst *.map *.obj *.xrf
clobber: clean
-$(RM) kernel.exe status.me

5
kernel/msc.cfg Normal file
View File

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

View File

@ -502,7 +502,7 @@ VOID DosUpFString(char FAR * str)
COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize, COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize,
VOID FAR * buf) VOID FAR * buf)
{ {
struct nlsPackage FAR *nls; /* NLS package to use to return the info from */ struct nlsPackage FAR *nls; /* NLS package to use to return the info from */
log(("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", log(("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n",
subfct, cp, cntry, bufsize)); subfct, cp, cntry, bufsize));
@ -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 */ /* Direct access to the data */
return (subfct == NLS_DOS_38) return nlsGetData(nls, subfct, buf, bufsize);
? mux38(nls->cp, nls->cntry, bufsize, buf) cp = nls->cp;
: mux65(subfct, nls->cp, nls->cntry, bufsize, buf); cntry = nls->cntry;
} }
/* Direct access to the data */ /* If the NLS pkg is not loaded into memory or the direct-access
return nlsGetData(nls, subfct, buf, bufsize); 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

@ -47,17 +47,12 @@ segment HMA_TEXT
; ;
; void exec_user(iregs far *irp, int disable_a20) ; void exec_user(iregs far *irp, int disable_a20)
; ;
global _exec_user global _exec_user
_exec_user: _exec_user:
%ifndef WATCOM
; PUSH$ALL ; exec_user declared with attribute `aborts'
; mov ds,[_DGROUP_] pop ax ; return address (unused)
; cld %endif
;
;
;
pop ax ; return address (unused)
pop ax ; irp (user ss:sp) pop ax ; irp (user ss:sp)
pop dx pop dx
pop cx ; disable A20? pop cx ; disable A20?
@ -280,10 +275,13 @@ _spawn_int23:
; prepare to call process 0 (the shell) from P_0() in C ; prepare to call process 0 (the shell) from P_0() in C
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
call _P_0 ; no return, allow parameter fetch from C %ifndef WATCOM
call _P_0 ; no return, allow parameter fetch from C
%else
; P_0 declared with attribute `aborts'
jmp _P_0 ; no return, allow parameter fetch from C
%endif

View File

@ -132,9 +132,14 @@ VOID ASMCFUNC DosIdle_int(void);
int ParseDosName(const char *, char *, BOOL); 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,21 +230,20 @@ 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]
#endif #endif
/* ioctl.c */ /* ioctl.c */
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

File diff suppressed because it is too large Load Diff

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
$(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM)
$(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i
$(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM)
-$(RM) *.OBJ
libm.lib: $(CLIB) $(DEPENDS)
-$(RM) $*.lib
$(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM)
$(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i
$(LIBUTIL) $* $(MATH_INSERT) $(LIBTERM)
-$(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\*.*
.asm.obj : # Implicit Rules #######################################################
$(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm
# *Implicit Rules* .asm.obj:
.c.obj : $(NASM) $(NASMFLAGS) $<
$(CC) $(CFLAGS) $*.c
.cpp.obj : .c.obj:
$(CC) $(CFLAGS) $*.cpp $(CC) $(CFLAGS) $<
.cpp.obj:
$(CC) $(CFLAGS) $<
.c.com:
$(CL) $(CFLAGST) $<
.c.exe:
$(CL) $(CFLAGSC) $<

31
mkfiles/msc.mak Normal file
View File

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

View File

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

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
# -w=<num> set warning level number
# -we treat all warnings as errors
# -zq operate quietly
#
# -j change char default from unsigned to signed
# -ms small memory model (small code/small data) # -ms small memory model (small code/small data)
# -j change char default from unsigned to signed
#-nc=<id> set code class name
#-nd=<id> set data segment name
#-nm=<file> set module name
#-nt=<id> set name of text segment
# -g=<id> set code group name
# -os -> favor code size over execution time in optimizations # -os -> favor code size over execution time in optimizations
# -s remove stack overflow checks # -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.) # -ze enable extensions (i.e., near, far, export, etc.)
# -zl remove default library information # -zl remove default library information
# -zp=<num> pack structure members with alignment {1,2,4,8,16} # -zp=<num> pack structure members with alignment {1,2,4,8,16}
# -zq operate quietly
# #
# -3 optimization for 386 - given in CONFIG.MAK, not here # -3 optimization for 386 - given in $(CPUOPT)
# -g=<id> set code group name
# -nc=<id> set code class name
# -nd=<id> set data segment name
# -nm=<file> set module name
# -nt=<id> set name of text segment
# #
ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r 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

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

View File

@ -52,8 +52,6 @@ large portions copied from task.c
#define BUFSIZE 32768u #define 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);
} }
@ -282,31 +280,33 @@ int main(int argc, char **argv)
if (UPX) if (UPX)
{ {
/* 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