sop
is short for Sector OPerations.
It's an overengineered x86 real mode BIOS bootsector (<=510 bytes) that implements a fully-working command line.
sop
is very extensible and easily hackable: you can add your own commands, make them run at boot, and alter the existing ones as well as internal behavior. All labels (aka function symbols) are public and can be monkeypatched and trampolined.
This terminal-like interface supports:
- Text-mode screen assertion
- ASCII-only BIOS keyboard with backspace support
- One-way scrolling
- Clearing
The command-line enters a prompt loop in which commands can be ran. Out of the box, there are two supported commands which allow bootstrapping an enhanced shell:
l
is for load. Loads a sector into a given address.- Usage:
l <.4 hex address> <.4 hex LBA>
- Example:
l 8000 0001
- Usage:
c
is for call. Performs acall
to a given address.- Usage:
c <.4 hex address>
- Example:
c 8000
- Usage:
Clone the repository and run make
. This will generate sop.bin
and symbols.txt
.
sop.bin
contains sop; that is, the bootsectorsymbols.txt
is a generated NASM source that addresses the labels (functions)
Have a look at what you can do first. If you have qemu
installed, run make run
.
Example extensions are available under examples/
. The following ship with sop:
helloworld
, run withmake runhelloworld
, and executel 8000 0001
andc 8000
. PrintsHello world!
.color
, run withmake runcolor
, no need to execute anything. Adds acolor
command which behaves like DOS' one.- Usage:
color 00<.2 hex color>
- Example:
color 00F1
- Usage:
If you want to develop an extension, copy examples/helloworld.asm
and build on top of that.
symbols.txt
includes addresses for SOP labels. These are the most useful:
printz
prints a null-terminated string to screenprint_char
prints only one characterclear
clears the screenget_line
gets a line from keyboard input (blocks)get_char
gets only one characterreadsect
loads a sector from disk into memorydapack_lba
contains the LBA to load when you runreadsect
dapack_offset
contains the addres into which to copy the sector
For usage reference and side-effects, check the comment on top of each function in sop's source.
Extensions can be loaded automatically by sop if their first byte is 0x69
.
- This can only happen with the first extension, the one located at disk's LBA #1.
- Unlike a regular sop extension,
ret
is not available, and one must jmp toSOP_cmd
.