├── .gitattributes ├── .gitignore ├── MAKEPKGS.BAT ├── README.md ├── RELEASE.BAT ├── bin ├── autoexec.bat ├── config.sys └── install.bat ├── boot ├── boot.asm ├── boot32.asm ├── boot32lb.asm ├── makefile └── oemboot.asm ├── build.bat ├── buildall.bat ├── clean.bat ├── clobber.bat ├── config.b ├── config.m ├── default.bat ├── docs ├── CNAME ├── _config.yml ├── bugs.txt ├── build.txt ├── config.txt ├── contrib.txt ├── copying ├── fdkernel.lsm ├── history.txt ├── index.md ├── intfns.txt ├── lfnapi.txt ├── memdisk.txt ├── mkboot.txt ├── nls.txt ├── readme.cvs ├── readme.txt └── sys.txt ├── drivers ├── floppy.asm ├── makefile ├── rdpcclk.asm ├── wratclk.asm └── wrpcclk.asm ├── filelist ├── hdr ├── algnbyte.h ├── algndflt.h ├── buffer.h ├── cds.h ├── clock.h ├── date.h ├── dcb.h ├── debug.h ├── device.h ├── dirmatch.h ├── dsk.h ├── dyn.h ├── error.h ├── exe.h ├── fat.h ├── fcb.h ├── file.h ├── fnode.h ├── kbd.h ├── kconfig.h ├── lol.h ├── mcb.h ├── network.h ├── nls.h ├── pcb.h ├── portab.h ├── process.h ├── sft.h ├── stacks.inc ├── tail.h ├── time.h ├── version.h ├── win.h └── xstructs.h ├── kernel ├── apisupt.asm ├── asmsupt.asm ├── blockio.c ├── break.c ├── chario.c ├── config.c ├── config.h ├── console.asm ├── country.asm ├── cpu.asm ├── dosfns.c ├── dosidle.asm ├── dsk.c ├── dyndata.h ├── dyninit.c ├── entry.asm ├── error.c ├── execrh.asm ├── fatdir.c ├── fatfs.c ├── fattab.c ├── fcbfns.c ├── globals.h ├── init-dat.h ├── init-mod.h ├── initclk.c ├── initdisk.c ├── inithma.c ├── initoem.c ├── int2f.asm ├── inthndlr.c ├── intr.asm ├── intwrap.asm ├── io.asm ├── io.inc ├── ioctl.c ├── iprf.c ├── irqstack.asm ├── kernel.asm ├── kernel.cfg ├── kernel.ld ├── lfnapi.c ├── ludivmul.inc ├── main.c ├── makefile ├── memdisk.asm ├── memmgr.c ├── misc.c ├── network.c ├── newstuff.c ├── nls.c ├── nls │ ├── 001-437.hc │ ├── 001-437.unf │ ├── 001-437.up │ ├── 049-850.hc │ ├── 049-850.unf │ ├── 049-850.up │ └── files ├── nls_hc.asm ├── nls_load.c ├── nlssupt.asm ├── prf.c ├── printer.asm ├── procsupt.asm ├── proto.h ├── segs.inc ├── serial.asm ├── strings.c ├── sysclk.c ├── syspack.c ├── systime.c ├── task.c └── turboc.cfg ├── lib └── makefile ├── makefile ├── mkfiles ├── bc3.mak ├── bc5.mak ├── gcc.mak ├── generic.mak ├── mscl8.mak ├── owlinux.mak ├── owwin.mak ├── tc2.mak ├── tc3.mak ├── turbocpp.mak └── watcom.mak ├── share ├── makefile ├── share.c └── share.hlp ├── sys ├── bin2c.c ├── fdkrncfg.c ├── makefile ├── sys.c └── talloc.c ├── tests └── absread │ ├── absread.c │ └── build.bat └── utils ├── echoto.bat ├── exeflat.c ├── indent.ini ├── makefile ├── patchobj.c ├── proto.bat ├── relocinf.c ├── rmfiles.bat └── wlinker.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=crlf 2 | *.up -text 3 | *.UP -text 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object Files 2 | *.OBJ 3 | *.obj 4 | 5 | # List Files 6 | *.LST 7 | *.lst 8 | 9 | # Map files 10 | *.MAP 11 | *.map 12 | *.SYM 13 | *.sym 14 | 15 | # Executable files 16 | *.EXE 17 | *.exe 18 | *.COM 19 | *.com 20 | 21 | # Bin files 22 | *.BIN 23 | *.bin 24 | 25 | # Libraries 26 | *.LIB 27 | *.lib 28 | 29 | # generated text files 30 | sys/*.h 31 | sys/*.H 32 | kernel/*.lnk 33 | kernel/*.LNK 34 | 35 | # FreeDOS build tools configuration 36 | config.bat 37 | config.mak 38 | 39 | kernel/*.SYS 40 | kernel/*.sys 41 | bin/[kK]*.SYS 42 | bin/[kK]*.sys 43 | bin/COMMAND.COM 44 | bin/command.com 45 | bin/COUNTRY.SYS 46 | bin/country.sys 47 | 48 | # backup files 49 | *.orig 50 | *~ 51 | *.diff 52 | *.rej 53 | -------------------------------------------------------------------------------- /MAKEPKGS.BAT: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | IF "%1"=="" GOTO USAGE 3 | REM assumes ran in same directory as this file, ie base of kernel source 4 | SET BASEPATH=%CD% 5 | CD .. 6 | 7 | ECHO create source copy 8 | if EXIST SOURCE RMDIR /S /Q SOURCE > NUL 9 | MKDIR SOURCE 10 | ECHO \.svn>SOURCE\SKIPLIST 11 | ECHO .git>>SOURCE\SKIPLIST 12 | XCOPY %BASEPATH% SOURCE\ke%1 /S /V /I /Q /G /H /R /Y /EXCLUDE:SOURCE\SKIPLIST 13 | DEL SOURCE\SKIPLIST > NUL 14 | ECHO ensuring clean 15 | PUSHD . 16 | CD SOURCE\ke%1 17 | CALL clobber.bat 18 | POPD 19 | PAUSE 20 | 21 | SET VERSION=%1 22 | SET LSMRET=SRC 23 | SET LSMFILE=SOURCE\ke%1\docs\fdkernel.lsm 24 | GOTO LSM 25 | :SRC 26 | ECHO zipping source 27 | 7z.exe a -tzip -mx9 -mpass15 -r ke%1s.zip SOURCE\* 28 | ECHO creating APPINFO and expected packaging dir structure 29 | ECHO using working configuration file 30 | ::COPY trunk\CONFIG.BAT SOURCE\ke%1 > NUL 31 | CD SOURCE\ke%1 32 | 33 | ECHO build and packaging 34 | SET VERSION=%1 (FAT12/FAT16) 35 | SET FAT=16 36 | SET BZKRET=F16 37 | GOTO BZK 38 | :F16 39 | SET VERSION=%1 (FAT12/FAT16/FAT32) 40 | SET FAT=32 41 | SET BZKRET=F32 42 | GOTO BZK 43 | :F32 44 | ECHO clean up 45 | CD ..\.. 46 | RMDIR /S /Q SOURCE > NUL 47 | ECHO Done. 48 | SET BZKRET= 49 | GOTO DONE 50 | 51 | 52 | :BZK 53 | ECHO build kernel %VERSION% 54 | CALL build.bat /D KERNEL_VERSION /V "%1 " 86 win upx fat%FAT% 55 | DEL BIN\K??86??.sys 56 | SET LSMRET=BZK_2 57 | SET LSMFILE=docs\fdkernel.lsm 58 | GOTO LSM 59 | :BZK_2 60 | SET LSMRET= 61 | ECHO zipping FAT%FAT% release version 62 | 7z.exe a -tzip -mx9 -mpass15 -r ..\..\ke%1_86f%FAT%.zip BIN\* DOCS\* 63 | ECHO restructuring and zipping update package 64 | DEL BIN\K??86??.* > NUL 65 | MKDIR DOC 66 | MKDIR DOC\KERNEL 67 | COPY DOCS\* DOC\KERNEL\ 68 | MKDIR APPINFO 69 | MOVE DOC\KERNEL\*.lsm APPINFO\ 70 | 7z.exe a -tzip -mx9 -mpass15 -r ..\..\kernel%FAT%.zip APPINFO\* BIN\* DOC\* 71 | ECHO cleaning up between builds 72 | CALL clobber.bat 73 | RMDIR /S /Q DOC 74 | RMDIR /S /Q APPINFO 75 | GOTO %BZKRET% 76 | 77 | :LSM 78 | ECHO Begin3>%LSMFILE% 79 | ECHO Title: The FreeDOS Kernel>>%LSMFILE% 80 | ECHO Version: %VERSION%>>%LSMFILE% 81 | ECHO Entered-date: %DATE%>>%LSMFILE% 82 | ECHO Description: The FreeDOS Kernel>>%LSMFILE% 83 | ECHO Keywords: kernel, FreeDOS, DOS, MSDOS>>%LSMFILE% 84 | ECHO Author: (developers: can be reached on the freedos-kernel mailing list)>>%LSMFILE% 85 | ECHO Maintained-by: freedos-kernel@lists.sourceforge.net>>%LSMFILE% 86 | ECHO Primary-site: http://freedos.sourceforge.net/kernel/>>%LSMFILE% 87 | ECHO Alternate-site: http://www.fdos.org/kernel/>>%LSMFILE% 88 | ECHO Alternate-site: https://github.com/PerditionC/fdkernel>>%LSMFILE% 89 | ECHO Alternate-site: https://freedos.svn.sourceforge.net/svnroot/freedos>>%LSMFILE% 90 | ECHO Original-site: http://www.gcfl.net/pub/FreeDOS/kernel>>%LSMFILE% 91 | ECHO Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom C or Turbo C, NASM, UPX)>>%LSMFILE% 92 | ECHO Copying-policy: GPL2>>%LSMFILE% 93 | ECHO End>>%LSMFILE% 94 | SET LSMFILE= 95 | SET VERSION= 96 | GOTO %LSMRET% 97 | 98 | :USAGE 99 | ECHO Build kernel packages (interim builds or release without tagging) - usage: RELEASE {VERSION} e.g. RELEASE 2039 100 | :DONE 101 | CD %BASEPATH% 102 | SET BASEPATH= 103 | 104 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fdkernel 2 | ======== 3 | 4 | FreeDOS kernel - branch from 2042 SVN 0xFD kernel 5 | 6 | http://www.fdos.org/kernel/ 7 | 8 | The FreeDOS kernel implements the core MS/PC-DOS (R) compatible functions. It is derived from Pat Villani's DOS-C kernel and released under the GPL v2. Please see http://www.freedos.org/ for more details about the FreeDOS (TM) Project. Compiled kernels ready to use (just copy kernel.sys over an existing install) are available at http://www.fdos.org/kernel/testing/git/ - also available are the source archive and fdpkg compatible packages. 9 | 10 | 11 | This version of the kernel is intended only for 8086+ or 80386+ IBM compatible computers in continuation of the goals of the FreeDOS Project. Please see http://www.fdos.org/kernel for my 0xDC kernel that is work on merging back in some of the original portability aspects and other supported features at the cost of some compatibility with older hardware/software. 12 | 13 | Please feel free to email me - PerditionC@gmail.com 14 | Jan 2014 15 | -------------------------------------------------------------------------------- /RELEASE.BAT: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | IF "%1"=="" GOTO USAGE 3 | REM goto to just below trunk and tags directory, assume ran in trunk directory 4 | CD .. 5 | 6 | ECHO tag SVN with release version - svn copy trunk/ tags/ke%1 7 | svn copy https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/trunk/ https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/tags/ke%1 -m "Tag kernel release %1" 8 | PAUSE 9 | ECHO svn export to get clean tree 10 | if EXIST SOURCE RMDIR /S /Q SOURCE > NUL 11 | svn export https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/tags/ke%1 SOURCE\ke%1 12 | REM svn export https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/trunk SOURCE\ke%1 13 | 14 | SET VERSION=%1 15 | SET LSMRET=SRC 16 | SET LSMFILE=SOURCE\ke%1\docs\fdkernel.lsm 17 | GOTO LSM 18 | :SRC 19 | ECHO zipping source 20 | 7z.exe a -tzip -mx9 -mpass15 -r ke%1s.zip SOURCE\* 21 | ECHO creating APPINFO and expected packaging dir structure 22 | ECHO using working configuration file 23 | COPY trunk\CONFIG.BAT SOURCE\ke%1 > NUL 24 | CD SOURCE\ke%1 25 | 26 | ECHO build and packaging 27 | SET VERSION=%1 (FAT12/FAT16) 28 | SET FAT=16 29 | SET BZKRET=F16 30 | GOTO BZK 31 | :F16 32 | SET VERSION=%1 (FAT12/FAT16/FAT32) 33 | SET FAT=32 34 | SET BZKRET=F32 35 | GOTO BZK 36 | :F32 37 | ECHO clean up 38 | CD ..\.. 39 | RMDIR /S /Q SOURCE > NUL 40 | ECHO Done. 41 | SET BZKRET= 42 | GOTO DONE 43 | 44 | 45 | :BZK 46 | ECHO build kernel %VERSION% 47 | CALL build.bat /D KERNEL_VERSION /V "%1 " 86 upx fat%FAT% 48 | DEL BIN\K??86??.sys 49 | SET LSMRET=BZK_2 50 | SET LSMFILE=docs\fdkernel.lsm 51 | GOTO LSM 52 | :BZK_2 53 | SET LSMRET= 54 | ECHO zipping FAT%FAT% release version 55 | 7z.exe a -tzip -mx9 -mpass15 -r ..\..\ke%1_86f%FAT%.zip BIN\* DOCS\* 56 | ECHO restructuring and zipping update package 57 | DEL BIN\K??86??.* > NUL 58 | MKDIR DOC 59 | MKDIR DOC\KERNEL 60 | COPY DOCS\* DOC\KERNEL\ 61 | MKDIR APPINFO 62 | MOVE DOC\KERNEL\*.lsm APPINFO\ 63 | 7z.exe a -tzip -mx9 -mpass15 -r ..\..\kernel%FAT%.zip APPINFO\* BIN\* DOC\* 64 | ECHO cleaning up between builds 65 | CALL clobber.bat 66 | RMDIR /S /Q DOC 67 | RMDIR /S /Q APPINFO 68 | GOTO %BZKRET% 69 | 70 | :LSM 71 | ECHO Begin3>%LSMFILE% 72 | ECHO Title: The FreeDOS Kernel>>%LSMFILE% 73 | ECHO Version: %VERSION%>>%LSMFILE% 74 | ECHO Entered-date: %DATE%>>%LSMFILE% 75 | ECHO Description: The FreeDOS Kernel>>%LSMFILE% 76 | ECHO Keywords: kernel, FreeDOS, DOS, MSDOS>>%LSMFILE% 77 | ECHO Author: (developers: can be reached on the freedos-kernel mailing list)>>%LSMFILE% 78 | ECHO Maintained-by: freedos-kernel@lists.sourceforge.net>>%LSMFILE% 79 | ECHO Primary-site: http://freedos.sourceforge.net/kernel/>>%LSMFILE% 80 | ECHO Alternate-site: http://www.fdos.org/kernel/>>%LSMFILE% 81 | ECHO Alternate-site: https://freedos.svn.sourceforge.net/svnroot/freedos>>%LSMFILE% 82 | ECHO Original-site: http://www.gcfl.net/pub/FreeDOS/kernel>>%LSMFILE% 83 | ECHO Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom C or Turbo C, NASM, UPX)>>%LSMFILE% 84 | ECHO Copying-policy: GPL2>>%LSMFILE% 85 | ECHO End>>%LSMFILE% 86 | SET LSMFILE= 87 | SET VERSION= 88 | GOTO %LSMRET% 89 | 90 | :USAGE 91 | ECHO Tag and build release kernels - usage: RELEASE {VERSION} e.g. RELEASE 2039 92 | :DONE 93 | -------------------------------------------------------------------------------- /bin/autoexec.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Welcome to FreeDOS (http://www.freedos.org)! 3 | path=a:\ 4 | -------------------------------------------------------------------------------- /bin/config.sys: -------------------------------------------------------------------------------- 1 | rem dos=high 2 | rem device=fdxms.sys (or himem.sys) 3 | files=20 4 | buffers=20 5 | rem screen=0x12 6 | -------------------------------------------------------------------------------- /bin/install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem 3 | rem Create a distribution floppy 4 | rem 5 | rem $Header$ 6 | 7 | set D=A: 8 | if "%1" == "b:" set D=B: 9 | if "%1" == "B:" set D=B: 10 | if "%1" == "b" set D=B: 11 | if "%1" == "B" set D=B: 12 | 13 | echo This utility will create a distribution floppy on the disk in drive %D% 14 | pause 15 | 16 | rem try to transfer system files -- abort if it cannot. 17 | sys %D% 18 | if errorlevel 1 goto out 19 | 20 | rem copy remaining files 21 | echo copying remaining files... 22 | echo copying autoexec.bat... 23 | copy autoexec.bat %D% 24 | echo copying config.sys.. 25 | copy config.sys %D% 26 | echo copying sys.com.. 27 | copy sys.com %D% 28 | label %D% freedos 29 | 30 | rem exit methods 31 | goto done 32 | :out 33 | echo Floppy creation aborted 34 | :done 35 | set D= 36 | 37 | -------------------------------------------------------------------------------- /boot/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for DOS-C boot 3 | # 4 | 5 | 6 | !include "../mkfiles/generic.mak" 7 | 8 | production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin oemfat12.bin oemfat16.bin 9 | 10 | fat12com.bin: boot.asm 11 | $(NASM) -dISFAT12 boot.asm -l$*.lst -ofat12com.bin 12 | 13 | fat16com.bin: boot.asm 14 | $(NASM) -dISFAT16 boot.asm -l$*.lst -ofat16com.bin 15 | 16 | fat32chs.bin: boot32.asm 17 | $(NASM) boot32.asm -l$*.lst -ofat32chs.bin 18 | 19 | fat32lba.bin: boot32lb.asm 20 | $(NASM) boot32lb.asm -l$*.lst -ofat32lba.bin 21 | 22 | oemfat12.bin: oemboot.asm 23 | $(NASM) -dISFAT12 oemboot.asm -l$*.lst -ooemfat12.bin 24 | 25 | oemfat16.bin: oemboot.asm 26 | $(NASM) -dISFAT16 oemboot.asm -l$*.lst -ooemfat16.bin 27 | 28 | clobber: clean 29 | -$(RM) *.bin status.me 30 | 31 | clean: 32 | -$(RM) *.lst *.map *.bak *.obj 33 | 34 | -------------------------------------------------------------------------------- /buildall.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem IF NOTHING COMPILES, CHECK IF YOUR CVS CHECKOUT USES CORRECT DOS LINEBREAKS 3 | 4 | :- $Id: buildall.bat 1305 2006-10-31 21:13:02Z bartoldeman $ 5 | 6 | :---------------------------------------------------------- 7 | :- batch file to build _many_ KERNELS, hope build works. 8 | :- takes 3 minutes on my(TE) Win2K/P700. your milage may vary :-) 9 | :---------------------------------------------------------- 10 | 11 | if "%1" == "$SUMMARY" goto summary 12 | 13 | set onerror=if not "%XERROR%" == "" goto daswarwohlnix 14 | 15 | :***** MSCL kernels 16 | 17 | call config.bat 18 | set dos4g=quiet 19 | 20 | if "%MS_BASE%" == "" goto no_ms 21 | call build -r msc 386 fat16 22 | %ONERROR% 23 | call build -r msc 186 fat16 24 | %ONERROR% 25 | call build -r msc 86 fat16 26 | %ONERROR% 27 | call build -r msc 386 fat32 28 | %ONERROR% 29 | call build -r msc 186 fat32 30 | %ONERROR% 31 | call build -r msc 86 fat32 32 | %ONERROR% 33 | :no_ms 34 | 35 | :***** TC 2.01 kernels 36 | 37 | if "%TC2_BASE%" == "" goto no_tc 38 | call build -r tc 186 fat16 39 | %ONERROR% 40 | call build -r tc 86 fat16 41 | %ONERROR% 42 | call build -r tc 186 fat32 43 | %ONERROR% 44 | call build -r tc 86 fat32 45 | %ONERROR% 46 | :no_tc 47 | 48 | :***** (Open) Watcom kernels 49 | 50 | if not "%COMPILER%" == "WATCOM" goto no_wc 51 | call build -r wc 386 fat32 52 | %ONERROR% 53 | call build -r wc 386 fat16 54 | %ONERROR% 55 | call build -r wc 86 fat32 56 | %ONERROR% 57 | call build -r wc 86 fat16 58 | %ONERROR% 59 | :no_wc 60 | 61 | :***** now rebuild the default kernel 62 | 63 | call build -r 64 | 65 | :************************************************************** 66 | :* now we build a summary of all kernels HMA size + total size 67 | :* Yes, I know - "mit Linux waer das nicht passiert" :-) 68 | :* at least, it's possible with standard DOS tools 69 | :************************************************************** 70 | 71 | set Sumfile=bin\ksummary.txt 72 | set TempSumfile=bin\tsummary.txt 73 | 74 | :****echo >%TempSumfile% Summary of all kernels build 75 | :****echo.|date >>%TempSumfile% 76 | :****echo.|time >>%TempSumfile% 77 | :****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i 78 | 79 | if exist %Sumfile% del %Sumfile% 80 | if exist %TempSumfile% del %TempSumfile% 81 | >ktemp.bat 82 | for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat 83 | sort ktemps.bat 84 | call ktemps.bat 85 | del ktemp.bat 86 | del ktemps.bat 87 | 88 | echo >>%Sumfile% Summary of all kernels build 89 | echo.|date >>%Sumfile% 90 | echo.|time >>%Sumfile% 91 | find <%TempSumfile% "H" >>%Sumfile% 92 | del %TempSumfile% 93 | 94 | set TempSumfile= 95 | set Sumfile= 96 | goto end 97 | 98 | :summary 99 | echo H************************************************* %2 >>%TempSumfile% 100 | find<%2 " HMA_TEXT"|find/V "HMA_TEXT_START"|find/V "HMA_TEXT_END">>%TempSumfile% 101 | find<%2 " STACK">>%TempSumfile% 102 | goto end 103 | 104 | :************* done with summary ********************************* 105 | 106 | :daswarwohlnix 107 | echo Sorry, something didn't work as expected :-( 108 | set ONERROR= 109 | 110 | :end 111 | -------------------------------------------------------------------------------- /clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :- batch file to clean everything 4 | :- $Id: clean.bat 1181 2006-05-20 20:45:59Z mceric $ 5 | 6 | if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! 7 | if not exist config.bat goto end 8 | 9 | call config.bat 10 | call default.bat 11 | 12 | cd utils 13 | %MAKE% clean 14 | 15 | cd ..\lib 16 | %MAKE% clean 17 | 18 | cd ..\drivers 19 | %MAKE% clean 20 | 21 | cd ..\boot 22 | %MAKE% clean 23 | 24 | cd ..\sys 25 | %MAKE% clean 26 | 27 | cd ..\kernel 28 | %MAKE% clean 29 | 30 | cd ..\hdr 31 | if exist *.bak del *.bak 32 | 33 | cd .. 34 | if exist *.bak del *.bak 35 | 36 | :end 37 | default.bat clearset 38 | -------------------------------------------------------------------------------- /clobber.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :- batch file to clobber everything 4 | :- $Id: clobber.bat 1181 2006-05-20 20:45:59Z mceric $ 5 | 6 | if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! 7 | if not exist config.bat goto end 8 | 9 | call config.bat 10 | call default.bat 11 | 12 | cd utils 13 | %MAKE% clobber 14 | 15 | cd ..\lib 16 | %MAKE% clobber 17 | 18 | cd ..\drivers 19 | %MAKE% clobber 20 | 21 | cd ..\boot 22 | %MAKE% clobber 23 | 24 | cd ..\sys 25 | %MAKE% clobber 26 | 27 | cd ..\kernel 28 | %MAKE% clobber 29 | 30 | cd ..\hdr 31 | if exist *.bak del *.bak 32 | 33 | cd ..\bin 34 | if exist sys.com del sys.com 35 | if exist country.sys del country.sys 36 | 37 | cd .. 38 | if exist *.bak del *.bak 39 | if exist status.me del status.me 40 | 41 | 42 | :end 43 | default.bat clearset 44 | -------------------------------------------------------------------------------- /config.b: -------------------------------------------------------------------------------- 1 | :- 2 | :- batch file that is included in all other batch files for configuration 3 | :- 4 | 5 | :-**************************************************************** 6 | :- NOTICE! You must edit and rename this file to CONFIG.BAT! * 7 | :-**************************************************************** 8 | 9 | :-********************************************************************* 10 | :- determine your compiler settings 11 | :- 12 | :- you have to 13 | :- search for XNASM - and set the path for NASM 14 | :- search for COMPILER - and set your compiler 15 | :- search for ??_BASE - and set the path to your compiler 16 | :- 17 | :-********************************************************************* 18 | 19 | :-********************************************************************** 20 | :-- define NASM executable - remember - it should not be protected 21 | :- mode DJGPP version if you're using Windows NT/2k/XP to compile 22 | :- because DJGPP-nasm crashes when using protected mode Borland's 23 | :- make under Windows NT/2k/XP 24 | :-********************************************************************** 25 | 26 | set XNASM=nasm 27 | 28 | :********************************************************************** 29 | :- define your COMPILER type here, pick one of them 30 | :********************************************************************** 31 | 32 | :- Turbo C 2.01 33 | :- set COMPILER=TC2 34 | :- Turbo C++ 1.01 35 | :- set COMPILER=TURBOCPP 36 | :- Turbo C 3.0 37 | :- set COMPILER=TC3 38 | :- Borland C 3.1 39 | set COMPILER=BC3 40 | :- Borland C 41 | :- set COMPILER=BC5 42 | :- Microsoft C 43 | :- set COMPILER=MSCL8 44 | :- Watcom C 45 | :- set COMPILER=WATCOM 46 | 47 | :-********************************************************************** 48 | :-- where is the BASE dir of your compiler(s) ?? 49 | :-********************************************************************** 50 | 51 | :- set TC2_BASE=c:\tc201 52 | :- set TP1_BASE=c:\tcpp 53 | :- set TC3_BASE=c:\tc3 54 | set BC3_BASE=c:\bc 55 | :- set BC5_BASE=c:\bc5 56 | :- set MS_BASE=c:\msvc 57 | 58 | :- if WATCOM maybe you need to set your WATCOM environment variables 59 | :- and path 60 | :- if not \%WATCOM% == \ goto watcom_defined 61 | :- set WATCOM=c:\watcom 62 | :- set PATH=%PATH%;%WATCOM%\binw 63 | :watcom_defined 64 | 65 | :-********************************************************************** 66 | :- where is UPX and which options to use? 67 | :-********************************************************************** 68 | set XUPX=upx --8086 --best 69 | :- or use set XUPX= 70 | :- if you don't want to use it 71 | 72 | :-********************************************************************** 73 | :- (optionally) which linker to use: 74 | :- (otherwise will be determined automatically) 75 | :- 76 | :- WARNING TLINK needs to be in your PATH! 77 | :-********************************************************************** 78 | 79 | :- Turbo Link 80 | :- set XLINK=tlink /m/c/s/l 81 | :- Microsoft Link 82 | :- set XLINK=d:\qb\link /ma 83 | :- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo 84 | :- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink) 85 | :- set XLINK=..\utils\wlinker /ma /nologo 86 | 87 | :- set path for Turbo Link - use OLDPATH to restore normal path 88 | :- set OLDPATH=%PATH% 89 | :- set PATH=%PATH%;%TC2_BASE% 90 | 91 | :********************************************************************** 92 | :* optionally define your MAKE type here, if not then 93 | :* it will be automatically determined, pick one of them 94 | :* use MS nmake if you want to compile with MSCL 95 | :********************************************************************** 96 | 97 | :- Borland MAKE 98 | :- set MAKE=%TC2_BASE%\make 99 | :- Watcom MAKE in MS mode 100 | :- set MAKE=%WATCOM%\binw\wmake /ms 101 | :- Microsoft MAKE 102 | :- set MAKE=%MS_BASE%\bin\nmake /nologo 103 | 104 | :********************************************************************** 105 | :* select your default target: required CPU and what FAT system to support 106 | :********************************************************************** 107 | 108 | :- set XCPU=86 109 | :- set XCPU=186 110 | set XCPU=386 111 | 112 | :- set XFAT=16 113 | set XFAT=32 114 | 115 | :- Give extra compiler DEFINE flags here 116 | :- such as -DDEBUG : extra DEBUG output 117 | :- -DDOSEMU : printf output goes to dosemu log 118 | :- set ALLCFLAGS=-DDEBUG 119 | 120 | 121 | :- 122 | :- $Id: config.b 864 2004-04-11 12:21:25Z bartoldeman $ 123 | :- 124 | -------------------------------------------------------------------------------- /config.m: -------------------------------------------------------------------------------- 1 | # 2 | # Linux cross compilation only! 3 | # config file that is included in the main makefile for configuration 4 | # 5 | 6 | #**************************************************************** 7 | # NOTICE! If you edit you must rename this file to config.mak!* 8 | #**************************************************************** 9 | 10 | #********************************************************************** 11 | #- define NASM executable 12 | #********************************************************************** 13 | XNASM=nasm 14 | 15 | #********************************************************************** 16 | #- where is the BASE dir of your compiler(s) ?? 17 | #********************************************************************** 18 | 19 | # if WATCOM maybe you need to set your WATCOM environment variables 20 | # and path 21 | ifndef WATCOM 22 | WATCOM=$(HOME)/watcom 23 | PATH:=$(WATCOM)/binl:$(PATH) 24 | endif 25 | 26 | #********************************************************************** 27 | # where is UPX and which options to use? 28 | #********************************************************************** 29 | XUPX=upx --8086 --best 30 | 31 | # or use 32 | #unexport XUPX 33 | # without the # if you don't want to use it 34 | 35 | #********************************************************************** 36 | # (optionally) which linker to use: 37 | # (otherwise will be determined automatically) 38 | 39 | # WATCOM Link 40 | #XLINK=wlink 41 | 42 | #********************************************************************* 43 | # optionally define your MAKE type here, if not then 44 | # it will be automatically determined, pick one of them 45 | # use MS nmake if you want to compile with MSCL 46 | #********************************************************************* 47 | 48 | # Watcom MAKE in MS mode 49 | #MAKE=wmake -ms -h 50 | 51 | #********************************************************************* 52 | # select your default target: required CPU and what FAT system to support 53 | #********************************************************************* 54 | 55 | # XCPU=86 56 | # XCPU=186 57 | XCPU=386 58 | 59 | # XFAT=16 60 | XFAT=32 61 | 62 | # Give extra compiler DEFINE flags here 63 | # such as -DDEBUG : extra DEBUG output 64 | # -DDOSEMU : printf output goes to dosemu log 65 | # set ALLCFLAGS=-DDEBUG 66 | -------------------------------------------------------------------------------- /default.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :- $Id: default.bat 1482 2009-07-11 16:59:43Z perditionc $ 3 | 4 | :- with option clearset, clears all config.bat-made environment variables 5 | :- without options, MAKE / LINK / ... are set to defaults based on COMPILER ... 6 | 7 | if "%1" == "clearset" goto clearset 8 | 9 | :----------------------------------------------------------------------- 10 | 11 | if not "%COMPILER%" == "" goto skip_cc 12 | 13 | set COMPILER=WATCOM 14 | 15 | echo No compiler specified, defaulting to Open Watcom 16 | 17 | :skip_cc 18 | 19 | :----------------------------------------------------------------------- 20 | 21 | if not "%MAKE%" == "" goto skip_make 22 | 23 | if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make 24 | if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make 25 | if "%COMPILER%" == "TC3" set MAKE=%TC3_BASE%\bin\make 26 | if "%COMPILER%" == "BC3" set MAKE=%BC3_BASE%\bin\make 27 | if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make 28 | if "%COMPILER%" == "WATCOM" set MAKE=wmake /ms /h 29 | if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake /nologo 30 | 31 | echo Make is %MAKE%. 32 | 33 | :skip_make 34 | 35 | :----------------------------------------------------------------------- 36 | 37 | if not "%XLINK%" == "" goto skip_xlink 38 | 39 | if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c 40 | if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink /m/c 41 | if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink /m/c 42 | if "%COMPILER%" == "BC3" set XLINK=%BC3_BASE%\bin\tlink /m/c 43 | if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink /m/c 44 | if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker /ma/nologo 45 | if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo 46 | 47 | echo Linker is %XLINK%. 48 | 49 | :skip_xlink 50 | 51 | :----------------------------------------------------------------------- 52 | 53 | if not "%XUPX%" == "" set UPXOPT=-U 54 | if "%XUPX%" == "" set UPXOPT= 55 | 56 | goto end 57 | 58 | :----------------------------------------------------------------------- 59 | 60 | :clearset 61 | 62 | if not "%OLDPATH%" == "" set PATH=%OLDPATH% 63 | if not "%OLDPATH%" == "" set OLDPATH= 64 | 65 | set MAKE= 66 | set COMPILER= 67 | set ALLCFLAGS= 68 | set CFLAGS= 69 | set XCPU= 70 | set XCPU_EX= 71 | set XFAT= 72 | set XLINK= 73 | set TC2_BASE= 74 | set TP1_BASE= 75 | set TC3_BASE= 76 | set BC3_BASE= 77 | set BC5_BASE= 78 | set MS_BASE= 79 | set XNASM= 80 | set NASMFLAGS= 81 | set XUPX= 82 | set UPXOPT= 83 | set LOADSEG= 84 | 85 | :end 86 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | dosc.fdos.org -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-tactile -------------------------------------------------------------------------------- /docs/bugs.txt: -------------------------------------------------------------------------------- 1 | The current bug database is available on the web at 2 | 3 | http://sourceforge.net/tracker/?group_id=5109&atid=105109 4 | 5 | Please request an account if you want to report or 6 | update bugs. Reading the database needs no login. 7 | 8 | Thanks! 9 | -------------------------------------------------------------------------------- /docs/contrib.txt: -------------------------------------------------------------------------------- 1 | These are the known contributors of the FreeDOS kernel. If you have 2 | contributed in any way to the kernel, but are not on this list, please 3 | email the current kernel maintainer so we can add you to the list! 4 | 5 | Thanks to all the following for contributing to the FreeDOS kernel: 6 | 7 | Aitor Santamaria (aitor.sm@wanadoo.es) 8 | Arkady Belousov (ark@mos.ru) 9 | Bart Oldeman (bart@dosemu.org) 10 | Bernd Blaauw (bblaauw@home.nl) 11 | Brian Reifsnyder (reifsnyderb@mindspring.com) 12 | Charles Dye (raster@highfiber.com) 13 | Eduardo Casino (casino_e@terra.es) 14 | Eric Auer (e.auer@jpberlin.de) 15 | Eric Biederman (ebiederm+eric@ccr.net) 16 | Eric Luttmann (ecl@users.sourceforge.net) 17 | Fritz Mueller (fritz.mueller@mail.com) 18 | Geraldo Netto (geraldonetto@gmail.com) 19 | Helmut Fritsch (helmut.fritsch@gcd-hs.de) 20 | James Tabor (jimtabor@infohwy.com) 21 | Jason Hood (jadoxa@yahoo.com.au) 22 | Jens Horstmeier (Jens.Horstmeier@abg1.siemens.de) 23 | Jeremy Davis (jeremyd@fdos.org) 24 | Jim Hall (jhall@freedos.org) 25 | John Price (linux-guru@gcfl.net) 26 | Kolya Ksenev (7207@mx.csd.tsu.ru) 27 | Lixing Yuan (yuanlixg@china.com) 28 | Luchezar Georgiev (lig@linux.tu-varna.acad.bg) 29 | Martin Stromberg (ams@ludd.luth.se) 30 | Michal Bakowski (mb@orad.pl) 31 | Ron Cemer (roncemer@gte.net) 32 | "ror4" (ror4@angelfire.com) 33 | Rune Espeseth (re@icd.no) 34 | sava (lpproj@gmail.com) 35 | Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) 36 | Steve Miller (SMiller@dsfx.com) 37 | Tom Ehlert (te@drivesnapshot.de) 38 | Victor Vlasenko (victor_vlasenko@hotbox.ru) 39 | 40 | At this place we should also thank Ralf Brown for his interrupt list. 41 | It is a truely invaluable resource for us. 42 | 43 | And last, but not least, a big thanks to Pasquale J. Villani 44 | (patv@iop.com), who is the original author of DOS-C, on which 45 | the FreeDOS kernel is based. 46 | -------------------------------------------------------------------------------- /docs/fdkernel.lsm: -------------------------------------------------------------------------------- 1 | Begin3 2 | Title: The FreeDOS Kernel 3 | Version: SVN 4 | Entered-date: N/A 5 | Description: The FreeDOS Kernel 6 | Keywords: kernel, FreeDOS, DOS, MSDOS 7 | Author: (developers: can be reached on the freedos-kernel mailing list) 8 | Maintained-by: freedos-kernel@lists.sourceforge.net 9 | Primary-site: http://freedos.sourceforge.net/kernel/ 10 | Original-site: http://www.gcfl.net/pub/FreeDOS/kernel 11 | Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom C or Turbo C, NASM, optionally UPX) 12 | Copying-policy: GPL2 13 | End 14 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | FreeDOS kernel 2 | -------------------------------------------------------------------------------- /docs/lfnapi.txt: -------------------------------------------------------------------------------- 1 | FreeDOS LFN helper API. 2 | 3 | struct lfn_inode 4 | { 5 | UNICODE name[261]; 6 | 7 | struct dirent l_dir; /* this file's dir entry image */ 8 | 9 | ULONG l_diroff; /* offset of the dir entry */ 10 | }; 11 | typedef struct lfn_inode FAR * lfn_inode_ptr; 12 | 13 | COUNT lfn_allocate_inode(VOID); 14 | COUNT lfn_free_inode(COUNT handle); 15 | 16 | COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff); 17 | 18 | COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); 19 | 20 | COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip); 21 | COUNT lfn_dir_write(COUNT handle); 22 | -------------------------------------------------------------------------------- /docs/memdisk.txt: -------------------------------------------------------------------------------- 1 | FreeDOS kernel with memdisk support compiled in: 2 | 3 | When enabled one can supplement (or replace) CONFIG.SYS from the memdisk 4 | command line. The kernel upon booting will verify running on a 386+ and 5 | then check for memdisk using int 13h call with magic values. If found 6 | then the memdisk command line is processed and simulated CONFIG.SYS lines 7 | are evaluated left to right as though they logically followed the last 8 | line in CONFIG.SYS (or FDCONFIG.SYS). 9 | 10 | Example syslinux.cfg section: 11 | LABEL FreeDOS 12 | KERNEL memdisk 13 | MENU LABEL FreeDOS example 14 | INITRD FDSTD.img 15 | APPEND {ECHO Booting FreeDOS}{ECHO This is the second line.} 16 | 17 | 18 | FreeDOS config lines are denoted by surrounding the line in curly braces {} 19 | thus allowing multiple simulated lines on a single APPEND line. However, 20 | the closing brace } may be omitted if it would be immediately followed by 21 | an opening brace { or end of the APPEND line. Anything on the memdisk line 22 | outside of the curly braces {} is ignored. The lines may be preceeded by 23 | FD= to be compatible with earlier FD kernel release or any other key= to 24 | specify the environment variable generated by getargs utility. All simulated 25 | config lines (text between the { and }) are evaluated by the kernel asis 26 | except the final line (the line within final {}). 27 | 28 | The final } is optional which results in the memdisk options initrd= and 29 | BOOT_IMAGE= to appear as part of the config.sys line. To avoid issues 30 | several memdisk options are ignored if after the last opening brace {. 31 | Note that the syslinux/memdisk options are case sensitive. Currently 32 | ignored options are: initrd, BOOT_IMAGE, floppy, harddisk, and iso. 33 | 34 | Additionally, to simplify passing and overriding arguments when syslinux 35 | is booting, any key=value pairs seen after any memdisk options will cause 36 | all corresponding key=??? prior to any memdisk options to be cleared on 37 | the resulting config line. 38 | For example if the final assembled memdisk line appears to the kernel as: 39 | {ECHO HI{ECHO X=1 X=2 Y=1 Z=1 initrd=FDSTD10.img BOOT_IMAGE=memdisk X=386 40 | then the following two lines will evaluated by the kernel after processing 41 | any CONFIG.SYS lines. 42 | ECHO HI 43 | ECHO Y=1 Z=1 X=386 44 | 45 | The following APPEND lines are all treated identically by the kernel. 46 | APPEND floppy FD={ECHO Welcome}{ECHO 2nd line}{ECHO third} 47 | APPEND floppy FD={ECHO Welcome{ECHO 2nd line{ECHO third 48 | APPEND {ECHO Welcome} {ECHO 2nd line} {ECHO third} floppy 49 | APPEND {ECHO Welcome{Echo 2nd line} {ECHO third floppy 50 | resulting in the following equivalent three CONFIG.SYS lines 51 | ECHO Welcome 52 | ECHO 2nd line 53 | ECHO third 54 | 55 | 56 | The following complete example syslinux.cfg and FreeDOS configuration files 57 | could be used to boot various kernel options avoiding the use of the FreeDOS 58 | kernel menu in addition to the Sylinux menu. 59 | 60 | # CONFIG.SYS 61 | REM always executed, in common with all choices 62 | FILES=20 63 | LASTDRIVE=Z 64 | SHELLHIGH=\COMMAND.COM /E:256 /P 65 | 66 | 67 | #AUTOEXEC.BAT 68 | @ECHO OFF 69 | CLS 70 | ECHO Welcome to FreeDOS (http://www.freedos.org)! 71 | ECHO User selected menu %CONFIG% 72 | 73 | 74 | # SYSLINUX.CFG 75 | UI vesamenu.c32 76 | DEFAULT clean 77 | 78 | LABEL clean 79 | MENU LABEL FreeDOS with no drivers 80 | KERNEL memdisk 81 | INITRD /fdos0360.img 82 | APPEND floppy FD={SET config=0} 83 | 84 | LABEL jemm 85 | MENU LABEL FreeDOS with memory manager 86 | KERNEL memdisk 87 | INITRD /fdos0360.img 88 | APPEND floppy FD={SET config=1}{DEVICE?=JEMMEX.EXE 89 | 90 | 91 | Syslinux boot-prompt (when vesamenu not used): 92 | jemm 93 | or 94 | jemm NOEMS 95 | -------------------------------------------------------------------------------- /docs/mkboot.txt: -------------------------------------------------------------------------------- 1 | To create a bootable floppy suitable for copying the system to 2 | another drive: 3 | 4 | 1. Change directory (if necessary) to where the FreeDOS Kernel BIN 5 | directory. 6 | 7 | 3. Enter the command "install" to transfer the system files to the 8 | diskette in drive A. If you want to install on drive B, type 9 | "install b:" 10 | 11 | 4. Write protect this disk and use it to boot from. 12 | -------------------------------------------------------------------------------- /docs/readme.cvs: -------------------------------------------------------------------------------- 1 | 2 | Thanks to Bart Oldeman for helping us with moving the FreeDOS source code 3 | from CVS to Subversion! The old CVS repository is still available for 4 | browsing, but will no longer be used for managing FreeDOS Projects - and 5 | will probably be deleted later. Please use Subversion for the FreeDOS 6 | kernel, FreeCOM (FreeDOS command.com), Install, and Mem. 7 | 8 | Bart has also written a Subversion at SourceForge Mini How-to: 9 | http://fd-doc.sourceforge.net/wiki/index.php?n=FdDocEn.SVN 10 | 11 | This information was mostly lifted from SourceForge.net: 12 | https://sourceforge.net/svn/?group_id 13 | 14 | FreeDOS Subversion: 15 | 16 | Subversion (SVN) is a tool used by many software developers to manage 17 | changes within their source code tree. SVN provides the means to store not 18 | only the current version of a piece of source code, but a record of all 19 | changes (and who made those changes) that have occurred to that source code. 20 | Use of SVN is particularly common on projects with multiple developers, 21 | since SVN ensures changes made by one developer are not accidentally removed 22 | when another developer posts their changes to the source tree. 23 | 24 | In order to access a Subversion repository, you must install a special piece 25 | of software called a Subversion client. Subversion clients are available for 26 | most any operating system. 27 | 28 | To get a working copy, do svn co URL freedos where URL is the complete path 29 | to the trunk of the project you want. For example: 30 | 31 | FreeDOS kernel 32 | https://freedos.svn.sourceforge.net/svnroot/freedos/kernel/trunk 33 | FreeDOS FreeCOM 34 | https://freedos.svn.sourceforge.net/svnroot/freedos/freecom/trunk 35 | FreeDOS MEM 36 | https://freedos.svn.sourceforge.net/svnroot/freedos/mem/trunk 37 | FreeDOS Install 38 | https://freedos.svn.sourceforge.net/svnroot/freedos/install/trunk 39 | 40 | Be careful NOT to use the top level 41 | * https://freedos.svn.sourceforge.net/svnroot/freedos URL 42 | instead of one of the trunk URLs. This will pull all modules, tags and/or 43 | branches of the project - it will be huge. Instead, you will want to use 44 | /trunk to the URL to check out only the trunk code (main development line). 45 | 46 | Though Subversion repositories are most commonly accessed using a special 47 | piece of software called a Subversion client, SourceForge also provides a 48 | web-based interface to view Subversion repositories. Browsing the Subversion 49 | tree gives you a great view into the current status of this project's code. 50 | You may also view the complete history of any file in the repository. 51 | 52 | * Browse Subversion repository 53 | http://freedos.svn.sourceforge.net/viewvc/freedos/ 54 | 55 | FreeDOS is a trademark of Jim Hall. 56 | 57 | 58 | 59 | Note: Readonly access via the old CVS interface worked as follows: 60 | To check out the code, first log in: 61 | cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/cvsroot/freedos login 62 | Password: Press the Enter key. 63 | Then, to get the kernel code: 64 | cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/cvsroot/freedos checkout kernel 65 | -------------------------------------------------------------------------------- /docs/readme.txt: -------------------------------------------------------------------------------- 1 | INTRODUCTION 2 | ------------ 3 | 4 | This archive contains the current FreeDOS Kernel, also 5 | known as DOS-C, originally written by Pasquale J. Villani. 6 | 7 | The FreeDOS Kernel is available from http://freedos.sourceforge.net/ 8 | It's also available from http://www.dosemu.org/ (somewhere on there). 9 | 10 | The FreeDOS Kernel is also available through the FreeDOS Project at 11 | http://www.freedos.org/ 12 | 13 | See the DOCS directory for more documentation and information about 14 | the FreeDOS Kernel. 15 | 16 | Contents of zip files: 17 | ke20xx_16.zip : binaries for 8086, FAT16 18 | ke20xx_32.zip : binaries for 8086, FAT16, FAT32 19 | ke20xxsrc.zip : sources for the kernel 20 | 21 | BUG REPORTS 22 | ----------- 23 | 24 | If you have found a bug, think you have found a bug, or would just 25 | like to make a suggestion, go to the bug tracking web page at 26 | http://sourceforge.net/tracker/?group_id=5109&atid=105109 27 | 28 | An archive of old (Bugzilla) items is at www.freedos.org/bugzilla/ 29 | 30 | There is also a feature request tracker on our SourceForge pages at 31 | http://sourceforge.net/tracker/?atid=355109&group_id=5109&func=browse 32 | 33 | 34 | Copyright 35 | --------- 36 | 37 | DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani 38 | All Rights Reserved. 39 | -------------------------------------------------------------------------------- /drivers/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for device.lib 3 | # 4 | # $Id: makefile 1387 2009-05-19 21:39:29Z bartoldeman $ 5 | # 6 | 7 | 8 | !include "../mkfiles/generic.mak" 9 | 10 | 11 | # MICROSOFT C 12 | # ----------- 13 | #MODEL = s 14 | #CFLAGS = /c /Gs /A$(MODEL) 15 | #AFLAGS = /Mx /Dmem$(MODEL)=1 16 | #TERM = ; 17 | 18 | # BORLAND C 19 | # ----------- 20 | #MODEL = s 21 | #CFLAGS = -c -m$(MODEL) 22 | #AFLAGS = /Mx /Dmem$(MODEL)=1 23 | #LIBFLAGS = /c 24 | 25 | OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj 26 | 27 | LIBOBJS= $(LIBPLUS)floppy.obj $(LIBPLUS)rdpcclk.obj $(LIBPLUS)wrpcclk.obj $(LIBPLUS)wratclk.obj 28 | 29 | 30 | 31 | # Build the LIBRARY 32 | # ----------------- 33 | all: production 34 | 35 | production: ../lib/device.lib 36 | 37 | ../lib/device.lib: device.lib 38 | $(CP) device.lib ..$(DIRSEP)lib 39 | 40 | clobber: clean 41 | -$(RM) device.lib status.me ..$(DIRSEP)lib$(DIRSEP)device.lib 42 | 43 | clean: 44 | -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err 45 | 46 | device.lib : $(OBJS) 47 | -$(RM) device.lib 48 | $(LIBUTIL) $(LIBFLAGS) device.lib $(LIBOBJS) $(LIBTERM) 49 | 50 | -------------------------------------------------------------------------------- /drivers/rdpcclk.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; File: 3 | ; rdpcclk.asm 4 | ; Description: 5 | ; read the PC style clock from bios 6 | ; 7 | ; Copyright (c) 1995 8 | ; Pasquale J. Villani 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; You should have received a copy of the GNU General Public 24 | ; License along with DOS-C; see the file COPYING. If not, 25 | ; write to the Free Software Foundation, 675 Mass Ave, 26 | ; Cambridge, MA 02139, USA. 27 | ; 28 | ; $Header$ 29 | ; 30 | 31 | %include "../kernel/segs.inc" 32 | 33 | segment HMA_TEXT 34 | 35 | ; 36 | ; ULONG ReadPCClock(void) 37 | ; 38 | global READPCCLOCK 39 | READPCCLOCK: 40 | mov ah,0 41 | int 1ah 42 | extern _DaysSinceEpoch ; ; update days if necessary 43 | 44 | ; (ah is still 0, al contains midnight flag) 45 | add word [_DaysSinceEpoch ],ax ; *some* BIOSes accumulate several days 46 | adc word [_DaysSinceEpoch+2],byte 0; 47 | 48 | ; set return value dx:ax 49 | xchg ax,cx ; ax=_cx, cx=_ax 50 | xchg ax,dx ; dx=_cx, ax=_dx (cx=_ax) 51 | 52 | ret 53 | 54 | -------------------------------------------------------------------------------- /drivers/wratclk.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; File: 3 | ; wratclk.asm 4 | ; Description: 5 | ; WriteATClock - sysclock support 6 | ; 7 | ; Copyright (c) 1995 8 | ; Pasquale J. Villani 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; You should have received a copy of the GNU General Public 24 | ; License along with DOS-C; see the file COPYING. If not, 25 | ; write to the Free Software Foundation, 675 Mass Ave, 26 | ; Cambridge, MA 02139, USA. 27 | ; 28 | ; $Header$ 29 | ; 30 | 31 | %include "../kernel/segs.inc" 32 | %include "../hdr/stacks.inc" 33 | 34 | segment HMA_TEXT 35 | 36 | ; 37 | ; VOID WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) 38 | ; BYTE *bcdDays; 39 | ; BYTE bcdHours; 40 | ; BYTE bcdMinutes; 41 | ; BYTE bcdSeconds; 42 | ; 43 | global WRITEATCLOCK 44 | WRITEATCLOCK: 45 | push bp 46 | mov bp,sp 47 | ; bcdSeconds = 4 48 | ; bcdMinutes = 6 49 | ; bcdHours = 8 50 | ; bcdDays = 10 51 | arg bcdDays, bcdHours, bcdMinutes, bcdSeconds 52 | mov ch,byte [.bcdHours] 53 | mov cl,byte [.bcdMinutes] 54 | mov dh,byte [.bcdSeconds] 55 | mov dl,0 56 | mov ah,3 57 | int 1ah 58 | mov bx,word [.bcdDays] 59 | mov dx,word [bx] 60 | mov cx,word [bx+2] 61 | mov ah,5 62 | int 1ah 63 | pop bp 64 | ret 8 65 | 66 | -------------------------------------------------------------------------------- /drivers/wrpcclk.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; File: 3 | ; wrpcclk.asm 4 | ; Description: 5 | ; WritePCClock - sysclock support 6 | ; 7 | ; Copyright (c) 1995 8 | ; Pasquale J. Villani 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; You should have received a copy of the GNU General Public 24 | ; License along with DOS-C; see the file COPYING. If not, 25 | ; write to the Free Software Foundation, 675 Mass Ave, 26 | ; Cambridge, MA 02139, USA. 27 | ; 28 | ; $Header$ 29 | ; 30 | %include "../kernel/segs.inc" 31 | %include "../hdr/stacks.inc" 32 | 33 | segment HMA_TEXT 34 | 35 | 36 | ; 37 | ; VOID WritePCClock(Ticks) 38 | ; ULONG Ticks; 39 | ; 40 | global WRITEPCCLOCK 41 | WRITEPCCLOCK: 42 | ; Ticks = 4 43 | pop ax ; return address 44 | popargs {dx,cx} ; Ticks 45 | push ax ; restore stack 46 | mov ah,1 47 | int 1ah 48 | ret 49 | 50 | -------------------------------------------------------------------------------- /filelist: -------------------------------------------------------------------------------- 1 | */*/build.bat 2 | */*/buildall.bat 3 | */*/clean.bat 4 | */*/clobber.bat 5 | */*/config.b 6 | */*/filelist 7 | */*/default.bat 8 | */*/makefile 9 | */*/boot/boot.asm 10 | */*/boot/boot32.asm 11 | */*/boot/boot32lb.asm 12 | */*/boot/makefile 13 | */*/docs/bugs.txt 14 | */*/docs/build.txt 15 | */*/docs/config.txt 16 | */*/docs/contrib.txt 17 | */*/docs/copying 18 | */*/docs/fdkernel.lsm 19 | */*/docs/history.txt 20 | */*/docs/intfns.txt 21 | */*/docs/lfnapi.txt 22 | */*/docs/mkboot.txt 23 | */*/docs/nls.txt 24 | */*/docs/readme.cvs 25 | */*/docs/readme.txt 26 | */*/docs/sys.txt 27 | */*/drivers/floppy.asm 28 | */*/drivers/makefile 29 | */*/drivers/rdpcclk.asm 30 | */*/drivers/wratclk.asm 31 | */*/drivers/wrpcclk.asm 32 | */*/hdr/algnbyte.h 33 | */*/hdr/algndflt.h 34 | */*/hdr/buffer.h 35 | */*/hdr/cds.h 36 | */*/hdr/clock.h 37 | */*/hdr/date.h 38 | */*/hdr/dcb.h 39 | */*/hdr/device.h 40 | */*/hdr/dirmatch.h 41 | */*/hdr/error.h 42 | */*/hdr/exe.h 43 | */*/hdr/fat.h 44 | */*/hdr/fcb.h 45 | */*/hdr/file.h 46 | */*/hdr/fnode.h 47 | */*/hdr/kbd.h 48 | */*/hdr/kconfig.h 49 | */*/hdr/lol.h 50 | */*/hdr/mcb.h 51 | */*/hdr/network.h 52 | */*/hdr/nls.h 53 | */*/hdr/pcb.h 54 | */*/hdr/portab.h 55 | */*/hdr/process.h 56 | */*/hdr/sft.h 57 | */*/hdr/stacks.inc 58 | */*/hdr/tail.h 59 | */*/hdr/time.h 60 | */*/hdr/version.h 61 | */*/hdr/xstructs.h 62 | */*/kernel/nls/001-437.hc 63 | */*/kernel/nls/001-437.unf 64 | */*/kernel/nls/001-437.up 65 | */*/kernel/nls/049-850.hc 66 | */*/kernel/nls/049-850.unf 67 | */*/kernel/nls/049-850.up 68 | */*/kernel/nls/files 69 | */*/kernel/apisupt.asm 70 | */*/kernel/asmsupt.asm 71 | */*/kernel/blockio.c 72 | */*/kernel/break.c 73 | */*/kernel/chario.c 74 | */*/kernel/config.c 75 | */*/kernel/config.h 76 | */*/kernel/console.asm 77 | */*/kernel/dosfns.c 78 | */*/kernel/dosidle.asm 79 | */*/kernel/dosnames.c 80 | */*/kernel/dsk.c 81 | */*/kernel/dyndata.h 82 | */*/kernel/dyninit.c 83 | */*/kernel/entry.asm 84 | */*/kernel/error.c 85 | */*/kernel/execrh.asm 86 | */*/kernel/fatdir.c 87 | */*/kernel/fatfs.c 88 | */*/kernel/fattab.c 89 | */*/kernel/fcbfns.c 90 | */*/kernel/globals.h 91 | */*/kernel/init-dat.h 92 | */*/kernel/init-mod.h 93 | */*/kernel/initclk.c 94 | */*/kernel/initdisk.c 95 | */*/kernel/inithma.c 96 | */*/kernel/initoem.c 97 | */*/kernel/int2f.asm 98 | */*/kernel/inthndlr.c 99 | */*/kernel/intr.asm 100 | */*/kernel/makefile 101 | */*/kernel/io.asm 102 | */*/kernel/io.inc 103 | */*/kernel/ioctl.c 104 | */*/kernel/iprf.c 105 | */*/kernel/irqstack.asm 106 | */*/kernel/kernel.asm 107 | */*/kernel/kernel.cfg 108 | */*/kernel/lfnapi.c 109 | */*/kernel/ludivmul.inc 110 | */*/kernel/main.c 111 | */*/kernel/memdisk.asm 112 | */*/kernel/memmgr.c 113 | */*/kernel/misc.c 114 | */*/kernel/network.c 115 | */*/kernel/newstuff.c 116 | */*/kernel/nls.c 117 | */*/kernel/nls_hc.asm 118 | */*/kernel/nls_load.c 119 | */*/kernel/nlssupt.asm 120 | */*/kernel/prf.c 121 | */*/kernel/printer.asm 122 | */*/kernel/procsupt.asm 123 | */*/kernel/proto.h 124 | */*/kernel/segs.inc 125 | */*/kernel/serial.asm 126 | */*/kernel/strings.c 127 | */*/kernel/sysclk.c 128 | */*/kernel/syspack.c 129 | */*/kernel/systime.c 130 | */*/kernel/task.c 131 | */*/kernel/turboc.cfg 132 | */*/lib/makefile 133 | */*/mkfiles/generic.mak 134 | */*/mkfiles/bc5.mak 135 | */*/mkfiles/mscl8.mak 136 | */*/mkfiles/tc2.mak 137 | */*/mkfiles/tc3.mak 138 | */*/mkfiles/turbocpp.mak 139 | */*/mkfiles/watcom.mak 140 | */*/sys/fdkrncfg.c 141 | */*/sys/bin2c.c 142 | */*/sys/makefile 143 | */*/sys/sys.c 144 | */*/sys/talloc.c 145 | */*/utils/echoto.bat 146 | */*/utils/exeflat.c 147 | */*/utils/indent.ini 148 | */*/utils/makefile 149 | */*/utils/patchobj.c 150 | */*/utils/proto.bat 151 | */*/utils/relocinf.c 152 | */*/utils/rmfiles.bat 153 | */*/utils/wlinker.bat 154 | -------------------------------------------------------------------------------- /hdr/algnbyte.h: -------------------------------------------------------------------------------- 1 | 2 | #if defined(_MSC_VER) 3 | #if _MSC_VER >= 700 4 | #pragma warning(disable:4103) 5 | #endif 6 | #pragma pack(1) 7 | #elif defined(_QC) || defined(__WATCOMC__) || defined(__GNUC__) 8 | #pragma pack(1) 9 | #elif defined(__ZTC__) 10 | #pragma ZTC align 1 11 | #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) 12 | #pragma option -a- 13 | #endif 14 | -------------------------------------------------------------------------------- /hdr/algndflt.h: -------------------------------------------------------------------------------- 1 | #if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) || defined(__GNUC__) 2 | #pragma pack() 3 | #elif defined (__ZTC__) 4 | #pragma ZTC align 5 | #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) 6 | #pragma option -a. 7 | #endif 8 | -------------------------------------------------------------------------------- /hdr/buffer.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* buffer.h */ 4 | /* */ 5 | /* Sector buffer structure */ 6 | /* */ 7 | /* Copyright (c) 2001 */ 8 | /* Bart Oldeman */ 9 | /* */ 10 | /* Largely taken from globals.h: */ 11 | /* Copyright (c) 1995, 1996 */ 12 | /* Pasquale J. Villani */ 13 | /* All Rights Reserved */ 14 | /* */ 15 | /* This file is part of DOS-C. */ 16 | /* */ 17 | /* DOS-C is free software; you can redistribute it and/or */ 18 | /* modify it under the terms of the GNU General Public License */ 19 | /* as published by the Free Software Foundation; either version */ 20 | /* 2, or (at your option) any later version. */ 21 | /* */ 22 | /* DOS-C is distributed in the hope that it will be useful, but */ 23 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 24 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 25 | /* the GNU General Public License for more details. */ 26 | /* */ 27 | /* You should have received a copy of the GNU General Public */ 28 | /* License along with DOS-C; see the file COPYING. If not, */ 29 | /* write to the Free Software Foundation, 675 Mass Ave, */ 30 | /* Cambridge, MA 02139, USA. */ 31 | /****************************************************************/ 32 | 33 | #ifdef MAIN 34 | #ifdef VERSION_STRINGS 35 | static BYTE *buffer_hRcsId = 36 | "$Id: buffer.h 1702 2012-02-04 08:46:16Z perditionc $"; 37 | #endif 38 | #endif 39 | 40 | #include "dsk.h" /* only for MAX_SEC_SIZE */ 41 | #define BUFFERSIZE MAX_SEC_SIZE 42 | 43 | struct buffer { 44 | UWORD b_next; /* next buffer in LRU list */ 45 | UWORD b_prev; /* previous buffer in LRU list */ 46 | BYTE b_unit; /* disk for this buffer */ 47 | BYTE b_flag; /* buffer flags */ 48 | ULONG b_blkno; /* block for this buffer */ 49 | UBYTE b_copies; /* number of copies to write */ 50 | UWORD b_offset; /* offset in sectors between copies 51 | to write for FAT sectors */ 52 | struct dpb FAR *b_dpbp; /* pointer to DPB */ 53 | UWORD b_remotesz; /* size of remote buffer if remote */ 54 | BYTE b_padding; 55 | UBYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ 56 | }; 57 | 58 | #define BFR_DIRTY 0x40 /* buffer modified */ 59 | #define BFR_VALID 0x20 /* buffer contains valid data */ 60 | #define BFR_DATA 0x08 /* buffer is from data area */ 61 | #define BFR_DIR 0x04 /* buffer is from dir area */ 62 | #define BFR_FAT 0x02 /* buffer is from fat area */ 63 | #define BFR_UNCACHE 0x01 /* buffer to be released ASAP */ 64 | 65 | -------------------------------------------------------------------------------- /hdr/cds.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* cds.h */ 4 | /* */ 5 | /* Current Directory structures */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | 30 | #define MAX_CDSPATH 67 31 | 32 | struct cds { 33 | BYTE cdsCurrentPath[MAX_CDSPATH]; 34 | UWORD cdsFlags; /* see below */ 35 | struct dpb FAR *cdsDpb; /* if != 0, associated DPB */ 36 | 37 | union { 38 | BYTE FAR *_cdsRedirRec; /* IFS record */ 39 | struct { 40 | UWORD _cdsStrtClst; /* if local path (Flags & CDSPHYSDRV): 41 | start cluster of CWD; root == 0, 42 | never access == 0xFFFF */ 43 | UWORD _cdsParam; 44 | } _cdsRedir; 45 | } _cdsUnion; 46 | 47 | UWORD cdsStoreUData; 48 | 49 | #define cdsJoinOffset cdsBackslashOffset 50 | WORD cdsBackslashOffset; /* Position of "root directory" backslash for 51 | this drive within CurrentPath[] 52 | prerequisites: 53 | + ofs <= strlen(currentPath) 54 | + if UNC: ofs > share component 55 | if local path: ofs > colon 56 | */ 57 | 58 | BYTE cdsNetFlag1; /* According to PCDOS 7 Tech Ref: IFS drive, 2=IFS, 4=NetUse */ 59 | BYTE FAR *cdsIfs; /* Pointer to Installable File System Header */ 60 | UWORD cdsNetFlags2; /* File System specific data */ 61 | 62 | }; 63 | 64 | #define cdsStrtClst _cdsUnion._cdsRedir._cdsStrtClst 65 | #define cdsRedirRec _cdsUnion._cdsRedirRec 66 | #define cdsParam _cdsUnion._cdsRedir._cdsParam 67 | 68 | /* Bits for cdsFlags (OR combination) */ 69 | #define CDSNETWDRV 0x8000 70 | #define CDSPHYSDRV 0x4000 71 | #define CDSJOINED 0x2000 /* not in combination with NETWDRV or SUBST */ 72 | #define CDSSUBST 0x1000 /* not in combination with NETWDRV or JOINED */ 73 | #define CDS_HIDDEN (1 << 7) /* hide drive from redirector's list */ 74 | 75 | /* NETWORK PHYSICAL meaning 76 | 0 0 drive not accessable 77 | 0 1 local file system 78 | 1 0 networked file system (UNC naming convention) 79 | 1 1 installable file system (IFS) 80 | */ 81 | #define CDSMODEMASK (CDSNETWDRV | CDSPHYSDRV) 82 | 83 | /* #define CDSVALID (CDSNETWDRV | CDSPHYSDRV) */ 84 | #define CDSVALID CDSMODEMASK 85 | 86 | #define IS_DEVICE 0x20 87 | #define IS_NETWORK 0x40 88 | 89 | #define CDS_MODE_SKIP_PHYSICAL 0x01 /* don't resolve SUBST, JOIN, NETW */ 90 | #define CDS_MODE_CHECK_DEV_PATH 0x02 /* check for existence of device path */ 91 | #define CDS_MODE_ALLOW_WILDCARDS 0x04 /* allow wildcards in "truename" */ 92 | -------------------------------------------------------------------------------- /hdr/clock.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* clock.h */ 4 | /* */ 5 | /* Clock Driver data structures & declarations */ 6 | /* */ 7 | /* November 26, 1991 */ 8 | /* */ 9 | /* Adapted to DOS/NT June 12, 1993 */ 10 | /* */ 11 | /* Copyright (c) 1995 */ 12 | /* Pasquale J. Villani */ 13 | /* All Rights Reserved */ 14 | /* */ 15 | /* This file is part of DOS-C. */ 16 | /* */ 17 | /* DOS-C is free software; you can redistribute it and/or */ 18 | /* modify it under the terms of the GNU General Public License */ 19 | /* as published by the Free Software Foundation; either version */ 20 | /* 2, or (at your option) any later version. */ 21 | /* */ 22 | /* DOS-C is distributed in the hope that it will be useful, but */ 23 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 24 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 25 | /* the GNU General Public License for more details. */ 26 | /* */ 27 | /* You should have received a copy of the GNU General Public */ 28 | /* License along with DOS-C; see the file COPYING. If not, */ 29 | /* write to the Free Software Foundation, 675 Mass Ave, */ 30 | /* Cambridge, MA 02139, USA. */ 31 | /****************************************************************/ 32 | 33 | #ifdef MAIN 34 | #ifdef VERSION_STRINGS 35 | static BYTE *clock_hRcsId = 36 | "$Id: clock.h 485 2002-12-09 00:17:15Z bartoldeman $"; 37 | #endif 38 | #endif 39 | 40 | struct ClockRecord { 41 | UWORD clkDays; /* days since Jan 1, 1980. */ 42 | UBYTE clkMinutes; /* residual minutes. */ 43 | UBYTE clkHours; /* residual hours. */ 44 | UBYTE clkHundredths; /* residual hundredths of a second. */ 45 | UBYTE clkSeconds; /* residual seconds. */ 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /hdr/date.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* date.h */ 4 | /* */ 5 | /* DOS General Date Structure */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | /* TC 2.01 complains if `date' is defined twice. -- ror4 */ 30 | #ifndef DOSC_DATE_H 31 | #define DOSC_DATE_H 32 | 33 | #ifdef MAIN 34 | #ifdef VERSION_STRINGS 35 | static BYTE *date_hRcsId = 36 | "$Id: date.h 485 2002-12-09 00:17:15Z bartoldeman $"; 37 | #endif 38 | #endif 39 | 40 | /* FAT file date - takes the form of yyyy yyym mmmd dddd where physical */ 41 | /* year=1980+yyyyyy */ 42 | 43 | #define DT_YEAR(d) (((d)>>9)&0x7f) 44 | #define DT_MONTH(d) (((d)>>5)&0x0f) 45 | #define DT_DAY(d) ((d)&0x1f) 46 | 47 | #define DT_ENCODE(m,d,y) ((((m)&0x0f)<<5)|((d)&0x1f)|(((y)&0x7f)<<9)) 48 | 49 | #define EPOCH_WEEKDAY 2 /* Tuesday (i. e.- 0 == Sunday) */ 50 | #define EPOCH_MONTH 1 /* January */ 51 | #define EPOCH_DAY 1 /* 1 for January 1 */ 52 | #define EPOCH_YEAR 1980 /* for Tues 1-1-80 epoch */ 53 | 54 | typedef UWORD date; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /hdr/dcb.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* dcb.h */ 4 | /* */ 5 | /* DOS Device Control Block Structure */ 6 | /* */ 7 | /* November 20, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *clock_hRcsId = 34 | "$Id: dcb.h 485 2002-12-09 00:17:15Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | /* Internal drive parameter block */ 39 | struct dpb { 40 | BYTE dpb_unit; /* unit for error reporting */ 41 | BYTE dpb_subunit; /* the sub-unit for driver */ 42 | UWORD dpb_secsize; /* sector size */ 43 | UBYTE dpb_clsmask; /* mask (sectors/cluster-1) */ 44 | UBYTE dpb_shftcnt; /* log base 2 of cluster size */ 45 | UWORD dpb_fatstrt; /* FAT start sector */ 46 | UBYTE dpb_fats; /* # of FAT copies */ 47 | UWORD dpb_dirents; /* # of dir entries */ 48 | UWORD dpb_data; /* start of data area */ 49 | UWORD dpb_size; /* # of clusters+1 on media */ 50 | UWORD dpb_fatsize; /* # of sectors / FAT */ 51 | UWORD dpb_dirstrt; /* start sec. of root dir */ 52 | struct dhdr FAR * /* pointer to device header */ 53 | dpb_device; 54 | UBYTE dpb_mdb; /* media descr. byte */ 55 | BYTE dpb_flags; /* -1 = force MEDIA CHK */ 56 | struct dpb FAR * /* next dpb in chain */ 57 | dpb_next; /* -1 = end */ 58 | UWORD dpb_cluster; /* cluster # of first free */ 59 | /* -1 if not known */ 60 | #ifndef WITHFAT32 61 | UWORD dpb_nfreeclst; /* number of free clusters */ 62 | /* -1 if not known */ 63 | #else 64 | union { 65 | struct { 66 | UWORD dpb_nfreeclst_lo; 67 | UWORD dpb_nfreeclst_hi; 68 | } dpb_nfreeclst_st; 69 | ULONG _dpb_xnfreeclst; /* number of free clusters */ 70 | /* -1 if not known */ 71 | } dpb_nfreeclst_un; 72 | #define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo 73 | #define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst 74 | 75 | UWORD dpb_xflags; /* extended flags, see bpb */ 76 | UWORD dpb_xfsinfosec; /* FS info sector number, */ 77 | /* 0xFFFF if unknown */ 78 | UWORD dpb_xbackupsec; /* backup boot sector number */ 79 | /* 0xFFFF if unknown */ 80 | ULONG dpb_xdata; 81 | ULONG dpb_xsize; /* # of clusters+1 on media */ 82 | ULONG dpb_xfatsize; /* # of sectors / FAT */ 83 | ULONG dpb_xrootclst; /* starting cluster of root dir */ 84 | ULONG dpb_xcluster; /* cluster # of first free */ 85 | /* -1 if not known */ 86 | #endif 87 | }; 88 | 89 | #define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ 90 | #define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ 91 | #define UNKNCLSTFREE 0xffff /* unknown for DOS */ 92 | 93 | -------------------------------------------------------------------------------- /hdr/dirmatch.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* dirmatch.h */ 4 | /* */ 5 | /* FAT File System Match Data Structure */ 6 | /* */ 7 | /* January 4, 1992 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *dirmatch_hRcsId = 34 | "$Id: dirmatch.h 1415 2009-06-02 13:18:24Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | typedef struct { 39 | UBYTE dm_drive; 40 | BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; 41 | UBYTE dm_attr_srch; 42 | UWORD dm_entry; 43 | CLUSTER dm_dircluster; 44 | #ifndef WITHFAT32 45 | UWORD reserved; 46 | #endif 47 | UWORD reserved2; 48 | 49 | UBYTE dm_attr_fnd; /* found file attribute */ 50 | time dm_time; /* file time */ 51 | date dm_date; /* file date */ 52 | ULONG dm_size; /* file size */ 53 | BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ 54 | } dmatch; 55 | -------------------------------------------------------------------------------- /hdr/dsk.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* dsk.h */ 4 | /* Disk access Header File */ 5 | /* */ 6 | /* Copyright (c) 2012 */ 7 | /* FreeDOS */ 8 | /* All Rights Reserved */ 9 | /* */ 10 | /* This file is part of DOS-C. */ 11 | /* */ 12 | /* DOS-C is free software; you can redistribute it and/or */ 13 | /* modify it under the terms of the GNU General Public License */ 14 | /* as published by the Free Software Foundation; either version */ 15 | /* 2, or (at your option) any later version. */ 16 | /* */ 17 | /* DOS-C is distributed in the hope that it will be useful, but */ 18 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 19 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 20 | /* the GNU General Public License for more details. */ 21 | /* */ 22 | /* You should have received a copy of the GNU General Public */ 23 | /* License along with DOS-C; see the file COPYING. If not, */ 24 | /* write to the Free Software Foundation, 675 Mass Ave, */ 25 | /* Cambridge, MA 02139, USA. */ 26 | /****************************************************************/ 27 | 28 | 29 | #ifndef MAX_SEC_SIZE 30 | #define MAX_SEC_SIZE (1*512) /* max supported size of sector in bytes */ 31 | #endif 32 | -------------------------------------------------------------------------------- /hdr/dyn.h: -------------------------------------------------------------------------------- 1 | /* 2 | DynData.h 3 | 4 | declarations for dynamic NEAR data allocations 5 | 6 | the DynBuffer must initially be large enough to hold 7 | the PreConfig data. 8 | after the disksystem has been initialized, the kernel is 9 | moveable and Dyn.Buffer resizable, but not before 10 | */ 11 | 12 | #ifndef DYN_H 13 | #define DYN_H 14 | 15 | struct DynS { 16 | unsigned Allocated; 17 | char Buffer[1]; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /hdr/error.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* error.h */ 4 | /* */ 5 | /* DOS-C error return codes */ 6 | /* */ 7 | /* December 1, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *error_hRcsId = 34 | "$Id: error.h 485 2002-12-09 00:17:15Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | /* Internal system error returns */ 39 | #define SUCCESS 0 /* Function was successful */ 40 | #define DE_INVLDFUNC -1 /* Invalid function number */ 41 | #define DE_FILENOTFND -2 /* File not found */ 42 | #define DE_PATHNOTFND -3 /* Path not found */ 43 | #define DE_TOOMANY -4 /* Too many open files */ 44 | #define DE_ACCESS -5 /* Access denied */ 45 | #define DE_INVLDHNDL -6 /* Invalid handle */ 46 | #define DE_MCBDESTRY -7 /* Memory control blocks shot */ 47 | #define DE_NOMEM -8 /* Insufficient memory */ 48 | #define DE_INVLDMCB -9 /* Invalid memory control block */ 49 | #define DE_INVLDENV -10 /* Invalid enviornement */ 50 | #define DE_INVLDFMT -11 /* Invalid format */ 51 | #define DE_INVLDACC -12 /* Invalid access */ 52 | #define DE_INVLDDATA -13 /* Invalid data */ 53 | #define DE_INVLDDRV -15 /* Invalid drive */ 54 | #define DE_RMVCUDIR -16 /* Attempt remove current dir */ 55 | #define DE_DEVICE -17 /* Not same device */ 56 | #define DE_NFILES -18 /* No more files */ 57 | #define DE_WRTPRTCT -19 /* No more files */ 58 | #define DE_BLKINVLD -20 /* invalid block */ 59 | #define DE_INVLDBUF -24 /* invalid buffer size, ext fnc */ 60 | #define DE_SEEK -25 /* error on file seek */ 61 | #define DE_HNDLDSKFULL -28 /* handle disk full (?) */ 62 | 63 | #define DE_INVLDPARM -0x57 /* invalid parameter */ 64 | 65 | #define DE_DEADLOCK -36 66 | #define DE_LOCK -39 67 | 68 | #define DE_FILEEXISTS -80 /* File exists */ 69 | 70 | /* Critical error flags */ 71 | #define EFLG_READ 0x00 /* Read error */ 72 | #define EFLG_WRITE 0x01 /* Write error */ 73 | #define EFLG_RSVRD 0x00 /* Error in rserved area */ 74 | #define EFLG_FAT 0x02 /* Error in FAT area */ 75 | #define EFLG_DIR 0x04 /* Error in dir area */ 76 | #define EFLG_DATA 0x06 /* Error in data area */ 77 | #define EFLG_ABORT 0x08 /* Handler can abort */ 78 | #define EFLG_RETRY 0x10 /* Handler can retry */ 79 | #define EFLG_IGNORE 0x20 /* Handler can ignore */ 80 | #define EFLG_CHAR 0x80 /* Error in char or FAT image */ 81 | 82 | /* error results returned after asking user */ 83 | /* MS-DOS compatible -- returned by CriticalError */ 84 | #define CONTINUE 0 85 | #define RETRY 1 86 | #define ABORT 2 87 | #define FAIL 3 88 | 89 | -------------------------------------------------------------------------------- /hdr/exe.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* exe.h */ 4 | /* */ 5 | /* DOS EXE Header Data Structure */ 6 | /* */ 7 | /* December 1, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *exe_hRcsId = 34 | "$Id: exe.h 485 2002-12-09 00:17:15Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | typedef struct { 39 | UWORD exSignature; 40 | UWORD exExtraBytes; 41 | UWORD exPages; 42 | UWORD exRelocItems; 43 | UWORD exHeaderSize; 44 | UWORD exMinAlloc; 45 | UWORD exMaxAlloc; 46 | UWORD exInitSS; 47 | UWORD exInitSP; 48 | UWORD exCheckSum; 49 | UWORD exInitIP; 50 | UWORD exInitCS; 51 | UWORD exRelocTable; 52 | UWORD exOverlay; 53 | } exe_header; 54 | 55 | #define MAGIC 0x5a4d 56 | #define OLD_MAGIC 0x4d5a 57 | 58 | -------------------------------------------------------------------------------- /hdr/file.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* file.h */ 4 | /* */ 5 | /* DOS File mode flags */ 6 | /* */ 7 | /* December 1, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *file_hRcsId = 34 | "$Id: file.h 831 2004-03-27 00:27:11Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | /* 0 = CON, standard input, can be redirected */ 39 | /* 1 = CON, standard output, can be redirected */ 40 | /* 2 = CON, standard error */ 41 | /* 3 = AUX, auxiliary */ 42 | /* 4 = PRN, list device */ 43 | /* 5 = 1st user file ... */ 44 | #define STDIN 0 45 | #define STDOUT 1 46 | #define STDERR 2 47 | #define STDAUX 3 48 | #define STDPRN 4 49 | 50 | /* mode bits */ 51 | #define O_VALIDMASK 0xfff3 /* valid open mask */ 52 | 53 | #define O_RDONLY 0x0000 54 | #define O_WRONLY 0x0001 55 | #define O_RDWR 0x0002 56 | #define O_ACCMODE 0x0003 57 | 58 | /* bits 2, 3 reserved */ 59 | 60 | /* bits 4, 5, 6 sharing modes */ 61 | /* see PC Mag Nov 15, 1988 "Networked Database" p234 by Frank J Derfler Jr */ 62 | #define O_SHAREMASK 0x0070 /* mask to isolate shared bits */ 63 | 64 | #define O_COMPAT 0x0000 /* default, compatibility mode */ 65 | #define O_DENYALL 0x0010 /* sharing bits */ 66 | #define O_DENYWRITE 0x0020 /* " " */ 67 | #define O_DENYREAD 0x0030 /* " " */ 68 | #define O_DENYNONE 0x0040 /* " " */ 69 | #define O_NETFCB 0x0070 /* networked fcb */ 70 | 71 | #define O_NOINHERIT 0x0080 72 | #define O_OPEN 0x0100 /* not */ 73 | #define O_TRUNC 0x0200 /* both */ 74 | #define O_CREAT 0x0400 75 | #define O_LEGACY 0x0800 76 | #define O_LARGEFILE 0x1000 77 | #define O_NOCRIT 0x2000 78 | #define O_SYNC 0x4000 79 | #define O_FCB 0x8000 80 | 81 | /* status for extended open */ 82 | enum {S_OPENED = 1, S_CREATED = 2, S_REPLACED = 3}; 83 | 84 | -------------------------------------------------------------------------------- /hdr/fnode.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* fnode.h */ 4 | /* */ 5 | /* Internal File Node for FAT File System */ 6 | /* */ 7 | /* January 4, 1992 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *fnode_hRcsId = 34 | "$Id: fnode.h 1432 2009-06-10 16:10:54Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | struct f_node { 39 | UWORD f_flags; /* file flags */ 40 | 41 | dmatch *f_dmp; /* this file's dir match */ 42 | struct dirent f_dir; /* this file's dir entry image */ 43 | 44 | ULONG f_dirsector; /* the sector containing dir entry*/ 45 | UBYTE f_diridx; /* offset/32 of dir entry in sec*/ 46 | /* when dir is not root */ 47 | struct dpb FAR *f_dpb; /* the block device for file */ 48 | 49 | ULONG f_offset; /* byte offset for next op */ 50 | CLUSTER f_cluster_offset; /* relative cluster number within file */ 51 | CLUSTER f_cluster; /* the cluster we are at */ 52 | UBYTE f_sft_idx; /* corresponding SFT index */ 53 | }; 54 | 55 | typedef struct f_node *f_node_ptr; 56 | 57 | struct lfn_inode { 58 | UNICODE l_name[261]; /* Long file name string */ 59 | /* If the string is empty, */ 60 | /* then file has the 8.3 name */ 61 | struct dirent l_dir; /* Directory entry image */ 62 | UWORD l_diroff; /* Current directory entry offset */ 63 | }; 64 | 65 | typedef struct lfn_inode FAR * lfn_inode_ptr; 66 | -------------------------------------------------------------------------------- /hdr/kbd.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* kbd.h */ 4 | /* */ 5 | /* Buffered Keyboard Input data structures & declarations */ 6 | /* */ 7 | /* July 5, 1993 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *kbd_hRcsId = 34 | "$Id: kbd.h 485 2002-12-09 00:17:15Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | #define LINEBUFSIZECON 128 39 | #define KBD_MAXLENGTH LINEBUFSIZECON+1 /* the above + LF */ 40 | #define LINEBUFSIZE0A 256 /* maximum length for int21/ah=0a */ 41 | 42 | /* Keyboard buffer */ 43 | typedef struct { 44 | UBYTE kb_size; /* size of buffer in bytes */ 45 | UBYTE kb_count; /* number of bytes returned */ 46 | BYTE kb_buf[KBD_MAXLENGTH]; /* the buffer itself */ 47 | } keyboard; 48 | 49 | -------------------------------------------------------------------------------- /hdr/kconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | KConfig.h 3 | 4 | DLASortByDriveNo 5 | 0 : Drive Letter Assignement ike MSDOS 6 | 1 : DLA - first drive completely first, then to next drive 7 | 8 | InitDiskShowDriveAssignment 9 | 0 : don't show what drive/partition assigned to what drive letter 10 | 1 : show info 11 | 12 | SkipConfigSeconds: 13 | < 0 : not possible to skip config.sys 14 | = 0 : only possible if already pressed before, no message 15 | > 0 : wait so long for F5/F8 16 | 17 | BootHarddiskSeconds: boots by default - and without user interaction - from HD 18 | <= 0: normal 19 | > 0: 20 | display message 21 | ' hit any key to continue to boot from 'diskette or CD' 22 | wait ## seconds 23 | if no key hit, boot from HD 24 | 25 | Version_: only in kernel 2042 or higher, offline version identification 26 | OemID: 0xFD for FreeDOS kernel, 0xDC for DosC kernel 27 | Major: actual kernel version (not MS-DOS compatibility version), e.g. 2 28 | Revision: revision sequence, e.g. 42 for kernel 2042 29 | Release: 0 if released version, >0 for svn builds (e.g. svn revision #) 30 | 31 | */ 32 | 33 | #ifndef KCONFIG_H 34 | #define KCONFIG_H 35 | 36 | typedef struct _KernelConfig { 37 | char CONFIG[6]; /* "CONFIG" */ 38 | unsigned short ConfigSize; 39 | 40 | unsigned char DLASortByDriveNo; 41 | unsigned char InitDiskShowDriveAssignment; 42 | signed char SkipConfigSeconds; 43 | unsigned char ForceLBA; 44 | unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ 45 | signed char BootHarddiskSeconds; 46 | 47 | /* for version 2042 and higher only */ 48 | unsigned char Version_OemID; 49 | unsigned char Version_Major; 50 | unsigned short Version_Revision; 51 | unsigned short Version_Release; 52 | 53 | } KernelConfig; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /hdr/mcb.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* mcb.h */ 4 | /* */ 5 | /* Memory Control Block data structures and declarations */ 6 | /* */ 7 | /* November 23, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *mcb_hRcsId = 34 | "$Id: mcb.h 822 2004-03-25 00:20:20Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | #define LARGEST -1 39 | #define FIRST_FIT 0 40 | #define BEST_FIT 1 41 | #define LAST_FIT 2 42 | #define FIRST_FIT_UO 0x40 43 | #define BEST_FIT_UO 0x41 44 | #define LAST_FIT_UO 0x42 45 | #define FIRST_FIT_U 0x80 46 | #define BEST_FIT_U 0x81 47 | #define LAST_FIT_U 0x82 48 | #define FIT_U_MASK 0xc0 49 | #define FIT_MASK 0x3f 50 | 51 | #define MCB_NORMAL 0x4d 52 | #define MCB_LAST 0x5a 53 | 54 | #define DOS_PSP 0x0060 /* 0x0008 What? seg 8 =0:0080 */ 55 | #define FREE_PSP 0 56 | 57 | #define MCB_SIZE(x) ((((LONG)(x))<<4)+sizeof(mcb)) 58 | 59 | typedef UWORD seg; 60 | typedef UWORD offset; 61 | 62 | typedef struct { 63 | BYTE m_type; /* mcb type - chain or end */ 64 | UWORD m_psp; /* owner id via psp segment */ 65 | UWORD m_size; /* size of segment in paragraphs */ 66 | BYTE m_fill[3]; 67 | BYTE m_name[8]; /* owner name limited to 8 bytes */ 68 | } mcb; 69 | 70 | -------------------------------------------------------------------------------- /hdr/network.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* network.h */ 4 | /* */ 5 | /* DOS Networking */ 6 | /* */ 7 | /* October 10, 1999 */ 8 | /* */ 9 | /* Copyright (c) 1999 */ 10 | /* James Tabor */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifndef NETWORK_H 32 | #define NETWORK_H 33 | 34 | /* Defines for remote access functions */ 35 | #define REM_RMDIR 0x1101 36 | #define REM_MKDIR 0x1103 37 | #define REM_CHDIR 0x1105 38 | #define REM_CLOSE 0x1106 39 | #define REM_FLUSH 0x1107 40 | #define REM_READ 0x1108 41 | #define REM_WRITE 0x1109 42 | #define REM_LOCK 0x110a 43 | #define REM_UNLOCK 0x110b 44 | #define REM_GETSPACE 0x110c 45 | #define REM_SETATTR 0x110e 46 | #define REM_GETATTRZ 0x110f 47 | #define REM_RENAME 0x1111 48 | #define REM_DELETE 0x1113 49 | #define REM_OPEN 0x1116 50 | #define REM_CREATE 0x1117 51 | #define REM_CRTRWOCDS 0x1118 52 | #define REM_FND1WOCDS 0x1119 53 | #define REM_FINDFIRST 0x111B 54 | #define REM_FINDNEXT 0x111C 55 | #define REM_CLOSEALL 0x111d 56 | #define REM_DOREDIRECT 0x111e 57 | #define REM_PRINTSET 0x111f 58 | #define REM_FLUSHALL 0x1120 59 | #define REM_LSEEK 0x1121 60 | #define REM_PROCESS_END 0x1122 61 | #define REM_FILENAME 0x1123 62 | #define REM_PRINTREDIR 0x1125 63 | #define REM_EXTOC 0x112e 64 | 65 | struct rgds { 66 | UWORD r_spc; 67 | UWORD r_navc; 68 | UWORD r_bps; 69 | UWORD r_nc; 70 | }; 71 | 72 | struct remote_fileattrib { 73 | UWORD rfa_file; /* File Attributes */ 74 | union { 75 | ULONG rfa_filesize; /* file size */ 76 | struct { 77 | UWORD rfa_filesize_lo; /* DI Low */ 78 | UWORD rfa_filesize_hi; /* BX High */ 79 | } _split_rfa_fz; 80 | } rfa_fz_union; 81 | UWORD rfa_time; 82 | UWORD rfa_date; 83 | }; 84 | 85 | struct remote_lock_unlock { 86 | UDWORD ofs, len; 87 | }; 88 | 89 | #endif /* NETWORK_H */ 90 | -------------------------------------------------------------------------------- /hdr/nls.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/hdr/nls.h -------------------------------------------------------------------------------- /hdr/tail.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* tail.h */ 4 | /* */ 5 | /* Command tail data structures */ 6 | /* */ 7 | /* July 1, 1993 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #ifdef MAIN 32 | #ifdef VERSION_STRINGS 33 | static BYTE *tail_hRcsId = 34 | "$Id: tail.h 485 2002-12-09 00:17:15Z bartoldeman $"; 35 | #endif 36 | #endif 37 | 38 | #define CTBUFFERSIZE 127 39 | 40 | typedef struct { 41 | UBYTE ctCount; /* number of bytes returned */ 42 | char ctBuffer[CTBUFFERSIZE]; /* the buffer itself */ 43 | } CommandTail; 44 | 45 | -------------------------------------------------------------------------------- /hdr/time.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* time.h */ 4 | /* */ 5 | /* DOS General Time Structure */ 6 | /* */ 7 | /* January 21, 1993 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | /* TC 2.01 complains if `time' is defined twice. -- ror4 */ 32 | #ifndef DOSC_TIME_H 33 | #define DOSC_TIME_H 34 | 35 | #ifdef MAIN 36 | #ifdef VERSION_STRINGS 37 | static BYTE *time_hRcsId = 38 | "$Id: time.h 942 2004-05-23 15:00:37Z bartoldeman $"; 39 | #endif 40 | #endif 41 | 42 | typedef UWORD time; 43 | 44 | struct dostime 45 | { 46 | unsigned char minute, hour, hundredth, second; 47 | }; 48 | 49 | struct dosdate 50 | { 51 | unsigned short year; 52 | unsigned char monthday, month; 53 | }; 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /hdr/version.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* version.h */ 4 | /* */ 5 | /* Common version information */ 6 | /* */ 7 | /* Copyright (c) 1997 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | /* The version the kernel reports as compatible with */ 30 | /* The version of DOS kernel reported as compatible with to */ 31 | /* applications - major.minor.revision */ 32 | /* DOS version 7.10 with FAT32 support or 6.22 otherwise */ 33 | #ifdef WITHFAT32 34 | #define MAJOR_RELEASE 7 35 | #define MINOR_RELEASE 10 36 | #else 37 | #define MAJOR_RELEASE 6 38 | #define MINOR_RELEASE 22 39 | #endif 40 | 41 | /* The actual kernel revision */ 42 | #ifdef OEM_DOSC 43 | /* 3000+REVISION_SEQ = 3.REVISION_SEQ */ 44 | #define REVISION_SEQ 0 /* returned in BL by int 21 function 30 */ 45 | #define OEM_ID 0xdc /* FreeDOS, returned in BH by int 21 30 */ 46 | #define OEM_NAME "DOS-C" 47 | #define OEM_BUILD "3." 48 | #else 49 | /* 2000+REVISION_SEQ = 2.REVISION_SEQ */ 50 | #define REVISION_SEQ 42 /* returned in BL by int 21 function 30 */ 51 | #define OEM_ID 0xfd /* FreeDOS, returned in BH by int 21 30 */ 52 | #define OEM_NAME "FreeDOS" 53 | #define OEM_BUILD "20" 54 | #endif 55 | 56 | 57 | /* Used for version information displayed to user at boot (& stored in os_release string) */ 58 | #ifndef KERNEL_VERSION 59 | #define KERNEL_VERSION "- VCS " /* Version Control System, e.g. SVN,GIT,... */ 60 | #endif 61 | 62 | 63 | /* actual version string, displayed at signon & via FD int 21h/ax=33FFh */ 64 | #define KVS(v,s,o,n,b) n " kernel " v "(build " b #s " OEM:" #o ") [compiled " __DATE__ "]\n" 65 | #define xKVS(v,s,o,n,b) KVS(v,s,o,n,b) 66 | #define KERNEL_VERSION_STRING xKVS(KERNEL_VERSION, REVISION_SEQ, OEM_ID, OEM_NAME, OEM_BUILD) 67 | 68 | -------------------------------------------------------------------------------- /hdr/win.h: -------------------------------------------------------------------------------- 1 | #ifndef __WINSUPPORT_H 2 | #define __WINSUPPORT_H 3 | #ifdef WIN31SUPPORT /* defined to enable kernel hooks for win3.x compatibility */ 4 | 5 | 6 | extern UWORD winInstanced; /* internal flag marking if Windows is active */ 7 | 8 | /* contains information about data that must be kept for each active DOS 9 | instance, ie data that can NOT be shared between multiple VMs. 10 | */ 11 | struct WinStartupInfo 12 | { 13 | UWORD winver; /* this structure version, matches Windows version */ 14 | ULONG next; /* far pointer to next WinStartupInfo structure or NULL */ 15 | ULONG vddName; /* far pointer to ASCIIZ pathname of virtual device driver */ 16 | ULONG vddInfo; /* far pointer to vdd reference data or NULL if vddName=NULL */ 17 | ULONG instanceTable; /* far pointer to array of instance data */ 18 | ULONG optInstanceTable; /* used only if winver set to 0x400 (w95)*/ 19 | }; 20 | extern struct WinStartupInfo winStartupInfo; 21 | 22 | /* contains a list of offsets relative to DOS data segment of 23 | various internal variables. 24 | */ 25 | struct WinPatchTable 26 | { 27 | UWORD dosver; 28 | UWORD OffTempDS; 29 | UWORD OffTempBX; 30 | UWORD OffInDOS; 31 | UWORD OffMachineID; 32 | UWORD OffCritSectPatches; 33 | UWORD OffLastMCBSeg; /* used by Win 3.1 if DOS version 5 or higher */ 34 | }; 35 | extern struct WinPatchTable winPatchTable; 36 | 37 | 38 | #endif /* WIN31SUPPORT */ 39 | #endif /* __WINSUPPORT_H */ 40 | -------------------------------------------------------------------------------- /hdr/xstructs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* xstructs.h */ 4 | /* */ 5 | /* Extended DOS 7.0+ structures */ 6 | /* */ 7 | /****************************************************************/ 8 | 9 | #ifdef MAIN 10 | #ifdef VERSION_STRINGS 11 | static BYTE *XStructs_hRcsId = 12 | "$Id: xstructs.h 1457 2009-06-26 20:00:41Z bartoldeman $"; 13 | #endif 14 | #endif 15 | 16 | struct xdpbdata { 17 | UWORD xdd_dpbsize; 18 | struct dpb xdd_dpb; 19 | }; 20 | 21 | struct xfreespace { 22 | UWORD xfs_datasize; /* size of this structure */ 23 | union { 24 | UWORD requested; /* requested structure version */ 25 | UWORD actual; /* actual structure version */ 26 | } xfs_version; 27 | ULONG xfs_clussize; /* number of sectors per cluster */ 28 | ULONG xfs_secsize; /* number of bytes per sector */ 29 | ULONG xfs_freeclusters; /* number of available clusters */ 30 | ULONG xfs_totalclusters; /* total number of clusters on the drive */ 31 | ULONG xfs_freesectors; /* number of physical sectors available */ 32 | ULONG xfs_totalsectors; /* total number of physical sectors */ 33 | ULONG xfs_freeunits; /* number of available allocation units */ 34 | ULONG xfs_totalunits; /* total allocation units */ 35 | UBYTE xfs_reserved[8]; 36 | }; 37 | 38 | struct xdpbforformat { 39 | UWORD xdff_datasize; /* size of this structure */ 40 | union { 41 | UWORD requested; /* requested structure version */ 42 | UWORD actual; /* actual structure version */ 43 | } xdff_version; 44 | UDWORD xdff_function; /* function number: 45 | 00h invalidate DPB counts 46 | 01h rebuild DPB from BPB 47 | 02h force media change 48 | 03h get/set active FAT number and mirroring 49 | 04h get/set root directory cluster number 50 | */ 51 | union { 52 | struct { 53 | DWORD nfreeclst; /* # free clusters 54 | (-1 - unknown, 0 - don't change) */ 55 | DWORD cluster; /* cluster # of first free 56 | (-1 - unknown, 0 - don't change) */ 57 | UDWORD reserved[2]; 58 | } setdpbcounts; 59 | 60 | struct { 61 | UDWORD unknown; 62 | bpb FAR *bpbp; 63 | UDWORD reserved[2]; 64 | } rebuilddpb; 65 | 66 | struct { 67 | DWORD new; /* new active FAT/mirroring state, or -1 to get 68 | bits 3-0: the 0-based FAT number of the active FAT 69 | bits 6-4: reserved (0) 70 | bit 7: do not mirror active FAT to inactive FATs 71 | or: 72 | set new root directory cluster, -1 - get current 73 | */ 74 | DWORD old; /* previous active FAT/mirroring state (as above) 75 | or 76 | get previous root directory cluster 77 | */ 78 | UDWORD reserved[2]; 79 | } setget; 80 | } xdff_f; 81 | }; 82 | 83 | COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp); 84 | -------------------------------------------------------------------------------- /kernel/apisupt.asm: -------------------------------------------------------------------------------- 1 | ; File: 2 | ; apisupt.asm 3 | ; Description: 4 | ; Assembly support routines for stack manipulation, etc. 5 | ; 6 | ; Copyright (c) 1995, 1998 7 | ; Pasquale J. Villani 8 | ; All Rights Reserved 9 | ; 10 | ; This file is part of DOS-C. 11 | ; 12 | ; DOS-C is free software; you can redistribute it and/or 13 | ; modify it under the terms of the GNU General Public License 14 | ; as published by the Free Software Foundation; either version 15 | ; 2, or (at your option) any later version. 16 | ; 17 | ; DOS-C is distributed in the hope that it will be useful, but 18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 20 | ; the GNU General Public License for more details. 21 | ; 22 | ; You should have received a copy of the GNU General Public 23 | ; License along with DOS-C; see the file COPYING. If not, 24 | ; write to the Free Software Foundation, 675 Mass Ave, 25 | ; Cambridge, MA 02139, USA. 26 | ; 27 | ; $Id: apisupt.asm 538 2003-03-12 22:43:53Z bartoldeman $ 28 | ; 29 | 30 | %include "segs.inc" 31 | 32 | segment HMA_TEXT 33 | %if 0 34 | 35 | extern _api_sp:wrt DGROUP ; api stacks - for context 36 | extern _api_ss:wrt DGROUP ; switching 37 | extern _usr_sp:wrt DGROUP ; user stacks 38 | extern _usr_ss:wrt DGROUP 39 | 40 | global _set_stack 41 | ; 42 | ; void set_stack(void) - 43 | ; save current stack and setup our local stack 44 | ; 45 | _set_stack: 46 | 47 | ; save foreground stack 48 | 49 | ; we need to get the return values from the stack 50 | ; since the current stack will change 51 | pop ax ;get return offset 52 | 53 | ; Save the flags so that we can restore correct interrupt 54 | ; state later. We need to disable interrupts so that we 55 | ; don't trash memory with new sp-old ss combination 56 | pushf 57 | pop dx 58 | cli 59 | 60 | ; save bp 61 | push bp 62 | 63 | mov cx, sp 64 | neg cx 65 | 66 | ; save away foreground process' stack 67 | push word [_usr_ss] 68 | push word [_usr_sp] 69 | 70 | mov word [_usr_ss],ss 71 | mov word [_usr_sp],sp 72 | 73 | ; setup our local stack 74 | mov ss,word [_api_ss] 75 | mov sp,word [_api_sp] 76 | 77 | add cx, sp 78 | add bp, cx 79 | 80 | ; setup for ret 81 | push ax 82 | 83 | ; now restore interrupt state 84 | push dx 85 | popf 86 | 87 | ret 88 | 89 | ; 90 | ; void restore_stack(void) - 91 | ; restore foreground stack, throw ours away 92 | ; 93 | global _restore_stack 94 | _restore_stack: 95 | 96 | ; we need to get the return values from the stack 97 | ; since the current stack will change 98 | pop cx ;get return offset 99 | 100 | ; Save the flags so that we can restore correct interrupt 101 | ; state later. We need to disable interrupts so that we 102 | ; don't trash memory with new sp-old ss combination 103 | pushf 104 | pop dx 105 | cli 106 | 107 | ; save background stack 108 | mov word [_api_ss],ss 109 | mov word [_api_sp],sp 110 | 111 | ; restore foreground stack here 112 | mov ss,word [_usr_ss] 113 | mov sp,word [_usr_sp] 114 | 115 | pop word [_usr_sp] 116 | pop word [_usr_ss] 117 | 118 | ; make bp relative to our stack frame 119 | pop bp 120 | ;mov bp,sp 121 | 122 | ; setup for ret 123 | push cx 124 | 125 | ; now restore interrupt state 126 | push dx 127 | popf 128 | 129 | ret 130 | %endif 131 | -------------------------------------------------------------------------------- /kernel/break.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* break.c */ 4 | /* FreeDOS */ 5 | /* */ 6 | /* Control Break detection and handling */ 7 | /* */ 8 | /* Copyright (c) 1999 */ 9 | /* Steffen Kaiser */ 10 | /* All Rights Reserved */ 11 | /* */ 12 | /* This file is part of DOS-C. */ 13 | /* */ 14 | /* DOS-C is free software; you can redistribute it and/or */ 15 | /* modify it under the terms of the GNU General Public License */ 16 | /* as published by the Free Software Foundation; either version */ 17 | /* 2, or (at your option) any later version. */ 18 | /* */ 19 | /* DOS-C is distributed in the hope that it will be useful, but */ 20 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 21 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 22 | /* the GNU General Public License for more details. */ 23 | /* */ 24 | /* You should have received a copy of the GNU General Public */ 25 | /* License along with DOS-C; see the file COPYING. If not, */ 26 | /* write to the Free Software Foundation, 675 Mass Ave, */ 27 | /* Cambridge, MA 02139, USA. */ 28 | /****************************************************************/ 29 | 30 | #include "portab.h" 31 | #include "globals.h" 32 | #include "proto.h" 33 | 34 | #ifdef VERSION_STRINGS 35 | static BYTE *RcsId = 36 | "$Id: break.c 885 2004-04-14 15:40:51Z bartoldeman $"; 37 | #endif 38 | 39 | #define CB_FLG *(UBYTE FAR*)MK_FP(0x0, 0x471) 40 | #define CB_MSK 0x80 41 | 42 | /* Check for ^Break/^C. 43 | * Three sources are available: 44 | * 1) flag at 40:71 bit 7 45 | * 2) syscon stream (usually CON:) 46 | * 3) i/o stream (if unequal to syscon, e.g. AUX) 47 | */ 48 | 49 | unsigned char ctrl_break_pressed(void) 50 | { 51 | return CB_FLG & CB_MSK; 52 | } 53 | 54 | unsigned char check_handle_break(struct dhdr FAR **pdev) 55 | { 56 | unsigned char c = CTL_C; 57 | if (!ctrl_break_pressed()) 58 | c = (unsigned char)ndread(&syscon); 59 | if (c != CTL_C && *pdev != syscon) 60 | c = (unsigned char)ndread(pdev); 61 | if (c == CTL_C) 62 | handle_break(pdev, -1); 63 | return c; 64 | } 65 | 66 | /* 67 | * Handles a ^Break state 68 | * 69 | * Actions: 70 | * 1) clear the ^Break flag 71 | * 2) clear the STDIN stream 72 | * 3) echo ^C to sft_out or pdev if sft_out==-1 73 | * 4) decrease the InDOS flag as the kernel drops back to user space 74 | * 5) invoke INT-23 and never come back 75 | */ 76 | 77 | void handle_break(struct dhdr FAR **pdev, int sft_out) 78 | { 79 | char *buf = "^C\r\n"; 80 | 81 | CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ 82 | con_flush(pdev); 83 | if (sft_out == -1) 84 | cooked_write(pdev, 4, buf); 85 | else 86 | DosRWSft(sft_out, 4, buf, XFR_FORCE_WRITE); 87 | if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ 88 | if (InDOS) 89 | --InDOS; /* fail-safe */ 90 | 91 | spawn_int23(); /* invoke user INT-23 and never come back */ 92 | } 93 | 94 | -------------------------------------------------------------------------------- /kernel/config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* config.h */ 4 | /* DOS-C */ 5 | /* */ 6 | /* Global data structures and declarations */ 7 | /* */ 8 | /* Copyright (c) 2000 */ 9 | /* Steffen Kaiser */ 10 | /* All Rights Reserved */ 11 | /* */ 12 | /* This file is part of DOS-C. */ 13 | /* */ 14 | /* DOS-C is free software; you can redistribute it and/or */ 15 | /* modify it under the terms of the GNU General Public License */ 16 | /* as published by the Free Software Foundation; either version */ 17 | /* 2, or (at your option) any later version. */ 18 | /* */ 19 | /* DOS-C is distributed in the hope that it will be useful, but */ 20 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 21 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 22 | /* the GNU General Public License for more details. */ 23 | /* */ 24 | /* You should have received a copy of the GNU General Public */ 25 | /* License along with DOS-C; see the file COPYING. If not, */ 26 | /* write to the Free Software Foundation, 675 Mass Ave, */ 27 | /* Cambridge, MA 02139, USA. */ 28 | /****************************************************************/ 29 | 30 | struct config { /* Configuration variables */ 31 | UBYTE cfgDosDataUmb; 32 | BYTE cfgBuffers; /* number of buffers in the system */ 33 | UBYTE cfgFiles; /* number of available files */ 34 | UBYTE cfgFilesHigh; 35 | UBYTE cfgFcbs; /* number of available FCBs */ 36 | UBYTE cfgProtFcbs; /* number of protected FCBs */ 37 | BYTE *cfgInit; /* init of command.com */ 38 | BYTE *cfgInitTail; /* command.com's tail */ 39 | UBYTE cfgLastdrive; /* last drive */ 40 | UBYTE cfgLastdriveHigh; 41 | BYTE cfgStacks; /* number of stacks */ 42 | BYTE cfgStacksHigh; 43 | UWORD cfgStackSize; /* stacks size for each stack */ 44 | UBYTE cfgP_0_startmode; /* load command.com high or not */ 45 | unsigned ebda2move; /* value for switches=/E:nnnn */ 46 | }; 47 | -------------------------------------------------------------------------------- /kernel/cpu.asm: -------------------------------------------------------------------------------- 1 | ; File: 2 | ; cpu.asm 3 | ; Description: 4 | ; Query basic CPU running on 5 | ; 6 | ; DOS-C 7 | ; Copyright (c) 2012 8 | ; FreeDOS 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; 24 | 25 | %include "segs.inc" 26 | segment INIT_TEXT 27 | 28 | CPU 386 29 | ;********************************************************************* 30 | ; 31 | ; UWORD query_cpu() based on Eric Auer's public domain cpulevel.asm 32 | ; input: none 33 | ; output: ax = cpu, 0=8086/8088, 1=186/188, 2=286, 3=386+ 34 | global _query_cpu 35 | _query_cpu: 36 | ; save registers, assumes enough space on stack & valid stack frame setup 37 | ;push ax - no need to save, return value saved here 38 | push bx 39 | push cx 40 | pushf ; save flags 41 | 42 | ; begin check, assume x86 unless later family detected 43 | xor bx, bx ; 808x or 186 highest detected family stored in bx 44 | push bx 45 | popf ; try to clear all flag bits 46 | pushf ; copy flags to ax so we can test if clear succeeded 47 | pop ax 48 | and ax, 0f000h 49 | cmp ax, 0f000h 50 | jnz is286 ; no the 4 msb stuck set to 1, so is a 808x or 8018x 51 | mov ax,1 ; determine if 8086 or 186 52 | mov cl,64 ; try to shift further than size of ax 53 | shr ax,cl 54 | or ax,ax 55 | jz is086 ; 186 ignores the upper bits of cl 56 | mov bx, 1 ; 186: above 808x, below 286 57 | is086: jmp short cleanup 58 | is286: mov bx, 2 ; at least 286 59 | mov ax, 0f000h 60 | push ax 61 | popf ; try to set 4 msb of flags 62 | pushf ; copy flags to ax so we can test if clear succeeded 63 | pop ax 64 | test ax, 0f000h 65 | jz cleanup ; 4 msb stuck to 0: 80286 66 | mov bx, 3 ; at least 386 67 | 68 | cleanup: 69 | mov ax, bx ; return CPU family 70 | popf 71 | pop cx 72 | pop bx 73 | retn 74 | 75 | -------------------------------------------------------------------------------- /kernel/dosidle.asm: -------------------------------------------------------------------------------- 1 | ; File: 2 | ; DosIdle.asm 3 | ; Description: 4 | ; Dos Idle Interrupt Call 5 | ; 6 | ; DOS-C 7 | ; Copyright (c) 1995, 1999 8 | ; James B. Tabor 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; You should have received a copy of the GNU General Public 24 | ; License along with DOS-C; see the file COPYING. If not, 25 | ; write to the Free Software Foundation, 675 Mass Ave, 26 | ; Cambridge, MA 02139, USA. 27 | ; 28 | ; 29 | %include "segs.inc" 30 | 31 | PSP_USERSP equ 2eh 32 | PSP_USERSS equ 30h 33 | 34 | segment HMA_TEXT 35 | 36 | global _DosIdle_int 37 | global _DosIdle_hlt 38 | 39 | extern _InDOS 40 | extern _cu_psp 41 | extern _MachineId 42 | extern critical_sp 43 | extern _user_r 44 | ; variables as the following are "part of" module inthndlr.c 45 | ; because of the define MAIN before include globals.h there! 46 | extern _HaltCpuWhileIdle 47 | extern _DGROUP_ 48 | ; 49 | _DosIdle_hlt: 50 | push ds 51 | mov ds, [cs:_DGROUP_] 52 | cmp byte [_HaltCpuWhileIdle],1 53 | jb DosId0 54 | pushf 55 | sti 56 | hlt ; save some energy :-) 57 | popf 58 | DosId0: pop ds 59 | retn 60 | ; 61 | _DosIdle_int: 62 | call _DosIdle_hlt 63 | push ds 64 | mov ds, [cs:_DGROUP_] 65 | cmp byte [_InDOS],1 66 | ja DosId1 67 | call Do_DosI 68 | DosId1: 69 | pop ds 70 | retn 71 | 72 | Do_DosI: 73 | push ax 74 | push es 75 | push word [_MachineId] 76 | push word [_user_r] 77 | push word [_user_r+2] 78 | mov es,word [_cu_psp] 79 | push word [es:PSP_USERSS] 80 | push word [es:PSP_USERSP] 81 | 82 | int 28h 83 | 84 | mov es,word [_cu_psp] 85 | pop word [es:PSP_USERSP] 86 | pop word [es:PSP_USERSS] 87 | pop word [_user_r+2] 88 | pop word [_user_r] 89 | pop word [_MachineId] 90 | pop es 91 | pop ax 92 | ret 93 | 94 | ; segment _DATA ; belongs to DGROUP 95 | ; whatever db whatever 96 | 97 | -------------------------------------------------------------------------------- /kernel/dyndata.h: -------------------------------------------------------------------------------- 1 | /* 2 | DynData.h 3 | 4 | declarations for dynamic NEAR data allocations 5 | 6 | the DynBuffer must initially be large enough to hold 7 | the PreConfig data. 8 | after the disksystem has been initialized, the kernel is 9 | moveable and Dyn.Buffer resizable, but not before 10 | */ 11 | 12 | #ifndef DYNDATA_H 13 | #define DYNDATA_H 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | void far *DynAlloc(char *what, unsigned num, unsigned size); 20 | void far *DynLast(void); 21 | void DynFree(void *ptr); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /kernel/dyninit.c: -------------------------------------------------------------------------------- 1 | /* 2 | DYNINIT.C 3 | 4 | this serves requests from the INIT modules to 5 | allocate dynamic data. 6 | 7 | kernel layout: 8 | 00000H 000FFH 00100H PSP PSP 9 | 00100H 004E1H 003E2H _TEXT CODE 10 | 004E2H 007A7H 002C6H _IO_TEXT CODE 11 | 007A8H 008E5H 0013EH _IO_FIXED_DATA CODE 12 | 008F0H 0139FH 00AB0H _FIXED_DATA DATA 13 | 013A0H 019F3H 00654H _DATA DATA 14 | 019F4H 0240DH 00A1AH _BSS BSS 15 | 16 | additionally: 17 | DYN_DATA DYN 18 | 19 | 20 | 02610H 0F40EH 0CDFFH HMA_TEXT HMA 21 | 22 | FCBs, f_nodes, buffers,... 23 | drivers 24 | 25 | 26 | 0F410H 122DFH 02ED0H INIT_TEXT INIT 27 | 122E0H 12AA5H 007C6H ID ID 28 | 12AA6H 12CBFH 0021AH IB IB 29 | 30 | purpose is to move the HMA_TEXT = resident kernel 31 | around, so that below it - after BSS, there is data 32 | addressable near by the kernel, to hold some arrays 33 | like f_nodes 34 | 35 | making f_nodes near saves ~2.150 code in HMA 36 | 37 | */ 38 | #include "portab.h" 39 | #include "init-mod.h" 40 | #include "dyn.h" 41 | #include "dyndata.h" 42 | #include "debug.h" 43 | 44 | 45 | #ifndef __TURBOC__ 46 | extern struct DynS DOSFAR ASM Dyn; 47 | #else 48 | extern struct DynS FAR ASM Dyn; 49 | #endif 50 | 51 | void far *DynAlloc(char *what, unsigned num, unsigned size) 52 | { 53 | void far *now; 54 | unsigned total = num * size; 55 | struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); 56 | 57 | #ifndef DEBUG 58 | UNREFERENCED_PARAMETER(what); 59 | #endif 60 | 61 | if ((ULONG) total + Dynp->Allocated > 0xffff) 62 | { 63 | printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated); 64 | for (;;) ; 65 | } 66 | 67 | DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", 68 | what, num, size, total, Dynp->Allocated, 69 | Dynp->Allocated + total)); 70 | 71 | now = (void far *)&Dynp->Buffer[Dynp->Allocated]; 72 | fmemset(now, 0, total); 73 | 74 | Dynp->Allocated += total; 75 | 76 | return now; 77 | } 78 | 79 | void DynFree(void *ptr) 80 | { 81 | struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); 82 | Dynp->Allocated = (char *)ptr - (char *)Dynp->Buffer; 83 | } 84 | 85 | void FAR * DynLast() 86 | { 87 | struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); 88 | DebugPrintf(("dynamic data end at %p\n", 89 | (void FAR *)(Dynp->Buffer + Dynp->Allocated))); 90 | 91 | return Dynp->Buffer + Dynp->Allocated; 92 | } 93 | -------------------------------------------------------------------------------- /kernel/error.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* error.c */ 4 | /* */ 5 | /* Main Kernel Error Handler Functions */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | #include "portab.h" 30 | 31 | #ifdef VERSION_STRINGS 32 | static BYTE *errorRcsId = 33 | "$Id: error.c 709 2003-09-24 19:34:11Z bartoldeman $"; 34 | #endif 35 | 36 | #include "globals.h" 37 | 38 | #ifdef DEBUG 39 | /* error registers */ 40 | VOID dump(void) 41 | { 42 | printf("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n", 43 | error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS); 44 | printf("AX:%04x BX:%04x CX:%04x DX:%04x\n", 45 | error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX); 46 | printf("SI:%04x DI:%04x DS:%04x ES:%04x\n", 47 | error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES); 48 | } 49 | #endif 50 | 51 | /* issue a panic message for corrupted data structures */ 52 | VOID panic(BYTE * s) 53 | { 54 | put_string("\nPANIC: "); 55 | put_string(s); 56 | put_string("\nSystem halted"); 57 | for (;;) ; 58 | } 59 | 60 | #ifdef IPL 61 | /* issue an internal error message */ 62 | VOID fatal(BYTE * err_msg) 63 | { 64 | printf("\nInternal IPL error - %s\nSystem halted\n", err_msg); 65 | exit(-1); 66 | } 67 | #else 68 | /* issue an internal error message */ 69 | #if 0 70 | VOID fatal(BYTE * err_msg) 71 | { 72 | printf("\nInternal kernel error - \n"); 73 | panic(err_msg); 74 | } 75 | #endif 76 | #endif 77 | 78 | /* Abort, retry or fail for character devices */ 79 | COUNT char_error(request * rq, struct dhdr FAR * lpDevice) 80 | { 81 | CritErrCode = (rq->r_status & S_MASK) + 0x13; 82 | return CriticalError(EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, 83 | 0, rq->r_status & S_MASK, lpDevice); 84 | } 85 | 86 | /* Abort, retry or fail for block devices */ 87 | COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice, 88 | int mode) 89 | { 90 | CritErrCode = (rq->r_status & S_MASK) + 0x13; 91 | return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE | 92 | (mode == DSKWRITE ? EFLG_WRITE : 0), 93 | nDrive, rq->r_status & S_MASK, lpDevice); 94 | } 95 | 96 | -------------------------------------------------------------------------------- /kernel/execrh.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; File: 3 | ; execrh.asm 4 | ; Description: 5 | ; request handler for calling device drivers 6 | ; 7 | ; Copyright (c) 1995, 1998 8 | ; Pasquale J. Villani 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; You should have received a copy of the GNU General Public 24 | ; License along with DOS-C; see the file COPYING. If not, 25 | ; write to the Free Software Foundation, 675 Mass Ave, 26 | ; Cambridge, MA 02139, USA. 27 | ; 28 | ; $Id: execrh.asm 1184 2006-05-20 20:49:59Z mceric $ 29 | ; 30 | 31 | %include "segs.inc" 32 | %include "stacks.inc" 33 | 34 | segment HMA_TEXT 35 | ; EXECRH 36 | ; Execute Device Request 37 | ; 38 | ; execrh(rhp, dhp) 39 | ; request far *rhp; 40 | ; struct dhdr far *dhp; 41 | ; 42 | ; 43 | ; The stack is very critical in here. 44 | ; 45 | global EXECRH 46 | global INIT_EXECRH 47 | 48 | %macro EXECRHM 0 49 | push bp ; perform c entry 50 | mov bp,sp 51 | push si 52 | push ds ; sp=bp-8 53 | 54 | arg {rhp,4}, {dhp,4} 55 | lds si,[.dhp] ; ds:si = device header 56 | les bx,[.rhp] ; es:bx = request header 57 | 58 | 59 | mov ax, [si+6] ; construct strategy address 60 | mov [.dhp], ax 61 | 62 | push si ; the bloody fucking RTSND.DOS 63 | push di ; driver destroys SI,DI (tom 14.2.03) 64 | 65 | call far[.dhp] ; call far the strategy 66 | 67 | pop di 68 | pop si 69 | 70 | ; Protect386Registers ; old free-EMM386 versions destroy regs in their INIT method 71 | 72 | mov ax,[si+8] ; construct 'interrupt' address 73 | mov [.dhp],ax ; construct interrupt address 74 | call far[.dhp] ; call far the interrupt 75 | 76 | ; Restore386Registers ; less stack load and better performance... 77 | 78 | sti ; damm driver turn off ints 79 | cld ; has gone backwards 80 | pop ds 81 | pop si 82 | pop bp 83 | ret 8 84 | %endmacro 85 | 86 | EXECRH: 87 | EXECRHM 88 | 89 | %ifndef WATCOM 90 | 91 | segment INIT_TEXT 92 | 93 | INIT_EXECRH: 94 | EXECRHM 95 | 96 | %endif 97 | -------------------------------------------------------------------------------- /kernel/init-dat.h: -------------------------------------------------------------------------------- 1 | #undef DOSFAR 2 | #undef DOSTEXTFAR 3 | 4 | /* Included by initialisation functions */ 5 | 6 | #if _MSC_VER != 0 7 | extern __segment DosDataSeg; /* serves for all references to the DOS DATA segment 8 | necessary for MSC+our funny linking model 9 | */ 10 | 11 | extern __segment DosTextSeg; 12 | 13 | #define DOSFAR __based(DosDataSeg) 14 | #define DOSTEXTFAR __based(DosTextSeg) 15 | 16 | #elif defined(__TURBOC__) 17 | 18 | #define DOSFAR FAR 19 | #define DOSTEXTFAR FAR 20 | 21 | #elif defined(__WATCOMC__) 22 | 23 | #define DOSFAR FAR 24 | #define DOSTEXTFAR FAR 25 | 26 | #elif defined(__GNUC__) 27 | 28 | #define DOSFAR FAR 29 | #define DOSTEXTFAR FAR 30 | 31 | #elif !defined(I86) 32 | 33 | #define DOSFAR 34 | #define DOSTEXTFAR 35 | 36 | #else 37 | 38 | #error unknown compiler - please adjust 39 | We might even deal with a pre-ANSI compiler. This will certainly not compile. 40 | #endif 41 | -------------------------------------------------------------------------------- /kernel/initclk.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* initclk.c */ 4 | /* */ 5 | /* System Clock Driver - initialization */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | #include "portab.h" 30 | #include "init-mod.h" 31 | 32 | #ifdef VERSION_STRINGS 33 | static char *RcsId = 34 | "$Id: initclk.c 1359 2008-03-09 16:11:10Z mceric $"; 35 | #endif 36 | 37 | /* */ 38 | /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ 39 | /* */ 40 | 41 | STATIC int InitBcdToByte(int x) 42 | { 43 | return ((x >> 4) & 0xf) * 10 + (x & 0xf); 44 | } 45 | 46 | void Init_clk_driver(void) 47 | { 48 | static iregs regsT = {0x200}; /* ah=0x02 */ 49 | static iregs regsD = {0x400, 0, 0x1400, 0x101}; 50 | /* ah=4, ch=20^ ^cl=0, ^dh=dl=1 (2000/1/1) 51 | * (above date will be set on error) */ 52 | iregs dosregs; 53 | 54 | init_call_intr(0x1a, ®sT); /* get BIOS time */ 55 | init_call_intr(0x1a, ®sD); /* get BIOS date */ 56 | 57 | /* DosSetDate */ 58 | dosregs.a.b.h = 0x2b; 59 | dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) /* century */ 60 | + InitBcdToByte(regsD.c.b.l);/* year */ 61 | /* A BIOS with y2k (year 2000) bug will always report year 19nn */ 62 | if ((dosregs.c.x >= 1900) && (dosregs.c.x < 1980)) dosregs.c.x += 100; 63 | dosregs.d.b.h = InitBcdToByte(regsD.d.b.h); /* month */ 64 | dosregs.d.b.l = InitBcdToByte(regsD.d.b.l); /* day */ 65 | init_call_intr(0x21, &dosregs); 66 | 67 | /* DosSetTime */ 68 | dosregs.a.b.h = 0x2d; 69 | dosregs.c.b.l = InitBcdToByte(regsT.c.b.l); /* minutes */ 70 | dosregs.c.b.h = InitBcdToByte(regsT.c.b.h); /* hours */ 71 | dosregs.d.b.h = InitBcdToByte(regsT.d.b.h); /*seconds */ 72 | dosregs.d.b.l = 0; 73 | init_call_intr(0x21, &dosregs); 74 | } 75 | -------------------------------------------------------------------------------- /kernel/initoem.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* initoem.c */ 4 | /* */ 5 | /* OEM Initializattion Functions */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /* */ 28 | /****************************************************************/ 29 | 30 | #include "portab.h" 31 | #include "init-mod.h" 32 | 33 | #ifdef VERSION_STRINGS 34 | static BYTE *RcsId = 35 | "$Id: initoem.c 1321 2007-05-21 02:16:36Z bartoldeman $"; 36 | #endif 37 | 38 | #define EBDASEG 0x40e 39 | #define RAMSIZE 0x413 40 | 41 | unsigned init_oem(void) 42 | { 43 | iregs r; 44 | init_call_intr(0x12, &r); 45 | return r.a.x; 46 | } 47 | 48 | void movebda(size_t bytes, unsigned new_seg) 49 | { 50 | unsigned old_seg = peek(0, EBDASEG); 51 | fmemcpy(MK_FP(new_seg, 0), MK_FP(old_seg, 0), bytes); 52 | poke(0, EBDASEG, new_seg); 53 | poke(0, RAMSIZE, ram_top); 54 | } 55 | 56 | unsigned ebdasize(void) 57 | { 58 | unsigned ebdaseg = peek(0, EBDASEG); 59 | unsigned ramsize = ram_top; 60 | 61 | if (ramsize == peek(0, RAMSIZE)) 62 | if (ramsize * 64 == ebdaseg && ramsize < 640 && peek(0, RAMSIZE) == ramsize) 63 | { 64 | unsigned ebdasz = peekb(ebdaseg, 0); 65 | 66 | /* sanity check: is there really no more than 63 KB? 67 | * must be at 640k (all other values never seen and are untested) 68 | */ 69 | if (ebdasz <= 63 && ramsize + ebdasz == 640) 70 | return ebdasz * 1024U; 71 | } 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /kernel/io.inc: -------------------------------------------------------------------------------- 1 | ; 2 | ; File: 3 | ; io.inc 4 | ; Description: 5 | ; Segments and external common routines used by various device drivers 6 | ; 7 | ; Copyright (c) 1998 8 | ; Pasquale J. Villani 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; You should have received a copy of the GNU General Public 24 | ; License along with DOS-C; see the file COPYING. If not, 25 | ; write to the Free Software Foundation, 675 Mass Ave, 26 | ; Cambridge, MA 02139, USA. 27 | ; 28 | ; $Header$ 29 | ; 30 | 31 | %include "segs.inc" 32 | 33 | ; 34 | ; Error Return Codes 35 | ; 36 | 37 | %define E_WRPRT 0 ; Write Protect 38 | %define E_UNIT 1 ; Unknown Unit 39 | %define E_NOTRDY 2 ; Device Not Ready 40 | %define E_CMD 3 ; Unknown Command 41 | %define E_CRC 4 ; Crc Error 42 | %define E_LENGTH 5 ; Bad Length 43 | %define E_SEEK 6 ; Seek Error 44 | %define E_MEDIA 7 ; Unknown MEDIA 45 | %define E_NOTFND 8 ; Sector Not Found 46 | %define E_PAPER 9 ; No Paper 47 | %define E_WRITE 10 ; Write Fault 48 | %define E_READ 11 ; Read Fault 49 | %define E_FAILURE 12 ; General Failure 50 | 51 | 52 | extern _IOExit 53 | extern _IOSuccess 54 | extern _IOErrorExit 55 | extern _IOErrCnt 56 | extern _IODone 57 | extern _IOCommandError 58 | extern GetUnitNum 59 | extern _ReqPktPtr 60 | 61 | -------------------------------------------------------------------------------- /kernel/iprf.c: -------------------------------------------------------------------------------- 1 | /* init code printf */ 2 | /* simply include prf.c while defining */ 3 | /* _INIT: reduces command line length */ 4 | /* and simplifies make procedure */ 5 | #define _INIT 1 6 | #include "prf.c" 7 | -------------------------------------------------------------------------------- /kernel/kernel.cfg: -------------------------------------------------------------------------------- 1 | -1- 2 | -f- 3 | -ff- 4 | -O 5 | -Z 6 | -d 7 | -k- 8 | -vi- 9 | -w 10 | -wpro 11 | -weas 12 | -wpre 13 | -I..\hdr 14 | -v -X- -I. -D__STDC__=0 -DTSC -DDEBUG -DKERNEL -DI86 -DPROTO -DSHWR -DASMSUPT 15 | -------------------------------------------------------------------------------- /kernel/ludivmul.inc: -------------------------------------------------------------------------------- 1 | ; this one adapted from elks, http://elks.sourceforge.net 2 | ; multiply cx:bx * dx:ax, result in dx:ax 3 | 4 | %macro LMULU 0 5 | 6 | push si 7 | push cx 8 | mov si, ax ; save _ax in si 9 | mov ax, bx ; cx:ax = _cx:_bx 10 | mul dx ; dx:ax = _bx*_dx (forget dx) 11 | xchg cx, ax ; cx = low(_dx*_bx) 12 | mul si ; dx:ax = _cx*_ax (forget dx) 13 | add cx, ax ; cx = low(_cx*_ax + _dx*_bx) 14 | mov ax, si ; restore _ax 15 | mul bx ; dx:ax = _bx*_ax 16 | add dx, cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) 17 | pop cx 18 | pop si 19 | ret 20 | 21 | %endmacro 22 | 23 | ; divide dx:ax / cx:bx, quotient in dx:ax, remainder in cx:bx 24 | 25 | %macro LDIVMODU 0 26 | ; this one is adapted from an assembly gem: 27 | ; gem writer: Norbert Juffa, norbert.juffa@amd.com 28 | 29 | ; Dividing 64-bit unsigned integers Assembler / 80386 30 | 31 | ; Here is a division routine for dividing two 64-bit unsigned integers. 32 | ; I derived it by modifying some old 33 | ; 16-bit code for dividing 32-bit integers that I did several years ago for a 34 | ; Turbo-Pascal replacement library. 35 | ; If a 64-bit signed integer division is needed, appropriate shell code for 36 | ; this routine can easily be written. 37 | ; 38 | ; (adapted back to 32-bit by Bart Oldeman ;-)) 39 | ; 40 | ; __U4D divides two unsigned long numbers, the dividend and the divisor 41 | ; resulting in a quotient and a remainder. 42 | ; 43 | ; input: 44 | ; dx:ax = dividend 45 | ; cx:bx = divisor 46 | ; 47 | ; output: 48 | ; dx:ax = quotient of division of dividend by divisor 49 | ; cx:bx = remainder of division of dividend by divisor 50 | ; 51 | ; destroys: 52 | ; flags 53 | ; 54 | %ifdef STDCALL 55 | push bp 56 | mov bp, sp 57 | mov ax, [bp+6] 58 | mov dx, [bp+8] 59 | mov bx, [bp+10] 60 | mov cx, [bp+12] 61 | pop bp 62 | %endif 63 | 64 | test cx, cx ; divisor > 2^16-1 ? 65 | jnz %%big_divisor ; yes, divisor > 2^16-1 66 | cmp dx, bx ; only one division needed ? (cx = 0) 67 | jb %%one_div ; yes, one division sufficient 68 | 69 | 70 | xchg cx, ax ; save dividend-lo in cx, ax=0 71 | xchg ax, dx ; get dividend-hi in ax, dx=0 72 | div bx ; quotient-hi in ax 73 | xchg ax, cx ; cx = quotient-hi, ax =dividend-lo 74 | 75 | %%one_div: 76 | div bx ; ax = quotient-lo 77 | mov bx, dx ; bx = remainder-lo 78 | mov dx, cx ; dx = quotient-hi(quotient in dx:ax) 79 | xor cx, cx ; cx = remainder-hi (rem. in cx:bx) 80 | ret 81 | 82 | %%big_divisor: 83 | push si ; save temp 84 | push di ; variables 85 | push dx ; save 86 | push ax ; dividend 87 | mov si, bx ; divisor now in 88 | mov di, cx ; di:si and cx:bx 89 | %%shift_loop: 90 | shr dx, 1 ; shift both 91 | rcr ax, 1 ; dividend 92 | shr cx, 1 ; and divisor 93 | rcr bx, 1 ; right by 1 bit 94 | jnz %%shift_loop ; loop if di non-zero (rcr does not touch ZF) 95 | div bx ; compute quotient dx:ax>>x / cx:bx>>x (stored in ax; remainder in dx not used) 96 | pop bx ; get dividend lo-word 97 | mov cx, ax ; save quotient 98 | mul di ; quotient * divisor hi-word (low only) 99 | pop dx ; dividend high 100 | sub dx,ax ; dividend high - divisor high * quotient, no overflow (carry/borrow) possible here 101 | push dx ; save dividend high 102 | mov ax, cx ; ax=quotient 103 | mul si ; quotient * divisor lo-word 104 | sub bx, ax ; dividend-lo - (quot.*divisor-lo)-lo 105 | mov ax, cx ; get quotient 106 | pop cx ; restore dividend hi-word 107 | sbb cx, dx ; subtract (divisor-lo * quot.)-hi from dividend-hi 108 | sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh 109 | and si, dx ; nothing to add 110 | and di, dx ; back if remainder positive di:si := di:si(cx:bx) & dx:dx 111 | add bx, si ; correct remainder cx:bx += di:si 112 | adc cx, di ; and 113 | add ax, dx ; quotient if necessary ax += dx 114 | xor dx, dx ; clear hi-word of quot (ax<=FFFFh) dx := 0 115 | pop di ; restore temp 116 | pop si ; variables 117 | ret 118 | 119 | %endmacro 120 | 121 | %macro LSHLU 0 122 | pop bx 123 | popargs {dx,ax},cx 124 | push bx 125 | jcxz %%ret 126 | %%loop: shl ax, 1 127 | rcl dx, 1 128 | loop %%loop 129 | %%ret: ret 130 | %endmacro 131 | 132 | %macro LSHRU 0 133 | pop bx 134 | popargs {dx,ax},cx 135 | push bx 136 | jcxz %%ret 137 | %%loop: shr dx, 1 138 | rcr ax, 1 139 | loop %%loop 140 | %%ret: ret 141 | %endmacro 142 | -------------------------------------------------------------------------------- /kernel/memdisk.asm: -------------------------------------------------------------------------------- 1 | ; File: 2 | ; memdisk.asm 3 | ; Description: 4 | ; Query for memdisk provided config.sys parameters 5 | ; 6 | ; DOS-C 7 | ; Copyright (c) 2011 8 | ; FreeDOS 9 | ; All Rights Reserved 10 | ; 11 | ; This file is part of DOS-C. 12 | ; 13 | ; DOS-C is free software; you can redistribute it and/or 14 | ; modify it under the terms of the GNU General Public License 15 | ; as published by the Free Software Foundation; either version 16 | ; 2, or (at your option) any later version. 17 | ; 18 | ; DOS-C is distributed in the hope that it will be useful, but 19 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 21 | ; the GNU General Public License for more details. 22 | ; 23 | ; 24 | 25 | ; requires 386+ registers, check LoL->CPU >=3 prior to calling (or use 386 build) 26 | 27 | %include "segs.inc" 28 | segment INIT_TEXT 29 | 30 | CPU 386 31 | ;********************************************************************* 32 | ; 33 | ; query_memdisk() based on similar subroutine in Eric Auer's public domain getargs.asm which is based on IFMEMDSK 34 | ; input: drive (in AL) to query if memdisk provided disk 35 | ; output: a far * to a memdiskinfo structure as defined by memdisk (see config.c) 36 | ; struct memdiskinfo FAR * query_memdisk(UBYTE drive); 37 | global _query_memdisk 38 | _query_memdisk: 39 | ; save registers, assumes enough space on stack & valid stack frame setup, ax & dx return values 40 | push es 41 | push di 42 | push ebx 43 | push ecx 44 | push edx ; we only care about high word 45 | push eax ; we only care about high word 46 | mov edx,53490000h ; magic3 + 47 | mov dl, al ; drive number (only argument, assumed to be in AL) 48 | mov eax,454d0800h ; magic1 + AH=8 (get geometry) 49 | mov ecx,444d0000h ; magic2 50 | mov ebx,3f4b0000h ; magic4 51 | int 13h ; BIOS DISK API 52 | shr eax,16 ; ignore AX 53 | shr ebx,16 ; ignore BX 54 | shr ecx,16 ; ignore CX (geometry C/S) 55 | shr edx,16 ; ignore DX (geometry H in DH) 56 | cmp ax,4d21h ; magic5 57 | jnz nomemdisk 58 | cmp cx,4d45h ; magic6 59 | jnz nomemdisk 60 | cmp dx,4944h ; magic7 61 | jnz nomemdisk 62 | cmp bx,4b53h ; magic8 63 | jnz nomemdisk 64 | jmp cleanup 65 | 66 | nomemdisk: 67 | xor di, di ; return NULL; 68 | mov es, di 69 | 70 | cleanup: 71 | pop eax 72 | pop edx 73 | mov ax, di ; return MK_FP(es, di); 74 | mov dx, es 75 | pop ecx 76 | pop ebx 77 | pop di 78 | pop es 79 | retn 80 | -------------------------------------------------------------------------------- /kernel/misc.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* misc.c */ 4 | /* */ 5 | /* Miscellaneous Kernel Functions */ 6 | /* */ 7 | /* Copyright (c) 1993 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | #include "portab.h" 30 | 31 | #ifdef VERSION_STRINGS 32 | static BYTE *miscRcsId = 33 | "$Id: misc.c 653 2003-08-09 09:35:18Z bartoldeman $"; 34 | #endif 35 | 36 | #include "globals.h" 37 | #ifndef I86 38 | 39 | char *strcpy(REG BYTE * d, REG CONST BYTE * s) 40 | { 41 | char *tmp = d; 42 | 43 | while ((*d++ = *s++) != '\0') 44 | ; 45 | 46 | return tmp; 47 | } 48 | 49 | VOID fstrcpy(REG BYTE FAR * d, REG CONST BYTE FAR * s) 50 | { 51 | while (*s) 52 | *d++ = *s++; 53 | *d = '\0'; 54 | } 55 | 56 | VOID * memcpy(REG VOID * d, REG CONST VOID * s, REG size_t n) 57 | { 58 | char *cd = d; 59 | CONST char *cs = s; 60 | 61 | while (n--) 62 | *cd++ = *cs++; 63 | return d; 64 | } 65 | 66 | VOID fmemcpy(REG VOID FAR * d, REG CONST VOID FAR * s, REG size_t n) 67 | { 68 | while (n--) 69 | *((BYTE FAR *) d)++ = *((BYTE FAR *) s)++; 70 | } 71 | 72 | VOID fmemset(REG VOID FAR * s, REG int ch, REG size_t n) 73 | { 74 | while (n--) 75 | *((BYTE FAR *) s)++ = ch; 76 | } 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /kernel/newstuff.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/kernel/newstuff.c -------------------------------------------------------------------------------- /kernel/nls/001-437.hc: -------------------------------------------------------------------------------- 1 | ; Hardcoded DOS-NLS information for country = 1, codepage = 437 2 | ; This is an automatically generated file! 3 | ; Any modifications will be lost! 4 | 5 | ; Prerequisites: 6 | ;; ==> Assuming that data of tables remains constant all the time 7 | ;; ==> Reordering tables 1, 2, 4 and 5 8 | 9 | %include "segs.inc" 10 | segment _DATA 11 | 12 | GLOBAL _nlsPackageHardcoded 13 | _nlsPackageHardcoded: 14 | DB 000h, 000h, 000h, 000h, 001h, 000h, 0b5h, 001h 15 | DB 00fh, 000h, 059h, 04eh, 006h, 000h 16 | DB 002h 17 | DW ?table2, SEG ?table2 18 | DB 004h 19 | DW ?table4, SEG ?table4 20 | DB 005h 21 | DW ?table5, SEG ?table5 22 | DB 006h 23 | DW ?table6, SEG ?table6 24 | DB 007h 25 | DW ?table7, SEG ?table7 26 | GLOBAL _nlsCountryInfoHardcoded 27 | _nlsCountryInfoHardcoded: 28 | DB 001h 29 | ?table1: 30 | DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h 31 | DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh 32 | DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h 33 | extern _CharMapSrvc:wrt TGROUP 34 | DW _CharMapSrvc, SEG _CharMapSrvc 35 | DB 02ch, 000h 36 | GLOBAL _hcTablesStart 37 | _hcTablesStart: 38 | GLOBAL _nlsFUpcaseHardcoded 39 | _nlsFUpcaseHardcoded: 40 | ?table4: 41 | GLOBAL _nlsUpcaseHardcoded 42 | _nlsUpcaseHardcoded: 43 | ?table2: 44 | DB 080h, 000h, 080h, 09ah, 045h, 041h, 08eh, 041h 45 | DB 08fh, 080h, 045h, 045h, 045h, 049h, 049h, 049h 46 | DB 08eh, 08fh, 090h, 092h, 092h, 04fh, 099h, 04fh 47 | DB 055h, 055h, 059h, 099h, 09ah, 09bh, 09ch, 09dh 48 | DB 09eh, 09fh, 041h, 049h, 04fh, 055h, 0a5h, 0a5h 49 | DB 0a6h, 0a7h, 0a8h, 0a9h, 0aah, 0abh, 0ach, 0adh 50 | DB 0aeh, 0afh, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h 51 | DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh 52 | DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h 53 | DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh 54 | DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h 55 | DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh 56 | DB 0deh, 0dfh, 0e0h, 0e1h, 0e2h, 0e3h, 0e4h, 0e5h 57 | DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh 58 | DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h 59 | DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh 60 | DB 0feh, 0ffh 61 | GLOBAL _nlsFnameTermHardcoded 62 | _nlsFnameTermHardcoded: 63 | ?table5: 64 | DB 016h, 000h, 08eh, 000h, 0ffh, 041h, 000h, 020h 65 | DB 0eeh, 00eh, 02eh, 022h, 02fh, 05ch, 05bh, 05dh 66 | DB 03ah, 07ch, 03ch, 03eh, 02bh, 03dh, 03bh, 02ch 67 | GLOBAL _nlsCollHardcoded 68 | _nlsCollHardcoded: 69 | ?table6: 70 | DB 000h, 001h, 000h, 001h, 002h, 003h, 004h, 005h 71 | DB 006h, 007h, 008h, 009h, 00ah, 00bh, 00ch, 00dh 72 | DB 00eh, 00fh, 010h, 011h, 012h, 013h, 014h, 015h 73 | DB 016h, 017h, 018h, 019h, 01ah, 01bh, 01ch, 01dh 74 | DB 01eh, 01fh, 020h, 021h, 022h, 023h, 024h, 025h 75 | DB 026h, 027h, 028h, 029h, 02ah, 02bh, 02ch, 02dh 76 | DB 02eh, 02fh, 030h, 031h, 032h, 033h, 034h, 035h 77 | DB 036h, 037h, 038h, 039h, 03ah, 03bh, 03ch, 03dh 78 | DB 03eh, 03fh, 040h, 041h, 042h, 043h, 044h, 045h 79 | DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh 80 | DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h 81 | DB 056h, 057h, 058h, 059h, 05ah, 05bh, 05ch, 05dh 82 | DB 05eh, 05fh, 060h, 041h, 042h, 043h, 044h, 045h 83 | DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh 84 | DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h 85 | DB 056h, 057h, 058h, 059h, 05ah, 07bh, 07ch, 07dh 86 | DB 07eh, 07fh, 043h, 055h, 045h, 041h, 041h, 041h 87 | DB 041h, 043h, 045h, 045h, 045h, 049h, 049h, 049h 88 | DB 041h, 041h, 045h, 041h, 041h, 04fh, 04fh, 04fh 89 | DB 055h, 055h, 059h, 04fh, 055h, 024h, 024h, 024h 90 | DB 024h, 024h, 041h, 049h, 04fh, 055h, 04eh, 04eh 91 | DB 0a6h, 0a7h, 03fh, 0a9h, 0aah, 0abh, 0ach, 021h 92 | DB 022h, 022h, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h 93 | DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh 94 | DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h 95 | DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh 96 | DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h 97 | DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh 98 | DB 0deh, 0dfh, 0e0h, 053h, 0e2h, 0e3h, 0e4h, 0e5h 99 | DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh 100 | DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h 101 | DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh 102 | DB 0feh, 0ffh 103 | GLOBAL _nlsDBCSHardcoded 104 | _nlsDBCSHardcoded: 105 | ?table7: 106 | DB 000h, 000h, 000h, 000h 107 | GLOBAL _hcTablesEnd 108 | _hcTablesEnd: 109 | 110 | 111 | END 112 | -------------------------------------------------------------------------------- /kernel/nls/001-437.unf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/kernel/nls/001-437.unf -------------------------------------------------------------------------------- /kernel/nls/001-437.up: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/kernel/nls/001-437.up -------------------------------------------------------------------------------- /kernel/nls/049-850.hc: -------------------------------------------------------------------------------- 1 | ; Hardcoded DOS-NLS information for country = 49, codepage = 850 2 | ; This is an automatically generated file! 3 | ; Any modifications will be lost! 4 | 5 | ; Prerequisites: 6 | ;; ==> Assuming that data of tables remains constant all the time 7 | ;; ==> Reordering tables 1, 2, 4 and 5 8 | 9 | %include "segs.inc" 10 | segment _DATA 11 | 12 | GLOBAL _nlsPackageHardcoded 13 | _nlsPackageHardcoded: 14 | DB 000h, 000h, 000h, 000h, 031h, 000h, 052h, 003h 15 | DB 00fh, 000h, 04ah, 04eh, 006h, 000h 16 | DB 002h 17 | DW ?table2, SEG ?table2 18 | DB 004h 19 | DW ?table4, SEG ?table4 20 | DB 005h 21 | DW ?table5, SEG ?table5 22 | DB 006h 23 | DW ?table6, SEG ?table6 24 | DB 007h 25 | DW ?table7, SEG ?table7 26 | GLOBAL _nlsCountryInfoHardcoded 27 | _nlsCountryInfoHardcoded: 28 | DB 001h 29 | ?table1: 30 | DB 01ch, 000h, 031h, 000h, 052h, 003h, 001h, 000h 31 | DB 044h, 04dh, 000h, 000h, 000h, 02eh, 000h, 02ch 32 | DB 000h, 02eh, 000h, 03ah, 000h, 003h, 002h, 001h 33 | extern _CharMapSrvc:wrt TGROUP 34 | DW _CharMapSrvc, SEG _CharMapSrvc 35 | DB 03bh, 000h 36 | GLOBAL _hcTablesStart 37 | _hcTablesStart: 38 | GLOBAL _nlsFUpcaseHardcoded 39 | _nlsFUpcaseHardcoded: 40 | ?table4: 41 | GLOBAL _nlsUpcaseHardcoded 42 | _nlsUpcaseHardcoded: 43 | ?table2: 44 | DB 080h, 000h, 080h, 09ah, 090h, 0b6h, 08eh, 0b7h 45 | DB 08fh, 080h, 0d2h, 0d3h, 0d4h, 0d8h, 0d7h, 0deh 46 | DB 08eh, 08fh, 090h, 092h, 092h, 0e2h, 099h, 0e3h 47 | DB 0eah, 0ebh, 05fh, 099h, 09ah, 09dh, 09ch, 09dh 48 | DB 09eh, 09fh, 0b5h, 0d6h, 0e0h, 0e9h, 0a5h, 0a5h 49 | DB 0a6h, 0a7h, 0a8h, 0a9h, 0aah, 0abh, 0ach, 0adh 50 | DB 0aeh, 0afh, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h 51 | DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh 52 | DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h 53 | DB 0c7h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh 54 | DB 0ceh, 0cfh, 0d1h, 0d1h, 0d2h, 0d3h, 0d4h, 049h 55 | DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh 56 | DB 0deh, 0dfh, 0e0h, 0e1h, 0e2h, 0e3h, 0e5h, 0e5h 57 | DB 0e6h, 0e8h, 0e8h, 0e9h, 0eah, 0ebh, 0edh, 0edh 58 | DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h 59 | DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh 60 | DB 0feh, 0ffh 61 | GLOBAL _nlsFnameTermHardcoded 62 | _nlsFnameTermHardcoded: 63 | ?table5: 64 | DB 016h, 000h, 08eh, 000h, 0ffh, 0b6h, 000h, 020h 65 | DB 0eeh, 00eh, 02eh, 022h, 02fh, 05ch, 05bh, 05dh 66 | DB 03ah, 07ch, 03ch, 03eh, 02bh, 03dh, 03bh, 02ch 67 | GLOBAL _nlsCollHardcoded 68 | _nlsCollHardcoded: 69 | ?table6: 70 | DB 000h, 001h, 000h, 001h, 002h, 003h, 004h, 005h 71 | DB 006h, 007h, 008h, 009h, 00ah, 00bh, 00ch, 00dh 72 | DB 00eh, 00fh, 010h, 011h, 012h, 013h, 014h, 015h 73 | DB 016h, 017h, 018h, 019h, 01ah, 01bh, 01ch, 01dh 74 | DB 01eh, 01fh, 020h, 021h, 022h, 023h, 024h, 025h 75 | DB 026h, 027h, 028h, 029h, 02ah, 02bh, 02ch, 02dh 76 | DB 02eh, 02fh, 030h, 031h, 032h, 033h, 034h, 035h 77 | DB 036h, 037h, 038h, 039h, 03ah, 03bh, 03ch, 03dh 78 | DB 03eh, 03fh, 040h, 041h, 042h, 043h, 044h, 045h 79 | DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh 80 | DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h 81 | DB 056h, 057h, 058h, 059h, 05ah, 05bh, 05ch, 05dh 82 | DB 05eh, 05fh, 060h, 041h, 042h, 043h, 044h, 045h 83 | DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh 84 | DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h 85 | DB 056h, 057h, 058h, 059h, 05ah, 07bh, 07ch, 07dh 86 | DB 07eh, 07fh, 043h, 055h, 045h, 041h, 041h, 041h 87 | DB 041h, 043h, 045h, 045h, 045h, 049h, 049h, 049h 88 | DB 041h, 041h, 045h, 041h, 041h, 04fh, 04fh, 04fh 89 | DB 055h, 055h, 059h, 04fh, 055h, 04fh, 024h, 04fh 90 | DB 09eh, 024h, 041h, 049h, 04fh, 055h, 04eh, 04eh 91 | DB 0a6h, 0a7h, 03fh, 0a9h, 0aah, 0abh, 0ach, 021h 92 | DB 022h, 022h, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 041h 93 | DB 041h, 041h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 024h 94 | DB 024h, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h 95 | DB 041h, 041h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh 96 | DB 0ceh, 024h, 044h, 044h, 045h, 045h, 045h, 049h 97 | DB 049h, 049h, 049h, 0d9h, 0dah, 0dbh, 0dch, 0ddh 98 | DB 049h, 0dfh, 04fh, 053h, 04fh, 04fh, 04fh, 04fh 99 | DB 0e6h, 0e8h, 0e8h, 055h, 055h, 055h, 059h, 059h 100 | DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h 101 | DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh 102 | DB 0feh, 0ffh 103 | GLOBAL _nlsDBCSHardcoded 104 | _nlsDBCSHardcoded: 105 | ?table7: 106 | DB 000h, 000h, 000h, 000h 107 | GLOBAL _hcTablesEnd 108 | _hcTablesEnd: 109 | 110 | 111 | END 112 | -------------------------------------------------------------------------------- /kernel/nls/049-850.unf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/kernel/nls/049-850.unf -------------------------------------------------------------------------------- /kernel/nls/049-850.up: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/kernel/nls/049-850.up -------------------------------------------------------------------------------- /kernel/nls/files: -------------------------------------------------------------------------------- 1 | NLS files 2 | 3 | Filenames are encoded as: 4 | CCC-PPP 5 | CCC: country code 6 | PPP: codepage ID 7 | both are zero-padded three digits numbers; one number may 8 | use four digits. 9 | 10 | Extensions: 11 | UNF: Uniform NLS file Format 12 | plain text representation of NLS package (7bit US-ASCII) 13 | may be used to validate GRAB_UNF output 14 | see UNF toolset for more information 15 | UP : NLSUPTST data file 16 | used to validate DOS API normal character upcase functions DOS-65-2[0-2] 17 | HC : Hardcoded NLS file to be included into the kernel 18 | produced by UNF2HC 19 | copy to ..\NLS_HC.ASM in order to use this NLS package as the hardcoded one 20 | kernel must be re-compiled 21 | -------------------------------------------------------------------------------- /kernel/nls_load.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* nls_load.c */ 4 | /* FreeDOS */ 5 | /* */ 6 | /* National Languge Support functions and data structures */ 7 | /* Load an entry from FreeDOS COUNTRY.SYS file. */ 8 | /* */ 9 | /* Copyright (c) 2000 */ 10 | /* Steffen Kaiser */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of FreeDOS. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #include "portab.h" 32 | #include "init-mod.h" 33 | 34 | #ifdef VERSION_STRINGS 35 | static BYTE *RcsId = 36 | "$Id: nls_load.c 625 2003-06-27 22:02:57Z bartoldeman $"; 37 | #endif 38 | 39 | /** Setup the environment for shared source NLS_LOAD.SRC **/ 40 | /**ska obsoleted #define cfgMemory Config.cfgCSYS_memory */ 41 | /**ska obsoleted #define cfgFilename Config.cfgCSYS_fnam */ 42 | #define cfgFilename nlsInfo.fname /* char FAR * */ 43 | /**ska obsoleted #define cfgCountry Config.cfgCSYS_cntry */ 44 | /**ska obsoleted #define cfgCodepage Config.cfgCSYS_cp */ 45 | #define cfgData Config.cfgCSYS_data /* struct nlsCSys_loadPackage FAR * */ 46 | #define getMem(bytes) KernelAlloc(bytes) 47 | #define openSYSFile(filename) open(filename, 0) /* read-only, binary */ 48 | #define nlsStartOfChain nlsInfo.chain 49 | #define upCaseFct CharMapSrvc 50 | 51 | #include "nls_load.src" 52 | -------------------------------------------------------------------------------- /kernel/nlssupt.asm: -------------------------------------------------------------------------------- 1 | ; File: 2 | ; nls.asm 3 | ; Description: 4 | ; Assembly support routines for nls functions. 5 | ; 6 | ; Copyright (c) 1995, 1998 7 | ; Pasquale J. Villani 8 | ; All Rights Reserved 9 | ; 10 | ; This file is part of DOS-C. 11 | ; 12 | ; DOS-C is free software; you can redistribute it and/or 13 | ; modify it under the terms of the GNU General Public License 14 | ; as published by the Free Software Foundation; either version 15 | ; 2, or (at your option) any later version. 16 | ; 17 | ; DOS-C is distributed in the hope that it will be useful, but 18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 20 | ; the GNU General Public License for more details. 21 | ; 22 | ; You should have received a copy of the GNU General Public 23 | ; License along with DOS-C; see the file COPYING. If not, 24 | ; write to the Free Software Foundation, 675 Mass Ave, 25 | ; Cambridge, MA 02139, USA. 26 | ; 27 | ; $Id: nlssupt.asm 971 2004-05-30 19:31:07Z bartoldeman $ 28 | ; 29 | 30 | 31 | %include "segs.inc" 32 | %include "stacks.inc" 33 | 34 | segment HMA_TEXT 35 | global _reloc_call_CharMapSrvc 36 | extern _DosUpChar 37 | extern _DGROUP_ 38 | ; 39 | ; CharMapSrvc: 40 | ; User callable character mapping service. 41 | ; Part of Function 38h 42 | ; 43 | _reloc_call_CharMapSrvc: 44 | 45 | Protect386Registers 46 | push ds 47 | push es 48 | ; push bp 49 | ; push si 50 | ; push di 51 | push dx 52 | push cx 53 | push bx 54 | 55 | push ax ; arg of _upChar 56 | mov ds,[cs:_DGROUP_] 57 | 58 | call _DosUpChar 59 | ;add sp, byte 2 // next POP retrieves orig AX 60 | 61 | pop bx 62 | mov ah, bh ; keep hibyte untouched 63 | 64 | pop bx 65 | pop cx 66 | pop dx 67 | ; pop di 68 | ; pop si 69 | ; pop bp 70 | pop es 71 | pop ds 72 | Restore386Registers 73 | retf ; Return far 74 | -------------------------------------------------------------------------------- /kernel/segs.inc: -------------------------------------------------------------------------------- 1 | ; File: 2 | ; segs.inc 3 | ; Description: 4 | ; Segment definitions for the kernel 5 | ; 6 | ; Copyright (c) 1998 7 | ; Pasquale J. Villani 8 | ; All Rights Reserved 9 | ; 10 | ; This file is part of DOS-C. 11 | ; 12 | ; DOS-C is free software; you can redistribute it and/or 13 | ; modify it under the terms of the GNU General Public License 14 | ; as published by the Free Software Foundation; either version 15 | ; 2, or (at your option) any later version. 16 | ; 17 | ; DOS-C is distributed in the hope that it will be useful, but 18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 20 | ; the GNU General Public License for more details. 21 | ; 22 | ; You should have received a copy of the GNU General Public 23 | ; License along with DOS-C; see the file COPYING. If not, 24 | ; write to the Free Software Foundation, 675 Mass Ave, 25 | ; Cambridge, MA 02139, USA. 26 | ; 27 | ; $Header$ 28 | ; 29 | 30 | ; CPU specification -- putting it here because all .asm files include this 31 | ; file __NASM_VER__ was introduced in NASM after CPU -- ver 0.98 doesn't 32 | ; understand it 33 | %ifdef __NASM_VER__ 34 | %if XCPU == 86 35 | CPU 8086 36 | %else 37 | CPU XCPU 38 | %endif 39 | %endif 40 | 41 | ; for OW on Linux: 42 | %ifdef owlinux 43 | %define WATCOM 44 | %endif 45 | 46 | %ifidn __OUTPUT_FORMAT__, obj 47 | group PGROUP PSP 48 | group LGROUP _IRQTEXT _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT 49 | group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA 50 | %ifdef WATCOM 51 | group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END 52 | %define IGROUP TGROUP 53 | group I_GROUP ID_B I_DATA ICONST ICONST2 ID_E IB_B I_BSS IB_E 54 | %else 55 | group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END 56 | group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END 57 | group I_GROUP ID_B ID ID_E IC IDATA IB_B IB IB_E 58 | %endif 59 | %define class(x) class=x 60 | %define nobits 61 | %define exec 62 | %define INITSIZE init_end wrt INIT_TEXT 63 | %define INITTEXTSIZE __INIT_DATA_START wrt INIT_TEXT 64 | 65 | %else ; using ELF 66 | 67 | BITS 16 68 | ; groups are defined in the linker script kernel.ld 69 | extern PGROUP 70 | extern DGROUP 71 | extern LGROUP 72 | extern TGROUP 73 | extern IGROUP 74 | extern I_GROUP 75 | %define class(x) 76 | %define stack 77 | extern INITSIZE 78 | %define INITTEXTSIZE __InitTextEnd 79 | 80 | %endif 81 | 82 | segment PSP class(PSP) 83 | segment _IRQTEXT class(LCODE) exec 84 | segment _LOWTEXT class(LCODE) exec 85 | segment _IO_TEXT class(LCODE) exec 86 | segment _IO_FIXED_DATA class(LCODE) align=2 87 | segment _TEXT class(LCODE) exec 88 | segment _FIXED_DATA class(FDATA) align=16 89 | segment _BSS class(BSS) align=2 90 | segment _DATA class(DATA) align=2 91 | segment _DATAEND class(DATA) align=1 92 | ;for WATCOM 93 | segment CONST class(DATA) align=2 94 | segment CONST2 class(DATA) align=2 95 | ;for MSC 96 | segment DCONST class(DCONST) align=2 97 | segment DYN_DATA class(DYN_DATA) 98 | segment HMA_TEXT_START class(CODE) align=16 99 | segment HMA_TEXT class(CODE) exec 100 | segment HMA_TEXT_END class(CODE) align=16 101 | segment INIT_TEXT_START class(CODE) align=16 102 | segment INIT_TEXT class(CODE) exec 103 | segment INIT_TEXT_END class(CODE) align=16 104 | 105 | %ifdef WATCOM 106 | segment ID_B class(FAR_DATA) align=16 107 | segment I_DATA class(FAR_DATA) align=2 108 | segment ICONST class(FAR_DATA) align=2 109 | segment ICONST2 class(FAR_DATA) align=2 110 | segment ID_E class(FAR_DATA) align=2 111 | segment IB_B class(FAR_DATA) align=2 112 | segment I_BSS class(FAR_DATA) align=2 113 | segment IB_E class(FAR_DATA) align=2 114 | %else 115 | segment ID_B class(ID) align=16 116 | segment ID class(ID) align=2 117 | segment IDATA class(ID) align=2 118 | segment ID_E class(ID) align=2 119 | segment IC class(IC) align=2 120 | segment IB_B class(IB) align=2 nobits 121 | segment IB class(IB) align=2 nobits 122 | segment IB_E class(IB) align=2 nobits 123 | %endif 124 | -------------------------------------------------------------------------------- /kernel/strings.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* strings.c */ 4 | /* */ 5 | /* Global String Handling Functions */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | #include "portab.h" 30 | 31 | #ifdef VERSION_STRINGS 32 | static BYTE *stringsRcsId = 33 | "$Id: strings.c 653 2003-08-09 09:35:18Z bartoldeman $"; 34 | #endif 35 | 36 | #ifndef I86 37 | size_t strlen(REG CONST BYTE * s) 38 | { 39 | REG size_t cnt = 0; 40 | 41 | while (*s++ != 0) 42 | ++cnt; 43 | return cnt; 44 | } 45 | 46 | size_t fstrlen(REG CONST BYTE FAR * s) 47 | { 48 | REG size_t cnt = 0; 49 | 50 | while (*s++ != 0) 51 | ++cnt; 52 | return cnt; 53 | } 54 | 55 | VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s) 56 | { 57 | while (*s != 0) 58 | *d++ = *s++; 59 | *d = 0; 60 | } 61 | 62 | int strcmp(REG CONST BYTE * d, REG CONST BYTE * s) 63 | { 64 | while (*s != '\0' && *d != '\0') 65 | { 66 | if (*d == *s) 67 | ++s, ++d; 68 | else 69 | return *d - *s; 70 | } 71 | return *d - *s; 72 | } 73 | 74 | COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s) 75 | { 76 | while (*s != '\0' && *d != '\0') 77 | { 78 | if (*d == *s) 79 | ++s, ++d; 80 | else 81 | return *d - *s; 82 | } 83 | return *d - *s; 84 | } 85 | 86 | int strncmp(register const char *d, register const char *s, size_t l) 87 | { 88 | size_t index = 1; 89 | while (*s != '\0' && *d != '\0' && index++ <= l) 90 | { 91 | if (*d == *s) 92 | ++s, ++d; 93 | else 94 | return *d - *s; 95 | } 96 | return *d - *s; 97 | } 98 | 99 | COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l) 100 | { 101 | COUNT index = 1; 102 | while (*s != '\0' && *d != '\0' && index++ <= l) 103 | { 104 | if (*d == *s) 105 | ++s, ++d; 106 | else 107 | return *d - *s; 108 | } 109 | return *d - *s; 110 | } 111 | 112 | char *strchr(const char * s, int c) 113 | { 114 | REG CONST BYTE *p; 115 | p = s - 1; 116 | do 117 | { 118 | if (*++p == (char)c) 119 | return (char *)p; 120 | } 121 | while (*p); 122 | return 0; 123 | } 124 | 125 | void *memchr(const void * s, int c) 126 | { 127 | REG unsigned char *p; 128 | p = (unsigned char *)s - 1; 129 | do 130 | { 131 | if (*++p == (unsigned char)c) 132 | return (void *)p; 133 | } 134 | while (*p); 135 | return 0; 136 | } 137 | #endif 138 | 139 | -------------------------------------------------------------------------------- /kernel/syspack.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* syspack.c */ 4 | /* */ 5 | /* System Disk Byte Order Packing Functions */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /* */ 28 | /****************************************************************/ 29 | 30 | #include "portab.h" 31 | #include "globals.h" 32 | 33 | #ifdef VERSION_STRINGS 34 | static BYTE *syspackRcsId = 35 | "$Id: syspack.c 485 2002-12-09 00:17:15Z bartoldeman $"; 36 | #endif 37 | 38 | #ifdef NONNATIVE 39 | UDWORD getlong(REG VOID * vp) 40 | { 41 | return (((UBYTE *) vp)[0] & 0xff) + 42 | ((((UBYTE *) vp)[1] & 0xff) << 8) + 43 | ((((UBYTE *) vp)[2] & 0xff) << 16) + 44 | ((((UBYTE *) vp)[3] & 0xff) << 24); 45 | } 46 | 47 | UWORD getword(REG VOID * vp) 48 | { 49 | return (((UBYTE *) vp)[0] & 0xff) + ((((UBYTE *) vp)[1] & 0xff) << 8); 50 | } 51 | 52 | UBYTE getbyte(VOID * vp) 53 | { 54 | return *((BYTE *) vp); 55 | } 56 | 57 | UWORD fgetword(REG VOID FAR * vp) 58 | { 59 | return (((UBYTE FAR *) vp)[0] & 0xff) + ((((UBYTE FAR *) vp)[1] & 0xff) << 8); 60 | } 61 | 62 | UDWORD fgetlong(REG VOID FAR * vp) 63 | { 64 | return (((UBYTE *) vp)[0] & 0xff) + 65 | ((((UBYTE *) vp)[1] & 0xff) << 8) + 66 | ((((UBYTE *) vp)[2] & 0xff) << 16) + 67 | ((((UBYTE *) vp)[3] & 0xff) << 24); 68 | } 69 | 70 | UBYTE fgetbyte(VOID FAR * vp) 71 | { 72 | return *((UBYTE FAR *) vp); 73 | } 74 | 75 | VOID fputlong(VOID FAR * vp, UDWORD l) 76 | { 77 | REG UBYTE FAR *bp = (UBYTE FAR *) vp; 78 | 79 | bp[0] = l & 0xff; 80 | bp[1] = (l >> 8) & 0xff; 81 | bp[2] = (l >> 16) & 0xff; 82 | bp[3] = (l >> 24) & 0xff; 83 | } 84 | 85 | VOID fputword(VOID FAR * vp, UWORD w) 86 | { 87 | REG UBYTE FAR *bp = (UBYTE FAR *) vp; 88 | 89 | bp[0] = w & 0xff; 90 | bp[1] = (w >> 8) & 0xff; 91 | } 92 | 93 | VOID fputbyte(VOID FAR * vp, UBYTE b) 94 | { 95 | *(UBYTE FAR *) vp = b; 96 | } 97 | 98 | VOID getdirent(UBYTE FAR * vp, struct dirent FAR * dp) 99 | { 100 | fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE + FEXT_SIZE); 101 | dp->dir_attrib = fgetbyte(&vp[DIR_ATTRIB]); 102 | dp->dir_time = fgetword(&vp[DIR_TIME]); 103 | dp->dir_date = fgetword(&vp[DIR_DATE]); 104 | dp->dir_start = fgetword(&vp[DIR_START]); 105 | dp->dir_size = fgetlong(&vp[DIR_SIZE]); 106 | } 107 | 108 | VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp) 109 | { 110 | REG COUNT i; 111 | REG BYTE FAR *p; 112 | 113 | fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE + FEXT_SIZE); 114 | fputbyte(&vp[DIR_ATTRIB], dp->dir_attrib); 115 | fputword(&vp[DIR_TIME], dp->dir_time); 116 | fputword(&vp[DIR_DATE], dp->dir_date); 117 | fputword(&vp[DIR_START], dp->dir_start); 118 | fputlong(&vp[DIR_SIZE], dp->dir_size); 119 | for (i = 0, p = (UBYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) 120 | *p++ = NULL; 121 | } 122 | #endif 123 | 124 | -------------------------------------------------------------------------------- /kernel/turboc.cfg: -------------------------------------------------------------------------------- 1 | -f- 2 | -ff- 3 | -O 4 | -Z 5 | -d 6 | -k- 7 | -vi- 8 | -wpro 9 | -weas 10 | -wpre 11 | -w 12 | -g1 13 | -I..\hdr 14 | -p 15 | -v- -I. -D__STDC__=0 -DKERNEL -DI86 -DPROTO -DASMSUPT 16 | -------------------------------------------------------------------------------- /lib/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for libm.lib 3 | # 4 | # $Id: makefile 688 2003-09-15 10:46:24Z bartoldeman $ 5 | # 6 | 7 | 8 | !include "../mkfiles/generic.mak" 9 | 10 | 11 | libm.lib: $(CLIB) 12 | -$(RM) libm.lib 13 | $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) 14 | $(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i 15 | $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) 16 | -$(RM) *.OBJ 17 | 18 | 19 | clobber: clean 20 | -$(RM) status.me 21 | 22 | clean: 23 | -$(RM) *.obj *.bak libm.lib 24 | 25 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # What you WANT on DOS is: 2 | # EDIT CONFIG.B, COPY CONFIG.B to CONFIG.BAT, RUN BUILD.BAT 3 | # On Linux, use config.mak, and "make all", "make clean", or "make clobber" 4 | # On Windows, use config.mak, and 5 | # "mingw32-make all", "mingw32-make clean", or "mingw32-make clobber" 6 | 7 | default: 8 | @echo On DOS, please type build, clean, or clobber. 9 | @echo On Linux, please type make all, make clean, or make clobber. 10 | @echo On Windows, please type mingw32-make all, mingw32-make clean, or 11 | @echo mingw32-make clobber. 12 | 13 | build: 14 | build 15 | 16 | bin\kwc8616.sys: 17 | build -r wc 86 fat16 18 | 19 | bin\kwc8632.sys: 20 | build -r wc 86 fat32 21 | 22 | # use as follows: wmake -ms zip VERSION=2029 23 | zip_src: 24 | cd ..\.. 25 | zip -9 -r -k source/ke$(VERSION)s.zip source/ke$(VERSION) -i@source/ke$(VERSION)/filelist 26 | cd source\ke$(VERSION) 27 | 28 | BINLIST1 = doc bin/kernel.sys bin/sys.com 29 | # removed - as the 2nd zip -r line to add those to the zip: 30 | # BINLIST2 = bin/config.sys bin/autoexec.bat bin/command.com bin/install.bat 31 | 32 | zipfat16: bin\kwc8616.sys 33 | mkdir doc 34 | mkdir doc\kernel 35 | copy docs\*.txt doc\kernel 36 | copy docs\*.cvs doc\kernel 37 | copy docs\copying doc\kernel 38 | copy docs\*.lsm doc\kernel 39 | del doc\kernel\build.txt 40 | del doc\kernel\lfnapi.txt 41 | copy bin\kwc8616.sys bin\kernel.sys 42 | zip -r -k ../ke$(VERSION)16.zip $(BINLIST) 43 | utils\rmfiles doc\kernel\*.txt doc\kernel\*.cvs doc\kernel\*.lsm doc\kernel\copying 44 | rmdir doc\kernel 45 | rmdir doc 46 | 47 | zipfat32: bin\kwc8632.sys 48 | mkdir doc 49 | mkdir doc\kernel 50 | copy docs\*.txt doc\kernel 51 | copy docs\*.cvs doc\kernel 52 | copy docs\copying doc\kernel 53 | copy docs\*.lsm doc\kernel 54 | del doc\kernel\build.txt 55 | del doc\kernel\lfnapi.txt 56 | copy bin\kwc8632.sys bin\kernel.sys 57 | zip -r -k ../ke$(VERSION)32.zip $(BINLIST) 58 | utils\rmfiles doc\kernel\*.txt doc\kernel\*.cvs doc\kernel\*.lsm doc\kernel\copying 59 | rmdir doc\kernel 60 | rmdir doc 61 | 62 | zip: zip_src zipfat16 zipfat32 63 | 64 | #Linux part 65 | #defaults: override using config.mak 66 | export 67 | 68 | ifeq ($(OS),Windows_NT) 69 | BUILDENV ?= windows 70 | else 71 | BUILDENV ?= linux 72 | endif 73 | 74 | ifeq ($(BUILDENV),windows) 75 | COMPILER=owwin 76 | TEST_F=type >nul 2>nul 77 | TOUCH=wtouch 78 | else 79 | COMPILER=owlinux 80 | TEST_F=test -f 81 | TOUCH=touch 82 | ifndef WATCOM 83 | WATCOM=$(HOME)/watcom 84 | PATH:=$(WATCOM)/binl:$(PATH) 85 | endif 86 | endif 87 | 88 | XCPU=86 89 | XFAT=32 90 | XUPX=upx --8086 --best 91 | XNASM=nasm 92 | ifeq ($(COMPILER),gcc) 93 | MAKE=make 94 | MAKEADJUST=for i in utils lib drivers boot sys kernel; do sed 's@!include "\(.*\)"@include ../mkfiles/gcc.mak@' < $$i/makefile > $$i/GNUmakefile; done 95 | MAKEREMOVE=for i in utils lib drivers boot sys kernel; do rm -f $$i/GNUmakefile; done 96 | XLINK=ia16-elf-gcc 97 | else 98 | MAKE=wmake -ms -h 99 | MAKEADJUST= 100 | MAKEREMOVE= 101 | XLINK=wlink 102 | endif 103 | #ALLCFLAGS=-DDEBUG 104 | 105 | -include config.mak 106 | ifdef XUPX 107 | UPXOPT=-U 108 | endif 109 | 110 | all: 111 | $(MAKEADJUST) 112 | cd utils && $(MAKE) production 113 | cd lib && ( $(TEST_F) libm.lib || $(TOUCH) libm.lib ) 114 | cd drivers && $(MAKE) production 115 | cd boot && $(MAKE) production 116 | cd sys && $(MAKE) production 117 | cd kernel && $(MAKE) production 118 | 119 | clean: 120 | cd utils && $(MAKE) clean 121 | cd lib && $(MAKE) clean 122 | cd drivers && $(MAKE) clean 123 | cd boot && $(MAKE) clean 124 | cd sys && $(MAKE) clean 125 | cd kernel && $(MAKE) clean 126 | 127 | clobber: 128 | cd utils && $(MAKE) clobber 129 | cd lib && $(MAKE) clobber 130 | cd drivers && $(MAKE) clobber 131 | cd boot && $(MAKE) clobber 132 | cd sys && $(MAKE) clobber 133 | cd kernel && $(MAKE) clobber 134 | $(MAKEREMOVE) 135 | -------------------------------------------------------------------------------- /mkfiles/bc3.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/mkfiles/bc3.mak -------------------------------------------------------------------------------- /mkfiles/bc5.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/mkfiles/bc5.mak -------------------------------------------------------------------------------- /mkfiles/gcc.mak: -------------------------------------------------------------------------------- 1 | # 2 | # GCC.MAK - kernel compiler options for ia16-elf-gcc 3 | # 4 | 5 | #********************************************************************** 6 | #* TARGET : we create a %TARGET%.sys file 7 | #* TARGETOPT : options, handled down to the compiler 8 | #********************************************************************** 9 | 10 | TARGET=KGC$(XCPU)$(XFAT) 11 | TARGETOPT=-march=i8086 12 | 13 | ifeq ($(XCPU),186) 14 | TARGETOPT=march=i80186 15 | ALLCFLAGS+=-DI186 16 | endif 17 | ifeq ($(XCPU),386) 18 | TARGETOPT=-march=i80286 19 | ALLCFLAGS+=-DI386 20 | endif 21 | 22 | ifeq ($(XFAT),32) 23 | ALLCFLAGS+=-DWITHFAT32 24 | NASMFLAGS+=-DWITHFAT32 25 | endif 26 | 27 | NASM=$(XNASM) 28 | NASMFLAGS+=-i../hdr/ -DXCPU=$(XCPU) -felf -o $@ 29 | 30 | CC=ia16-elf-gcc -c 31 | CL=ia16-elf-gcc 32 | INCLUDEPATH=. 33 | 34 | LIBUTIL=ar crs 35 | LIBPLUS= 36 | LIBTERM= 37 | 38 | TINY=-mcmodel=tiny 39 | CFLAGST=-Os -fno-strict-aliasing -fpack-struct -fcall-used-es -Wno-pointer-to-int-cast -Wno-pragmas -Wno-array-bounds -Werror -o $@ 40 | CFLAGSC= 41 | 42 | # 43 | # heavy stuff - building 44 | # 45 | # -mcmodel=small small memory model (small code/small data) 46 | # -Os -> favor code size over execution time in optimizations 47 | # -fno-strict-aliasing don't assume strict aliasing rules 48 | # -fleading-underscore underscores leading field for DOS compiler compat 49 | # -fno-common no "common" variables, just BSS for uninitialized data 50 | # -fpack-struct pack structure members 51 | # -ffreestanding don't assume any headers 52 | # -fcall-used-es es clobbered in function calls 53 | # -mrtd use stdcall calling convention 54 | # -Wno-pointer-to-int-cast do not warn about FP_OFF 55 | # -Wno-pragmas do not warn about #pragma pack 56 | # -Werror treat all warnings as errors 57 | # -mfar-function-if-far-return-type treat `int __far f ();' as a far function 58 | 59 | ALLCFLAGS+=-I../hdr $(TARGETOPT) -mcmodel=small -fleading-underscore -fno-common -fpack-struct -ffreestanding -fcall-used-es -mrtd -Wno-pointer-to-int-cast -Wno-pragmas -Werror -Os -fno-strict-aliasing -mfar-function-if-far-return-type 60 | INITCFLAGS=$(ALLCFLAGS) -o $@ 61 | CFLAGS=$(ALLCFLAGS) -o $@ 62 | 63 | DIRSEP=/ 64 | RM=rm -f 65 | CP=cp 66 | ECHOTO=echo>> 67 | ifeq ($(LOADSEG)0, 0) 68 | LOADSEG=0x60 69 | endif 70 | 71 | INITPATCH=ia16-elf-objcopy --redefine-sym ___umodsi3=_init_umodsi3 --redefine-sym ___udivsi3=_init_udivsi3 --redefine-sym ___ashlsi3=_init_ashlsi3 --redefine-sym ___lshrsi3=_init_lshrsi3 72 | CLDEF=1 73 | CLT=gcc -DDOSC_TIME_H -I../hdr -o $@ 74 | CLC=$(CLT) 75 | LINK=$(XLINK) -Tkernel.ld -Wl,-Map,kernel.map -o kernel.exe $(OBJS) -Wl,--whole-archive ../drivers/device.lib -Wl,--no-whole-archive \# 76 | 77 | .SUFFIXES: .obj .asm 78 | 79 | # *Implicit Rules* 80 | .asm.obj : 81 | $(NASM) -D$(COMPILER) $(NASMFLAGS) $*.asm 82 | 83 | .c.obj : 84 | $(CC) $(CFLAGS) $*.c 85 | -------------------------------------------------------------------------------- /mkfiles/generic.mak: -------------------------------------------------------------------------------- 1 | # These are generic definitions 2 | 3 | #********************************************************************** 4 | #* TARGET : we create a %TARGET%.sys file 5 | #* TARGETOPT : options, handled down to the compiler 6 | #********************************************************************** 7 | 8 | TARGETOPT=-1- 9 | 10 | !if $(XCPU) == 186 11 | TARGETOPT=-1 12 | ALLCFLAGS=$(ALLCFLAGS) -DI186 13 | !endif 14 | !if $(XCPU) == 386 15 | TARGETOPT=-3 16 | ALLCFLAGS=$(ALLCFLAGS) -DI386 17 | !endif 18 | 19 | !if $(XFAT) == 32 20 | ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32 21 | NASMFLAGS=$(NASMFLAGS) -DWITHFAT32 22 | !endif 23 | 24 | NASM=$(XNASM) 25 | NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU) 26 | 27 | LINK=$(XLINK) 28 | 29 | INITPATCH=@rem 30 | DIRSEP=\ #a backslash 31 | RM=..\utils\rmfiles 32 | CP=copy 33 | ECHOTO=..\utils\echoto 34 | CLDEF=0 35 | 36 | !if $(LOADSEG)0 == 0 37 | LOADSEG=0x60 38 | !endif 39 | 40 | !include "../mkfiles/$(COMPILER).mak" 41 | 42 | !if $(CLDEF) == 0 43 | CLT=$(CL) $(CFLAGST) $(TINY) -I$(INCLUDEPATH) 44 | CLC=$(CL) $(CFLAGSC) -I$(INCLUDEPATH) 45 | !endif 46 | 47 | TARGET=$(TARGET)$(XCPU)$(XFAT) 48 | 49 | .asm.obj : 50 | $(NASM) -D$(COMPILER) -f obj $(NASMFLAGS) $*.asm 51 | 52 | # *Implicit Rules* 53 | .c.obj : 54 | $(CC) $(CFLAGS) $*.c 55 | 56 | .cpp.obj : 57 | $(CC) $(CFLAGS) $*.cpp 58 | 59 | -------------------------------------------------------------------------------- /mkfiles/mscl8.mak: -------------------------------------------------------------------------------- 1 | # 2 | # MSCL8.MAK - kernel copiler options for MS CL8 = MSVC1.52 3 | # 4 | 5 | # Use these for MSCV 1.52 6 | COMPILERPATH=$(MS_BASE) 7 | COMPILERBIN=$(COMPILERPATH)\bin 8 | INCLUDEPATH=$(COMPILERPATH)\include 9 | CC=$(COMPILERBIN)\cl -c 10 | CL=$(COMPILERBIN)\cl 11 | TINY= 12 | CFLAGST=/Fm /AT /Os /Zp1 13 | CFLAGSC=/Fm /AL /Os /Zp1 14 | LIBPATH=$(COMPILERPATH)\lib 15 | LIB=$(COMPILERPATH)\lib 16 | INCLUDE=$(COMPILERPATH)\include 17 | LIBUTIL=$(COMPILERBIN)\lib /nologo 18 | LIBPLUS=+ 19 | LIBTERM=; 20 | INCLUDE=$(COMPILERPATH)\include 21 | LIB=$(COMPILERPATH)\lib 22 | 23 | # used for building the library 24 | 25 | CLIB=$(COMPILERPATH)\lib\slibce.lib 26 | MATH_EXTRACT=*aflmul *aFlshl *aFNaulsh *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv 27 | MATH_INSERT= +aflmul +aFlshl +aFNaulsh +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv 28 | 29 | TARGETOPT= 30 | !if $(XCPU) == 186 31 | TARGETOPT=-G1 32 | !endif 33 | !if $(XCPU) == 386 34 | TARGETOPT=-G3 35 | !endif 36 | 37 | TARGET=KMS 38 | 39 | # 40 | # heavy stuff - building 41 | 42 | 43 | ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1 44 | 45 | INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT 46 | CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT 47 | INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC 48 | -------------------------------------------------------------------------------- /mkfiles/owlinux.mak: -------------------------------------------------------------------------------- 1 | # 2 | # WATCOM.MAK - kernel compiler options for Open Watcom on Linux (cross-compile) 3 | # 4 | 5 | # Get definitions from watcom.mak, then override 6 | include "../mkfiles/watcom.mak" 7 | 8 | DIRSEP=/ 9 | INCLUDEPATH=$(COMPILERPATH)/h 10 | RM=rm -f 11 | CP=cp 12 | ECHOTO=echo>> 13 | INITPATCH=@echo > /dev/null 14 | CLDEF=1 15 | CLT=gcc -DDOSC_TIME_H -I../hdr -o $@ 16 | CLC=$(CLT) 17 | CFLAGST=-fo=.obj $(CFLAGST) 18 | ALLCFLAGS=-fo=.obj $(ALLCFLAGS) 19 | XLINK=$(XLINK) debug all op symfile format dos option map,statics,verbose F { $(OBJS) } L ../lib/device.lib N kernel.exe $# 20 | -------------------------------------------------------------------------------- /mkfiles/owwin.mak: -------------------------------------------------------------------------------- 1 | # 2 | # WATCOM.MAK - kernel compiler options for Open Watcom on Windows (cross-compile) 3 | # 4 | 5 | # Get definitions from watcom.mak, then override 6 | include "../mkfiles/watcom.mak" 7 | 8 | DIRSEP=\ 9 | 10 | INCLUDEPATH=$(COMPILERPATH)$(DIRSEP)h 11 | #RM=del 2>nul 12 | #CP=copy 13 | #ECHOTO=echo>> 14 | #INITPATCH=@echo > nul 15 | CLDEF=1 16 | CLT=owcc -DDOSC_TIME_H -DBUILD_UTILS -I../hdr -o $@ 17 | CLC=$(CLT) 18 | CFLAGST=-fo=.obj $(CFLAGST) 19 | ALLCFLAGS=-fo=.obj $(ALLCFLAGS) 20 | NASMFLAGS=-Dowlinux $(NASMFLAGS) 21 | XLINK=$(XLINK) debug all op symfile format dos option map,statics,verbose F { $(OBJS) } L ..$(DIRSEP)lib$(DIRSEP)device.lib N kernel.exe $# 22 | -------------------------------------------------------------------------------- /mkfiles/tc2.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/mkfiles/tc2.mak -------------------------------------------------------------------------------- /mkfiles/tc3.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/mkfiles/tc3.mak -------------------------------------------------------------------------------- /mkfiles/turbocpp.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerditionC/fdkernel/169637e1765264780ee4d98f51f13253c2250360/mkfiles/turbocpp.mak -------------------------------------------------------------------------------- /mkfiles/watcom.mak: -------------------------------------------------------------------------------- 1 | # 2 | # WATCOM.MAK - kernel copiler options for WATCOM C 11.0c 3 | # 4 | 5 | # Use these for WATCOM 11.0c 6 | COMPILERPATH=$(WATCOM) 7 | CC=*wcc 8 | CL=wcl 9 | INCLUDEPATH=$(COMPILERPATH)\H 10 | INCLUDE=$(COMPILERPATH)\h 11 | EDPATH=$(COMPILERPATH)\EDDAT 12 | 13 | !if $(XCPU) != 186 14 | !if $(XCPU) != 386 15 | TARGETOPT=-0 16 | !endif 17 | !endif 18 | 19 | LIBPATH=$(COMPILERPATH)\lib286 20 | LIBUTIL=wlib -q 21 | LIBPLUS= 22 | LIBTERM= 23 | 24 | TINY=-mt 25 | CFLAGST=-zq-zp1-os-s-we-e3-wx-bt=DOS 26 | CFLAGSC=-mc-zq-zp1-os-s-we-e3-wx-bt=DOS 27 | 28 | TARGET=KWC 29 | 30 | # used for building the library 31 | 32 | CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib 33 | 34 | # we use our own ones, which override these ones when linking. 35 | # 36 | 37 | MATH_EXTRACT=*i4m 38 | MATH_INSERT=+i4m 39 | 40 | 41 | # 42 | # heavy stuff - building 43 | # 44 | # -e= set limit on number of error messages 45 | # -ms small memory model (small code/small data) 46 | # -j change char default from unsigned to signed 47 | #-nc= set code class name 48 | #-nd= set data segment name 49 | #-nm= set module name 50 | #-nt= set name of text segment 51 | # -g= set code group name 52 | # -os -> favor code size over execution time in optimizations 53 | # -s remove stack overflow checks 54 | # -w= set warning level number 55 | # -we treat all warnings as errors 56 | # -ze enable extensions (i.e., near, far, export, etc.) 57 | # -zl remove default library information 58 | # -zp= pack structure members with alignment {1,2,4,8,16} 59 | # -zq operate quietly 60 | # 61 | # -3 optimization for 386 - given in CONFIG.MAK, not here 62 | # 63 | 64 | ALLCFLAGS=-I..$(DIRSEP)hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r 65 | INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI 66 | CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT 67 | 68 | -------------------------------------------------------------------------------- /share/makefile: -------------------------------------------------------------------------------- 1 | 2 | # nmake makefile 3 | # share must be linked as COM file 4 | # best is to use TC 2.01 which is freely available 5 | 6 | USETC2=1 7 | COM=1 8 | 9 | !if $(USETC2) 10 | TCC=d:\alt\tc201\tcc 11 | TLINK=d:\alt\tc201\tlink 12 | LIBS=d:\alt\tc201 13 | COPT=-c -mt -1 -Id:\alt\tc201 14 | LOPT=/m /s /c /t 15 | !else 16 | TCC=d:\alt\tc30\bin\tcc 17 | TLINK=d:\alt\tc30\bin\tlink 18 | LIBS=d:\alt\tc30\lib 19 | !if $(COM) 20 | COPT=-c -mt -1 -Id:\alt\tc30\Include 21 | LOPT=-m -s -c -t 22 | !else 23 | COPT=-c -ms -1 -Id:\alt\tc30\Include 24 | LOPT=-m -s -c 25 | !endif 26 | !endif 27 | 28 | SHARE.COM: SHARE.OBJ 29 | $(TLINK) $(LOPT) $(LIBS)\c0t.obj share.obj,share.com,,$(LIBS)\cs.lib 30 | 31 | SHARE.OBJ: SHARE.C 32 | $(TCC) $(COPT) share.c 33 | 34 | -------------------------------------------------------------------------------- /share/share.hlp: -------------------------------------------------------------------------------- 1 | Installs file-sharing and locking capabilities on your hard disk. 2 | 3 | SHARE [/F:space] [/L:locks] 4 | 5 | /F:space Allocates file space (in bytes) for file-sharing information. 6 | /L:locks Sets the number of files that can be locked at one time. 7 | -------------------------------------------------------------------------------- /sys/bin2c.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | FILE *in, *out; 6 | int col; 7 | int c; 8 | 9 | if (argc < 4) 10 | { 11 | fprintf(stderr, 12 | "Usage: bin2c \n"); 13 | return 1; 14 | } 15 | 16 | if ((in = fopen(argv[1], "rb")) == NULL) 17 | { 18 | fprintf(stderr, "Cannot open input file (%s).\n", argv[1]); 19 | return 1; 20 | } 21 | 22 | if ((out = fopen(argv[2], "wt")) == NULL) 23 | { 24 | fprintf(stderr, "Cannot open output file (%s).\n", argv[2]); 25 | return 1; 26 | } 27 | 28 | col = 0; 29 | 30 | fprintf(out, "unsigned char %s[] = {\n ", argv[3]); 31 | 32 | while ((c = fgetc(in)) != EOF) 33 | { 34 | if (col) 35 | { 36 | fprintf(out, ", "); 37 | } 38 | if (col >= 8) 39 | { 40 | fprintf(out, "\n "); 41 | col = 0; 42 | } 43 | fprintf(out, "0x%02X", c); 44 | col++; 45 | } 46 | 47 | fprintf(out, "\n};\n"); 48 | fclose(in); 49 | fclose(out); 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /sys/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for bin2c.exe and sys.com 3 | # 4 | # $Id: makefile 1482 2009-07-11 16:59:43Z perditionc $ 5 | # 6 | 7 | !include "../mkfiles/generic.mak" 8 | 9 | CFLAGS = -I$(INCLUDEPATH) -I..$(DIRSEP)hdr -DFORSYS -DWITHFAT32 $(CFLAGST) 10 | NASMFLAGS = -DSYS=1 11 | 12 | # *List Macros* 13 | 14 | SYS_EXE_dependencies = \ 15 | sys.obj \ 16 | fdkrncfg.obj \ 17 | prf.obj \ 18 | talloc.obj 19 | 20 | # *Explicit Rules* 21 | production: bin2c.exe ../bin/sys.com 22 | 23 | bin2c.exe: bin2c.c 24 | $(CLC) bin2c.c 25 | 26 | ../bin/sys.com: sys.com 27 | $(CP) sys.com ..$(DIRSEP)bin 28 | 29 | fat12com.h: ../boot/fat12com.bin bin2c.exe 30 | .$(DIRSEP)bin2c.exe ../boot/fat12com.bin fat12com.h fat12com 31 | 32 | fat16com.h: ../boot/fat16com.bin bin2c.exe 33 | .$(DIRSEP)bin2c.exe ../boot/fat16com.bin fat16com.h fat16com 34 | 35 | fat32chs.h: ../boot/fat32chs.bin bin2c.exe 36 | .$(DIRSEP)bin2c.exe ../boot/fat32chs.bin fat32chs.h fat32chs 37 | 38 | fat32lba.h: ../boot/fat32lba.bin bin2c.exe 39 | .$(DIRSEP)bin2c.exe ../boot/fat32lba.bin fat32lba.h fat32lba 40 | 41 | oemfat12.h: ../boot/oemfat12.bin bin2c.exe 42 | .$(DIRSEP)bin2c.exe ../boot/oemfat12.bin oemfat12.h oemfat12 43 | 44 | oemfat16.h: ../boot/oemfat16.bin bin2c.exe 45 | .$(DIRSEP)bin2c.exe ../boot/oemfat16.bin oemfat16.h oemfat16 46 | 47 | prf.obj: ../kernel/prf.c 48 | $(CC) $(CFLAGS) ..$(DIRSEP)kernel$(DIRSEP)prf.c 49 | 50 | fdkrncfg.obj: fdkrncfg.c ../hdr/kconfig.h 51 | 52 | talloc.obj: talloc.c 53 | 54 | sys.com: $(SYS_EXE_dependencies) 55 | $(CL) $(CFLAGST) $(TINY) $(SYS_EXE_dependencies) 56 | 57 | clobber: clean 58 | -$(RM) bin2c.exe bin2c.com sys.com fat*.h oemfat*.h 59 | 60 | clean: 61 | -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me 62 | 63 | # *Individual File Dependencies* 64 | sys.obj: sys.c ../hdr/portab.h ../hdr/device.h fat12com.h fat16com.h fat32chs.h fat32lba.h oemfat12.h oemfat16.h 65 | $(CC) $(CFLAGS) $*.c 66 | 67 | -------------------------------------------------------------------------------- /tests/absread/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | wcl -e3-we-wx-zq-os-s-zp1-mt-bt=DOS absread.c 3 | -------------------------------------------------------------------------------- /utils/echoto.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set FILE=%1 3 | set STR=%2 4 | 5 | :loop 6 | shift 7 | if "%2" == "" goto end 8 | set STR=%STR% %2 9 | goto loop 10 | :end 11 | 12 | echo %STR%>> %FILE% 13 | -------------------------------------------------------------------------------- /utils/indent.ini: -------------------------------------------------------------------------------- 1 | -kr 2 | -di2 3 | -nbc 4 | -nfca 5 | -bl 6 | -bli0 7 | -ss 8 | -npcs 9 | -ncs 10 | -nbs 11 | -i2 12 | -ci4 13 | -nce 14 | -sob 15 | -nut 16 | -nbad 17 | -cli2 18 | -hnl 19 | -------------------------------------------------------------------------------- /utils/makefile: -------------------------------------------------------------------------------- 1 | !include "../mkfiles/generic.mak" 2 | 3 | CFLAGS = -I..$(DIRSEP)hdr 4 | 5 | production: patchobj.com exeflat.exe 6 | 7 | patchobj.com: patchobj.c 8 | $(CLT) $(CFLAGS) patchobj.c 9 | 10 | exeflat.exe: exeflat.c ../hdr/exe.h 11 | $(CLC) $(CFLAGS) exeflat.c 12 | 13 | 14 | clobber: clean 15 | 16 | clean: 17 | $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me 18 | $(RM) exeflat.exe patchobj.com 19 | 20 | -------------------------------------------------------------------------------- /utils/proto.bat: -------------------------------------------------------------------------------- 1 | for %%f in ( %1 %2 %3 %4 %5 %6 %7 %8 %9 ) do mkptypes %%f >>proto.h 2 | -------------------------------------------------------------------------------- /utils/relocinf.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | ** RelocInf.C 3 | ** 4 | ** provide some info about relocation entries in an exe file 5 | ** 6 | ** usage: 7 | ** RelocInfo exefile 8 | ** 9 | ** 10 | ** Copyright 2001 by tom ehlert 11 | ** 12 | ** GPL bla to be added, but intended as GPL 13 | ** 14 | ** 15 | ** 09/06/2001 - initial revision 16 | ** not my biggest kind of software; anyone willing to add 17 | ** comments, errormessages, usage info,...??? 18 | ** 19 | *****************************************************************************/ 20 | 21 | * / 22 | #include 23 | #include 24 | #include 25 | typedef unsigned short UWORD; 26 | typedef unsigned long ULONG; 27 | #ifndef _MSC_VER 28 | #define const 29 | #define __cdecl cdecl 30 | #endif 31 | 32 | /* from EXE.H */ 33 | typedef struct { 34 | UWORD exSignature; 35 | UWORD exExtraBytes; 36 | UWORD exPages; 37 | UWORD exRelocItems; 38 | UWORD exHeaderSize; 39 | UWORD exMinAlloc; 40 | UWORD exMaxAlloc; 41 | UWORD exInitSS; 42 | UWORD exInitSP; 43 | UWORD exCheckSum; 44 | UWORD exInitIP; 45 | UWORD exInitCS; 46 | UWORD exRelocTable; 47 | UWORD exOverlay; 48 | } exe_header; 49 | 50 | #define MAGIC 0x5a4d 51 | 52 | struct relocEntry { 53 | UWORD off; 54 | UWORD seg; 55 | UWORD refseg; 56 | }; 57 | 58 | int __cdecl compReloc(const void *p1, const void *p2) 59 | { 60 | struct relocEntry *r1 = (struct relocEntry *)p1; 61 | struct relocEntry *r2 = (struct relocEntry *)p2; 62 | 63 | if (r1->refseg > r2->refseg) 64 | return 1; 65 | if (r1->refseg < r2->refseg) 66 | return -1; 67 | 68 | if (r1->seg > r2->seg) 69 | return 1; 70 | if (r1->seg < r2->seg) 71 | return -1; 72 | 73 | if (r1->off > r2->off) 74 | return 1; 75 | if (r1->off < r2->off) 76 | return -1; 77 | 78 | return 0; 79 | } 80 | 81 | main(int argc, char *argv[]) 82 | { 83 | FILE *fdin; 84 | exe_header header; 85 | struct relocEntry *reloc; 86 | 87 | int i; 88 | ULONG image_offset; 89 | 90 | if (argc < 2 || (fdin = fopen(argv[1], "rb")) == NULL) 91 | { 92 | printf("can't open %s\n", argv[1]); 93 | exit(1); 94 | } 95 | 96 | if (fread(&header, sizeof(header), 1, fdin) != 1 || 97 | header.exSignature != MAGIC) 98 | { 99 | printf("%s is no EXE file\n"); 100 | exit(1); 101 | } 102 | 103 | printf("%u relocation entries found\n", header.exRelocItems); 104 | 105 | if (header.exRelocItems > 0x8000 / sizeof(*reloc)) 106 | { 107 | printf("too many relocation entries \n"); 108 | exit(1); 109 | } 110 | 111 | if ((reloc = malloc(header.exRelocItems * sizeof(*reloc))) == NULL) 112 | { 113 | printf("can't alloc memory\n"); 114 | exit(1); 115 | } 116 | 117 | if (fseek(fdin, header.exRelocTable, 0)) 118 | { 119 | printf("can't seek\n"); 120 | exit(1); 121 | } 122 | 123 | for (i = 0; i < header.exRelocItems; i++) 124 | if (fread(reloc + i, 4, 1, fdin) != 1) 125 | { 126 | printf("can't read reloc info\n"); 127 | exit(1); 128 | } 129 | 130 | for (i = 0; i < header.exRelocItems; i++) 131 | { 132 | image_offset = (ULONG) header.exHeaderSize * 16; 133 | 134 | image_offset += ((ULONG) reloc[i].seg << 4) + reloc[i].off; 135 | 136 | if (fseek(fdin, image_offset, 0)) 137 | { 138 | printf("can't seek reloc data\n"); 139 | exit(1); 140 | } 141 | 142 | if (fread(&reloc[i].refseg, 2, 1, fdin) != 1) 143 | { 144 | printf("can't read rel data for item %d\n", i); 145 | exit(1); 146 | } 147 | /* printf("%04x:%04x -> %04x\n", reloc[i].seg, reloc[i].off, reloc[i].refseg); */ 148 | } 149 | 150 | /* sort reloc entries */ 151 | 152 | qsort(reloc, header.exRelocItems, sizeof(*reloc), compReloc); 153 | 154 | for (i = 0; i < header.exRelocItems; i++) 155 | { 156 | if (i == 0) 157 | printf("# seg:off references data in -->\n"); 158 | printf("%3d %04x:%04x -> %04x\n", i, reloc[i].seg, reloc[i].off, 159 | reloc[i].refseg); 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /utils/rmfiles.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :loop_commandline 3 | 4 | if \%1 == \ goto done_with_commandline 5 | if exist %1 del %1>nul 6 | shift 7 | goto loop_commandline 8 | 9 | :done_with_commandline 10 | 11 | -------------------------------------------------------------------------------- /utils/wlinker.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk 3 | echo op map,statics,verbose >> kernel.lnk 4 | call wlink @kernel.lnk 5 | --------------------------------------------------------------------------------