How To Build An Operating System: User Modes- Part 06

User Mode

Loading an External Program

GRUB Modules

module /modules/program
mkdir -p iso/modules
MAGIC_NUMBER  equ 0x1BADB002      ; define the magic number constant
ALIGN_MODULES equ 0x00000001 ; tell GRUB to align modules

; calculate the checksum (all options + checksum should equal 0)

section .text: ; start of the text (code) section
align 4 ; the code must be 4 byte aligned
dd MAGIC_NUMBER ; write the magic number
dd ALIGN_MODULES ; write the align modules instruction
dd CHECKSUM ; write the checksum

Executing a Program

Finding the Program in Memory

int kmain(/* additional arguments */ unsigned int ebx)
multiboot_info_t *mbinfo = (multiboot_info_t *) ebx;
unsigned int address_of_module = mbinfo->mods_addr;
typedef void (*call_module_t)(void);
call_module_t start_program = (call_module_t) address_of_module;
/* we'll never get here, unless the module code returns */




Software Engineering Undergraduate at University of Kelaniya

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Costing a bus operation by municipality from a GTFS with R

Getting Started with DataBricks — Community Edition for PySpark

Adventures Getting R and Swagger 2.0 Together

Python GIL: a case study.

Jenkins & Its Use Cases

Why I Decided to Learn Software Engineering

Laptop Lenovo IdeaPad 1 14" (64 GB eMMC, AMD A6 A6–9220e, 1,60 GHz, 4GB)

Factory Method Design Pattern

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pubudu Wickramathunge

Pubudu Wickramathunge

Software Engineering Undergraduate at University of Kelaniya

More from Medium

4 Areas of GIT

Snake JARs, Part I: Hidden log4j Dependencies in Python Packages

Histogram of log4j JAR file frequency in Python PyPI packages

Prototype Pollution HIGH vulnerability in ‘mixme’ NPM package

Logs management with Datadog Agent on Docker container