Difference between revisions of "The NitrOS-9 Boot Process Explained"

From NitrOS-9
Jump to: navigation, search
m (Add link to new "More about the NitrOS-9 Boot file" page. Fix typo.)
Line 36: Line 36:
 
Track 34 consists of 18 sectors of 256 bytes each; a total of 4,608 ($1200) bytes. The first 2 bytes of KERNELFILE are 'O' and 'S'; executable code starts at offset 2 (the 3rd byte) and is a BRA to the entry point of the REL module.
 
Track 34 consists of 18 sectors of 256 bytes each; a total of 4,608 ($1200) bytes. The first 2 bytes of KERNELFILE are 'O' and 'S'; executable code starts at offset 2 (the 3rd byte) and is a BRA to the entry point of the REL module.
  
[[More about the NitrOS-9 Kernel file]]
+
[[More about the NitrOS-9 Kernel file]] [[More about the NitrOS-9 Boot file]]
  
 
The boot process proceeds like this:
 
The boot process proceeds like this:
 
<ol>
 
<ol>
<li>REL copies the book track ($2600 to $3800) to address $ED00, and jumps to another routine inside of REL at the new address</li>
+
<li>REL copies the boot track ($2600 to $3800) to address $ED00, and jumps to another routine inside of REL at the new address</li>
 
<li>REL then jumps to KRN (OS9P1), which sets up system variables, the system memory map, system call tables, IRQ and SWI setup, and calls BOOT.</li>
 
<li>REL then jumps to KRN (OS9P1), which sets up system variables, the system memory map, system call tables, IRQ and SWI setup, and calls BOOT.</li>
 
<li>BOOT reads sector $000000 off of a disk, and finds out where the OS9Boot file is.</li>
 
<li>BOOT reads sector $000000 off of a disk, and finds out where the OS9Boot file is.</li>

Revision as of 15:15, 21 May 2017

The NitrOS-9 boot process involves 2 binary lumps. The first is named (in the makefile target) KERNELFILE_xxx and the second is named BOOTFILE_yyy - where xxx and yyy identify variants targeting different hardware configurations. In this description they will be called KERNELFILE and BOOTFILE respectively.

In each case, the lump is created by concatenating multiple NitrOS-9 binary modules. This works because each module is relocatable code and because there is a header on each module which allows the modules to be treated as a linked list that is searchable by module name.

KERNELFILE is written to track 34 of the boot disk and is the first part of NitrOS-9 to be loaded and executed. BOOTFILE is stored in the filesystem of the boot disk just like any other file. However, the LSN (the Logical Sector Number) at which the BOOTFILEFILE starts on the disk is coded into the LSN0, which is a data structure stored at the first block on the disk.

Coding the start address into the LSN0 makes the process of reading KERNELFILE from disk into memory simpler -- the driver that performs this task does not need to include code that understands the file-system. However, it does impose a couple of restrictions:

  • (At least on some systems) the KERNELFILE_xxx must use contiguous blocks on the disk -- it must not be fragmented.
  • In order to use a modified KERNELFILE_xxx on a disk, the LSN0 must be re-written.

When creating disk images on a non-NitrOS-9 host system, the Toolshed os9 tool's "gen" command is used to set up LSN0 as part of the build process. For example, from level1/mc09/makefile:

        $(OS9FORMAT_DS80) -q $@ -n"NitrOS-9/$(CPU) Level $(LEVEL)"
        $(OS9GEN) $@ -b=$(BOOTFILE_COVDG_SD80) -t=$(KERNELFILE_COCOSDC)
  • the -t argument specifies the KERNELFILE; the file to be written to track 34
  • the -b argument specifies the BOOTFILE; the file whose start LSN must be written into LSN0.

In order to start the boot process, some command must be issued on the system to load and execute track 34.

On a CoCo this is typically done from the Disk Extended Color BASIC (DECB) 'OK' prompt. Typing 'DOS' at the prompt loads track 34 from the disk into memory at $2600 and jumps to address $2602. At this point, control has passed to NitrOS-9.

Track 34 consists of 18 sectors of 256 bytes each; a total of 4,608 ($1200) bytes. The first 2 bytes of KERNELFILE are 'O' and 'S'; executable code starts at offset 2 (the 3rd byte) and is a BRA to the entry point of the REL module.

More about the NitrOS-9 Kernel file More about the NitrOS-9 Boot file

The boot process proceeds like this:

  1. REL copies the boot track ($2600 to $3800) to address $ED00, and jumps to another routine inside of REL at the new address
  2. REL then jumps to KRN (OS9P1), which sets up system variables, the system memory map, system call tables, IRQ and SWI setup, and calls BOOT.
  3. BOOT reads sector $000000 off of a disk, and finds out where the OS9Boot file is.
  4. BOOT requests system memory for the size of OS9Boot, seeks to where OS9Boot is, and loads it directly into RAM.
  5. It then returns to KRN (OS9P1), after setting up pointers in low memory to the OS9Boot file.
  6. KRN (OS9P1) links to KRNP2 (OS9P2), and jumps into its execution entry point.
  7. KRNP2 (OS9P2) sets up more system calls, links to the CLOCK module, and calls it.
  8. CLOCK sets up some more system calls, starts multitasking, and returns to KRNP2.
  9. KRNP2 then does F$Chain of SYSGO (CC3GO). This prints a start up banner, and runs your 'startup' file through a shell.


References: