amiga-bootcamp/02_boot_sequence/kickstart_init.md
Ilia Sharin 21751c0025 docs(amiga): complete AmigaOS 3.1/3.2 developer reference — 172 files across 17 sections
Comprehensive technical documentation covering:
- Hardware: OCS/ECS/AGA custom chip registers, Copper & Blitter deep dives
- Boot sequence: cold boot through startup-sequence
- Binary format: HUNK executable spec, relocation, debug info
- Linking & ABI: .fd files, LVO tables, register calling conventions
- Exec kernel: tasks, interrupts, memory, signals, semaphores
- AmigaDOS: file I/O, FFS/OFS layout, CLI/Shell scripting
- Graphics: planar bitmaps, Copper programming, HAM/EHB modes
- Intuition: screens, windows, IDCMP, BOOPSI
- Devices: trackdisk, SCSI, serial, timer, audio, keyboard
- Libraries: utility, expansion, IFFParse, locale, ARexx
- Networking: bsdsocket API, SANA-II, TCP/IP stack comparison
- Toolchain: GCC, vasm/vlink, SAS/C, NDK, debugging
- Reverse engineering: IDA/Ghidra setup, compiler fingerprints, case studies
- CPU & MMU: 68040/060 emulation libs, PMMU, cache management
- Driver development: SANA-II, Picasso96/RTG, AHI audio

All files include breadcrumb navigation. No local paths or proprietary content.
2026-04-23 12:17:35 -04:00

104 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[← Home](../README.md) · [Boot Sequence](README.md)
# Kickstart Initialisation — ROM Scan, ExecBase, Resident Modules
## Overview
After hardware init, the Kickstart ROM creates `ExecBase` and scans for **resident modules** — the OS components compiled into ROM. This process builds the entire OS kernel from tagged structures embedded in the ROM image.
---
## ExecBase Creation
1. Allocate ExecBase structure at a known address (end of Chip RAM)
2. Initialise memory lists, library list, device list, resource list
3. Store ExecBase pointer at **address `$000004`** — the global `SysBase`
4. Initialise the Supervisor stack, interrupt vectors, trap vectors
```
After this step:
*(ULONG *)4 == ExecBase pointer
SysBase->LibNode.lib_Version == Kickstart version
```
---
## Resident Module Scan
The ROM scanner searches for **RomTag** markers (`$4AFC`) throughout the ROM address range:
```c
struct Resident {
UWORD rt_MatchWord; /* $4AFC — magic marker */
struct Resident *rt_MatchTag; /* pointer to self (verification) */
APTR rt_EndSkip; /* skip past this address */
UBYTE rt_Flags; /* RTF_COLDSTART, RTF_SINGLETASK, etc. */
UBYTE rt_Version; /* version number */
UBYTE rt_Type; /* NT_LIBRARY, NT_DEVICE, NT_RESOURCE */
BYTE rt_Pri; /* init priority (higher = earlier) */
char *rt_Name; /* module name */
char *rt_IdString; /* version string */
APTR rt_Init; /* init function or auto-init table */
};
```
### Scan Algorithm
```
for addr in ROM_START to ROM_END step 2:
if *(UWORD *)addr == $4AFC:
tag = (struct Resident *)addr
if tag->rt_MatchTag == tag: /* self-pointer validates */
add to resident list
addr = tag->rt_EndSkip /* skip past module */
```
---
## Initialisation Phases
Residents are initialised in **priority order** within each phase:
### Phase 1: RTF_COLDSTART (flags bit 0)
Called during cold boot, single-tasking (no scheduler yet):
| Priority | Module | Description |
|---|---|---|
| 126 | `exec.library` | Core kernel |
| 120 | `expansion.library` | AutoConfig Zorro boards |
| 105 | `68040.library` | CPU trap handlers (if present) |
| 100 | `utility.library` | Tag/hook support |
| 70 | `graphics.library` | Display init |
| 50 | `layers.library` | Clipping layers |
| 50 | `intuition.library` | GUI subsystem |
| 40 | `timer.device` | Timing services |
| 30 | `keyboard.device` | Keyboard |
| 20 | `input.device` | Input event merging |
| 10 | `trackdisk.device` | Floppy |
| 50 | `dos.library` | AmigaDOS file system |
| 120 | `ramlib` | Disk-based library/device loader |
### Phase 2: RTF_SINGLETASK
Runs after all COLDSTART modules but before multitasking begins. Used by strap (bootstrap) module.
### Phase 3: RTF_AFTERDOS
Runs after DOS is available. External disk-based modules.
---
## After Resident Init
1. Multitasking enabled (scheduler starts)
2. `dos.library` creates initial CLI process
3. Boot task launches `strap` → reads boot block from DF0: or boot device
4. Control passes to `startup-sequence`
---
## References
- NDK39: `exec/resident.h`
- RKRM: Resident modules chapter