Skip to content

A minimal 64-bit operating system written in Assembly (NASM) that demonstrates the boot process from Real Mode to Protected Mode and finally into Long Mode with paging.

License

Notifications You must be signed in to change notification settings

MadhurKumar004/OS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Operating System

This project is a simple operating system written in assembly. It includes a bootloader, a protected mode kernel, and a transition to long mode with basic paging. The OS displays "HELLO WORLD" in protected mode and a blue screen in long mode.

Features

  • A bootloader that loads the kernel into memory.
  • Transition to protected mode and long mode.
  • Basic paging setup for identity mapping.
  • CPUID and long mode detection.
  • Displays "HELLO WORLD" in protected mode.
  • Displays a blue screen in long mode.

Requirements

  • Assembler: nasm (Netwide Assembler)
  • Emulator: qemu-system-x86_64

Install them on Linux:

sudo apt install nasm qemu-system-x86

Project Structure

OS/
├── Makefile                # Build automation
├── build_and_run.sh        # Script to build and run the OS
├── Sector1/                # Bootloader and utility functions
│   ├── bootloader.asm      # Bootloader code
│   ├── DiskRead.asm        # Disk reading function
│   └── print.asm           # Print function for debug messages
├── Sector2+/               # Kernel and supporting files
│   ├── ExtendedProgram.asm # Main kernel code
│   ├── gdt.asm             # Global Descriptor Table setup
│   ├── CPUID.asm           # CPUID and long mode detection
│   └── SimplePaging.asm    # Paging setup for long mode

How to Build and Run

Using the Makefile

  1. Build the OS:
    make
  2. Run the OS in QEMU:
    make run
  3. Clean up build files:
    make clean

Using the Script

  1. Run the build and execution script:
    ./build_and_run.sh

Execution Flow

  1. Bootloader:

    • Loads the kernel (Extended Program) into memory.
    • Jumps to the kernel at 0x7e00.
  2. Kernel:

    • Detects CPUID and long mode support.
    • Transitions to protected mode and sets up the GDT.
    • Sets up paging and transitions to long mode.
    • Displays "HELLO WORLD" in protected mode.
    • Displays a blue screen in long mode.

Debugging

To debug the OS, run QEMU with GDB support:

qemu-system-x86_64 -drive format=raw,file=os-img.bin -boot c -S -gdb tcp::1234

Then connect with GDB:

gdb
target remote localhost:1234

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A minimal 64-bit operating system written in Assembly (NASM) that demonstrates the boot process from Real Mode to Protected Mode and finally into Long Mode with paging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published