mirror of
https://github.com/alfishe/amiga-bootcamp.git
synced 2026-06-13 00:26:28 +00:00
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.
97 lines
2.6 KiB
Markdown
97 lines
2.6 KiB
Markdown
[← Home](../README.md) · [Exec Kernel](README.md)
|
|
|
|
# Library System — OpenLibrary Lifecycle
|
|
|
|
## Overview
|
|
|
|
The AmigaOS library system provides **versioned, shared code** via a standardised interface. Libraries are identified by name, opened with a version check, and reference-counted for safe unloading.
|
|
|
|
---
|
|
|
|
## Library Node
|
|
|
|
Every library is an `NT_LIBRARY` node on `SysBase->LibList`:
|
|
|
|
```c
|
|
struct Library {
|
|
struct Node lib_Node; /* ln_Name = "dos.library" */
|
|
UBYTE lib_Flags; /* LIBF_SUMUSED | LIBF_DELEXP */
|
|
UBYTE lib_Pad;
|
|
UWORD lib_NegSize; /* size of JMP table in bytes */
|
|
UWORD lib_PosSize; /* size of library base struct */
|
|
UWORD lib_Version; /* major version */
|
|
UWORD lib_Revision; /* minor revision */
|
|
APTR lib_IdString; /* "dos.library 40.1 (16.7.93)" */
|
|
ULONG lib_Sum; /* JMP table checksum */
|
|
UWORD lib_OpenCnt; /* reference count */
|
|
};
|
|
```
|
|
|
|
---
|
|
|
|
## OpenLibrary / CloseLibrary
|
|
|
|
```c
|
|
/* Open — get a reference: */
|
|
struct DosLibrary *DOSBase =
|
|
(struct DosLibrary *)OpenLibrary("dos.library", 40);
|
|
|
|
/* Use the library ... */
|
|
|
|
/* Close — release reference: */
|
|
CloseLibrary((struct Library *)DOSBase);
|
|
```
|
|
|
|
Internally:
|
|
1. `exec` scans `LibList` for `ln_Name == "dos.library"`
|
|
2. If not found, searches resident list and `LIBS:` path
|
|
3. If found on disk: `LoadSeg` + call `InitLib`
|
|
4. Check `lib_Version >= requested_version`
|
|
5. Call library's `Open()` vector → `lib_OpenCnt++`
|
|
6. Return library base
|
|
|
|
---
|
|
|
|
## Library Flags
|
|
|
|
| Flag | Value | Meaning |
|
|
|---|---|---|
|
|
| `LIBF_SUMUSED` | 0x01 | Checksum is maintained |
|
|
| `LIBF_CHANGED` | 0x02 | Checksum needs recalculation |
|
|
| `LIBF_DELEXP` | 0x04 | Expunge deferred (opened while expunge pending) |
|
|
|
|
---
|
|
|
|
## Version Numbering Convention
|
|
|
|
`lib_Version.lib_Revision`:
|
|
- `40.1` = OS 3.1 release
|
|
- `40.x` = OS 3.1 (various revisions)
|
|
- `44.x` = OS 3.2
|
|
|
|
Increment rules:
|
|
- `lib_Revision` — minor bugfix, compatible
|
|
- `lib_Version` — API change or major update (requestors check this)
|
|
|
|
---
|
|
|
|
## Finding a Library Without Opening
|
|
|
|
```c
|
|
/* Read-only peek — no open count increment */
|
|
Forbid();
|
|
struct Library *lib = FindName(&SysBase->LibList, "graphics.library");
|
|
Permit();
|
|
if (lib) printf("Found v%d\n", lib->lib_Version);
|
|
```
|
|
|
|
> [!CAUTION]
|
|
> Using `FindName` without `Forbid()` is a race condition — the library could be expunged between finding it and using it.
|
|
|
|
---
|
|
|
|
## References
|
|
|
|
- NDK39: `exec/libraries.h`
|
|
- ADCD 2.1: `OpenLibrary`, `CloseLibrary`, `FindName`
|
|
- `04_linking_and_libraries/shared_libraries_runtime.md` — expunge lifecycle
|