Category Archives: bootldr

ReactOS as a 32bit Open Watcom Dev Environment

I was having problems with the old Windows XP VM I use to compile Open Watcom (OW) boot projects. This VM is an image of my original XP Desktop install that I have IDA and a lot of unused junk, so I decided to build a barebones VM for just using OW compiling. Initially, I was going to use a Windows 7 install as a lightweight single purpose solution; however, that turned out to be a real pain. Even using a real DVD on Windows 7 seemed to be more trouble than it was worth, so I looked for another option. I finally settled on setting up and giving a ReactOS VM.

ReactOS System About
VirtualBox ReactOS VM

I was incredibly surprised that this worked very well. The VM is lightweight, and I have not had many issues of concern. The VM does not seem to restore correctly from a VirtualBox save, but loading is so fast it really does not matter. My work setup for this project is to code in Visual Studio Code for Linux with the source on a Synology NAS share. The share is mounted (systemd automount) in my home directory. The ReactOS VM shares this directory for access to the source and the VM mounts a FAT16 vdi which is my test image that gets booted using Bochs emulator running from a bash shell on my Linux system.

VS Code About GUI

The workflow is to code in VS Code (on Linux), compile and copy the binary to the FAT16 vdi image using the ReactOS VM, and run the test system using Bochs (Linux) using its internal debugger.

VSCode and ReactOS VM on Gentoo Desktop

More output…

I finally hooked up output from the detected serial port using a DosHelp routine, but it might short lived if I can’t use it after relocation.

Guess the best part is that the IODelay matches what I see with a debug kernel on the same machine.

LDRINFO: Loader initialized and running …
Serial out: COM1 Address 3F8 BPB 0X8800:0XB
FileTable 0X8800:0X124A Bootflags: 0X1481
LDR: 0X1000 microFSD: 0X8800 miniFSD: 0X7C endldr: 0X5000
COM: 0X3F8 0X0 0X0 0X0 LPT: 0X378 0X0 0X0
OS2LDR size: 19326 GenuineIntel Type: 0X6 Model: 0X8
IODelay: 244 T0: 0 T1: -2 T2: -263 A20 gate enabled INT15-C1 not supported
bus:dev:func 0:0:0 0:1:0 0:1E:0 0:1F:0 0:1F:1 0:1F:2 0:1F:3 0:1F:5
bus:dev:func 1:0:0* 1:0:1 bus:dev:func 2:3:0*
PCI BIOS 2.16 Number Bus: 3 Status: C00 :: EISA not found
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 – 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 – 00000000000a0000 (reserved)
BIOS-e820: 00000000000e0000 – 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 – 000000003fff06c0 (usable)
BIOS-e820: 000000003fff06c0 – 000000003fff66c0 (ACPI data)
BIOS-e820: 000000003fff66c0 – 000000003fffe700 (ACPI NVS)
BIOS-e820: 000000003fffe700 – 0000000040000000 (reserved)
BIOS-e820: 00000000fec00000 – 00000000fec01000 (reserved)
BIOS-e820: 00000000fee00000 – 00000000fee01000 (reserved)
BIOS-e820: 00000000fff80000 – 0000000100000000 (reserved)

LDRINFO: End message

DosHlp Routines

In brief, which is all I can do, the os2ldr contains some hardware dependent routines call DosHlp routines. Thanks to Pasha for pointing out that the ddk contains doshlp.inc which lists most of these (baseinc).

The os2ldr contains a table of offsets that is passed to the kernel. The following is a structure I put together from this information and what I saw from a disassembled os2ldr (SMP v104a). The unknowns are not listed in the doshlp.inc.

typedef struct _DOSHLPFUNCTIONS {
uint16_t TableVersion;
uint32_t DosHlpInit;
uint32_t DosHlpReboot;
uint32_t DosHlpNMI;
uint32_t DosHlpSizeMem;
uint32_t DosHlpConfig;
uint32_t DosHlpBaseDDList;
uint32_t DosHlpGetDriveParms;
uint32_t DosHlpInitSystemDump;
uint32_t DosHlpSystemDump;
uint32_t DosHlpReadSectors;
uint32_t DosHlpSerInit;
uint32_t DosHlpSetBaudRate;
uint32_t DosHlpSerIn;
uint32_t DosHlpSerOut;
uint32_t DosHlpToneOn;
uint32_t DosHlpToneOff;
uint32_t DosHlpGetMask;
uint32_t DosHlpSetMask;
uint32_t DosHlpSetRealMask;
uint32_t DosHlpSetProtMask;
uint32_t DosHlpSetDosEnv;
uint32_t DosHlpCallInt10;
uint32_t DosHlpProtGetMessage;
uint32_t DosHlpRealGetMessage;
uint32_t DosHlpRegisterTmrDD;
uint32_t DosHlpTmr16QueryTime;
uint32_t DosHlpEnableWatchdogNMI;
uint32_t DosHlpDisableWatchdogNMI;
uint32_t DosHlpInstallIRET;
uint32_t DosHlpDiscard;
uint32_t DosHlpInitInterrupts;
uint32_t DosHlpSetIRQMask;
uint32_t DosHlpSendEOI;
uint32_t DosHlpTmr32QueryTime;
uint32_t DosHlpTmrSetRollover;
uint32_t DosHlpInitNPX;
uint32_t DosHlpClrBusyNPX;
uint32_t DosHlpAckIntNPX;
uint32_t DosHlpWaitNPX;
uint32_t DosHlpValidNPXSwitch;
uint32_t DosHlpVNPXReset;
uint32_t DosHlpVNPXClrBusy;
uint32_t DosHlpWhyNMI;
uint32_t DosHlpAckNMI;
uint32_t DosHlpResetWatchdogNMI;
uint32_t DosHlpDisableCache;
uint32_t DosHlpFindParity;
uint32_t DosHlpEnableCache;
uint32_t DosHlpGetErrorLogPtr;
uint32_t DosHlpWriteErrorLog;
uint32_t DosHlpReadErrorLog;
uint32_t DosHlpResetParity;
uint32_t Unknown1;
uint32_t Unknown2;
uint32_t Unknown3;
uint32_t Unknown4;
uint32_t Unknown5;
uint32_t Unknown6;
uint32_t Unknown7;
uint32_t Unknown8;
uint32_t Unknown9;
uint32_t Unknown10;
uint32_t Unknown11;
} DOSHLPFUNCTIONS, *PDOSHLPFUNCTIONS;

osFree…

I have joined the osFree Project at Sourceforge and will keep a mirror of my loader project there.

In the process of hooking in the freeLdr micro-FSD calls, I found a real pain in the ass with BootableJFS. Each call to open clears the screen and displays their copyright message. This messes up any messages anyone else wants to display…

The fix? Well in the newest BootableJFS (as of 2008) Pasha has a turn off. At the JFS uFSD segment and offset 0x1944 a check is made for the byte value 0x0F. If this is set to anything else the message is not displayed.