# Oberon/ETH Oberon/bootstrap

This document was originally hosted at the ETHZ. It remains under the ETH license and is in the WayBack archive.
The purpose of this document is to explain how an operating system is started starting from nothing (i.e. the bootstrap mechanism) in a systematic and progressive manner, from the simplest case of a single operating system setup, to a more complex and more demanding multi-boot manager setup including the cascading of boot loaders. Each operating system has its own boot sector on the installation medium and several of them will be reviewed here, but the generic aspect will be emphasized to facilitate the understanding of the details of the mechanism used for starting an OS.
The alternative ways to start an operating system will be reviewed in the order:
* boot directly from diskette: a diskette is a single partition storage medium (described in this document)
* boot a partition indirectly via the MBR of a (potentially multiple partition) mass storage medium
* boot via boot manager, commonly used in a multiple operating systems environment
* boot indirectly via another operating system, e.g. via DOS with noboot.exe (Oberon), or loadlin.exe (Linux)
* boot a virtual operating system hosted in a file (in FatFS or in Linux FS)
The recipe is generally applicable to most OSes but the focus is placed on ETH Oberon, the OS we are interested in.
This part is common to all x86-based machines, but some differences will be observed depending on the BIOS provided by different manufacturers and the BIOS set-up can differ from machine to machine too.
At the completion of a system's Power On Self Test (POST), the BIOS bootstrap routine generates an INT 19. Usually, INT 19 tries to read a boot sector from the first floppy drive (see next section "Boot directly from diskette"). If a boot sector is found on the floppy diskette, that boot sector is read into memory at location 0000:7C00 and the BIOS checks that the last two bytes of the sector are "55 AA". If that is correct, the routine jumps to memory location 0000:7C00 to execute the boot loader program in charge of loading and starting the operating system (it starts with the kernel).
If the last two bytes do not contain the "55 AA" signature, a BIOS-dependant message such as "Non-bootable disk" or "Non-System" is issued and the machine will halt.
However, if no boot sector is found on the first floppy drive, INT 19 tries to read the MBR from the first hard drive. If an MBR is found it is read into memory at location 0000:7C00 and INT 19 jumps to memory location 0000:7C00. The small program in the MBR will attempt to locate an active (bootable) partition in its partition table in a simple case. Alternatively, it can be the starting part of a boot manager program.
INT 19 is also called when the Ctrl-Alt-Del keys are pressed. On most systems, Ctrl-Alt-Del causes a short version of the POST to be executed before INT 19 is called.
A simple and stable manner of starting an operating system, with the inconvenience of being comparatively slow. Most manufacturers recommend creating rescue floppy diskette(s) for use in case of difficulty starting the operating system of concern.
The prerequisites are:
* the machine must be equipped with a diskette drive. This cannot be the case for newer non-legacy machines.
* the BIOS set-up must give precedence to the floppy drive. In case two floppy drives are installed, it is possible to switch the A and B drives via the BIOS setup or by switching the cables in older machines whose BIOS does not support software switching.
* a bootable diskette must be available. For ETH Oberon cf. Diskette support.
Advantage: The possible difficulties encountered with the installation of an MBR or a boot manager are eliminated.
The complete ETH Oberon boot loader (OBL) assembly code is found in OBL.Asm and its compiled form in OBL.Bin.
An OBL is written in the first 4 sectors in an Oberon partition (type 76) when a Partitions.Format command is executed. A partition occupies an entire floppy diskette. The same applies to a partition on a mass storage device. The difference is that in the latter case OBL becomes the second stage loader after the first stage loader placed in the MBR.
The structure of the boot sector is:
When Oberon is running, the boot sector is displayed by executing: Partitions.ShowBlocks dev#part 0 1 ~. The same information can be obtained using the facilities of your preferred operating system or third-party software (commercial, shareware, ...).
Read "How it works: DOS Floppy Disk Boot Sector" by Hale Landis.
Read "Example Boot Sector"
19 Mar 2008 - Copyright © 2002 ETH Zürich. All rights reserved. E-Mail: oberon-web at inf.ethz.ch [expired] Homepage: http://www.ethoberon.ethz.ch/ [expired]