Commit Graph

163 Commits

Author SHA1 Message Date
Bocke
9b6a8579d1 Make build work on DOS
Double ampersands are not supported by DOS command line interpreters. The previous would work only on (modern-ish) Windows.
2024-02-05 10:47:59 -05:00
Bernd Boeckmann
093dea9a7b initdisk.c: format specifier fixes 2 2024-02-04 20:44:19 -05:00
Kenneth J Davis
4ffc5c10a5 fix bug#121 don't look for 123? unless still looking for verb at start of line
allows correctly parsing lines like SHELL=4DOS.COM which otherwise strips 4 leading to looking for shell of "DOS.COM"
2024-02-04 20:37:43 -05:00
Kenneth J Davis
f7bf549544 correct xor to test not clear value, invert test so 808x is 0 and NEC is 1 matching returned value 2024-02-04 19:43:09 -05:00
Kenneth J Davis
07155e6184 fix bug#123, detect NEC V20/V30 as 186 instead of only 8086/8088, based on ecm-pushbx ldebug
see https://hg.pushbx.org/ecm/ldebug/file/7f3440d5824d/source/init.asm#l3071

(cherry picked from commit 5fdcc1d214b821fde33a5bd92ea7d7c0134a2056)
2024-02-04 19:43:09 -05:00
Kenneth J Davis
431be02b0a rework update_dcb() to avoid potential access uninitialized memory 2024-02-03 22:00:17 -05:00
C. Masloch
1c2f541689 intr: avoid random trace in (init_)call_intr 2024-02-03 21:04:11 -05:00
C. Masloch
3ef6d61609 main: fix, only init env once in PSPInit, do not set cmdline tail 2024-02-03 21:01:17 -05:00
C. Masloch
ab3cac6d0c allow gcc build to succeed with -DWIN31SUPPORT 2024-02-03 20:59:11 -05:00
Bernd Boeckmann
9a7d22701d initdisk.c: fix wrong printf format specifiers, fixes #122 2024-02-03 20:52:42 -05:00
Kenneth J Davis
db71b1a783
don't normally show InitDisk while booting 2023-12-20 17:17:08 -05:00
Kenneth J Davis
de96d00402
additional comments about LBA detection 2023-12-20 00:35:01 -05:00
Bernd Boeckmann
cab32344bb only use AH for EDD version detection, as AL is reserved...
...according to the spec
2023-12-19 23:50:02 -05:00
Bernd Boeckmann
a5431d9245 remove BIOS assisted LBA translation, not sure its worth including it 2023-12-19 23:50:02 -05:00
Bernd Boeckmann
b33afdbfad change handling of head count < 2, was a no-op since last commit...
... because heads was always at least 1.
2023-12-19 23:50:02 -05:00
Bernd Boeckmann
c20a97e844 initdisk: actually restrict disk size to 2TB, fix ExtLBAForce usage 2023-12-19 23:50:02 -05:00
Kenneth J Davis
569337a7ef
fix bug# 98 (correct bad CONFIG value 19 with bad value 14, should be 6) and add support for additional CONFIG options Verbose and PartitionMode to sys CONFIG processing 2023-12-19 19:50:22 -05:00
Kenneth J Davis
2e849b36c1
update copyright string to 2023 2023-12-18 20:23:04 -05:00
Kenneth J Davis
7b0633b26b
only print messages once, not each time processing partitions; use LBA if forceLBA enabled in additional cases where LBA support not detected 2023-12-18 18:37:19 -05:00
Kenneth J Davis
4b0162c2a6
default to normal not quiet for initial messages 2023-12-18 18:31:20 -05:00
Kenneth J Davis
cfdd09963f
fix from boeckmann (Bernd Böckmann) for Format GitHub issue #1 - format divide by 0 due to kernel function 440D, subfunction 60 returning a zero for logical_sectors_per_fat as initdisk overflows and calculates incorrect value 2023-12-17 21:01:37 -05:00
Kenneth J Davis
f1249dcd6f
From bzt, initialize drive parameter head & sector values to avoid potential divisions by 0 2023-12-08 21:20:46 -05:00
Kenneth J Davis
5880d36ba9
add ability to adjust verboseness of messages during booting 2023-12-08 18:08:11 -05:00
C. Masloch
95694f7e34 config: delete variable only if it makes enough space to write new 2023-08-30 06:59:41 -04:00
C. Masloch
6101fb2aed config: pass searchvar result to deletevar 2023-08-30 06:59:41 -04:00
C. Masloch
24d19cd05c config: allow to delete variable with empty SET command 2023-08-30 06:59:41 -04:00
C. Masloch
3dafa54e8b config: delete existing variable before writing new contents 2023-08-30 06:59:41 -04:00
C. Masloch
132a0a9f94 truename: fix array overrun (pick from fdpp)
Picked from the commit at fe1c4dc7fe

The referenced issue is at https://github.com/dosemu2/fdpp/issues/212

The patch was applied using unix2dos on the patch file
then `patch -p1 --binary` with the patch file as stdin.
The original used a new define for the maximum path length.
As there is no difference to our current SFTMAX define I
changed this hunk to retain the SFTMAX use.

This fixes a bug when eg function 3Dh receives a buffer
that starts with ".\" but the byte in memory before this
buffer happens to be also a dot. I ran into this problem
semi-randomly during building EDR-DOS with the most recent
WarpLink build. If WarpLink was placed somewhat low in the
Low Memory Area then one of its function 3Dh calls would
happen to have a dot before the pathname buffer. (I had to
load lCDebug using the last fit strategy then enter TSR mode,
to catch the bug without the presence of the debugger working
around the occurrence of the bug.)

Original commit Metadata:

From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Wed, 1 Feb 2023 13:01:55 +0500
Subject: [PATCH] truename: fix array overrun [fixes #212]

src[-2] was peeking into a random memory location.
It seems entire truename() is written by some morons... :(
Its completely unreadable and full of bugs.
2023-08-26 21:32:19 -04:00
C. Masloch
29ccb6e454 main: insure master environment starts out empty 2023-07-03 07:37:00 -04:00
C. Masloch
a0549a395e config: make sure word marker trailing in environment is zero 2023-07-03 07:37:00 -04:00
C. Masloch
3d1ba0d486 config: build master environment during FDCONFIG.SYS processing
lDebug wants to access the environment while executing
as a device driver. Instead of building it in a variable
then copying it to 68h:0 after FDCONFIG.SYS processing,
just build it there to begin with.
2023-07-03 07:37:00 -04:00
Andrew Bird
afe7fbe068 inthndlr: align hma size to para
Based on a patch https://github.com/dosemu2/fdpp/commit/e7fe81d458
for FDDP by @stsp

[fixes #101]
2023-04-13 18:05:24 -04:00
Andrew Bird
fa3dc59367 DosGetExtFree: Use new redirector function 11a3
To be able to return free space on larger non local disks, the redirector
needs an extension. Dosemu2 has implemented this function and FDPP
has an almost identical patch to this. If the extension is not
implemented by your chosen redirector, then fallback to the standard
110c function is done for int21/7303.

With this patch up to 2TB (with Dosemu2 reporting in 512 blocks) can be
displayed.
2023-03-21 20:54:17 -04: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
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
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
C. Masloch
10b4d1581f exeflat: implement new-style UPX compression in DOS/SYS format 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
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
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
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