Generic autoboot / automount RDB parser and mounter.
This mounter is used by various Amiga disk controller drivers, including
a4091.device (A4091/A4092) and lide.device (LIDE).
This Mounter software is a generic, autoboot/automount Rigid Disk Block (RDB) parser and mounter for AmigaOS. It was originally developed by Toni Wilen and extended by Stefan Reinauer and Matt Harlum. It is meant to be built into device drivers that need to mount partitions and filesystems at boot time.
It is designed to be highly portable, 68000-compatible, and capable of operating in diverse environments, from a Kickstart 1.3 Boot ROM to a modern AmigaOS system. Its primary function is to scan the units of a device driver, interpret their partition maps (RDB, and optionally MBR/GPT), load the necessary filesystems, and make the partitions available to the operating system.
- Broad OS Compatibility: Full support for Kickstart 1.3 and newer, including autoboot on Kickstart 1.3.
- CPU Compatibility: Compatible with the Motorola 68000 processor, ensuring it runs on all classic Amiga models.
- Autoboot Capability: When run from a Boot ROM (before
dos.libraryis available), bootable partitions are added as boot nodes so the system can boot from them. - Full Automount Support: Automatically finds and mounts all partitions
that are not flagged
PBFF_NOMOUNT. - Partition Formats:
- RDB: Full support for the Amiga Rigid Disk Block (RDB) standard,
including loading filesystems stored in the RDB (
FSHD/LSEG). All RDB blocks are checksum-verified, honoringSummedLongs. - MBR & GPT (optional, build with
DISKLABELS): PC-style partition tables. Only FAT partitions are mounted (MBR partitions, and GPT partitions of type "Microsoft Basic Data"), asMS0:..MS9:, using aFAT\1(0x46415401, e.g. FAT95) filesystem. - CD-ROM (optional,
cdBoot): Booting from ISO 9660 CDs whose system identifier isAMIGA BOOTorCDTV, and from CDs that carry an RDB instead of an ISO 9660 volume descriptor.
- RDB: Full support for the Amiga Rigid Disk Block (RDB) standard,
including loading filesystems stored in the RDB (
- Filesystem Loading: Filesystems can come from the RDB, from
FileSystem.resource, or from the driver itself via theLoadFileSyscallback (e.g. a filesystem stored in the controller's ROM). - LUN Support: Can scan for and mount devices on multiple Logical Unit Numbers (LUNs).
- RDB Flags: Honors
RDBFF_LAST(stop scanning further units, unlessignoreLastis set) andRDBFF_LASTLUN(stop scanning further LUNs).
The Mounter's architecture is centered around a single primary entry point,
MountDrive(), which orchestrates the entire mounting process. It opens the
given device driver for each unit, and attempts to identify and mount
partitions.
-
struct MountStruct(mounter.h): This is the main input structure passed to theMountDrivefunction. It defines the parameters for a mounting session.deviceName: The name of the device driver to use (e.g.,scsi.device).unitNum: The units to scan. IfNULL,MountDrive()scans SCSI targets 0-7, skippinghostId. Otherwise it points to an array ofULONGs: the number of units, followed by the unit numbers, e.g.{ 3, 0, 1, 2 }. The entries are passed toOpenDevice()as they are (LUN 0), so a wide SCSI target above 7 must be given in the Phase V form,target * 10 + 8.hostIdis not applied to the list. Iflunsis set, the mounter adds the LUN to each unit number itself.creatorName: A string to identify the creator of the filesystem entries added toFileSystem.resource. May beNULL.configDev: A pointer to theConfigDevstructure of the autoconfig board. It is passed toAddBootNode()for bootable partitions.SysBase: A pointer to the Exec library base.LoadFileSys: An optional callback that lets the driver provide a filesystem (for example from its ROM). It is called with the wanted DosType(s) and should add the filesystem toFileSystem.resource. Set toNULLif not used.LoadFileSysCtx: Context pointer passed to theLoadFileSysfunction.luns,slowSpinup,cdBoot,ignoreLast: Boolean flags to control LUN scanning, spin-up delays, CD booting, and whether scanning continues to later device units after an RDB withRDBFF_LASTis found.hostId: The host controller's own SCSI ID, which is skipped during the default scan (unitNumisNULL). Set to 255 for non-SCSI controllers.
-
struct MountData(mounter.c): An internal state-management structure used during theMountDriveexecution. It holds pointers to opened libraries, the I/O request, the block size, and state variables for the scanning process.
The logical flow of the MountDrive function is as follows:
-
Initialization:
- Open
expansion.library(required) anddos.library(optional). Whetherdos.librarycould be opened decides whether partitions are added as boot nodes (Boot ROM mode) or mounted directly. - Allocate a
MountDatastructure to hold operational state. - Create a message port and an I/O request for communicating with the device driver.
- Open
-
Device Scanning Loop:
- Iterate through the units in
unitNum(or SCSI targets 0-7, skippinghostId, ifunitNumisNULL), and through LUNs 0-7 of each unit iflunsis set. - For each unit, attempt to
OpenDevice().
- Iterate through the units in
-
Partition Scheme Identification:
- If a device is opened successfully, get its geometry using
TD_GETGEOMETRY. - Based on the device type, determine the scanning strategy.
- For Direct Access Devices (
DG_DIRECT_ACCESS):- Attempt to find an RDB by scanning the first
RDB_LOCATION_LIMITblocks (ScanRDSK). - With
DISKLABELSonly: if no RDB is found, check for a GUID Partition Table (GPT) at block 1, then for a Master Boot Record (MBR) at block 0 (ScanMBR).
- Attempt to find an RDB by scanning the first
- For CD-ROM Devices (
DG_CDROM,DG_WORM,DG_OPTICAL_DISK), only ifcdBootis set (ScanCDROM):- Check that a disc is inserted and that track 1 is a data track.
- Read the ISO 9660 Primary Volume Descriptor (
CheckPVD). - If there is no PVD, scan for an RDB (
ScanRDSK). - If there is a PVD with system identifier
AMIGA BOOTorCDTV, mount the CD asCD0:(bootable, priority 2) using aCD01orCDVDfilesystem. CDs with any other system identifier are ignored.
- If a device is opened successfully, get its geometry using
-
Partition Processing:
- Call the appropriate parsing function (
ParseRDSK,ParseGPT,ParseMBR). - These functions iterate through partition entries.
- Call the appropriate parsing function (
-
Filesystem Loading & Mounting (RDB):
- For each partition without
PBFF_NOMOUNT,ParsePARTis called. - It reads the partition's
DosEnvecto determine the required filesystemDosType. - It calls
ParseFSHDto find or load the required filesystem.ParseFSHDwalks the RDB's FileSystem Header Blocks (FSHD). If one matches theDosTypeand is newer than the version inFileSystem.resource(or there is none there), the filesystem is loaded from itsLSEGblocks. Otherwise theLoadFileSyscallback is called (if set) and the filesystem is taken fromFileSystem.resource. - The loaded filesystem code is relocated in memory using the
fsrelocatefunction. - Duplicate DOS device names get a
.1,.2, ... suffix. - A
DeviceNodeis created usingMakeDosNode()and populated with the partition's parameters and the filesystem's patch flags. - If
dos.libraryis not available yet (Boot ROM mode) and the partition is bootable, it is added withAddBootNode(). Otherwise it is mounted withAddDosNode().
- For each partition without
-
Cleanup:
- The drive motor is turned off and the device is closed.
- The loop continues to the next LUN/target, unless
RDBFF_LASTLUN/RDBFF_LASTstops it. - After the loop, all allocated resources (I/O requests, ports, library bases) are freed.
A critical function is fsrelocate, which loads Amiga HUNK-formatted
filesystem binaries from disk into memory.
- It starts by reading a
HUNK_HEADER. - It pre-allocates memory for all hunks (
HUNK_CODE,HUNK_DATA,HUNK_BSS) defined in the header. - It reads each hunk's data from the LSEG (Load Segment) blocks on disk.
- It processes relocation hunks (
HUNK_RELOC32,HUNK_RELOC32SHORT) to resolve memory address pointers within the loaded code and data, making the filesystem executable from its new location in RAM. - Finally, on Kickstart 2.0 and newer, it calls
CacheClearU()to ensure instruction caches are flushed before the OS attempts to execute the newly loaded code.
The mounter interacts carefully with the central FileSystem.resource.
FSHDProcessis responsible for checking if a required filesystem (identified byDosType) is already present in the resource list.- If a filesystem is not present, or if the version on disk is newer than the
one in memory, it allocates a new
FileSysEntry. - After a filesystem is successfully loaded and relocated by
fsrelocate,FSHDAddadds the newFileSysEntrytoFileSystem.resource, making it available for all subsequent mounting operations system-wide. - If
FileSystem.resourcedoes not exist (common on KS 1.3), it is created.
To maintain compatibility with Kickstart 1.3, which lacks certain OS functions, the mounter includes its own implementations:
W_CreateMsgPort/W_DeleteMsgPortW_CreateIORequest/W_DeleteIORequest
These functions use AllocMem() to create the necessary structures and manage
signals manually, mimicking the behavior of their modern counterparts. For
autobooting, it manually creates and inserts a BootNode into the
expansion.library's MountList, as AddBootNode() does not exist on KS
1.3. When mounting without autoboot on KS 1.3, it starts the filesystem
process with DeviceProc(), since ADNF_STARTPROC is not supported there.
When a bootable partition is found and dos.library is not available yet
(i.e. the mounter runs from a Boot ROM during autoconfig), it uses
AddBootNode() instead of AddDosNode(). This links the partition to the
autoconfig board given in configDev, signaling to the OS that this is a
candidate for booting. When dos.library is available, partitions are
mounted right away and are not boot candidates.
When built with NO_CONFIGDEV, and no configDev is provided, the mounter
creates a "fake" ConfigDev to enable autobooting from devices that are not
on a standard autoconfig chain. This requires the driver to provide the
entrypoint and bootblock symbols.
A4091: Build fora4091.device. Uses the driver's own geometry function, enablesprintfoutput, and waits for drives that are not ready yet.DISKLABELS: Enable MBR and GPT support. Requireslegacy.h.NO_CONFIGDEV: Enable the fakeConfigDevdescribed above.DEBUG_MOUNTER: In thea4091.devicebuild, send the mounter's debug output to the serial port.
The Mounter relies on the following standard AmigaOS libraries:
exec.library(v34+): For memory management, tasking, ports, and core system functions.expansion.library(v34+): For adding boot nodes and interacting with the autoconfig process.dos.library(v34+, optional): For starting filesystem processes on Kickstart 1.3. Its absence selects Boot ROM (autoboot) mode.
Copyright 2021-2022 Toni Wilen
Copyright 2022-2026 Stefan Reinauer
Copyright 2023-2026 Matt Harlum
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.