Contents:
Overview
Memory layout
Memory layout table
Machine state
Jumping to the kernel
The setup code checks the computer to make sure it's capable of running Swarm and passes control to the kernel. This document describes the conditions that need to be fullfilled by the setup code before starting the setup code.
When control is passed to the kernel physical memory should look
like this:
Address | Size (bytes) | Use |
0x000000 | 1024 | Real mode IVT |
0x000400 | 512 | BIOS parameter area |
0x000600 | 2560 | Memory layout table |
0x001000 | 4096 | BIOS parameter block |
0x002000 | 65536 | GDT |
0x012000 | 65526 | LDT |
0x022000 | 4096 | unused |
0x023000 | 4096 | Setup code (start of boot image) |
0x024000 | - | Kernel (second in boot image) |
- | - | Rest of boot image |
- | - | BIOS extended data area |
0x0A0000 | 131072 | Video display memory |
0x0C0000 | 262144 | BIOS ROMS |
Descriptor 0 | Used for LGDT [GDTaddress] (null) |
Descriptor 1 | Descriptor for LDT |
Descriptor 2 | Descriptor for setup (removed by kernel) |
Others | Filled by 0 |
The first four LDT descriptors should be:
Descriptor 0 | Flat kernel code descriptor |
Descriptor 1 | Flat kernel data descriptor |
Descriptor 2 | Flat user code descriptor |
Descriptor 3 | Flat user data descriptor |
Others | Filled by 0 |
The amount and location of free memory should be detected by the setup
code. This information is passed to the memory manager in a table. The
format of the table is:
Size | Use |
16 | Entry 0 |
? | Entries 1 - N |
4 | 0 terminator |
Size | Use |
4 | Type of memory block |
4 | Base address of block |
4 | Size of block (in pages) |
4 | Reserved (set to 0) |
Type | Meaning |
00000000 | Terminator |
00000001 | Free RAM |
The cpu must be in 32 bit protected mode with flat descriptors (no stack needed). The video mode should be 80x50x16. Gate A20 must be enabled and the floppy motor turned off. Also the IRQ's need to be remapped to interrupts 0x20 to 0x2F and all IRQ's should be disabled.
This is done by loading parameters into registers followed by a 32 bit far call:
jmp 0x04:0x24008
Parameters are:
EAX Cursor X position
EBX Cursor Y position