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.
This commit is contained in:
Ilia Sharin 2026-04-23 12:16:52 -04:00
parent f07a368bf1
commit 21751c0025
172 changed files with 19701 additions and 0 deletions

View file

@ -0,0 +1,12 @@
[← Home](../README.md)
# Boot Sequence — Overview
## Section Index
| File | Description |
|---|---|
| [cold_boot.md](cold_boot.md) | Power-on to Kickstart: hardware init, ROM checksum |
| [kickstart_init.md](kickstart_init.md) | ROM scan, resident modules, ExecBase creation |
| [dos_boot.md](dos_boot.md) | BootStrap, eb_MountList, startup-sequence |
| [early_startup.md](early_startup.md) | Early Startup Control (ESC menu), boot priority |

View file

@ -0,0 +1,101 @@
[← Home](../README.md) · [Boot Sequence](README.md)
# Cold Boot — Power-On to Kickstart
## Overview
When the Amiga powers on or is reset (Ctrl-Amiga-Amiga), the 68000 CPU begins execution from the ROM. The boot process progresses from raw hardware init through to a fully running AmigaOS desktop in approximately 38 seconds.
---
## Hardware Initialisation (Pre-ROM)
### 1. CPU Reset Vector
The 68000 reads two longwords from address `$000000`:
```
$000000: Initial SSP (Supervisor Stack Pointer)
$000004: Initial PC (Program Counter) → ROM entry point
```
On Amiga, these locations map to Kickstart ROM at `$FC0000` (256 KB) or `$F80000` (512 KB). The ROM image contains:
- Word 01: SSP value (typically `$000400`)
- Word 23: PC value → ROM entry point
### 2. ROM Checksum
First code executed: compute checksum of entire ROM. If it fails → **red screen of death** (solid red background, no further boot).
```
Checksum: simple 32-bit additive checksum of all ROM longwords.
Result must equal $FFFFFFFF (complement to zero).
The last longword of the ROM is the complement value.
```
### 3. Chip Register Reset
```
- Write $7FFF to INTENA ($DFF09A) — disable all interrupts
- Write $7FFF to INTREQ ($DFF09C) — clear all pending interrupts
- Write $7FFF to DMACON ($DFF096) — disable all DMA
- CIA chips: reset timer, serial, port registers
```
### 4. Memory Detection
The ROM probes for available memory:
```
1. Test Chip RAM at $000000 by writing test patterns
2. Size Chip RAM: 256 KB, 512 KB, 1 MB, or 2 MB
3. Probe for Fast RAM at $C00000 (Ranger), $200000 (Slow/Ranger)
4. Probe for Zorro II auto-config space at $E80000
5. Probe for 32-bit fast RAM at $07000000+ (Zorro III)
```
### 5. Display Diagnostic Colours
During boot, the background colour indicates progress:
| Colour | Stage |
|---|---|
| Dark grey | ROM checksum passed |
| Light grey | Chip RAM sized |
| White | ExecBase initialised |
| Green flash | DOS boot starting |
| **Red** | ROM checksum fail |
| **Yellow** | Chip RAM test fail |
| **Blue** | Alert (Guru Meditation) |
---
## ROM Layout
### 256 KB ROM (Kickstart 1.x)
```
$FC0000$FFFFFF (256 KB)
$FC0000: Reset vectors (SSP + PC)
$FC0008: ROM header (version, checksum)
...
$FC0020: First resident module (exec.library)
...
$FFFFFC: Checksum complement word
```
### 512 KB ROM (Kickstart 2.0+)
```
$F80000$FFFFFF (512 KB)
$F80000: Reset vectors
$F80008: ROM header
...
$F80020: exec.library resident tag
...
$FFFFFC: Checksum complement
```
---
## References
- RKRM: *Hardware Reference Manual* — reset chapter

View file

@ -0,0 +1,121 @@
[← Home](../README.md) · [Boot Sequence](README.md)
# DOS Boot — Bootstrap, Mount List, Startup-Sequence
## Overview
After the Kickstart ROM initialises the kernel and resident modules, `dos.library` takes over to mount filesystems and run the user's startup scripts.
---
## Boot Sequence Flow
```
Kickstart ROM init complete
dos.library creates initial CLI process
BootStrap module (strap) reads boot block from boot device
Boot block executed (OFS/FFS bootblock code)
Mount configured devices from MountList (DEVS:DOSDrivers/)
Execute S:Startup-Sequence
Execute S:User-Startup
LoadWB (start Workbench)
```
---
## Boot Block Format
The first 2 sectors (1024 bytes) of a bootable disk:
```
Offset Size Description
$000 4 Boot block ID: "DOS\0" (OFS), "DOS\1" (FFS), etc.
$004 4 Checksum (complement to zero)
$008 4 Root block pointer (usually 880)
$00C ... Boot code (up to 1012 bytes of 68000 code)
```
### Boot Block Types
| ID | Hex | Type |
|---|---|---|
| `DOS\0` | `444F5300` | OFS (Old File System) |
| `DOS\1` | `444F5301` | FFS (Fast File System) |
| `DOS\2` | `444F5302` | OFS + International |
| `DOS\3` | `444F5303` | FFS + International |
| `DOS\4` | `444F5304` | OFS + Dir Cache |
| `DOS\5` | `444F5305` | FFS + Dir Cache |
| `DOS\6` | `444F5306` | OFS + Long Filenames (OS 3.2) |
| `DOS\7` | `444F5307` | FFS + Long Filenames (OS 3.2) |
---
## Boot Priority
Devices are booted in priority order. Highest priority device boots first:
| Device | Default Priority | Description |
|---|---|---|
| DF0: | 5 | First floppy drive |
| DH0: | 0 | First hard disk partition |
| DH1: | 5 | Second partition |
| DF1: | 10 | Second floppy |
Set in mountlist: `BootPri = 0` or via HDToolBox.
---
## Startup-Sequence
Standard `S:Startup-Sequence` for OS 3.1:
```
C:SetPatch QUIET ; apply ROM patches
C:AddBuffers DH0: 50 ; filesystem buffers
C:Version >NIL:
FailAt 21
MakeDir RAM:T RAM:Clipboards RAM:ENV RAM:ENV/Sys
Copy >NIL: ENVARC: RAM:ENV ALL NOREQ
Assign >NIL: T: RAM:T
Assign >NIL: CLIPS: RAM:Clipboards
Assign >NIL: REXX: S:
Assign >NIL: PRINTERS: DEVS:Printers
Assign >NIL: KEYMAPS: DEVS:Keymaps
Assign >NIL: LOCALE: SYS:Locale
Assign >NIL: LIBS: SYS:Classes ADD
Assign >NIL: HELP: LOCALE:Help DEFER
C:IPrefs
ConClip >NIL:
; Launch Workbench:
LoadWB
EndCLI >NIL:
```
---
## Early Startup Control (Boot Menu)
Hold **both mouse buttons** during boot to access the Early Startup Control menu:
| Option | Description |
|---|---|
| Boot With No Startup-Sequence | Skip S:Startup-Sequence |
| Boot Standard | Normal boot |
| Boot With: [device list] | Select boot device |
| Display Mode: [NTSC/PAL] | Override display standard |
---
## References
- RKRM: Boot chapter
- NDK39: `dos/dosextens.h` — BootStrap

View file

@ -0,0 +1,55 @@
[← Home](../README.md) · [Boot Sequence](README.md)
# Early Startup Control — Boot Options
## Overview
The **Early Startup Control** (ESC) menu appears when both mouse buttons are held during power-on or reset. It provides boot device selection, display mode override, and emergency recovery options.
---
## Activation
- **Both mouse buttons held** before the boot screen hand animation completes
- On A1200: hold both buttons during "floppy click" phase
- Requires Kickstart 2.0+ (not available on 1.3)
---
## Menu Options (OS 3.1)
```
┌──────────────────────────────────┐
│ EARLY STARTUP CONTROL │
│ │
│ Boot With No Startup-Sequence │
│ Boot Standard │
│ │
│ Boot Device: │
│ DF0: (pri 5) │
│ DH0: (pri 0) │
│ │
│ Display Mode: │
│ ● PAL ○ NTSC │
│ │
│ [BOOT] │
└──────────────────────────────────┘
```
---
## Recovery Scenarios
| Scenario | Fix |
|---|---|
| Corrupted Startup-Sequence | Boot with No Startup-Sequence, then `ED S:Startup-Sequence` |
| Wrong display mode (no image) | Hold both buttons → change PAL/NTSC |
| Boot from floppy instead of HD | Select DF0: as boot device |
| Assign loops / infinite boot | No Startup-Sequence → fix assigns manually |
---
## References
- RKRM: Early Startup chapter
- OS 3.1 AmigaGuide: `System/BootMenu`

View file

@ -0,0 +1,104 @@
[← 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