Commit Graph

276 Commits

Author SHA1 Message Date
C. Masloch 384e68529a sys: detect small FAT32 as FAT32 (zero in word SPF)
Also checks that the total amount of clusters is possible
for the detected file system, erroring out otherwise.
Small FAT32 is displayed in the verbose output specifically.
2023-01-10 13:17:16 -05:00
C. Masloch 7115d69cd2 sys: support 256 sectors per cluster
This was overlooked in the earlier commits because SYS
uses its own BPB structures and name for the SPC field.
2023-01-10 13:17:16 -05:00
C. Masloch 2efe4ab9f4 boot: enable loading from file systems with 256 sectors per cluster
This should be Enhanced DR-DOS compatible.

oemboot.asm contains an optimisation to save 2 bytes,
by using mov instead of a lea with bp evaluating to
a constant value. This was needed to fit the addition
for 256 spc support. It is otherwise unrelated.

The LBA detection patch offsets in SYS have also been
updated to match the changed boot.asm offsets.
2023-01-04 19:38:57 -05:00
C. Masloch 28cd58688a fatfs.c: allow bpbSectorsPerCluster == 0 to mean 256
This should be compatible to Enhanced DR-DOS.

Tested by building a boot image like the following:

nasm ../ldosmbr/oldmbr.asm -o oldmbr.bin
nasm ../ldosboot/boot.asm -D_FAT16=1 -I ../lmacros/ \
 -D_LOAD_NAME="'LDEBUG'" -o boot16.bin
nasm bootimg.asm -I ../lmacros/ -o disk16.img \
 -D_MBR -D_ALIGNDATA -D_BOOTPATCHFILE=boot16.bin \
 -D_MBRPATCHFILE=oldmbr.bin -D_BPE=16 \
 -D_SPI='(_SPC * 5000)' -D_NUMROOT=512 -D_SPC=256 \
 -D_SPF='((_SPI / _SPC + 255) / 256)' \
 -D_PAYLOADFILE=../ldebug/bin/ldebug.com,quit.com,\
::rename,../k256spc/bin/kernel.sys,kernel.sys,\
command.com,::fill,1,32,autoexec.bat

The repos bootimg, ldosboot, ldosmbr, and lmacros are
available at https://hg.pushbx.org/ecm/

The file ldebug.com is a recent bootable lDebug debugger.
The file command.com is a recent FreeCOM. The file quit.com
is assembled with NASM from
https://hg.pushbx.org/ecm/ldebug/file/e6035c05670a/misc/quit.asm

Run like this:

qemu-system-i386 -hda disk16.img -boot order=c -display curses

To the lDebug prompt "-" enter "boot protocol freedos",
then a "q" command. On success, the quit.com command
can be run to quit the qemu VM.

Not yet done:

- initdisk.c:512 uses MAXCLUSTSIZE defined to 128. This is
not difficult to change but it is unclear whether this
should be changed.

- The boot loaders are not yet adjuscted, requiring use of
the ldosboot or lDebug loaders instead.

- A patch for FORMAT (copylefted) version 0.91u is available
from the Enhanced DR-DOS project. Mirrored in the directory at
https://pushbx.org/ecm/download/edrdos/freedos/
This should be easy enough to update to the most recent version.
2023-01-04 19:38:57 -05:00
C. Masloch 302b002adb sys: enable building without WITHFAT32 defined 2022-12-31 09:37:42 -05:00
C. Masloch bf085a7ed6 sys: fix gcc build, int86 has to preserve ds
The int86 function is used to call interrupt 21h
service 32h in the reset_drive function. This
function returns a pointer using the ds register.
ds will usually point into the DOS data segment
then (for our kernel). However, the compiler
assumed ds to be unchanged.
2022-12-31 09:37:42 -05:00
Andrew Bird bb1bbbb1cb CI: Update deprecated output method 2022-10-28 07:05:26 -04:00
Andrew Bird ccf4367729 CI: Update std actions to avoid node version warnings 2022-10-28 07:05:26 -04:00
Kenneth J Davis 339256d6aa
revert changes to ci-build.yml 2022-10-25 07:12:50 -04:00
Kenneth J Davis 1c25390e49
update deprecated set-output 2022-10-25 07:01:09 -04:00
Kenneth J Davis e1b22c7035
update comments
(from Geoff Chappell blog and RBIL)
2022-10-24 20:19:32 -04:00
Kenneth J Davis 6f6e44e1b5
fix OW warning W115 in config.c 2022-10-24 18:08:27 -04:00
Kenneth J Davis af52b0c8c3
fix OW warning W115 in dsk.c 2022-10-24 18:01:50 -04:00
Kenneth J Davis c152d551de
fix OW warning W115
cast array using pointer to first element [newboot] instead of pointer to whole array [&newboot] to avoid OW error W115 "&array may not produce intended result" since the address of operator "&" is not required for getting the address of an array.
2022-10-24 17:56:33 -04:00
Kenneth J Davis 9d799c2a1e
Update ci-build.yml
enable ability to manually run workflow
2022-10-24 17:28:56 -04:00
tkchia 7149a8efe4 FCB (int 21h func 29h): should not accept field separator as "drive letter" 2022-07-16 07:20:24 -04:00
tkchia 031f17068a FCB (int 21h func 29h): should keep parsing name even if drive letter invalid 2022-07-15 09:45:10 -04:00
Kenneth J Davis 0e6d90cf82
build fixes, declare variables at start of block, use size_t to avoid int vs long errors 2022-06-03 23:29:37 -04:00
Kenneth J Davis bfd5328183
fix building on Windows with Open Watcom, using OWWIN helper tools built as win32 executables instead of DOS executables as done using WATCOM for COMPILER 2022-06-03 23:28:51 -04:00
C. Masloch 9343e00f9a exeflat: try to fix CI displaying upx output before exeflat output 2022-05-30 17:37:26 -04:00
C. Masloch b5299924c2 exeflat: update comments before prepending entry header 2022-05-30 17:37:26 -04:00
C. Masloch 70c498a309 exeflat: update usage screen with -E, -D, and -U switches 2022-05-30 17:37:26 -04:00
C. Masloch e3e58ee3fd upxentry, upxdevic: add header comments 2022-05-30 17:37:26 -04:00
C. Masloch 77d3c7e1d7 exeflat: document UPX 3.96 exact DOS/SYS limit but use a lower number 2022-05-30 17:37:26 -04:00
C. Masloch f23f035554 exeflat: allow to force either DOS/EXE or DOS/SYS compression format 2022-05-30 17:37:26 -04:00
C. Masloch 10b4d1581f exeflat: implement new-style UPX compression in DOS/SYS format 2022-05-30 17:37:26 -04:00
C. Masloch 9382d7ce00 exeflat: pass argv[3] to use as start_seg in write_header 2022-05-30 17:37:26 -04:00
C. Masloch 99614259ae exeflat: jump across nop slide when the stub is shorter than 192 bytes 2022-05-30 17:37:26 -04:00
C. Masloch 7f38303ade exeflat: shrink uncompressed stub size to 64 bytes
The code still allows for up to 192 bytes, should that
be useful. Simply by re-assembling upxentry.asm then
re-running exeflat, the changes will be picked up.
2022-05-30 17:37:26 -04:00
C. Masloch 45b3d9ef67 exeflat: move reading entry file into main, pass code to write_header 2022-05-30 17:37:26 -04:00
C. Masloch 992a898076 kernel.asm, exeflat: new format with UPX entry at 006C0h
This format has several advantages:

* The CONFIG block need not be moved.

* The entire compressed image (depacker and payload) need
not be moved another time before the UPX depacker's own
operation.

* The CONFIG block always lives at 00602h, and the kernel
need not be aware whether it was compressed for detecting
which CONFIG block to use.

* Support for compressed images beyond 64 KiB for free.
(The assembly define TEST_FILL_INIT_TEXT can be passed in
NASMENV to test this support with 32 KiB of LFSR output.)

* A subsequent commit will shorten the stub to 64 bytes,
compared to the prior 32 + 45 = 77 bytes, with no loss
of features. (The packed payload is a bit shorter too.)

* The new stub also sets ds and es to the segment value
that would point to the DOS/EXE process's PSP. This is
apparently not used by the UPX depacker but could be in
a future or past version, or if another packer is used.
2022-05-30 17:37:26 -04:00
C. Masloch 9dcd9ba051 mkfiles: add -Wall switch to host gcc variable
Refer to https://github.com/FDOS/kernel/pull/72#issuecomment-1133770757
2022-05-29 19:25:00 -04:00
C. Masloch d91c14723a kernel: optimise A20 check and enable/disable calls
Some assembly tricks:

* SMC instead of checking the XMS driver address
in the DOS DS stub,

* SMC so that the address goes right into a
`call far immediate` instruction,

* use `repe cmpsw` to compare multiple words (saves
space over the individual word compares),

* near calls to far functions use push cs to build
a far-call stack frame,

* segments 0 and FFFFh generated by segment arithmetic
instead of loading from memory,

* common case (A20 already enabled) made to be the case
where the conditional branch just falls through, which
may be slightly better.
2022-05-29 19:24:00 -04:00
C. Masloch 72edabfdb7 gcc.mak: make sure to redirect more internal function calls in init
Refer to https://github.com/tkchia/gcc-ia16/issues/109#issuecomment-1133867169
2022-05-29 18:05:46 -04:00
C. Masloch 8e6fc98a94 config: bugfix, make struct array configcommands static (fixes #73)
A crash was introduced by the prior commit, ee255d2. I
tested that the kernel still did build with gcc, but I
failed to test whether it also still runs. Turns out that
apparently changing the pointers to static made it so gcc
put the structure into the init data segment and
implicitly called memcpy to put it on the stack. That's
wrong, however. We depend on #define to convert all calls
in init to the init text copies of memcpy etc. The
implicit call by gcc however attempts to call the HMA text
copy of memcpy which happens to be at another offset.

The fix is to make the entire array of structs static so
that memory for it is allocated only in the init data
segment, not on the stack. This seems to work for both
gcc and OpenWatcom (no warnings, it builds, it runs).
2022-05-22 13:16:39 -04:00
C. Masloch ee255d2355 main, config: fix OW build (char not UBYTE, static file pointers) 2022-05-21 23:22:08 -04:00
C. Masloch 42b8e12bc7 ci_build.sh: fix CI build to correct OW file, wget --no-verbose
Refer to https://github.com/tkchia/gcc-ia16/issues/108
2022-05-21 23:22:08 -04:00
C. Masloch 5df9dbdbd7 mkfiles: fix compilation with current gcc-ia16
Refer to https://github.com/tkchia/gcc-ia16/issues/108
2022-05-21 23:22:08 -04:00
C. Masloch c0b8aa2bf4 task: return Invalid format on empty executable (fixes #70) 2022-05-21 23:22:08 -04:00
C. Masloch b562983222 config: add the CONFIG, ALTCONFIG, and OLDCONFIG kernel command line commands
CONFIG takes precedence and is by default initialised
to the empty string, that is, skipped. ALTCONFIG is
used to specify the 'alternative' filename and defaults
to fdconfig.sys. Finally, OLDCONFIG defaults to the
config.sys filename.
2022-05-21 23:22:08 -04:00
C. Masloch 4377a257e0 kernel, main: read kernel command line into init segment buffer
The protocol for this extension is based on what lDebug
already does given the PROTOCOL=FREEDOS with the switch
CMDLINE=1 (which was originally defined for the lDOS and
RxDOS load protocols). Therefore the stack frame mirrors
that of the lDOS protocol.
2022-05-21 23:22:08 -04:00
C. Masloch 49733547f1 kernel, main: add debugger_present variable and skip ints 0, 1, 3, 6
Also adds a CheckDebugger byte to the CONFIG block and
support for reading and writing this setting in the
SYS CONFIG program. Default is 0 (no check assume absent).
2022-05-21 23:22:08 -04:00
C. Masloch 7ff6c06814 kernel: copy CONFIG block from UPX help data early in kernel.asm
Here we depend on the signal instruction that is patched
by exeflat to indicate whether we were compressed. This
replaces the prior check that detected the UPX help data
solely by checking the CONFIG signature at 05E2h.
2022-05-21 23:22:08 -04:00
C. Masloch b7345d9165 main: note that we want to set int 31h segment to DOS DS
This commit does not change the behaviour of the code
as it already did the right thing. However, it notes
that that should happen. (This is DR DOS compatible.
For example, SHSUCDX depends on DR DOS setting this
segment so that it can keep track of the DOS DS
across it being relocated. We do not yet relocate it
but keeping a reference here is still useful.)
2022-05-21 23:22:08 -04:00
C. Masloch 3b6d8362b3 exeflat: store original ss:sp in UPX help data 2022-05-21 23:22:08 -04:00
C. Masloch ad368a4420 exeflat: support signal byte (clc/stc) to indicate compression to kernel 2022-05-21 23:22:08 -04:00
C. Masloch f51c8a5304 exeflat: copy original CONFIG block to the depacker header 2022-05-21 23:22:08 -04:00
C. Masloch 6d23a787fb fdkrncfg: bugfix, version info check should not include signature 2022-05-21 23:22:08 -04:00
Andrew Bird 8c8d213119 Build: Don't flip video mode for -DDEBUG in Dosemu 2022-01-16 12:40:47 -05:00
Andrew Bird 9135a644c2 Build: Fix missing constant for -DDEBUG 2022-01-16 12:40:47 -05:00