├── .gitattributes ├── .github └── workflows │ └── ci-build.yml ├── .gitignore ├── .gitmodules ├── COPYING ├── MAKEPKGS.BAT ├── README.md ├── RELEASE.BAT ├── bin ├── autoexec.bat ├── config.sys └── install.bat ├── boot ├── boot.asm ├── boot32.asm ├── boot32lb.asm ├── magic.mac ├── makefile └── oemboot.asm ├── build.bat ├── buildall.bat ├── ci_build.sh ├── ci_prereq.sh ├── ci_test.sh ├── clean.bat ├── clobber.bat ├── config.b ├── config.m ├── default.bat ├── docs ├── CNAME ├── _config.yml ├── bugs.txt ├── build.txt ├── config.txt ├── contrib.txt ├── fdkernel.lsm ├── history.txt ├── index.md ├── intfns.txt ├── lfnapi.txt ├── memdisk.txt ├── mkboot.txt ├── nls.txt ├── 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 ├── dcb.h ├── ddate.h ├── debug.h ├── device.h ├── dirmatch.h ├── dsk.h ├── dtime.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 ├── version.h ├── win.h └── xstructs.h ├── kernel ├── apisupt.asm ├── asmsupt.asm ├── blockio.c ├── break.c ├── chario.c ├── config.c ├── config.h ├── console.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 ├── 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 ├── setver ├── makefile └── setver.asm ├── sys ├── bin2c.c ├── fdkrncfg.c ├── makefile ├── sys.c └── talloc.c ├── test ├── bootimg │ ├── a.asm │ └── bootimg.asm ├── cfg.sh ├── ldosboot │ ├── boot.asm │ ├── boot32.asm │ ├── doc │ │ ├── ldosboot.src │ │ └── mak.sh │ ├── fdkernpl.asm │ ├── iniload.asm │ ├── kernshim.asm │ ├── multboot.asm │ ├── patch.sld │ ├── test │ │ ├── cfg.sh │ │ ├── quit.asm │ │ ├── run.sh │ │ └── test.sh │ ├── testpl.asm │ └── testwrit.asm ├── lmacros │ ├── jn_warn.mac │ ├── lmacros1.mac │ ├── lmacros2.mac │ ├── lmacros3.mac │ └── tests │ │ ├── 000.asm │ │ ├── 001.asm │ │ ├── 002.asm │ │ ├── 003.asm │ │ ├── 004.asm │ │ ├── 005.asm │ │ ├── 006.asm │ │ ├── 007.asm │ │ ├── 008.asm │ │ ├── 009.asm │ │ ├── 010.asm │ │ ├── 011.asm │ │ ├── 012.asm │ │ ├── 013.asm │ │ ├── 014.asm │ │ ├── 015.asm │ │ ├── 016.asm │ │ ├── 017.asm │ │ ├── 018.asm │ │ ├── 019.asm │ │ ├── test.sh │ │ ├── test2.asm │ │ ├── testalig.asm │ │ ├── testmap.sh │ │ ├── testpar.asm │ │ └── testsat.asm ├── test.asm └── test.sh ├── tests ├── absread │ ├── absread.c │ └── build.bat ├── fcb_rename │ ├── build.bat │ └── fcb_ren.c └── opendev │ ├── DIREXIST │ └── EMPTYDIR.txt │ ├── build.bat │ └── opendev.c └── utils ├── echoto.bat ├── exeflat.c ├── indent.ini ├── makefile ├── patchobj.c ├── proto.bat ├── relocinf.c ├── rmfiles.bat ├── upxdevic.asm ├── upxentry.asm └── wlinker.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=crlf 2 | *.up -text 3 | *.UP -text 4 | ci_*.sh text eol=lf 5 | .github/workflows/*.yml text eol=lf 6 | test/** binary diff 7 | -------------------------------------------------------------------------------- /.github/workflows/ci-build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | pull_request: 4 | types: 5 | - opened 6 | - ready_for_review 7 | - reopened 8 | - synchronize 9 | push: 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build: 14 | if: contains(github.event.head_commit.message, '[skip ci]') == false 15 | 16 | runs-on: ubuntu-22.04 17 | 18 | steps: 19 | - name: Checkout repository and submodules 20 | uses: actions/checkout@v4 21 | with: 22 | submodules: recursive 23 | 24 | - name: Package install 25 | run: ./ci_prereq.sh 26 | 27 | - name: build 28 | run: ./ci_build.sh 29 | 30 | - name: test 31 | run: ./ci_test.sh 32 | 33 | - name: make snapshot name 34 | id: snapshotname 35 | run: | 36 | ( 37 | today=`date -u +%F | tr '\n' '-'` 38 | s_sha=`echo -n ${GITHUB_SHA} | cut -c1-8` 39 | printf "fname=snapshot-%s%s\n" $today $s_sha >> $GITHUB_OUTPUT 40 | ) 41 | 42 | - name: upload 43 | if: github.repository == 'FDOS/kernel' && 44 | (github.event_name == 'push' || github.event.pull_request.merged == true) 45 | uses: actions/upload-artifact@v4 46 | with: 47 | name: ${{ steps.snapshotname.outputs.fname }} 48 | path: _output/*/*.??? 49 | -------------------------------------------------------------------------------- /.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 | bin/SETVER.SYS 48 | bin/setver.sys 49 | 50 | # backup files 51 | *.orig 52 | *~ 53 | *.diff 54 | *.rej 55 | 56 | # CI build 57 | _downloads/** 58 | _output/** 59 | _watcom/** 60 | kernel/exeflat.rsp 61 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "share"] 2 | path = share 3 | url = https://github.com/FDOS/share.git 4 | ignore = untracked 5 | [submodule "country"] 6 | path = country 7 | url = https://github.com/FDOS/country.git 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fd kernel 2 | ========= 3 | 4 | FreeDOS kernel - current 0xFD version is 2.44 (2044) 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. This was originally a branch based on 2042 SVN 0xFD kernel; the full svn history has since been added to git (see other branches) and current development of release kernels are available here. Please fork and submit a Pull Request! 9 | 10 | 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. *** TODO update links/upload archives 11 | 12 | 13 | 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. 14 | 15 | Please feel free to email me - PerditionC@gmail.com 16 | 17 | Now with automatic builds and soon tests [![Build](../../workflows/Build/badge.svg)](../../actions) 18 | -------------------------------------------------------------------------------- /RELEASE.BAT: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | IF "%1"=="" GOTO USAGE 3 | REM assume ran in root directory of kernel checkout, e.g. C:\fdos\source\kernel\ 4 | 5 | ECHO tag git with release version - 6 | git tag -a -m "Tag kernel release %1" ke%1 HEAD 7 | ECHO get a clean tree 8 | if EXIST ..\SOURCE RMDIR /S /Q ..\SOURCE > NUL 9 | ::git clone -v --local --branch ke%1 . ..\SOURCE\ke%1\ 10 | git clone -v --recurse-submodules --local . ..\SOURCE\ke%1\ 11 | 12 | REM delete files to exclude 13 | RD /S /Q ..\SOURCE\ke%1\.git > NUL 14 | RD /S /Q ..\SOURCE\ke%1\.github > NUL 15 | IF EXIST ..\SOURCE\ke%1\.git* DEL /Q ..\SOURCE\ke%1\.git* > NUL 16 | IF EXIST ..\SOURCE\ke%1\*.yml DEL /Q ..\SOURCE\ke%1\*.yml > NUL 17 | IF EXIST ..\SOURCE\ke%1\ci*.sh DEL /Q ..\SOURCE\ke%1\ci*.sh > NUL 18 | IF EXIST ..\SOURCE\ke%1\docs\*.yml DEL /Q ..\SOURCE\ke%1\docs\*.yml > NUL 19 | IF EXIST ..\SOURCE\ke%1\docs\CNAME DEL /Q ..\SOURCE\ke%1\docs\CNAME > NUL 20 | ::pause 21 | 22 | ECHO %CD% 23 | CALL MAKEPKGS.BAT %1 RELEASE 24 | GOTO DONE 25 | 26 | :USAGE 27 | ECHO Tag and build release kernels - usage: RELEASE {VERSION} e.g. RELEASE 2039 28 | :DONE 29 | ECHO Please git push the tag to origin and upload the archives. 30 | ECHO E.g. git push origin ke%1 31 | -------------------------------------------------------------------------------- /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/magic.mac: -------------------------------------------------------------------------------- 1 | 2 | ; Public Domain 2024 by E. C. Masloch 3 | 4 | %macro _appenddigitstrdef 2.nolist 5 | %substr %%ii "0123456789ABCDEF" (%2) + 1 6 | %strcat _%1 _%1,%%ii 7 | %endmacro 8 | 9 | ; %1 = name of single-line macro to set. will be prefixed by underscore 10 | ; %2 = number to write 11 | ; %3 = minimal number of hexits, 0..8. defaults to 1 12 | ; (setting it to 0 with a number of 0 defines macro to "") 13 | %macro _autohexitsstrdef 2-3.nolist 1 14 | %if %3 > 8 15 | %error Minimal number of hexits 9 or more: %3 16 | %endif 17 | %define _%1 "" 18 | %if (%2) >= 1_0000_0000h 19 | %error Number has to use 9 or more hexits: %2 20 | %endif 21 | %if (%2) >= 1000_0000h || %3 >= 8 22 | _appenddigitstrdef %1, (%2 >> (7 * 4)) & 0Fh 23 | %endif 24 | %if (%2) >= 100_0000h || %3 >= 7 25 | _appenddigitstrdef %1, (%2 >> (6 * 4)) & 0Fh 26 | %endif 27 | %if (%2) >= 10_0000h || %3 >= 6 28 | _appenddigitstrdef %1, (%2 >> (5 * 4)) & 0Fh 29 | %endif 30 | %if (%2) >= 1_0000h || %3 >= 5 31 | _appenddigitstrdef %1, (%2 >> (4 * 4)) & 0Fh 32 | %endif 33 | %if (%2) >= 1000h || %3 >= 4 34 | _appenddigitstrdef %1, (%2 >> (3 * 4)) & 0Fh 35 | %endif 36 | %if (%2) >= 100h || %3 >= 3 37 | _appenddigitstrdef %1, (%2 >> (2 * 4)) & 0Fh 38 | %endif 39 | %if (%2) >= 10h || %3 >= 2 40 | _appenddigitstrdef %1, (%2 >> (1 * 4)) & 0Fh 41 | %endif 42 | %if (%2) >= 1h || %3 >= 1 43 | _appenddigitstrdef %1, (%2 >> (0 * 4)) & 0Fh 44 | %endif 45 | %endmacro 46 | 47 | %macro magicoffset 2-4.nolist ,0 48 | %if ISFAT1216DUAL 49 | %ifdef ISFAT12 50 | %define SYSOFFSET %2 51 | %elifdef ISFAT16 52 | %define SYSOFFSET %3 53 | %else 54 | %define SYSOFFSET 0 55 | ; Just a placeholder, so the proper error message 56 | ; will be shown when assembling without either 57 | ; of the ISFATx defines. 58 | %endif 59 | %else 60 | %define SYSOFFSET %2 61 | %ifnempty %3 62 | %error Not in dual mode 63 | %endif 64 | %endif 65 | %assign NEWOFFSET $ + %4 - Entry 66 | %if NEWOFFSET != SYSOFFSET 67 | _autohexitsstrdef NEWOFFSETHEX, NEWOFFSET 68 | %strcat _NEWOFFSETHEX _NEWOFFSETHEX,'h' 69 | %deftok NEWOFFSET _NEWOFFSETHEX 70 | %if ISFAT1216DUAL 71 | %error Magic offset %1 changed for FATFS, old=SYSOFFSET, new=NEWOFFSET 72 | %else 73 | %error Magic offset %1 changed, old=SYSOFFSET, new=NEWOFFSET 74 | %endif 75 | %endif 76 | %endmacro 77 | -------------------------------------------------------------------------------- /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 magic.mac 11 | $(NASM) -dISFAT12 $(NASMBOOTFLAGS) boot.asm -lfat12com.lst -ofat12com.bin 12 | 13 | fat16com.bin: boot.asm magic.mac 14 | $(NASM) -dISFAT16 $(NASMBOOTFLAGS) boot.asm -lfat16com.lst -ofat16com.bin 15 | 16 | fat32chs.bin: boot32.asm magic.mac 17 | $(NASM) $(NASMBOOTFLAGS) boot32.asm -lfat32chs.lst -ofat32chs.bin 18 | 19 | fat32lba.bin: boot32lb.asm magic.mac 20 | $(NASM) $(NASMBOOTFLAGS) boot32lb.asm -lfat32lba.lst -ofat32lba.bin 21 | 22 | oemfat12.bin: oemboot.asm magic.mac 23 | $(NASM) -dISFAT12 $(NASMBOOTFLAGS) oemboot.asm -loemfat12.lst -ooemfat12.bin 24 | 25 | oemfat16.bin: oemboot.asm magic.mac 26 | $(NASM) -dISFAT16 $(NASMBOOTFLAGS) oemboot.asm -loemfat16.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 | 19 | if "%MS_BASE%" == "" goto no_ms 20 | call build -r msc 386 fat16 21 | %ONERROR% 22 | call build -r msc 186 fat16 23 | %ONERROR% 24 | call build -r msc 86 fat16 25 | %ONERROR% 26 | call build -r msc 386 fat32 27 | %ONERROR% 28 | call build -r msc 186 fat32 29 | %ONERROR% 30 | call build -r msc 86 fat32 31 | %ONERROR% 32 | :no_ms 33 | 34 | :***** TC 2.01 kernels 35 | 36 | if "%TC2_BASE%" == "" goto no_tc 37 | call build -r tc 186 fat16 38 | %ONERROR% 39 | call build -r tc 86 fat16 40 | %ONERROR% 41 | call build -r tc 186 fat32 42 | %ONERROR% 43 | call build -r tc 86 fat32 44 | %ONERROR% 45 | :no_tc 46 | 47 | :***** (Open) Watcom kernels 48 | 49 | if not "%COMPILER%" == "WATCOM" goto no_wc 50 | call build -r wc 386 fat32 51 | %ONERROR% 52 | call build -r wc 386 fat16 53 | %ONERROR% 54 | call build -r wc 86 fat32 55 | %ONERROR% 56 | call build -r wc 86 fat16 57 | %ONERROR% 58 | :no_wc 59 | 60 | :***** now rebuild the default kernel 61 | 62 | call build -r 63 | 64 | :************************************************************** 65 | :* now we build a summary of all kernels HMA size + total size 66 | :* Yes, I know - "mit Linux waer das nicht passiert" :-) 67 | :* at least, it's possible with standard DOS tools 68 | :************************************************************** 69 | 70 | set Sumfile=bin\ksummary.txt 71 | set TempSumfile=bin\tsummary.txt 72 | 73 | :****echo >%TempSumfile% Summary of all kernels build 74 | :****echo.|date >>%TempSumfile% 75 | :****echo.|time >>%TempSumfile% 76 | :****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i 77 | 78 | if exist %Sumfile% del %Sumfile% 79 | if exist %TempSumfile% del %TempSumfile% 80 | >ktemp.bat 81 | for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat 82 | sort ktemps.bat 83 | call ktemps.bat 84 | del ktemp.bat 85 | del ktemps.bat 86 | 87 | echo >>%Sumfile% Summary of all kernels build 88 | echo.|date >>%Sumfile% 89 | echo.|time >>%Sumfile% 90 | find <%TempSumfile% "H" >>%Sumfile% 91 | del %TempSumfile% 92 | 93 | set TempSumfile= 94 | set Sumfile= 95 | goto end 96 | 97 | :summary 98 | echo H************************************************* %2 >>%TempSumfile% 99 | find<%2 " HMA_TEXT"|find/V "HMA_TEXT_START"|find/V "HMA_TEXT_END">>%TempSumfile% 100 | find<%2 " STACK">>%TempSumfile% 101 | goto end 102 | 103 | :************* done with summary ********************************* 104 | 105 | :daswarwohlnix 106 | echo Sorry, something didn't work as expected :-( 107 | set ONERROR= 108 | 109 | :end 110 | -------------------------------------------------------------------------------- /ci_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ -z "${BUILD_DIR}" ] ; then 6 | BUILD_DIR=$(pwd) 7 | fi 8 | echo BUILD_DIR is \"${BUILD_DIR}\" 9 | 10 | # Output directory 11 | rm -rf _output 12 | mkdir _output 13 | 14 | # GCC 15 | mkdir _output/gcc 16 | git clean -x -d -f -e test -e _output -e _downloads -e _watcom 17 | make -C country clean 18 | make all COMPILER=gcc 19 | mv -n bin/KGC*.map bin/KGC*.sys _output/gcc/. 20 | mv -n bin/country.sys _output/gcc/. 21 | # GCC share 22 | ( 23 | cd share 24 | git submodule update --init --recursive 25 | git clean -x -d -f 26 | env COMPILER=gcc ./build.sh 27 | ) 28 | mv -n share/src/share.com _output/gcc/. 29 | mv -n share/src/share.map _output/gcc/. 30 | 31 | # Open Watcom Environment Setup 32 | export WATCOM=$BUILD_DIR/_watcom 33 | export PATH=$BUILD_DIR/bin:$PATH:$WATCOM/binl64 34 | 35 | mkdir _output/wc 36 | git clean -x -d -f -e test -e _output -e _downloads -e _watcom 37 | make -C country clean 38 | make all COMPILER=owlinux 39 | mv -n bin/KWC*.map bin/KWC*.sys _output/wc/. 40 | mv -n bin/country.sys _output/wc/. 41 | 42 | ## DOS (GCC) 43 | #mkdir _output/gcc_dos 44 | #git clean -x -d -f -e test -e _output -e _downloads -e _watcom 45 | #{ 46 | # echo set COMPILER=GCC 47 | # echo set MAKE=make 48 | # echo set XCPU=386 49 | # echo set XFAT=32 50 | # echo set XNASM='C:\\devel\\nasm\\nasm' 51 | # echo set OLDPATH=%PATH% 52 | # echo set PATH='C:\\devel\\i16gnu\\bin;C:\\bin;%OLDPATH%' 53 | #} | unix2dos > config.bat 54 | 55 | #dosemu -td -q -K . -E "build.bat" 56 | 57 | # DOS (Watcom) 58 | mkdir _output/wc_dos 59 | git clean -x -d -f -e test -e _output -e _downloads -e _watcom 60 | { 61 | echo set COMPILER=WATCOM 62 | echo set WATCOM='C:\\devel\\watcomc' 63 | echo set MAKE=wmake /ms 64 | echo set XCPU=386 65 | echo set XFAT=32 66 | echo set XNASM='C:\\devel\\nasm\\nasm' 67 | echo set XUPX=upx --8086 --best 68 | echo set OLDPATH=%PATH% 69 | echo set PATH='%WATCOM%\\binw;C:\\bin;%OLDPATH%' 70 | echo set DOS4G=QUIET 71 | } | unix2dos > config.bat 72 | 73 | dosemu -td -q -K . -E "build.bat" 74 | mv -n bin/KWC*.map bin/KWC*.sys _output/wc_dos/. 75 | mv -n bin/country.sys _output/wc_dos/. 76 | 77 | 78 | # DOS (Turbo C 2.01) 79 | if [ -d ${HOME}/.dosemu/drive_c/tc201 ] ; then 80 | mkdir _output/tc_dos 81 | git clean -x -d -f -e test -e _output -e _downloads -e _watcom 82 | { 83 | echo set COMPILER=TC2 84 | echo set TC2_BASE='C:\\tc201' 85 | echo set MAKE=make 86 | echo set XCPU=386 87 | echo set XFAT=32 88 | echo set XNASM=nasm 89 | echo set OLDPATH=%PATH% 90 | echo set PATH='%TC2_BASE%;C:\\devel\\nasm;C:\\bin;%OLDPATH%' 91 | } | unix2dos > config.bat 92 | 93 | dosemu -td -q -K . -E "build.bat lfn" 94 | mv -n bin/KTC*.map bin/KTC*.sys _output/tc_dos/. 95 | mv -n bin/country.sys _output/tc_dos/. 96 | # TC share 97 | ( 98 | cd share 99 | git submodule update --init --recursive 100 | git clean -x -d -f 101 | env COMPILER=tcc2-emu ./build.sh 102 | ) 103 | mv -n share/src/share.com _output/tc_dos/. 104 | mv -n share/src/share.map _output/tc_dos/. 105 | fi 106 | 107 | echo done 108 | -------------------------------------------------------------------------------- /ci_prereq.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | sudo add-apt-repository -y ppa:tkchia/build-ia16 6 | sudo add-apt-repository -y ppa:dosemu2/ppa 7 | sudo apt update 8 | 9 | # for cross building 10 | sudo apt install gcc-ia16-elf libi86-ia16-elf nasm upx qemu-system-x86 mtools util-linux bash 11 | 12 | # for building with DOS using an emulator 13 | sudo apt install dosemu2 dos2unix 14 | # Perhaps later we should build using Freecom from published package 15 | 16 | mkdir -p _downloads 17 | mkdir -p _watcom 18 | cd _downloads 19 | 20 | HERE=$(pwd) 21 | 22 | # download and unpack Open Watcom snapshot 23 | [ -f ow-snapshot.tar.xz ] || wget --no-verbose https://github.com/open-watcom/open-watcom-v2/releases/download/Current-build/ow-snapshot.tar.xz 24 | tar -C ../_watcom -xf ow-snapshot.tar.xz 25 | 26 | #IBIBLIO_PATH='http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos' 27 | IBIBLIO_PATH='https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/repositories/1.3' 28 | 29 | BASE=${IBIBLIO_PATH}/base 30 | 31 | # get FreeDOS kernel 32 | [ -f kernel.zip ] || wget --no-verbose ${BASE}/kernel.zip 33 | 34 | # get FreeCOM 35 | [ -f freecom.zip ] || wget --no-verbose ${BASE}/freecom.zip 36 | 37 | DEVEL=${IBIBLIO_PATH}/devel 38 | 39 | # get gnumake for DOS 40 | [ -f djgpp_mk.zip ] || wget --no-verbose ${DEVEL}/djgpp_mk.zip 41 | 42 | # get nasm for DOS 43 | [ -f nasm.zip ] || wget --no-verbose ${DEVEL}/nasm.zip 44 | 45 | # get upx for DOS 46 | [ -f upx.zip ] || wget --no-verbose ${DEVEL}/upx.zip 47 | 48 | # grab ia16-gcc from ibiblio.org 49 | #[ -f i16gcc.zip ] || wget --no-verbose ${DEVEL}/i16gcc.zip 50 | #[ -f i16newli.zip ] || wget --no-verbose ${DEVEL}/i16newli.zip 51 | #[ -f i16butil.zip ] || wget --no-verbose ${DEVEL}/i16butil.zip 52 | #[ -f i16lbi86.zip ] || wget --no-verbose ${DEVEL}/i16lbi86.zip 53 | 54 | # get watcom for DOS 55 | [ -f watcomc.zip ] || wget --no-verbose ${DEVEL}/watcomc.zip 56 | 57 | mkdir -p ${HOME}/.dosemu/drive_c 58 | cd ${HOME}/.dosemu/drive_c && ( 59 | 60 | mkdir -p bin 61 | 62 | # Boot files 63 | unzip -L -q ${HERE}/kernel.zip 64 | cp -p bin/kernl386.sys ./kernel.sys 65 | unzip -L -q ${HERE}/freecom.zip 66 | cp -p bin/command.com ./command.com 67 | cp -p /usr/share/dosemu/dosemu2-cmds-0.3/c/fdconfig.sys . 68 | 69 | # Development files 70 | unzip -L -q ${HERE}/djgpp_mk.zip 71 | cp -p devel/djgpp/bin/make.exe bin/. 72 | unzip -L -q ${HERE}/upx.zip 73 | cp -p devel/upx/upx.exe bin/. 74 | echo PATH to make and upx binaries is 'c:/bin' 75 | 76 | unzip -L -q ${HERE}/nasm.zip 77 | echo PATH to nasm binary is 'c:/devel/nasm' 78 | 79 | # unzip -L -q ${HERE}/i16gcc.zip 80 | # unzip -L -q ${HERE}/i16newli.zip 81 | # unzip -L -q ${HERE}/i16butil.zip 82 | # unzip -L -q ${HERE}/i16lbi86.zip 83 | # echo PATH to ia16 binaries is 'c:/devel/i16gnu/bin' 84 | 85 | unzip -L -q ${HERE}/watcomc.zip 86 | echo PATH to watcom binaries is 'c:/devel/watcomc/binw' 87 | ) 88 | -------------------------------------------------------------------------------- /ci_test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | KVER=8632 4 | 5 | if [ ! -f _output/gcc/KGC${KVER}.sys ] ; then 6 | echo GCC built kernel not present 7 | exit 1 8 | fi 9 | 10 | if [ ! -f _output/wc/KWC${KVER}.sys ] ; then 11 | echo Watcom built kernel not present 12 | exit 1 13 | fi 14 | 15 | if [ ! -f _output/wc_dos/KWC38632.sys ] ; then 16 | echo Watcom DOS built kernel not present 17 | exit 1 18 | fi 19 | 20 | if [ ! -f _output/tc_dos/KTC38632.sys ] && [ -d ${HOME}/.dosemu/drive_c/tc201 ] ; then 21 | echo Turbo C 2.01 built kernel not present 22 | exit 1 23 | fi 24 | 25 | echo Kernels have all been built 26 | find _output -ls 27 | 28 | cd test 29 | if ! ./test.sh ../_output/gcc/KGC${KVER}.sys diskgc bootgc 'boot gcc: ' 30 | then 31 | echo GCC boot test failed 32 | exit 2 33 | fi 34 | if ! ./test.sh ../_output/wc/KWC${KVER}.sys diskwc bootwc 'boot wc: ' 35 | then 36 | echo OpenWatcom boot test failed 37 | exit 2 38 | fi 39 | if ! ./test.sh ../_output/wc_dos/KWC38632.sys diskwcd bootwcd 'boot wcd: ' 40 | then 41 | echo 'OpenWatcom(DOS) boot test failed' 42 | exit 2 43 | fi 44 | if [ -d ${HOME}/.dosemu/drive_c/tc201 ] ; then 45 | if ! ./test.sh ../_output/tc_dos/KTC38632.sys disktcd boottcd 'boot tcd: ' 46 | then 47 | echo 'Turbo C 2.01 boot test failed' 48 | exit 2 49 | fi 50 | fi 51 | cd .. 52 | exit 0 53 | -------------------------------------------------------------------------------- /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 ..\setver 31 | %MAKE% clean 32 | 33 | cd ..\hdr 34 | if exist *.bak del *.bak 35 | 36 | cd .. 37 | if exist *.bak del *.bak 38 | 39 | :end 40 | default.bat clearset 41 | -------------------------------------------------------------------------------- /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 ..\setver 31 | %MAKE% clobber 32 | 33 | cd ..\hdr 34 | if exist *.bak del *.bak 35 | 36 | cd ..\bin 37 | if exist sys.com del sys.com 38 | if exist country.sys del country.sys 39 | 40 | cd .. 41 | if exist *.bak del *.bak 42 | if exist status.me del status.me 43 | 44 | 45 | :end 46 | default.bat clearset 47 | -------------------------------------------------------------------------------- /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%" == "OWWIN" set MAKE=wmake /ms /h 30 | if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake /nologo 31 | 32 | echo Make is %MAKE%. 33 | 34 | :skip_make 35 | 36 | :----------------------------------------------------------------------- 37 | 38 | if not "%XLINK%" == "" goto skip_xlink 39 | 40 | if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c 41 | if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink /m/c 42 | if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink /m/c 43 | if "%COMPILER%" == "BC3" set XLINK=%BC3_BASE%\bin\tlink /m/c 44 | if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink /m/c 45 | if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker /ma/nologo 46 | if "%COMPILER%" == "OWWIN" set XLINK=..\utils\wlinker /ma/nologo 47 | if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo 48 | 49 | echo Linker is %XLINK%. 50 | 51 | :skip_xlink 52 | 53 | :----------------------------------------------------------------------- 54 | 55 | if not "%XUPX%" == "" set UPXOPT=-U 56 | if "%XUPX%" == "" set UPXOPT= 57 | 58 | goto end 59 | 60 | :----------------------------------------------------------------------- 61 | 62 | :clearset 63 | 64 | if not "%OLDPATH%" == "" set PATH=%OLDPATH% 65 | if not "%OLDPATH%" == "" set OLDPATH= 66 | 67 | set MAKE= 68 | set COMPILER= 69 | set ALLCFLAGS= 70 | set CFLAGS= 71 | set XCPU= 72 | set XCPU_EX= 73 | set XFAT= 74 | set XLINK= 75 | set TC2_BASE= 76 | set TP1_BASE= 77 | set TC3_BASE= 78 | set BC3_BASE= 79 | set BC5_BASE= 80 | set MS_BASE= 81 | set XNASM= 82 | set NASMFLAGS= 83 | set NASMBOOTFLAGS= 84 | set XUPX= 85 | set UPXOPT= 86 | set LOADSEG= 87 | 88 | :end 89 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | kernel.fdos.org -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-tactile 2 | title: "FreeDOS kernel" 3 | description: "Implementation of the core DOS API for FreeDOS, kernel.sys" 4 | show_downloads: "true" 5 | -------------------------------------------------------------------------------- /docs/bugs.txt: -------------------------------------------------------------------------------- 1 | Please report kernel bugs / issues on GitHub at 2 | 3 | https://github.com/FDOS/kernel/issues 4 | 5 | 6 | For support (or if you don't wish to use GitHub) then 7 | please use the FreeDOS developer and/or user mailing list. 8 | 9 | The former bug database is available on the web at 10 | 11 | http://sourceforge.net/tracker/?group_id=5109&atid=105109 12 | 13 | (All bugs reported there are reviewed, but not updated!) 14 | 15 | Thanks! 16 | -------------------------------------------------------------------------------- /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: git 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://github.com/fdos/kernel 10 | Alternate-site: http://www.fdos.org/kernel/ 11 | Alternate-site: http://freedos.sourceforge.net/kernel/ 12 | Original-site: http://www.gcfl.net/pub/FreeDOS/kernel 13 | Platforms: DOS, FreeDOS, DOSEMU (OpenWatcom/Borland/GCC-ia16, NASM, UPX) 14 | Copying-policy: GPL2 15 | End 16 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | INTRODUCTION 2 | ------------ 3 | 4 | The release archives 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 https://github.com/FDOS/kernel/ 8 | (formally http://freedos.sourceforge.net/ ). 9 | It's also available from http://www.dosemu.org/ (somewhere on there). 10 | 11 | The FreeDOS Kernel is also available through the FreeDOS Project at 12 | http://www.freedos.org/ 13 | 14 | See the DOCS directory for more documentation and information about 15 | the FreeDOS Kernel. 16 | 17 | Contents of zip files: 18 | * [ke20xx_f16.zip](https://github.com/FDOS/kernel/releases/download/ke2043/ke2043_86f16.zip) : binaries for 8086, FAT12 and FAT16 only 19 | * [ke20xx_f32.zip](https://github.com/FDOS/kernel/releases/download/ke2043/ke2043_86f32.zip) : binaries for 8086, FAT12, FAT16, and FAT32 20 | * [ke20xxs.zip](https://github.com/FDOS/kernel/releases/download/ke2043/ke2043s.zip) : sources for the kernel 21 | 22 | BUG REPORTS 23 | ----------- 24 | 25 | If you have found a bug, think you have found a bug, or would just 26 | like to make a suggestion, go to the bug tracking web page at 27 | https://github.com/FDOS/kernel/issues 28 | 29 | (Previously at http://sourceforge.net/tracker/?group_id=5109&atid=105109, and 30 | even earlier archive of old (Bugzilla) items is at www.freedos.org/bugzilla/ ) 31 | 32 | 33 | Copyright 34 | --------- 35 | 36 | DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani 37 | All Rights Reserved. 38 | -------------------------------------------------------------------------------- /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.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 release 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 or feature request, then add an issue to 26 | the kernel's GitHub site: 27 | https://github.com/FDOS/kernel/issues 28 | 29 | Note: bugs (or feature requests) reported at the old bug tracking 30 | web page http://sourceforge.net/tracker/?group_id=5109&atid=105109 31 | and http://sourceforge.net/tracker/?atid=355109&group_id=5109&func=browse 32 | will still be reviewed, but not actively. 33 | 34 | An archive of old (Bugzilla) items is at www.freedos.org/bugzilla/ 35 | 36 | 37 | Copyright 38 | --------- 39 | 40 | DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani 41 | All Rights Reserved. 42 | 43 | Portions of FreeDOS kernel copyright others, 199?-2024 44 | -------------------------------------------------------------------------------- /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 {cx,dx} ; 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/dcb.h 38 | */*/hdr/ddate.h 39 | */*/hdr/device.h 40 | */*/hdr/dirmatch.h 41 | */*/hdr/dtime.h 42 | */*/hdr/error.h 43 | */*/hdr/exe.h 44 | */*/hdr/fat.h 45 | */*/hdr/fcb.h 46 | */*/hdr/file.h 47 | */*/hdr/fnode.h 48 | */*/hdr/kbd.h 49 | */*/hdr/kconfig.h 50 | */*/hdr/lol.h 51 | */*/hdr/mcb.h 52 | */*/hdr/network.h 53 | */*/hdr/nls.h 54 | */*/hdr/pcb.h 55 | */*/hdr/portab.h 56 | */*/hdr/process.h 57 | */*/hdr/sft.h 58 | */*/hdr/stacks.inc 59 | */*/hdr/tail.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/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/ddate.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* ddate.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 ddate; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /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 | dtime dm_time; /* file time */ 51 | ddate 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/dtime.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* dtime.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 dtime; 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/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 | CheckDebugger: during initialization enable/disable check to stop in debugger if one is active 32 | 0 = do not check (assume absent), 33 | 1 = do check by running breakpoint, 34 | 2 = assume present 35 | 36 | Verbose: amount of messages to display during initialization 37 | -1 = quiet 38 | 0 = normal 39 | 1 = verbose 40 | 41 | PartitionMode: how to handle GPT and MBR partitions 42 | bits 0-1: 01=GPT if found, 00=MBR if found, 11=Hybrid, GPT first then MBR, 10=Hybrid, MBR first then GPT 43 | in hybrid mode, EE partitions ignored, drives assigned by GPT or MBR first based on hybrid type 44 | bits 2-4: 001=mount ESP (usually FAT32) partition, 010=mount MS Basic partitions, 100=mount unknown partitions 45 | 111=attempt to mount all paritions, 110=attempt to mount all but ESP partitions 46 | bits 5-7: reserved, 0 else undefined behavior 47 | */ 48 | typedef struct _KernelConfig { 49 | char CONFIG[6]; /* "CONFIG" */ 50 | unsigned short ConfigSize; 51 | 52 | unsigned char DLASortByDriveNo; 53 | unsigned char InitDiskShowDriveAssignment; 54 | signed char SkipConfigSeconds; 55 | unsigned char ForceLBA; 56 | unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ 57 | signed char BootHarddiskSeconds; 58 | 59 | /* for version 2042 and higher only */ 60 | unsigned char Version_OemID; 61 | unsigned char Version_Major; 62 | unsigned short Version_Revision; 63 | unsigned short Version_Release; 64 | 65 | /* for version 2044 and higher only */ 66 | unsigned char CheckDebugger; 67 | signed char Verbose; 68 | unsigned char PartitionMode; 69 | } KernelConfig; 70 | -------------------------------------------------------------------------------- /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 | /* Defines for remote access functions */ 32 | #define REM_RMDIR 0x1101 33 | #define REM_MKDIR 0x1103 34 | #define REM_CHDIR 0x1105 35 | #define REM_CLOSE 0x1106 36 | #define REM_FLUSH 0x1107 37 | #define REM_READ 0x1108 38 | #define REM_WRITE 0x1109 39 | #define REM_LOCK 0x110a 40 | #define REM_UNLOCK 0x110b 41 | #define REM_GETSPACE 0x110c 42 | #define REM_SETATTR 0x110e 43 | #define REM_GETATTRZ 0x110f 44 | #define REM_RENAME 0x1111 45 | #define REM_DELETE 0x1113 46 | #define REM_OPEN 0x1116 47 | #define REM_CREATE 0x1117 48 | #define REM_CRTRWOCDS 0x1118 49 | #define REM_FND1WOCDS 0x1119 50 | #define REM_FINDFIRST 0x111B 51 | #define REM_FINDNEXT 0x111C 52 | #define REM_CLOSEALL 0x111d 53 | #define REM_DOREDIRECT 0x111e 54 | #define REM_PRINTSET 0x111f 55 | #define REM_FLUSHALL 0x1120 56 | #define REM_LSEEK 0x1121 57 | #define REM_PROCESS_END 0x1122 58 | #define REM_FILENAME 0x1123 59 | #define REM_PRINTREDIR 0x1125 60 | #define REM_EXTOC 0x112e 61 | 62 | /* Redirector extensions */ 63 | #define REM_GETLARGESPACE 0x11a3 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 | -------------------------------------------------------------------------------- /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/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 | #ifdef WITHFAT32 31 | #define MAJOR_RELEASE 7 32 | #define MINOR_RELEASE 10 33 | #else 34 | #define MAJOR_RELEASE 6 35 | #define MINOR_RELEASE 22 36 | #endif 37 | 38 | /* The actual kernel revision, 2000+REVISION_SEQ = 2.REVISION_SEQ */ 39 | #define REVISION_SEQ 43 /* returned in BL by int 21 function 30 */ 40 | #define OEM_ID 0xfd /* FreeDOS, returned in BH by int 21 30 */ 41 | 42 | /* Used for version information displayed to user at boot (& stored in os_release string) */ 43 | #ifndef KERNEL_VERSION 44 | #define KERNEL_VERSION "- GIT " 45 | #endif 46 | 47 | /* actual version string */ 48 | #define KVS(v,s,o) "FreeDOS kernel " v "(build 20" #s " OEM:" #o ") [compiled " __DATE__ "]\n" 49 | #define xKVS(v,s,o) KVS(v,s,o) 50 | #define KERNEL_VERSION_STRING xKVS(KERNEL_VERSION, REVISION_SEQ, OEM_ID) 51 | 52 | -------------------------------------------------------------------------------- /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 | #if defined __GNUC__ 22 | extern UWORD winseg1, winseg2, winseg3; 23 | extern UBYTE markEndInstanceData; 24 | extern struct lol FAR ASM DATASTART; 25 | #endif 26 | 27 | 28 | /* contains a list of offsets relative to DOS data segment of 29 | various internal variables. 30 | */ 31 | struct WinPatchTable 32 | { 33 | UWORD dosver; 34 | UWORD OffTempDS; 35 | UWORD OffTempBX; 36 | UWORD OffInDOS; 37 | UWORD OffMachineID; 38 | UWORD OffCritSectPatches; 39 | UWORD OffLastMCBSeg; /* used by Win 3.1 if DOS version 5 or higher */ 40 | }; 41 | extern struct WinPatchTable winPatchTable; 42 | 43 | 44 | #endif /* WIN31SUPPORT */ 45 | #endif /* __WINSUPPORT_H */ 46 | -------------------------------------------------------------------------------- /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/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 | ; NEC V20/V30 support 186 instructions but 52 | ; do not mask the shift count like a 186. 53 | ; based on https://hg.pushbx.org/ecm/ldebug/file/7f3440d5824d/source/init.asm#l3071 54 | ; which is based on http://www.textfiles.com/hamradio/v20_bug.txt 55 | mov ax, sp ; we use stack to do test 56 | mov cx, 0 ; after pop still 0 if 8088/8086 57 | push cx 58 | inc cx ; after pop still 1 if NEC V20/V30 59 | ; next instructions may lock system if breakpoint or trace flag set 60 | db 8Fh, 0C1h; pop r/m16 with operand cx on 808x, nop on NEC V20/V30 61 | mov sp, ax ; reset stack to known good state (pre push, optional pop) 62 | or cx, cx ; cx is 0 if 808x, 1 if NEC 63 | jz is808x ; if not NEC then goto test for 808x vs 8018x 64 | mov bx, cx ; treat NEC V20/V30 as 8018x, i.e. return 1 65 | jmp short cleanup 66 | is808x: 67 | mov ax,1 ; determine if 8086 or 186 68 | mov cl,64 ; try to shift further than size of ax 69 | shr ax,cl 70 | or ax,ax 71 | jz is086 ; 186 ignores the upper bits of cl 72 | mov bx, 1 ; 186: above 808x, below 286 73 | is086: jmp short cleanup 74 | is286: mov bx, 2 ; at least 286 75 | mov ax, 0f000h 76 | push ax 77 | popf ; try to set 4 msb of flags 78 | pushf ; copy flags to ax so we can test if clear succeeded 79 | pop ax 80 | test ax, 0f000h 81 | jz cleanup ; 4 msb stuck to 0: 80286 82 | mov bx, 3 ; at least 386 83 | 84 | cleanup: 85 | mov ax, bx ; return CPU family 86 | popf 87 | pop cx 88 | pop bx 89 | retn 90 | 91 | -------------------------------------------------------------------------------- /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 | void far *DynAlloc(char *what, unsigned num, unsigned size); 13 | void far *DynLast(void); 14 | void DynFree(void *ptr); 15 | 16 | struct DynS { 17 | unsigned Allocated; 18 | char Buffer[1]; 19 | }; 20 | -------------------------------------------------------------------------------- /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 "dyndata.h" 41 | 42 | #if defined(DEBUG) 43 | #define DebugPrintf(x) printf x 44 | #else 45 | #define DebugPrintf(x) 46 | #endif 47 | 48 | /*extern struct DynS FAR Dyn;*/ 49 | 50 | #ifndef __TURBOC__ 51 | extern struct DynS DOSFAR ASM Dyn; 52 | #else 53 | extern struct DynS FAR ASM Dyn; 54 | #endif 55 | 56 | void far *DynAlloc(char *what, unsigned num, unsigned size) 57 | { 58 | void far *now; 59 | unsigned total = num * size; 60 | struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); 61 | 62 | #ifndef DEBUG 63 | UNREFERENCED_PARAMETER(what); 64 | #endif 65 | 66 | if ((ULONG) total + Dynp->Allocated > 0xffff) 67 | { 68 | printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated); 69 | for (;;) ; 70 | } 71 | 72 | DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", 73 | what, num, size, total, Dynp->Allocated, 74 | Dynp->Allocated + total)); 75 | 76 | now = (void far *)&Dynp->Buffer[Dynp->Allocated]; 77 | fmemset(now, 0, total); 78 | 79 | Dynp->Allocated += total; 80 | 81 | return now; 82 | } 83 | 84 | void DynFree(void *ptr) 85 | { 86 | struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); 87 | Dynp->Allocated = (char *)ptr - (char *)Dynp->Buffer; 88 | } 89 | 90 | void FAR * DynLast() 91 | { 92 | struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); 93 | DebugPrintf(("dynamic data end at %p\n", 94 | (void FAR *)(Dynp->Buffer + Dynp->Allocated))); 95 | 96 | return Dynp->Buffer + Dynp->Allocated; 97 | } 98 | -------------------------------------------------------------------------------- /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 | #include "globals.h" 31 | #include "debug.h" 32 | 33 | 34 | #ifdef DEBUG 35 | /* error registers */ 36 | VOID dump(void) 37 | { 38 | DebugPrintf(("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n", 39 | error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS)); 40 | DebugPrintf(("AX:%04x BX:%04x CX:%04x DX:%04x\n", 41 | error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX)); 42 | DebugPrintf(("SI:%04x DI:%04x DS:%04x ES:%04x\n", 43 | error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES)); 44 | } 45 | #endif 46 | 47 | /* issue a panic message for corrupted data structures */ 48 | VOID panic(BYTE * s) 49 | { 50 | put_string("\nPANIC: "); 51 | put_string(s); 52 | put_string("\nSystem halted"); 53 | for (;;) ; 54 | } 55 | 56 | #ifdef IPL 57 | /* issue an internal error message */ 58 | VOID fatal(BYTE * err_msg) 59 | { 60 | printf("\nInternal IPL error - %s\nSystem halted\n", err_msg); 61 | exit(-1); 62 | } 63 | #else 64 | /* issue an internal error message */ 65 | #if 0 66 | VOID fatal(BYTE * err_msg) 67 | { 68 | printf("\nInternal kernel error - \n"); 69 | panic(err_msg); 70 | } 71 | #endif 72 | #endif 73 | 74 | /* Abort, retry or fail for character devices */ 75 | COUNT char_error(request * rq, struct dhdr FAR * lpDevice) 76 | { 77 | CritErrCode = (rq->r_status & S_MASK) + 0x13; 78 | return CriticalError(EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, 79 | 0, rq->r_status & S_MASK, lpDevice); 80 | } 81 | 82 | /* Abort, retry or fail for block devices */ 83 | COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice, 84 | int mode) 85 | { 86 | CritErrCode = (rq->r_status & S_MASK) + 0x13; 87 | return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE | 88 | (mode == DSKWRITE ? EFLG_WRITE : 0), 89 | nDrive, rq->r_status & S_MASK, lpDevice); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /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/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/network.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* network.c */ 4 | /* DOS-C */ 5 | /* */ 6 | /* Networking Support functions */ 7 | /* */ 8 | /* Copyright (c) 1995, 1999 */ 9 | /* James Tabor */ 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 | 33 | #ifdef VERSION_STRINGS 34 | static BYTE *RcsId = 35 | "$Id: network.c 895 2004-04-21 17:40:12Z bartoldeman $"; 36 | #endif 37 | 38 | /* see RBIL D-2152 and D-215D06 before attempting 39 | to change these two functions! 40 | */ 41 | UWORD get_machine_name(BYTE FAR * netname) 42 | { 43 | fmemcpy(netname, &net_name, 16); 44 | return (NetBios); 45 | } 46 | 47 | VOID set_machine_name(BYTE FAR * netname, UWORD name_num) 48 | { 49 | NetBios = name_num; 50 | fmemcpy(&net_name, netname, 15); 51 | net_set_count++; 52 | } 53 | 54 | int network_redirector_fp(unsigned cmd, void far *s) 55 | { 56 | return (int)network_redirector_mx(cmd, s, 0); 57 | } 58 | 59 | int network_redirector(unsigned cmd) 60 | { 61 | return network_redirector_fp(cmd, NULL); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /kernel/nls/001-437.unf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/kernel/nls/001-437.unf -------------------------------------------------------------------------------- /kernel/nls/001-437.up: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/kernel/nls/001-437.up -------------------------------------------------------------------------------- /kernel/nls/049-850.unf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/kernel/nls/049-850.unf -------------------------------------------------------------------------------- /kernel/nls/049-850.up: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/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/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/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 | -------------------------------------------------------------------------------- /mkfiles/bc3.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/mkfiles/bc3.mak -------------------------------------------------------------------------------- /mkfiles/bc5.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/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 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 --redefine-sym _printf=_init_printf --redefine-sym _sprintf=_init_sprintf --redefine-sym _execrh=_init_execrh --redefine-sym _memcpy=_init_memcpy --redefine-sym _fmemcpy=_init_fmemcpy --redefine-sym _fmemset=_init_fmemset --redefine-sym _fmemcmp=_init_fmemcmp --redefine-sym _memcmp=_init_memcmp --redefine-sym _memset=_init_memset --redefine-sym _strchr=_init_strchr --redefine-sym _strcpy=_init_strcpy --redefine-sym _fstrcpy=_init_fstrcpy --redefine-sym _strlen=_init_strlen --redefine-sym _fstrlen=_init_fstrlen --redefine-sym _open=_init_DosOpen 72 | CLDEF=1 73 | CLT=gcc -Wall -I../hdr -o $@ 74 | CLC=$(CLT) 75 | LINK=$(XLINK) -Tkernel.ld -nostdlib -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) -o $@ $< 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 | CC=$(CC) -fo=.obj 10 | CL=$(CL) -fo=.obj 11 | INCLUDEPATH=$(COMPILERPATH)/h 12 | RM=rm -f 13 | CP=cp 14 | ECHOTO=echo>> 15 | INITPATCH=@echo > /dev/null 16 | CLDEF=1 17 | CLT=wcl386 -zq -fo=.obj -bcl=linux -I../hdr -fe=$@ -I$(COMPILERPATH)/lh 18 | CLC=$(CLT) 19 | XLINK=$(XLINK) debug all format dos opt quiet,symfile,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)\h 11 | #RM=del 2>nul 12 | #CP=copy 13 | #ECHOTO=echo>> 14 | #INITPATCH=@echo > nul 15 | CLDEF=1 16 | CLT=wcl386 -zq -bcl=nt -I..\hdr -fe=$@ -I$(COMPILERPATH)\h -I$(COMPILERPATH)\h\nt 17 | CLC=$(CLT) 18 | NASMFLAGS=-DWATCOM $(NASMFLAGS) 19 | #linker arguments are passed via response file, so don't modify XLINK 20 | #XLINK=$(XLINK) debug all format dos opt quiet,symfile,map,statics,verbose F { $(OBJS) } L ..$(DIRSEP)lib$(DIRSEP)device.lib N kernel.exe $# 21 | -------------------------------------------------------------------------------- /mkfiles/tc2.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/mkfiles/tc2.mak -------------------------------------------------------------------------------- /mkfiles/tc3.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/mkfiles/tc3.mak -------------------------------------------------------------------------------- /mkfiles/turbocpp.mak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/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 -zq 8 | CL=wcl -zq 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=-zp1-os-s-we-e3-wx-bt=DOS 26 | CFLAGSC=-mc-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= 38 | MATH_INSERT= 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) -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 | -------------------------------------------------------------------------------- /setver/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for setver.sys 3 | # 4 | 5 | !include "../mkfiles/generic.mak" 6 | 7 | 8 | production: setver.sys 9 | 10 | setver.sys: setver.asm 11 | $(NASM) -o ..$(DIRSEP)bin$(DIRSEP)setver.sys setver.asm 12 | 13 | clobber: clean 14 | 15 | clean: 16 | -$(RM) *.obj *.map *.lst *.err 17 | 18 | -------------------------------------------------------------------------------- /setver/setver.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Initially written by Ricardo Hanke 3 | ; Released under the terms of the GNU General Public License. 4 | ; See the file 'COPYING' in the main directory for details. 5 | ; 6 | ; This driver loads the list of special programs into memory. 7 | ; 8 | 9 | section .text 10 | 11 | 12 | COMMAND equ 2 13 | STATUS equ 3 14 | DRIVEREND equ 14 15 | 16 | FAKETABLE equ 37h 17 | 18 | 19 | header dw -1, -1 20 | dw 1000000000000000b 21 | dw strategy 22 | dw interrupt 23 | db "SETVERXX" 24 | 25 | dw signature 26 | 27 | paramblock dd 0 28 | 29 | 30 | strategy: mov [cs:paramblock + 0], bx 31 | mov [cs:paramblock + 2], es 32 | retf 33 | 34 | 35 | interrupt: push ax 36 | push bx 37 | push di 38 | push es 39 | pushf 40 | 41 | les di, [paramblock] 42 | mov bl, [es:di + COMMAND] 43 | cmp bl, 0 44 | jne error 45 | 46 | mov ax, table 47 | add ax, [length] 48 | 49 | mov word [es:di + DRIVEREND + 0], ax 50 | mov word [es:di + DRIVEREND + 2], cs 51 | 52 | mov ah, 52h 53 | int 21h 54 | 55 | mov word [es:bx + FAKETABLE + 0], table 56 | mov word [es:bx + FAKETABLE + 2], cs 57 | 58 | xor ax, ax 59 | jmp exit 60 | 61 | error: mov ax, 8003h 62 | 63 | exit: or ax, 0100h 64 | mov [es:di + STATUS], ax 65 | 66 | popf 67 | pop es 68 | pop di 69 | pop bx 70 | pop ax 71 | 72 | retf 73 | 74 | 75 | signature db 'SDIR' 76 | length dw 1 77 | 78 | table: 79 | ;db 11, "SHOWVER.EXE", 5, 00 80 | ;db 12, "BUGGYPRG.EXE", 3, 31 81 | 82 | db 0 83 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/bootimg/a.asm: -------------------------------------------------------------------------------- 1 | 2 | %if 0 3 | 4 | Create test data in NASM 5 | 2022, by C. Masloch 6 | 7 | Usage of the works is permitted provided that this 8 | instrument is retained with the works, so that any entity 9 | that uses the works is notified of this instrument. 10 | 11 | DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 12 | 13 | %endif 14 | 15 | 16 | %ifndef SIZE 17 | %define SIZE 512*16 18 | %endif 19 | %ifndef CONTENT 20 | %define CONTENT "a" 21 | %endif 22 | 23 | times SIZE db CONTENT 24 | -------------------------------------------------------------------------------- /test/cfg.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Usage of the works is permitted provided that this 4 | # instrument is retained with the works, so that any entity 5 | # that uses the works is notified of this instrument. 6 | # 7 | # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 8 | 9 | # If you want to override configuration without the 10 | # hassle of having to exclude differences in this file 11 | # (cfg.sh) from the SCM, you may provide ovr.sh. 12 | # The meaning of this line allows you to copy cfg.sh 13 | # to serve as a template for ovr.sh without changes. 14 | [ -f ovr.sh ] && [[ "${BASH_SOURCE[0]##*/}" != ovr.sh ]] && . ovr.sh 15 | 16 | # As the below only are set if no value is provided 17 | # yet, any value can be overridden from the shell. 18 | [ -z "$LMACROS_DIR" ] && LMACROS_DIR=lmacros/ 19 | [ -z "$LDOSBOOT_DIR" ] && LDOSBOOT_DIR=ldosboot/ 20 | [ -z "$BOOTIMG_DIR" ] && BOOTIMG_DIR=bootimg/ 21 | 22 | [ -z "$QEMU" ] && QEMU=qemu-system-i386 23 | [ -z "$NASM" ] && NASM=nasm 24 | -------------------------------------------------------------------------------- /test/ldosboot/doc/mak.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Usage of the works is permitted provided that this 4 | # instrument is retained with the works, so that any entity 5 | # that uses the works is notified of this instrument. 6 | # 7 | # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 8 | 9 | echo -ne "\\U Source Control Revision ID\n\nhg $(hg id -i), from commit on at $(hg log -r . --template="{date|isodatesec}\n")\n\nIf this is in ecm's repository, you can find it at \\W{https://hg.pushbx.org/ecm/ldosboot/rev/$(hg log -r . --template "{node|short}")}{https://hg.pushbx.org/ecm/ldosboot/rev/$(hg log -r . --template "{node|short}")}\n" > screvid.src 10 | halibut --precise ldosboot.src screvid.src --html --text --pdf 11 | -------------------------------------------------------------------------------- /test/ldosboot/kernshim.asm: -------------------------------------------------------------------------------- 1 | 2 | %if 0 3 | 4 | FreeDOS kernel executable MZ header shim 5 | by C. Masloch, 2022 6 | 7 | Usage of the works is permitted provided that this 8 | instrument is retained with the works, so that any entity 9 | that uses the works is notified of this instrument. 10 | 11 | DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 12 | 13 | %endif 14 | 15 | %include "lmacros2.mac" 16 | 17 | defaulting 18 | 19 | strdef FILE, "" 20 | %ifidn _FILE,"" 21 | %fatal Has to specify a file! 22 | %endif 23 | 24 | 25 | org 0 26 | header: 27 | db "MZ" ; exeSignature 28 | dw (payload.end - $$) % 512 ; exeExtraBytes 29 | dw (payload.end - $$ + 511) / 512 ; exePages 30 | dw 0 ; exeRelocItems 31 | dw (payload -$$+0) >> 4 ; exeHeaderSize 32 | dw 0 ; exeMinAlloc 33 | dw -1 ; exeMaxAlloc 34 | dw (payload.end + 15 - payload) / 16 ; exeInitSS 35 | dw 512 ; exeInitSP 36 | dw 0 ; exeChecksum 37 | dw 0, 0 ; exeInitCSIP 38 | dw 0 ; exeRelocTable 39 | endarea header 40 | 41 | 42 | align 16, db 0 43 | payload: 44 | jmp strict short entry 45 | db "CONFIG" 46 | dw 1 47 | db -1 48 | 49 | times 32 - ($ - payload) db 0 50 | entry: equ $ 51 | jmp entry_common 52 | 53 | times 0xC0 - ($ - payload) nop 54 | entry_common: equ $ 55 | 56 | incbin _FILE 57 | .actual_end: 58 | .end: 59 | -------------------------------------------------------------------------------- /test/ldosboot/test/cfg.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Usage of the works is permitted provided that this 4 | # instrument is retained with the works, so that any entity 5 | # that uses the works is notified of this instrument. 6 | # 7 | # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 8 | 9 | # If you want to override configuration without the 10 | # hassle of having to exclude differences in this file 11 | # (cfg.sh) from the SCM, you may provide ovr.sh. 12 | # The meaning of this line allows you to copy cfg.sh 13 | # to serve as a template for ovr.sh without changes. 14 | [ -f ovr.sh ] && [[ "${BASH_SOURCE[0]##*/}" != ovr.sh ]] && . ovr.sh 15 | 16 | # As the below only are set if no value is provided 17 | # yet, any value can be overridden from the shell. 18 | [ -z "$LMACROS_DIR" ] && LMACROS_DIR=../../lmacros/ 19 | [ -z "$LDOSBOOT_DIR" ] && LDOSBOOT_DIR=../ 20 | [ -z "$SCANPTAB_DIR" ] && SCANPTAB_DIR=../../scanptab/ 21 | [ -z "$INICHECK_DIR" ] && INICHECK_DIR=../../crc16-t/ 22 | [ -z "$BOOTIMG_DIR" ] && BOOTIMG_DIR=../../bootimg/ 23 | [ -z "$LDEBUG_DIR" ] && LDEBUG_DIR=../../ldebug/bin/ 24 | [ -z "$LDOSMBR_DIR" ] && LDOSMBR_DIR=../../ldosmbr/ 25 | [ -z "$INSTSECT_DIR" ] && INSTSECT_DIR=../../instsect/ 26 | 27 | [ -z "$DOSEMU" ] && DOSEMU=dosemu 28 | [ -z "$QEMU" ] && QEMU=qemu-system-i386 29 | [ -z "$DEFAULT_MACHINE" ] && DEFAULT_MACHINE=dosemu 30 | [ -z "$SENDKEYS" ] && SENDKEYS=sendkeys 31 | [ -z "$BOOT_KERNEL" ] && BOOT_KERNEL=~/.dosemu/drive_c/kernel.sys 32 | [ -z "$BOOT_COMMAND" ] && BOOT_COMMAND=~/.dosemu/drive_c/command.com 33 | [ -z "$BOOT_PROTOCOL" ] && BOOT_PROTOCOL=FREEDOS 34 | [ -z "$BOOT_OPTIONS" ] && BOOT_OPTIONS=" " 35 | [ -z "$MKTMPINC" ] && MKTMPINC=mktmpinc.pl 36 | [ -z "$NASM" ] && NASM=nasm 37 | [ -z "$CHECKSUM" ] && CHECKSUM="${INICHECK_DIR%/}"/iniload/checksum 38 | 39 | [ -z "$use_build_inicheck" ] && use_build_inicheck=0 40 | -------------------------------------------------------------------------------- /test/ldosboot/test/quit.asm: -------------------------------------------------------------------------------- 1 | 2 | %if 0 3 | 4 | Shut down machine 5 | by C. Masloch, 2020 6 | 7 | Usage of the works is permitted provided that this 8 | instrument is retained with the works, so that any entity 9 | that uses the works is notified of this instrument. 10 | 11 | DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 12 | 13 | %endif 14 | 15 | 16 | cpu 8086 17 | org 256 18 | quit: 19 | int3 20 | 21 | mov ax, 0F000h 22 | mov es, ax 23 | mov di, 0FFF5h 24 | mov si, msg.dosemudate 25 | mov cx, 4 26 | repe cmpsw ; running in DosEmu? 27 | jne .quit_not_dosemu 28 | 29 | xor bx, bx 30 | mov ax, -1 31 | int 0E6h ; dosemu quit 32 | 33 | .quit_not_dosemu: 34 | 35 | ; from https://stackoverflow.com/a/5240330/738287 36 | mov ax, 5301h 37 | xor bx, bx 38 | int 15h ; connect to APM API 39 | 40 | mov ax, 530Eh 41 | xor bx, bx 42 | mov cx, 0102h 43 | int 15h ; set APM version to 1.02 44 | 45 | mov ax, 5307h 46 | mov bx, 1 47 | mov cx, 3 48 | int 15h ; shut down system 49 | 50 | mov dx, msg.failed 51 | mov ah, 09h 52 | int 21h 53 | mov ax, 4C00h 54 | int 21h 55 | 56 | 57 | align 4 58 | msg: 59 | .dosemudate: db "02/25/93" 60 | .failed: db "Quit failed.",13,10,36 61 | -------------------------------------------------------------------------------- /test/ldosboot/test/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Usage of the works is permitted provided that this 4 | # instrument is retained with the works, so that any entity 5 | # that uses the works is notified of this instrument. 6 | # 7 | # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 8 | 9 | testrunname="fat12 default: " \ 10 | ./test.sh diskette 11 | testrunname="fat12 direct: " \ 12 | ./test.sh diskette direct 13 | testrunname="fat12 hdimage: " \ 14 | ./test.sh hdimage 15 | testrunname="fat12 16spc 20MiB: " \ 16 | ./test.sh hdimage aligndata bpe 12 spc 16 mib 20 nr 512 17 | testrunname="fat16 4spc 32MiB: " \ 18 | ./test.sh hdimage aligndata bpe 16 spc 4 mib 32 nr 512 19 | testrunname="fat32 1spc 34MiB: " \ 20 | ./test.sh hdimage aligndata bpe 32 spc 1 mib 34 21 | -------------------------------------------------------------------------------- /test/lmacros/lmacros3.mac: -------------------------------------------------------------------------------- 1 | [list -] 2 | %if 0 3 | 4 | Extensions to NASM macro collection 5 | Public Domain by C. Masloch, 2019 6 | Intended for 86 Mode programs. 7 | 8 | %endif 9 | 10 | %ifndef __lMACROS3_MAC__ 11 | %assign __lMACROS3_MAC__ 1 12 | 13 | %include "lmacros2.mac" 14 | [list -] 15 | 16 | 17 | ; This macro is used to generate byte or word access to specific 18 | ; bits of a dword variable. 19 | ; %1 = token: if "~", bit value will be negated after checking 20 | ; %2 = instruction 21 | ; %3 = variable, in the form "[address]" without size specification 22 | ; %4 = bit value(s) to access 23 | ; %5 = bool: disable word access warning, defaults to 0 24 | ; If the value in %4 has bits set in different bytes so that 25 | ; a single 8- or 16-bit instruction cannot access all the bits, 26 | ; an error is displayed. This insures that the macro only has 27 | ; to generate one instruction, as a 32-bit access on 16-bit 28 | ; CPUs requires multiple instructions. This workaround code 29 | ; needs to be written specifically then, or the flags have to 30 | ; be re-ordered to allow the access. 31 | %macro _opt 4-5.nolist 0 32 | %push 33 | %defstr %$adr %3 34 | %strlen %$len %$adr 35 | %substr %$tf %$adr 1 36 | %substr %$tb %$adr %$len 37 | %substr %$adr %$adr 2,-2 38 | %deftok %$adr %$adr 39 | %%num: equ %4 40 | %assign %$num %%num 41 | %ifnidn %$tf,"[" 42 | %error Invalid memory access syntax 43 | %elifnidn %$tb,"]" 44 | %error Invalid memory access syntax 45 | %elifn %$num 46 | %error Bit value is zero! Check code. 47 | %elifn (%$num) & ~0FFh 48 | %2 byte [%$adr], %1(%$num) 49 | %elifn (%$num) & ~0FF00h 50 | %2 byte [%$adr+1], %1((%$num)>>8) 51 | %elifn (%$num) & ~0FF0000h 52 | %2 byte [%$adr+2], %1((%$num)>>16) 53 | %elifn (%$num) & ~0FF000000h 54 | %2 byte [%$adr+3], %1((%$num)>>24) 55 | %elifn (%$num) & ~0FFFFh 56 | %ifn %5 57 | %warning Macro generated word access 58 | %endif 59 | %2 word [%$adr], %1(%$num) 60 | %elifn (%$num) & ~0FFFF00h 61 | %ifn %5 62 | %warning Macro generated word access 63 | %endif 64 | %2 word [%$adr+1], %1((%$num)>>8) 65 | %elifn (%$num) & ~0FFFF0000h 66 | %ifn %5 67 | %warning Macro generated word access 68 | %endif 69 | %2 word [%$adr+2], %1((%$num)>>16) 70 | %else 71 | %error Unsupported macro usage, requires dword: 72 | %ifempty %1 73 | %error %2 dword [%$adr], %$num 74 | %else 75 | %error %2 dword [%$adr], %1(%$num) 76 | %endif 77 | %endif 78 | %pop 79 | %endmacro 80 | 81 | ; User forms for above macro. 82 | ; %1 = variable, in the form "[address]" without size specification 83 | ; %2 = bit value(s) to access 84 | ; %3 = bool: disable word access warning, defaults to 0 85 | ; testopt tests the specified bits (using a "test" instruction) and 86 | ; leaves a meaningful result in ZF, as well as NC. 87 | ; clropt clears the specified bits (using an "and" instruction with 88 | ; the negated value) and leaves NC, but a random ZF. 89 | ; setopt sets the specified bits (using an "or" instruction) and 90 | ; leaves NC, NZ. 91 | ; xoropt toggles the specified bits (using a "xor" instruction) and 92 | ; leaves NC, but a random ZF. 93 | %idefine testopt _opt ,test, 94 | %idefine clropt _opt ~,and, 95 | %idefine setopt _opt ,or, 96 | %idefine xoropt _opt ,xor, 97 | 98 | 99 | %imacro addsection 1-2.nolist 100 | %ifdef _SECTION_ADDED_%1 101 | %error Section %1 already added 102 | %endif 103 | section %1 %2 104 | %define _SECTION_ADDED_%1 1 105 | usesection %1 106 | %endmacro 107 | 108 | %imacro usesection 1-2.nolist 0 109 | %ifndef _SECTION_ADDED_%1 110 | %error Section %1 not yet added 111 | %endif 112 | %if %2 113 | %define _CURRENT_SECTION 114 | [section %1] 115 | %else 116 | %xdefine _CURRENT_SECTION %1 117 | section %1 118 | %endif 119 | %endmacro 120 | 121 | 122 | %macro subcpu 1.nolist 123 | %push SUBCPU 124 | %xdefine %$CPU_PREV __CPU__ 125 | cpu %1 126 | %endmacro 127 | 128 | %macro subcpureset 0.nolist 129 | %ifnctx SUBCPU 130 | %error Wrong context 131 | %endif 132 | %xdefine __CPU__ %$CPU_PREV 133 | %pop 134 | __CPU__ 135 | %endmacro 136 | 137 | 138 | %endif 139 | [list +] 140 | -------------------------------------------------------------------------------- /test/lmacros/tests/000.asm: -------------------------------------------------------------------------------- 1 | 2 | %assign _@@_check 2 3 | %assign _@@_start 0 4 | %include "lmacros2.mac" 5 | 6 | %ifdef _MAP 7 | [map symbols brief _MAP] 8 | %endif 9 | 10 | cpu 8086 11 | org 256 12 | sectalign off 13 | section lCode start=256 align=1 14 | 15 | start: @S 16 | jmp @F 17 | nop 18 | nop 19 | @@: 20 | 21 | ;%fatal 1>@F1< 2>@F2< 3>@F3< 4>@F4< 22 | jz @F 23 | nop 24 | nop 25 | @@: 26 | 27 | jnz @F 28 | nop 29 | nop 30 | @@: 31 | 32 | call @F 33 | nop 34 | @@: 35 | 36 | exit: 37 | mov ax, 4C00h 38 | int 21h 39 | align 16 40 | 41 | second: @S 0 42 | jmp @F 43 | nop 44 | nop 45 | @@: 46 | 47 | ;%fatal 1>@F1< 2>@F2< 3>@F3< 4>@F4< 48 | jz @F 49 | nop 50 | nop 51 | @@: 52 | 53 | jnz @F 54 | nop 55 | nop 56 | @@: 57 | 58 | call @F 59 | nop 60 | @@: 61 | jmp exit 62 | align 16 63 | 64 | jmp @B 65 | jmp @BB 66 | jmp @B3 67 | jmp @B4 68 | 69 | -------------------------------------------------------------------------------- /test/lmacros/tests/001.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun1 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun1: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | lvar word, quux 29 | push ax 30 | 31 | lleave 32 | lret 33 | -------------------------------------------------------------------------------- /test/lmacros/tests/002.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | push ax 18 | call fun2 19 | 20 | mov ax, 4C00h 21 | int 21h 22 | %endif 23 | 24 | fun2: 25 | lframe near 26 | lpar word, alpha 27 | lvar word, foo 28 | lvar word, bar 29 | lenter 30 | lvar word, quux 31 | push ax 32 | 33 | mov word [bp + ?foo], 0F00h 34 | mov dx, word [bp + ?alpha] 35 | 36 | lleave 37 | lret 38 | -------------------------------------------------------------------------------- /test/lmacros/tests/003.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | push bx 18 | push cx 19 | call fun3 20 | pop bx 21 | 22 | mov ax, 4C00h 23 | int 21h 24 | %endif 25 | 26 | fun3: 27 | lframe near 28 | lpar word, beta 29 | lpar_return 30 | lpar word, alpha 31 | lvar word, foo 32 | lvar word, bar 33 | lenter 34 | lvar word, quux 35 | push ax 36 | 37 | mov word [bp + ?beta], 0BE7Ah 38 | 39 | lleave 40 | lret 41 | -------------------------------------------------------------------------------- /test/lmacros/tests/004.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun4 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun4: 24 | lframe near 25 | lenter early 26 | lvar word, foo 27 | push bx 28 | lvar word, bar 29 | lenter 30 | lvar word, quux 31 | push ax 32 | 33 | lleave 34 | lret 35 | -------------------------------------------------------------------------------- /test/lmacros/tests/005.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun5 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun5: 24 | lframe near 25 | lenter 26 | lvar word, foo 27 | push bx 28 | lvar word, bar 29 | lreserve 30 | lvar word, quux 31 | push ax 32 | 33 | lleave 34 | lret 35 | -------------------------------------------------------------------------------- /test/lmacros/tests/006.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun6 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun6: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | 29 | mov word [bp + ?foo], ax 30 | 31 | lframe 0, nested 32 | lvar word, qux 33 | lvar word, foo 34 | lenter 35 | 36 | mov word [bp + ?foo], bx 37 | 38 | lleave 39 | 40 | mov ax, word [bp + ?foo] 41 | 42 | lleave 43 | lret 44 | -------------------------------------------------------------------------------- /test/lmacros/tests/007.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun7 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun7: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | 29 | mov word [bp + ?foo], ax 30 | 31 | lframe 0, inner 32 | lvar word, qux 33 | lvar word, foo 34 | lenter 35 | 36 | mov word [bp + ?foo], bx 37 | mov ax, word [bp + ?bar] 38 | 39 | lleave 40 | 41 | mov ax, word [bp + ?foo] 42 | 43 | lleave 44 | lret 45 | -------------------------------------------------------------------------------- /test/lmacros/tests/008.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun8 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun8: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | 29 | mov word [bp + ?foo], ax 30 | 31 | push cs 32 | push si 33 | 34 | lframe 0, inner 35 | lpar word, segment 36 | lpar word, offset 37 | lvar word, qux 38 | lvar word, foo 39 | lenter 40 | 41 | mov word [bp + ?foo], bx 42 | mov ax, word [bp + ?bar] 43 | mov bx, word [bp + ?segment] 44 | mov dx, word [bp + ?offset] 45 | 46 | lleave 47 | 48 | mov ax, word [bp + ?foo] 49 | 50 | lleave 51 | lret 52 | -------------------------------------------------------------------------------- /test/lmacros/tests/009.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun9 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun9: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | 29 | mov word [bp + ?foo], ax 30 | 31 | push cs 32 | push si 33 | 34 | lframe 0, inner 35 | lpar word, segment 36 | lpar word, offset 37 | lvar word, qux 38 | lvar word, foo 39 | lvar word, xyzzy 40 | lenter 41 | 42 | mov word [bp + ?foo], bx 43 | mov ax, word [bp + ?bar] 44 | mov bx, word [bp + ?segment] 45 | mov dx, word [bp + ?offset] 46 | 47 | lleave 48 | 49 | mov ax, word [bp + ?foo] 50 | 51 | lleave 52 | lret 53 | -------------------------------------------------------------------------------- /test/lmacros/tests/010.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun10 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun10: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | 29 | mov word [bp + ?foo], ax 30 | 31 | push cs 32 | push si 33 | 34 | lframe 0, inner 35 | lpar word, segment 36 | lpar word, offset 37 | lenter 38 | 39 | mov word [bp + ?foo], bx 40 | mov ax, word [bp + ?bar] 41 | mov bx, word [bp + ?segment] 42 | mov dx, word [bp + ?offset] 43 | 44 | lleave 45 | 46 | mov ax, word [bp + ?foo] 47 | 48 | lleave 49 | lret 50 | -------------------------------------------------------------------------------- /test/lmacros/tests/011.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun11 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun11: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | 29 | mov word [bp + ?foo], ax 30 | 31 | push cs 32 | push si 33 | 34 | lframe 0, inner 35 | lpar word, segment 36 | lpar_return 37 | lpar word, offset 38 | lenter 39 | 40 | mov word [bp + ?foo], bx 41 | mov ax, word [bp + ?bar] 42 | mov bx, word [bp + ?segment] 43 | mov dx, word [bp + ?offset] 44 | 45 | lleave 46 | 47 | mov ax, word [bp + ?foo] 48 | 49 | lleave 50 | lret 51 | -------------------------------------------------------------------------------- /test/lmacros/tests/012.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun12 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun12: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | lvar word, baz 29 | push bx 30 | 31 | mov word [bp + ?foo], ax 32 | 33 | lframe 0, inner 34 | lvar word, quux 35 | lvar word, foo 36 | lenter 37 | 38 | mov word [bp + ?foo], bx 39 | mov ax, word [bp + ?bar] 40 | mov bx, word [bp + ?quux] 41 | mov dx, word [bp + ?baz] 42 | 43 | lleave 44 | 45 | mov ax, word [bp + ?foo] 46 | 47 | lleave 48 | lret 49 | -------------------------------------------------------------------------------- /test/lmacros/tests/013.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun13 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun13: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | lvar word, baz 29 | push bx 30 | 31 | mov word [bp + ?foo], ax 32 | 33 | lframe 0, inner 34 | lenter 35 | lvar word, quux 36 | lvar word, foo 37 | lreserve 38 | 39 | mov word [bp + ?foo], bx 40 | mov ax, word [bp + ?bar] 41 | mov bx, word [bp + ?quux] 42 | mov dx, word [bp + ?baz] 43 | 44 | lleave 45 | 46 | mov ax, word [bp + ?foo] 47 | 48 | lleave 49 | lret 50 | -------------------------------------------------------------------------------- /test/lmacros/tests/014.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun14 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun14: 24 | lframe near 25 | lvar word, foo 26 | lvar word, bar 27 | lenter 28 | lvar word, baz 29 | push bx 30 | 31 | mov word [bp + ?foo], ax 32 | 33 | push cs 34 | push si 35 | lframe 0, inner 36 | lpar word, alpha 37 | lpar word, beta 38 | lpar_return 39 | lenter 40 | lvar word, quux 41 | lvar word, foo 42 | lreserve 43 | 44 | mov word [bp + ?foo], bx 45 | mov ax, word [bp + ?bar] 46 | mov bx, word [bp + ?quux] 47 | mov dx, word [bp + ?baz] 48 | mov si, word [bp + ?beta] 49 | inc word [bp + ?alpha] 50 | 51 | lleave 52 | 53 | mov ax, word [bp + ?foo] 54 | 55 | lleave 56 | lret 57 | -------------------------------------------------------------------------------- /test/lmacros/tests/015.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | push ax 18 | call fun15 19 | 20 | mov ax, 4C00h 21 | int 21h 22 | %endif 23 | 24 | fun15: 25 | .1: 26 | lframe near 27 | lpar word, alpha 28 | lvar word, foo 29 | lvar word, bar 30 | lenter 31 | lvar word, baz 32 | push bx 33 | jmp .common 34 | 35 | .2: 36 | %ifdef FAIL3 37 | bits 32 38 | %endif 39 | %ifdef FAIL4 40 | lframe far, nested 41 | %else 42 | lframe near, nested 43 | %endif 44 | lpar word, alpha 45 | %ifdef FAIL2 46 | lpar_return 47 | %endif 48 | lvar word, foo 49 | %ifdef FAIL5 50 | lvar word, foobar 51 | %else 52 | lvar word, bar 53 | %endif 54 | %ifdef FAIL1 55 | lvar word, quux 56 | %endif 57 | lenter 58 | lvar word, baz 59 | push bx 60 | 61 | ldup 62 | 63 | lleave ctx 64 | 65 | .common: 66 | mov dx, word [bp + ?alpha] 67 | mov word [bp + ?foo], ax 68 | 69 | lleave 70 | lret 71 | -------------------------------------------------------------------------------- /test/lmacros/tests/016.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | xor ax, ax 18 | push ax 19 | call fun16 20 | mov ax, 1 21 | push bx 22 | call fun16 23 | 24 | mov ax, 4C00h 25 | int 21h 26 | %endif 27 | 28 | fun16: 29 | mov bx, 0B3B3h 30 | mov dx, 0D3D3h 31 | lframe near 32 | lpar word, alpha 33 | lvar word, foo 34 | lvar word, bar 35 | lenter 36 | test ax, ax 37 | jnz .handler2 38 | 39 | .handler1: 40 | lvar word, quux 41 | push cx 42 | mov dx, word [bp + ?alpha] 43 | mov word [bp + ?foo], ax 44 | add ax, word [bp + ?quux] 45 | 46 | lleave 47 | lret 48 | 49 | .handler2: 50 | lframe near 51 | lemit off 52 | lpar word, alpha 53 | lvar word, foo 54 | lvar word, bar 55 | lenter 56 | lemit 57 | lvar word, baz 58 | push dx 59 | 60 | mov bx, word [bp + ?alpha] 61 | mov word [bp + ?foo], ax 62 | 63 | lleave 64 | lret 65 | -------------------------------------------------------------------------------- /test/lmacros/tests/017.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | mov cx, 1234h 18 | xor ax, ax 19 | push ax 20 | call fun17 21 | 22 | mov ax, 4C00h 23 | int 21h 24 | %endif 25 | 26 | fun17: 27 | lframe near 28 | lpar word, alpha 29 | lvar word, foo 30 | lvar word, bar 31 | lenter ; push bp \ mov bp, sp \ push ax \ push ax 32 | 33 | lvar word, quux 34 | push cx ; push cx 35 | lvar word, baz 36 | lvar dword, xyzzy 37 | lreserve ; lea sp, [bp - 0Ch] 38 | mov dx, word [bp + ?alpha] 39 | ; [bp + 4] 40 | mov word [bp + ?foo], ax 41 | ; [bp - 2] 42 | add ax, word [bp + ?quux] 43 | ; [bp - 6] 44 | mov word [bp + ?xyzzy], dx 45 | ; [bp - 0Ch] 46 | 47 | lframe 0, inner 48 | lvar word, e 49 | lvar word, f 50 | lvar word, g 51 | lenter ; lea sp, [bp - 12h] 52 | lvar word, h 53 | push ax ; push ax 54 | lvar dword, i 55 | lreserve ; lea sp, [bp - 18h] 56 | 57 | lleave ; lea sp, [bp - 0Ch] 58 | 59 | lleave ; mov sp, bp \ pop bp 60 | lret ; retn 2 61 | -------------------------------------------------------------------------------- /test/lmacros/tests/018.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | numdef STANDALONE, 1 5 | 6 | %if _STANDALONE 7 | %ifdef _MAP 8 | [map symbols brief _MAP] 9 | %endif 10 | 11 | cpu 8086 12 | org 256 13 | sectalign off 14 | section lCode start=256 align=1 15 | 16 | start: 17 | call fun18 18 | 19 | mov ax, 4C00h 20 | int 21h 21 | %endif 22 | 23 | fun18: 24 | lframe near 25 | lequ 16 * 3, 16tablesize 26 | lvar ?16tablesize, firsttable 27 | lvar fromparas(paras(26)), secondtable 28 | lenter ; push bp \ mov bp, sp \ lea sp, [bp - 50h] 29 | 30 | lea si, [bp + ?firsttable] 31 | ; lea si, [bp - 30h] 32 | lea di, [bp + ?secondtable] 33 | ; lea di, [bp - 50h] 34 | 35 | lleave ; mov sp, bp \ pop bp 36 | lret ; retn 37 | -------------------------------------------------------------------------------- /test/lmacros/tests/019.asm: -------------------------------------------------------------------------------- 1 | %define _@@_check 2 | %assign _@@_start 0 3 | %include "lmacros2.mac" 4 | 5 | @S 6 | nop 7 | @@: 8 | nop 9 | jmp @F 10 | nop 11 | nop 12 | jmp @B 13 | 14 | @@: 15 | nop 16 | nop 17 | @I 18 | 19 | nop 20 | nop 21 | @S 22 | @@: 23 | nop 24 | nop 25 | jmp @B 26 | @I 27 | -------------------------------------------------------------------------------- /test/lmacros/tests/test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | echo -ne "" > "$1.lst" 4 | [ -z "$NASM" ] && NASM=nasm 5 | "$NASM" "$1.asm" -D_MAP="$1.map" -l "$1.lst" -f bin -o "$@" -I ../ 6 | cat "$1.lst" 7 | ndisasm "$1" 8 | 9 | -------------------------------------------------------------------------------- /test/lmacros/tests/test2.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | %ifdef _MAP 5 | [map symbols brief _MAP] 6 | %endif 7 | 8 | cpu 8086 9 | org 256 10 | sectalign off 11 | section lCode start=256 align=1 12 | 13 | start: 14 | call fun1 15 | push ax 16 | call fun2 17 | push bx 18 | push cx 19 | call fun3 20 | pop bx 21 | call fun4 22 | call fun5 23 | call fun6 24 | call fun7 25 | call fun8 26 | call fun9 27 | call fun10 28 | call fun11 29 | call fun12 30 | call fun13 31 | call fun14 32 | 33 | mov ax, 4C00h 34 | int 21h 35 | 36 | overridedef STANDALONE, 0 37 | %include "001.asm" 38 | %include "002.asm" 39 | %include "003.asm" 40 | %include "004.asm" 41 | %include "005.asm" 42 | %include "006.asm" 43 | %include "007.asm" 44 | %include "008.asm" 45 | %include "009.asm" 46 | %include "010.asm" 47 | %include "011.asm" 48 | %include "012.asm" 49 | %include "013.asm" 50 | %include "014.asm" 51 | resetdef 52 | -------------------------------------------------------------------------------- /test/lmacros/tests/testalig.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | %ifdef _MAP 5 | [map symbols brief _MAP] 6 | %endif 7 | 8 | cpu 8086 9 | org 100h 10 | start: 11 | and sp, ~15 12 | call fun 13 | mov word [first], ax 14 | 15 | sub sp, 16 - 4 16 | mov cx, 3 17 | mov dx, 4 18 | push cx 19 | push dx 20 | call fun2 21 | pop ax 22 | 23 | mov word [fifth], ax 24 | 25 | mov ax, 4C00h 26 | int 21h 27 | 28 | fun: 29 | lframe near 30 | lenter 31 | lvar word, foo 32 | lalign 16 33 | %ifn %$alignment 34 | %error Should need alignment 35 | %endif 36 | %if %$alignment != 10 37 | %error Should need 10-byte alignment 38 | %endif 39 | lreserve 40 | lalign 16 41 | %if %$alignment 42 | %error Should not need alignment 43 | %endif 44 | lalign 8 45 | %if %$alignment 46 | %error Should not need alignment 47 | %endif 48 | mov ax, 1 49 | test sp, 15 50 | jz @F 51 | neg ax 52 | @@: 53 | lleave 54 | lret 55 | 56 | 57 | fun2: 58 | lframe near 59 | lpar word, gamma 60 | lpar_return 61 | lpar word, delta 62 | lenter 63 | mov ax, [bp + ?gamma] 64 | mov word [third], ax 65 | mov ax, [bp + ?delta] 66 | mov word [fourth], ax 67 | mov word [bp + ?gamma], 5 68 | 69 | lalign 16 70 | %ifn %$alignment 71 | %error Should need alignment 72 | %endif 73 | %if %$alignment != 12 74 | %error Should need 12-byte alignment 75 | %endif 76 | lreserve 77 | call fun 78 | mov word [second], ax 79 | 80 | lleave 81 | lret 82 | 83 | align 256 84 | first: dw 0 85 | second: dw 0 86 | third: dw 0 87 | fourth: dw 0 88 | fifth: dw 0 89 | -------------------------------------------------------------------------------- /test/lmacros/tests/testmap.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | echo -ne "" > "$1.lst" 4 | [ -z "$NASM" ] && NASM=nasm 5 | "$NASM" "$1.asm" -D_MAP="$1.map" -l "$1.lst" -f bin -o "$@" -I ../ 6 | cat "$1.lst" 7 | cat "$1.map" 8 | -------------------------------------------------------------------------------- /test/lmacros/tests/testpar.asm: -------------------------------------------------------------------------------- 1 | 2 | %include "lmacros2.mac" 3 | 4 | cpu 8086 5 | org 100h 6 | start: 7 | mov ax, 1 8 | mov bx, 2 9 | push ax 10 | push bx 11 | call fun 12 | 13 | mov cx, 3 14 | mov dx, 4 15 | push cx 16 | push dx 17 | call fun2 18 | pop ax 19 | 20 | mov word [fifth], ax 21 | 22 | mov ax, 4C00h 23 | int 21h 24 | 25 | fun: 26 | lframe near 27 | lpar word, alpha 28 | lpar word, beta 29 | lenter 30 | mov ax, [bp + ?alpha] 31 | mov word [first], ax 32 | mov ax, [bp + ?beta] 33 | mov word [second], ax 34 | lleave 35 | lret 36 | 37 | 38 | fun2: 39 | lframe near 40 | lpar word, gamma 41 | lpar_return 42 | lpar word, delta 43 | lenter 44 | mov ax, [bp + ?gamma] 45 | mov word [third], ax 46 | mov ax, [bp + ?delta] 47 | mov word [fourth], ax 48 | mov word [bp + ?gamma], 5 49 | lleave 50 | lret 51 | 52 | align 256 53 | first: dw 0 54 | second: dw 0 55 | third: dw 0 56 | fourth: dw 0 57 | fifth: dw 0 58 | 59 | -------------------------------------------------------------------------------- /test/lmacros/tests/testsat.asm: -------------------------------------------------------------------------------- 1 | %include "lmacros2.mac" 2 | 3 | [map all testsat.map] 4 | cpu 8086 5 | org 0 6 | 7 | struc TESTSTRUC 8 | resb 1 9 | struc_at 1, at_1: resb 3 10 | struc_at 4, at_4: 11 | resw 1 12 | exact_struc_at 6 13 | at_6: resb 1 14 | struc_at 32 15 | at_32: resb 10 16 | warn_struc_at 64 17 | at_64: resb 1 18 | endstruc 19 | -------------------------------------------------------------------------------- /test/test.asm: -------------------------------------------------------------------------------- 1 | 2 | %if 0 3 | 4 | Usage of the works is permitted provided that this 5 | instrument is retained with the works, so that any entity 6 | that uses the works is notified of this instrument. 7 | 8 | DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 9 | 10 | %endif 11 | 12 | %include "lmacros3.mac" 13 | 14 | cpu 8086 15 | org 256 16 | start: 17 | mov ah, 3Ch 18 | xor cx, cx 19 | mov dx, filename 20 | int 21h 21 | mov dx, msg.creating 22 | jc error.nofile 23 | xchg bx, ax 24 | mov ah, 40h 25 | mov dx, buffer 26 | mov cx, buffer.size 27 | int 21h 28 | mov dx, msg.writing 29 | jc error 30 | cmp ax, cx 31 | mov dx, msg.full 32 | jne error 33 | mov ah, 3Eh 34 | int 21h 35 | xor ax, ax 36 | jmp quit 37 | 38 | error: 39 | mov ah, 3Eh 40 | int 21h 41 | .nofile: 42 | push ax 43 | mov ah, 09h 44 | int 21h 45 | pop ax 46 | call disp_ax_hex 47 | mov al, 13 48 | call disp_al 49 | mov al, 10 50 | call disp_al 51 | mov ax, -1 52 | jmp quit 53 | 54 | 55 | ; INP: al = character to display 56 | ; CHG: - 57 | ; STT: ds, es don't care 58 | disp_al: 59 | push ax 60 | push dx 61 | xchg ax, dx 62 | mov ah, 02h 63 | int 21h 64 | pop dx 65 | pop ax 66 | retn 67 | 68 | 69 | ; Display number in ax hexadecimal, always 4 digits 70 | ; 71 | ; INP: ax = number 72 | ; OUT: displayed using disp_al 73 | ; CHG: none 74 | disp_ax_hex: 75 | xchg al, ah 76 | call disp_al_hex 77 | xchg al, ah 78 | disp_al_hex: 79 | push cx 80 | mov cl, 4 81 | rol al, cl 82 | call disp_al_nybble_hex 83 | rol al, cl 84 | pop cx 85 | disp_al_nybble_hex: 86 | push ax 87 | and al, 0Fh 88 | add al, '0' 89 | cmp al, '9' 90 | jbe @F 91 | add al, -'9' -1 +'A' 92 | @@: 93 | call disp_al 94 | pop ax 95 | retn 96 | 97 | 98 | %if 0 99 | 100 | Shut down machine 101 | by C. Masloch, 2020 102 | 103 | Usage of the works is permitted provided that this 104 | instrument is retained with the works, so that any entity 105 | that uses the works is notified of this instrument. 106 | 107 | DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 108 | 109 | %endif 110 | 111 | 112 | cpu 8086 113 | ; org 256 114 | quit: 115 | int3 116 | 117 | mov ax, 0F000h 118 | mov es, ax 119 | mov di, 0FFF5h 120 | mov si, msg.dosemudate 121 | mov cx, 4 122 | repe cmpsw ; running in DosEmu? 123 | jne .quit_not_dosemu 124 | 125 | xor bx, bx 126 | mov ax, -1 127 | int 0E6h ; dosemu quit 128 | 129 | .quit_not_dosemu: 130 | 131 | ; from https://stackoverflow.com/a/5240330/738287 132 | mov ax, 5301h 133 | xor bx, bx 134 | int 15h ; connect to APM API 135 | 136 | mov ax, 530Eh 137 | xor bx, bx 138 | mov cx, 0102h 139 | int 15h ; set APM version to 1.02 140 | 141 | mov ax, 5307h 142 | mov bx, 1 143 | mov cx, 3 144 | int 15h ; shut down system 145 | 146 | mov dx, msg.failed 147 | mov ah, 09h 148 | int 21h 149 | mov ax, 4C00h 150 | int 21h 151 | 152 | 153 | align 4 154 | msg: 155 | .dosemudate: db "02/25/93" 156 | .failed: db "Quit failed.",13,10,36 157 | .creating: ascic "Creating failed, code=" 158 | .writing: ascic "Writing failed, code=" 159 | .full: ascic "Writing failed, full. AX=" 160 | filename: 161 | asciz "result.txt" 162 | buffer: 163 | .: db "success" 164 | .size: equ $ - . 165 | -------------------------------------------------------------------------------- /test/test.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Usage of the works is permitted provided that this 4 | # instrument is retained with the works, so that any entity 5 | # that uses the works is notified of this instrument. 6 | # 7 | # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. 8 | 9 | if [[ "$1" != selfcall ]] 10 | then 11 | setsid -w "$0" selfcall "$@" 12 | exit $? 13 | fi 14 | shift 15 | 16 | . cfg.sh 17 | 18 | if [ -n "$LMACROS_DIR" ]; then { 19 | options_i_lmacros=-I"${LMACROS_DIR%/}"/ 20 | } fi 21 | 22 | if [ -n "$LDOSBOOT_DIR" ]; then { 23 | options_i_ldosboot=-I"${LDOSBOOT_DIR%/}"/ 24 | } fi 25 | 26 | if [ -n "$SCANPTAB_DIR" ]; then { 27 | options_i_scanptab=-I"${SCANPTAB_DIR%/}"/ 28 | } fi 29 | 30 | if [ -n "$BOOTIMG_DIR" ]; then { 31 | options_i_bootimg=-I"${BOOTIMG_DIR%/}"/ 32 | } fi 33 | 34 | if [ -n "$LDEBUG_DIR" ]; then { 35 | options_i_ldebug=-I"${LDEBUG_DIR%/}"/ 36 | } fi 37 | 38 | if [ -n "$LDOSMBR_DIR" ]; then { 39 | options_i_ldosmbr=-I"${LDOSMBR_DIR%/}"/ 40 | } fi 41 | 42 | if [ -n "$INSTSECT_DIR" ]; then { 43 | options_i_instsect=-I"${INSTSECT_DIR%/}"/ 44 | } fi 45 | 46 | direct=1 47 | bpe=12 48 | spc=1 49 | spi=2880 50 | nr=224 51 | pitype="" 52 | 53 | machine="qemu" 54 | qemu=1 55 | 56 | options_hdimage="" 57 | options_mcopy_offset="" 58 | diskette=1 59 | qemu_switch="-fda" 60 | unit=00h 61 | direct=1 62 | if [[ -z "$pitype" ]] 63 | then 64 | if [[ "$bpe" == 16 ]] 65 | then 66 | pitype=ptFAT16 67 | else 68 | pitype=ptFAT12 69 | fi 70 | fi 71 | 72 | echo -ne 'shell=test.com\r\n' > fdconfig.sys 73 | echo -ne 'failure\r\n' > result.txt 74 | if [[ -z "$1" || -z "$2" || -z "$3" ]] 75 | then 76 | echo Error, missing parameters. 1=KERNELPATHNAME, 2=DISKETTE, 3=BOOT 77 | exit 1 78 | fi 79 | KERNELPATHNAME="$1" 80 | DISKETTE="$2" 81 | BOOT="$3" 82 | testrunname="$4" 83 | shift 84 | shift 85 | shift 86 | shift 87 | 88 | "$NASM" "test.asm" \ 89 | "$options_i_lmacros" \ 90 | -o test.com && 91 | "$NASM" "${LDOSBOOT_DIR%/}"/boot.asm -w-user \ 92 | "$options_i_lmacros" \ 93 | -D_COMPAT_FREEDOS=1 \ 94 | -D_LBA=0 -D_USE_PART_INFO=0 -D_QUERY_GEOMETRY=0 \ 95 | -D_MAP=boot.map \ 96 | -D_FAT$bpe -D_UNIT=$unit \ 97 | "$@" \ 98 | -l "$BOOT".lst \ 99 | -o "$BOOT".bin && 100 | "$NASM" "${BOOTIMG_DIR%/}"/bootimg.asm \ 101 | -I ./ \ 102 | "$options_i_bootimg" \ 103 | "$options_i_lmacros" \ 104 | -D_PAYLOADFILE="::rename,'$KERNELPATHNAME',KERNEL.SYS,fdconfig.sys,test.com,result.txt" \ 105 | -D_BOOTPATCHFILE="'$BOOT.bin'" \ 106 | -D_WARN_DEFAULT_OFF=1 \ 107 | -D_WARN_TOOMANYFAT=0 -D_WARN_ALIGNDATA=0 \ 108 | $options_hdimage -D_MBR_PART_TYPE="$pitype" \ 109 | -D_BPE="$bpe" -D_SPC="$spc" -D_SPI="$spi" \ 110 | -D_SPF="$(( (spi / spc * bpe / 8 + 511) / 512 ))" \ 111 | -D_NUMROOT="$nr" \ 112 | -o "$DISKETTE".img -l "$DISKETTE".lst \ 113 | -D_UNIT=$unit \ 114 | "$@" 115 | (($?)) && exit $? 116 | 117 | pgid="$(ps -o pgid= $$)" 118 | function handle_timeout_process() { 119 | stty sane 2> /dev/null > /dev/null 120 | # The stty sane command in the CI environment shows: 121 | # 122 | # 'standard input': Inappropriate ioctl for device 123 | # 124 | # It is probably safe to ignore. 125 | ((debug)) && ps -e -o pgid=,comm=,pid= | grep -E "^\s*$pgid " 126 | pidlist="$(ps -e -o pgid=,comm=,pid= | 127 | grep -E "^\s*$pgid " | 128 | grep -Ev " (bash|test.sh|ps|grep) ")" 129 | pidlist="$(echo "$pidlist" | 130 | sed -re 's/^\s+//g' | 131 | tr -s " " | cut -d" " -f 3)" 132 | if [[ -n "$pidlist" ]] 133 | then 134 | ((debug)) && ps $pidlist 135 | kill $pidlist 136 | fi 137 | } 138 | timeout --foreground 10 "$QEMU" "$qemu_switch" "$DISKETTE".img -display none 2> /dev/null 139 | 140 | rc=$? 141 | handle_timeout_process 142 | if ((rc == 124)) 143 | then 144 | echo "${testrunname}timeout" 145 | exit 124 146 | fi 147 | if [[ "$(mtype -t -i $DISKETTE.img$options_mcopy_offset ::RESULT.TXT 2> /dev/null)" == success ]] 148 | then 149 | echo "${testrunname}success" 150 | exit 0 151 | else 152 | echo "${testrunname}failure" 153 | exit 1 154 | fi 155 | -------------------------------------------------------------------------------- /tests/absread/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | wcl -e3-we-wx-zq-os-s-zp1-mt-bt=DOS absread.c 3 | -------------------------------------------------------------------------------- /tests/fcb_rename/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | wcl -e3-we-wx-zq-os-s-zp1-ms-bt=DOS fcb_ren.c 3 | -------------------------------------------------------------------------------- /tests/opendev/DIREXIST/EMPTYDIR.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FDOS/kernel/b8ef68fb866534143565585c8970827de2a2e429/tests/opendev/DIREXIST/EMPTYDIR.txt -------------------------------------------------------------------------------- /tests/opendev/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | :: use -ms for exe, -mt for com 3 | wcl -e3-we-wx-zq-os-s-zp1-ms-bt=DOS opendev.c 4 | -------------------------------------------------------------------------------- /utils/echoto.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if "%2%3%4%5%6%7%8%9" == "" goto nothing 3 | echo %2 %3 %4 %5 %6 %7 %8 %9 >>%1 4 | shift 5 | if not "%9" == "" echo echoto.bat arguments overflow 6 | :nothing 7 | -------------------------------------------------------------------------------- /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 upxentry.bin upxdevic.bin 6 | 7 | patchobj.com: patchobj.c 8 | $(CLT) $(CFLAGS) patchobj.c 9 | 10 | upxentry.bin: upxentry.asm 11 | $(NASM) -f bin upxentry.asm -o upxentry.bin 12 | 13 | upxdevic.bin: upxdevic.asm 14 | $(NASM) -f bin upxdevic.asm -o upxdevic.bin 15 | 16 | exeflat.exe: exeflat.c ../hdr/exe.h 17 | $(CLC) $(CFLAGS) exeflat.c 18 | 19 | 20 | clobber: clean 21 | 22 | clean: 23 | $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me 24 | $(RM) exeflat.exe patchobj.com upxentry.bin upxdevic.bin 25 | 26 | -------------------------------------------------------------------------------- /utils/proto.bat: -------------------------------------------------------------------------------- 1 | for %%f in ( %1 %2 %3 %4 %5 %6 %7 %8 %9 ) do mkptypes %%f >>proto.h 2 | -------------------------------------------------------------------------------- /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/upxdevic.asm: -------------------------------------------------------------------------------- 1 | 2 | %if 0 3 | 4 | UPX preparation stub for DOS/SYS format compressed FreeDOS kernel 5 | Public Domain by C. Masloch, 2022 6 | 7 | %endif 8 | 9 | cpu 8086 10 | org 0 11 | 12 | bootloadunit: ; (byte of short jump re-used) 13 | start: 14 | jmp strict short entry 15 | times (32 - 4) - ($ - $$) db 0 16 | ; area for CONFIG block 17 | 18 | bootloadstack: ; (dword re-used for original ss:sp) 19 | entry: 20 | ; common setup (copied from kernel.asm) 21 | push cs 22 | pop ds 23 | xor di, di 24 | mov byte [di + bootloadunit - $$], bl 25 | push bp 26 | mov word [di + bootloadstack - $$], sp 27 | mov word [di + bootloadstack + 2 - $$], ss 28 | 29 | ; the UPX DOS/SYS depacker does not need a certain ss:sp 30 | ; however it appears to need cs == ds 31 | 32 | mov ds, word [di + patchcsip + 2 - $$] 33 | jmp 0:0 34 | patchcsip: equ $ - 4 35 | end: 36 | 37 | times 0C0h - ($ - $$) nop 38 | entry_common: 39 | 40 | times 100h - ($ - $$) db 0 41 | dw 0 42 | dw 0 43 | dw 0 44 | dw patchcsip 45 | dw end 46 | -------------------------------------------------------------------------------- /utils/upxentry.asm: -------------------------------------------------------------------------------- 1 | 2 | %if 0 3 | 4 | UPX preparation stub for DOS/EXE format compressed FreeDOS kernel 5 | Public Domain by C. Masloch, 2022 6 | 7 | %endif 8 | 9 | cpu 8086 10 | org 0 11 | 12 | bootloadunit: ; (byte of short jump re-used) 13 | start: 14 | jmp strict short entry 15 | times (32 - 4) - ($ - $$) db 0 16 | ; area for CONFIG block 17 | 18 | bootloadstack: ; (dword re-used for original ss:sp) 19 | entry: 20 | ; common setup (copied from kernel.asm) 21 | push cs 22 | pop ds 23 | xor di, di 24 | mov byte [di + bootloadunit - $$], bl 25 | push bp 26 | mov word [di + bootloadstack - $$], sp 27 | mov word [di + bootloadstack + 2 - $$], ss 28 | 29 | ; the UPX DOS/EXE depacker needs a certain ss:sp 30 | cli 31 | mov ax, 0 32 | patchstacksegment: equ $ - 2 33 | mov ss, ax 34 | mov sp, 0 35 | patchstackpointer: equ $ - 2 36 | sti 37 | 38 | mov ax, -10h 39 | patchpspsegment: equ $ - 2 40 | mov ds, ax 41 | mov es, ax 42 | 43 | jmp 0:0 44 | patchcsip: equ $ - 4 45 | end: 46 | 47 | times 0C0h - ($ - $$) nop 48 | entry_common: 49 | 50 | times 100h - ($ - $$) db 0 51 | dw patchstackpointer 52 | dw patchstacksegment 53 | dw patchpspsegment 54 | dw patchcsip 55 | dw end 56 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------