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

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

View File

@ -4,26 +4,28 @@
# $Id$
#
!include "../mkfiles/generic.mak"
production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin
########################################################################
fat12com.bin: boot.asm
$(NASM) -dISFAT12 boot.asm -ofat12com.bin
all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin
fat16com.bin: boot.asm
$(NASM) -dISFAT16 boot.asm -ofat16com.bin
fat12.bin: boot.asm $(DEPENDS)
$(NASM) -DISFAT12 boot.asm -o$*.bin
fat32chs.bin: boot32.asm
$(NASM) boot32.asm -ofat32chs.bin
fat16.bin: boot.asm $(DEPENDS)
$(NASM) -DISFAT16 boot.asm -o$*.bin
fat32lba.bin: boot32lb.asm
$(NASM) boot32lb.asm -ofat32lba.bin
fat32chs.bin: boot32.asm $(DEPENDS)
$(NASM) boot32.asm -o$*.bin
clobber: clean
-$(RM) *.bin status.me
fat32lba.bin: boot32lb.asm $(DEPENDS)
$(NASM) boot32lb.asm -o$*.bin
########################################################################
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
:- $Id$
:-----------------------------------------------------------------------
:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386]
:- option case is significant !!
:-----------------------------------------------------------------------
set XERROR=1
if "%XERROR%" == "" goto noenv
if "%1" == "-r" call clobber.bat
if "%1" == "-r" shift
set XERROR=
if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup!
if not exist config.bat goto abort
call config.bat
if "%LAST%" == "" goto noenv
:-----------------------------------------------------------------------
:- following is command line handling
@ -26,10 +30,10 @@ call config.bat
if "%1" == "fat32" set XFAT=32
if "%1" == "fat16" set XFAT=16
if "%1" == "msc" set COMPILER=MSCL8
if "%1" == "msc" set COMPILER=MSC
if "%1" == "wc" set COMPILER=WATCOM
if "%1" == "tc" set COMPILER=TC2
if "%1" == "tcpp" set COMPILER=TURBOCPP
if "%1" == "tc" set COMPILER=TC
if "%1" == "tcpp" set COMPILER=TCPP
if "%1" == "86" set XCPU=86
if "%1" == "186" set XCPU=186
@ -41,7 +45,8 @@ if not "%1" == "" goto loop_commandline
if "%COMPILER%" == "" echo you MUST define a COMPILER variable in CONFIG.BAT
if "%COMPILER%" == "" goto abort
call default.bat
call defaults.bat
if "%LAST%" == "" goto noenv
:-----------------------------------------------------------------------
:- finally - we are going to compile
@ -51,50 +56,51 @@ echo.
echo Process UTILS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd utils
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process LIB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\lib
%MAKE%
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process DRIVERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\drivers
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process BOOT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\boot
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process SYS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\sys
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
echo.
echo Process KERNEL +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo.
cd ..\kernel
%MAKE% production
call %MAKE% all
if errorlevel 1 goto abort-cd
cd ..
:- if you like, put some finalizing commands (like copy to floppy)
:- into build2.bat
:- if you like, put finalizing commands (like copy to floppy) into build2.bat
if exist build2.bat call build2
set XERROR=
if exist build2.bat call build2.bat
echo.
echo Processing is done.
@ -104,9 +110,9 @@ goto end
:abort-cd
cd ..
:noenv
:abort
echo Compilation was aborted!
set XERROR=1
:end
default.bat clearset
defaults.bat clearset

View File

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

View File

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

View File

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

177
config.b
View File

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

View File

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

87
defaults.bat Normal file
View File

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

View File

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

View File

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

155
filelist
View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

5
kernel/msc.cfg Normal file
View File

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

View File

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

View File

@ -47,17 +47,12 @@ segment HMA_TEXT
;
; void exec_user(iregs far *irp, int disable_a20)
;
global _exec_user
global _exec_user
_exec_user:
; PUSH$ALL
; mov ds,[_DGROUP_]
; cld
;
;
;
pop ax ; return address (unused)
%ifndef WATCOM
; exec_user declared with attribute `aborts'
pop ax ; return address (unused)
%endif
pop ax ; irp (user ss:sp)
pop dx
pop cx ; disable A20?
@ -280,10 +275,13 @@ _spawn_int23:
; 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:
%ifndef WATCOM
; reloc_call_p_0 declared with attribute `aborts'
pop ax ; return address (32-bit, unused)
pop ax
%endif
pop ax ; fetch parameter 0 (32-bit) from the old stack
pop dx
mov ds,[cs:_DGROUP_]
@ -293,4 +291,9 @@ reloc_call_p_0:
sti
push dx ; pass parameter 0 onto the new stack
push ax
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);
/* error.c */
VOID dump(void);
VOID panic(BYTE * s);
VOID fatal(BYTE * err_msg);
#ifdef __WATCOMC__
# pragma aux panic aborts
# pragma aux fatal aborts
#endif
/* fatdir.c */
VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart);
@ -225,21 +230,20 @@ void FcbCloseAll(void);
UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First);
/* intr.asm */
COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp);
UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count);
int ASMPASCAL res_DosExec(int mode, exec_blk *, PCStr);
unsigned ASMPASCAL res_read(int fd, void *buf, unsigned count);
#ifdef __WATCOMC__
#pragma aux (pascal) res_DosExec modify exact [ax bx dx es]
#pragma aux (pascal) res_read modify exact [ax bx cx dx]
# pragma aux (pascal) res_DosExec modify exact [ax bx dx es]
# pragma aux (pascal) res_read modify exact [ax bx cx dx]
#endif
/* ioctl.c */
COUNT DosDevIOctl(lregs * r);
/* memmgr.c */
seg far2para(VOID FAR * p);
seg long2para(ULONG size);
void FAR *add_far(void FAR * fp, unsigned off);
VOID FAR *adjust_far(const void FAR * fp);
VFP adjust_far(CVFP);
COUNT DosMemAlloc(UWORD size, COUNT mode, seg * para, UWORD * asize);
COUNT DosMemLargest(UWORD * size);
COUNT DosMemFree(UWORD para);
@ -364,12 +368,16 @@ const UWORD *is_leap_year_monthdays(UWORD year);
UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth);
/* task.c */
VOID new_psp(seg para, seg cur_psp);
VOID child_psp(seg para, seg cur_psp, int psize);
VOID return_user(void);
void new_psp(seg_t para, seg_t cur_psp);
void child_psp(seg_t para, seg_t cur_psp, seg_t beyond);
void return_user(void);
COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp);
ULONG SftGetFsize(int sft_idx);
VOID InitPSP(VOID);
#ifdef __WATCOMC__
# pragma aux return_user aborts
#endif
/* newstuff.c */
int SetJFTSize(UWORD nHandles);
@ -391,7 +399,11 @@ UWORD get_machine_name(BYTE FAR * netname);
VOID set_machine_name(BYTE FAR * netname, UWORD name_num);
/* procsupt.asm */
VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20);
void ASMCFUNC exec_user(iregs FAR *, int disable_a20);
#ifdef __WATCOMC__
# pragma aux (cdecl) exec_user aborts
#endif
/* new by TE */
@ -403,5 +415,4 @@ VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20);
ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8)
*/
#define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; }
#define ASSERT_CONST(x) { typedef struct { char _[(x) ? 1 : -1]; } _; }

View File

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

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
-f-
-k-
-vi-
-wpro
-weas
-wpre
-w
-g1
-I..\hdr
-O -Z
-p
-v- -I. -D__STDC__=0 -DKERNEL -DI86 -DPROTO -DASMSUPT
-v-
-w -g1
-I..\hdr
-DI86
-zCHMA_TEXT

5
kernel/vc.cfg Normal file
View File

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

9
kernel/wc.cfg Normal file
View File

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

11
kernel/wci.cfg Normal file
View File

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

View File

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

10
mkfiles/bc.mak Normal file
View File

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

View File

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

View File

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

31
mkfiles/msc.mak Normal file
View File

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

View File

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

16
mkfiles/tc.mak Normal file
View File

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

View File

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

View File

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

42
mkfiles/tcpp.mak Normal file
View File

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

7
mkfiles/tcpp3.mak Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

7
sys/turboc.cfg Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

7
utils/turboc.cfg Normal file
View File

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

View File

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