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.
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.
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.
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.
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).
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.
This changes the interface between reloc_call_int2f_handler
(int2f.asm) and int2F_12_handler( ) (inthndlr.c) so that
- int2F_12_handler( ) will not try to output values to its
caller by passing "back" input parameter values
- reloc_call_int2f_handler will switch to an internal
stack before calling int2F_12_handler( ), so that SS ==
DGROUP as expected by the latter.
This partly addresses https://github.com/FDOS/kernel/issues/11 .
(The call to syscall_MUX14( ) in int2f.asm seems to have
similar issues, and should probably also be updated.)
GCC has -mrtd but the args are pushed in reverse versus PASCAL. So asm
routines have to use macros to obtain the stack arguments.
For the complex call_nls assembly, revert the arguments in C using a
preprocessor macro.
Because ia16-elf-gcc and the GNU linker do not understand OMF we
need to use ELF everywhere.
This also means we cannot use "wrt", "seg" and "call/jmp far".
Most wrt's are superfluous, and seg and call/jmp far can be
replaced by explicit ?GROUP references (to be defined in the
linker script).