Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

WDe and GPT, booting DOS (Users)

posted by ecm Homepage E-mail, Düsseldorf, Germany, 02.11.2022, 11:21

> Largely the same information is encoded in the load settings for the lDebug
> BOOT commands at
> https://hg.pushbx.org/ecm/ldebug/file/b98dc45862ba/source/msg.asm#l1899
> (This is used by a single build of a loader that implements different
> protocols at run time.)

Quoting the MS-DOS v7 load protocol settings from this:

  istruc LOADSETTINGS
at lsKernelName,        dw msg.msdos7_kernel_name
at lsAddName,           dw msg.addname_empty
at lsMinPara,           dw 40h
at lsMaxPara,           dw 80h
at lsOptions,           dw LOAD_SET_DL_UNIT | LOAD_SET_SIDI_CLUSTER \
                         | LOAD_DATASTART_HIDDEN | LOAD_PUSH_DPT \
                         | LOAD_LBA_SET_TYPE | LOAD_MESSAGE_TABLE
at lsSegment,           dw 70h
at lsEntry,             dd 200h
at lsBPB,               dw 7C00h, -1
at lsCheckOffset,       dw 200h
at lsCheckValue,        db "BJ"
at lsName,              asciz "MSDOS7"
        iend


> > - the MS-DOS kernel is named IO.SYS.

Indeed the kernel name is IO.SYS

> > - the boot code of DOS71BSG.BIN loads IO.SYS at 0070:0000

Load address is linear 00700h (segment 70h)

> > - the boot code loads just the first 4 sectors of IO.SYS.

Technically the next loader at the start of IO.SYS expects that you load 2 KiB of it, regardless the sector size

> > - the boot code checks four bytes of loaded IO.SYS ( at pos 0 and pos
> 200h
> > )

The word at position 0 has the "MZ" signature, the word at position 200h a "BJ" signature

> > - the boot code loads SI:DI with the start cluster of IO.SYS

This appears to be only DI for FAT12/FAT16 file systems, though it is SI:DI for FAT32

> > - the boot code of MS-DOS jumps to 0070:0200 to switch control to the
> > kernel

Entrypoint is at 70h:200h, which will execute the "BJ" signature, which happens to be harmless: inc dx then dec dx. Visible at https://hg.pushbx.org/ecm/ldosboot/file/094041a616f5/iniload.asm#l796

> > - when jumping, there are a few values on the stack that IO.SYS might
> use.

The dword [SS:SP] holds the address of the IVT entry of interrupt 1Eh, that is the value 0:78h.

The dword [SS:SP + 4] holds the original contents of the int 1Eh vector

The dword [SS:BP - 4], while close to the stack, I wouldn't say it is "on the stack" exactly. Anyway, it holds the 32-bit sector number of the data of the first cluster in the FS (datastart). This includes the hidden sectors for the MS-DOS v6 and v7 load protocols, ie it is a value in the int 13h unit, not in the FS image.

The boot sector, much like for the FreeDOS load protocol, is stored at SS:BP. The MS-DOS initial loader actually uses its (E)BPB to load the remainder of its kernel.

Another part that is hardly "on the stack" is the message table. It is used in case of errors to display during the initial loader's operation. It is documented somewhat in https://hg.pushbx.org/ecm/ldebug/file/b98dc45862ba/source/msg.asm#l1860 and https://hg.pushbx.org/ecm/ldebug/file/b98dc45862ba/source/boot.asm#l2486 (The message table is the only part that my boot sector loaders do not provide even if MS-DOS v7 load protocol compatibility is enabled.)

Besides, DL passes the load int 13h unit and the third byte of the boot sector passed indicates whether to use the LBA extensions of int 13h to load from the load unit. It has to be a partition table type byte, where the values for FAT16 LBA and FAT32 LBA indicate to the initial loader to use LBA extensions.

---
l

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 113 users online (0 registered, 113 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum