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:
lis for load. Loads a sector into a given address.- Usage:
l <.4 hex address> <.4 hex LBA> - Example:
l 8000 0001
- Usage:
cis for call. Performs acallto 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.bincontains sop; that is, the bootsectorsymbols.txtis 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 0001andc 8000. PrintsHello world!.color, run withmake runcolor, no need to execute anything. Adds acolorcommand 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:
printzprints a null-terminated string to screenprint_charprints only one characterclearclears the screenget_linegets a line from keyboard input (blocks)get_chargets only one characterreadsectloads a sector from disk into memorydapack_lbacontains the LBA to load when you runreadsectdapack_offsetcontains 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,
retis not available, and one must jmp toSOP_cmd.