Stage 13
Boot Module
Modules in eXpOS are used to perform certain logical tasks, which are performed frequently. eXpOS modules serve various purposes like scheduling new process, acquiring and releasing resources etc. These modules run in kernel mode and are invoked only from the kernel module. Modules can be invoked from interrupt routines, other modules or the OS startup code.
The Boot module is responsible for initialization of all eXpOS data structures, user processes and also loading of all interrupt routines and modules.
According to the memory organization of eXpOS, the OS startup code is provided with only one memory page (page numer 1). However, the code for OS startup may exceed one page due to initialization of several OS data structures. So we design a module for the purpose of OS initialization. This module will be called the Boot module (module 7)
The idle process is run first to ensure that this process is scheduled at least once, so that its context gets initialized.
XSM supports eight modules - MOD_0 to MOD_7
CALL instruction pushes the IP+2 on the top of the kernel stack and starts execution of corresponding module. The RET instruction restores the IP+2 pushed earlier by the CALL instruction.
Kernel Stack Management during Kernel Module Calls
The register R0 is reserved for return value.
Module for the initialisation of OS is called BOOT MODULE
Role of the OS Startup Code
-
Minimalist Entry: In Stage 13, the Startup Code is no longer responsible for loading interrupts or initializing the INIT process directly.
-
Idle Setup: Its primary job is to load the Boot Module, set up a temporary kernel stack for the Idle Process, and call the Boot Module.
-
Final Transition: After the Boot Module returns, the Startup Code completes the Idle process setup and uses
ireturnto enter User Mode as PID 0 (Idle).
2. Role of the Boot Module (Module 7)
-
Centralized Loading: It loads all secondary data and code from disk to memory:
-
Library (Pages 63-64)
-
Interrupt Handlers (Timer, Console, Disk, INT 4-15)
-
Modules (0-6)
-
-
Process Initialization (INIT/PID 1): It sets up the Process Table and Page Table for the INIT process. It marks INIT as
CREATED. -
OS State Setup: It initializes global tables like the Memory Free List, System Status Table, and Terminal Status Table.
3. Critical Convention: PID 0 vs PID 1
-
In Stage 13, the Idle process (PID 0) is the first to run.
-
The INIT process (PID 1) is created and put in the
CREATEDstate. It will only begin running when the Timer Interrupt (Stage 14) or a scheduling event occurs.
4. Stack Management
-
The call from Startup Code to the Boot Module uses the Kernel Stack of the Idle process.
-
The
CALLinstruction pushes the return address onto this kernel stack, andRETin the Boot Module pops it to return control to the Startup Code.