blog:pushbx:2025:1130_late_november_work_on_the_pre-boot_loader
Table of Contents
Late November work on the pre-boot loader
2025-11-30
The prior two weeks we drafted some interfaces and a rough implementation of the pre-boot loader that's based on the debugger. Because the loader is a stripped down build of the debugger, many of its features come for free (or almost so), including:
- Chain loading of other kernels
- Script file reading
- Serial terminal I/O
- Expression evaluator
- Subset of the Extensions for lDebug infrastructure
- Memory dump and edit commands
- Dump interrupts command
- Port I/O commands
- Command line buffer related commands
lDOS boot (experimental)
- Add and use the LOADERIMAGEIDENT structure in the trivial example loader.
- Expect input ax equal to 60h in the liiEntryRelocate entrypoint of the example loader.
lDebug / lDOS pre-boot loader
- run.asm: Fix to allow building with _BREAKPOINTS=0, move copy_single_counted_string function out of the conditional assembly leg.
- bb.asm: Likewise, make point_swap and some more code conditional.
- Use repeatdw mmacro in several cases. The point is to allow the assembler to generate multiple errors if multiple operands to the mmacro are undefined symbols, which it cannot do for a single dw directive. Also reported this to the NASM bugzilla (which is down again).
- Initial commit of the special _LOADER build to generate a stripped-down variant of the debugger. This strips the assembler, disassembler, most of the run code (T, TP, P, G commands), the S commands, the C, L, W, N, and K commands, the RE buffer and commands, and the Q command. Further, it disables the application mode, device mode, DPMI support, all interrupt hooks except the serial interrupt, RH commands, D strings commands, DX command, immediate assembler, bb/breakpoints support, 40 columns mode, and the MCB dump command.
- Do include amis.asm in _LOADER build for a few variables needed by ELD linker. Catching int 2Dh is still disabled, which drops most of the AMIS code.
- Make ldmem Extension for lDebug work on the _LOADER build. For this, make the AMIS and aa (assembler) hooks optional in the ELD's list of hooks.
- Modify image ident to read NLDR (instead of NDEB) and place it at beginning of entry segment, rather than in the paragraph before the entry segment.
- In iniloadc.mac also disable the iniload loader support for a _LOADER build.
- Add trivial G and Q commands. G just calls "run" whereas Q just calls interrupt 19h. These are to be improved yet.
- Split the ?BOOT help page into _EXTBOOTHELP option to allow enabling it without all the _EXTHELP pages.
- In main online help page drop commands not supported by loader.
- Mark relocations of segment variables needed to relocate the loader.
- Disable more parts for the loader build, including the ?RE and ?RUN help pages, the yy script/extension load commands that use DOS, and the /R switch support variables.
- In debugger's loader support, use the new liiStackPointer variable to initialise sp for the debuggee.
- Add a MOVE command to the loader. Still a no-op.
- Fix to allow closing RC buffer if _INPUT_FILE_HANDLES=0.
- Drop another piece of RE buffer support for _LOADER build.
- Include the movp function for the loader build.
- Implement MOVE commands BOTTOM, TOP, and HIDDEN.
- Move the ldmem ELD display_patchareas.none code, to shorten a certain branch to prepare for next changeset.
- In ldmem.eld support movable aux buffer, code1, and code2 variables. These are treated the same as the existing ones but displayed with an "(M)" marker.
- In the link info tables, rename some variables for loader to indicate they're movable. (This means they're movable moreso than all segments for the loader. That is, the MOVE commands may move the entire loader instance, but the segments will stay at the same relative distances. The segments marked movable may not stay at the same relative distances.)
- ELD linker:
- Harden against empty link info tables (shouldn't happen).
- Optimise the other link error check branch. (Chain the jump to .error to another jump.)
- Allow to swap the aux buffer and the code segment to insure that the aux buffer doesn't cross a 64 KiB boundary.
- On a MOVE, rehook the serial interrupt if it is currently hooked.
- In boot.asm add checks that a bottom or top placed loader isn't overwritten by the BOOT commands.
- Use the LOADERIMAGEIDENT structure for the NLDR image ident.
- Add additional entrypoints for NLDR image ident, with a call to moveloader.
- Add the GODEBUG command to patch the LSV extra field and skip 9 bytes of the lDebug iniload lDOS load entry, then chain to run.
- For the GODEBUG command, also detect the presence of the LOADERSUPPORT00 signature.
TBD
- Add the SLEEP command to the loader. It was disabled by a simple conditional around sss.asm and the sss command, which includes both SLEEP and S (search).
- New ELD relocations that allow to pick the first match of multiple symbols? This would allow an easier way to access either the unmovable or movable aux/code symbols.
- Exclude more messages in msg.asm not needed by loader.
- Prepare an allowlist or denylist of help pages to avoid lengthy build of them when not needed for this build.
- Add current release builds for loader, using the makldr.sh script.
- Add int 18h and 19h hooks for hidden loader, hook or unhook on MOVE.
- Add better Q and G commands for loader.
- Add some helpers for ELDs to aid installing resident extensions into a hidden block. (The loader must be placed at the bottom for this to work.) Move EBDA as needed.
- Define a new image ident header for resident extensions (NEXT for "N extension" ?).
- Verify which current ELDs can be loaded by loader, and which installable ELDs can be used even across movement of the loader.
You could leave a comment if you were logged in.
blog/pushbx/2025/1130_late_november_work_on_the_pre-boot_loader.txt · Last modified: by ecm
