Osdev Notes

repository·master·Indexed 22 days ago

https://github.com/dreamportdev/osdev-notes

An educational resource and book guiding developers through building an x86_64 operating system kernel from scratch. The curriculum covers the build process (Multiboot2, Limine), architecture and drivers (GDT, APIC, PS/2 Keyboard), video output, memory management (Paging, VMM, Heap), scheduling (Processes, Threads, Locks), userspace transition (System Calls, ABI), Inter-Process Communication (IPC), Virtual File Systems (VFS), and ELF loading.

Tokens
86.1K
Snippets
187
Records
380
Agent score
76%

What's inside Osdev Notes

  1. Overview of the Kernel Build Process & Booting

    master

    The kernel build process involves setting up building scripts, selecting compilers, and choosing a bootloader. The process is broken down into several key stages:

    1. High-level Overview: Understanding the purpose of each step in the build pipeline.
    2. Boot Protocols & Bootloaders: Configuring the kernel to boot using protocols like Multiboot2 or Limine.
    3. Build Scripts: Using Makefiles to automate the compilation and linking process.
    4. Linker Scripts: Writing scripts to define how the kernel's code and data are laid out in memory.
    5. ISO Generation: Packaging the compiled kernel into a bootable ISO image for testing on emulators or real hardware.
  2. Overview of Osdev Notes

    master
    Osdev Notes is a comprehensive guide designed to walk a reader through the process of building an operating system kernel from scratch. The content covers the entire lifecycle of kernel development, starting from selecting a bootloader to successfully running a loaded ELF in userspace. The notes were developed through the practical experience of writing and rewriting multiple kernels.
  3. Overview of Userspace development in x86_64

    master

    This section of the notes covers the transition between supervisor mode (kernel) and user mode, specifically targeting the x86_64 architecture. It provides guidance on the lifecycle of a process, how to move between privilege levels, and how to manage resources once in userspace.

    Key topics covered include:

    • Switching modes between user and supervisor.
    • Interrupt handling while in User Mode.
    • Implementing and using System Calls.
    • Defining and implementing a System Call ABI (Application Binary Interface).
    • Resource management within the userspace environment.
  4. Overview of Video Output in Osdev Notes

    master

    The Video Output section provides guidance on implementing basic graphical capabilities in a custom operating system kernel. It focuses on two primary tasks:

    1. Framebuffer Management: Learning how to access a linear framebuffer and perform basic pixel plotting.
    2. Text Rendering: Loading a font into the kernel and rendering text directly onto the framebuffer.

    Refer to the specific chapters for implementation details on framebuffer access and font rendering.

  5. Explore the OS Development Architecture curriculum

    master

    The Architecture section of the Osdev Notes provides a structured learning path for low-level system development, covering kernel initialization, memory management, interrupt handling, and hardware drivers.

    Key topics include:

    • Kernel Basics: Overview of architecture topics, 'Hello World' kernel implementation, and moving the kernel to the Higher Half of memory.
    • Memory & CPU Management: Configuring the Global Descriptor Table (GDT) and managing memory segments.
    • Interrupts & Hardware Control: Handling CPU exceptions and external interrupts via the Advanced Programmable Interrupt Controller (APIC) and IOAPIC, parsing ACPI tables, and configuring system timers.
    • Device Drivers: A complete implementation guide for a PS/2 Keyboard driver, covering hardware overview, interrupt handling, and scancode-to-character translation.
  6. Explore future kernel development ideas in Going Beyond

    master
    The 'Going Beyond' section serves as a concluding overview for the OS development course. It provides high-level explanations of advanced kernel development concepts, the necessary prerequisites for implementation, and potential future directions for your project. This section is intended for developers who have completed the core curriculum and wish to extend their kernel's capabilities.
  7. Understand the structure and scope of Osdev Notes

    master

    Osdev Notes is a collection of notes designed to guide readers through building an operating system from scratch. The project focuses on concepts and theory, using x86_64 as the reference architecture. While the book is structured into sequential parts that add layers to a kernel, it is designed to be a jumping-off point for beginners.

    Core Curriculum Areas:

    • Build Process: Environment setup, toolchains, and kernel testing.
    • Architecture/Drivers: Hardware-specific components, data structures, and early drivers (e.g., keyboard, timer).
    • Video Output: Working with linear framebuffers and text display for debugging.
    • Memory Management: The full stack from physical memory management to virtual memory and the heap.
    • Scheduling: Implementation of processes, threads, and schedulers, including concurrency handling.
    • Userspace: Managing privilege levels and resource isolation.
    • Inter-Process Communication (IPC): Implementing controlled communication between isolated programs.
    • Virtual File System (VFS): Presenting file systems and implementing a 'tempfs' loaded from a tar archive (similar to initrd).
    • The ELF format: Writing a program loader for ELF64 binaries.
    • Appendices: Reference material covering debugging, language-specific info, and troubleshooting.
  8. Explore the Scheduling subsystem

    master

    The Scheduling section provides a structured learning path for understanding how task and thread scheduling works in an operating system. The curriculum is divided into four main areas:

    1. Scheduling Workflow Overview: Basic concepts and the general lifecycle of scheduling.
    2. The Scheduler: The core subsystem responsible for selecting the next process to run and performing housekeeping tasks.
    3. Processes and Threads: The fundamental units of execution.
      • Threads: Represent a stream of code and include a stack, saved register state, and an iret frame for context switching.
      • Processes: Represent a complete program, containing one or more threads, a Virtual Memory Manager (VMM), and resource handles (e.g., file descriptors).
      • Both entities support names and unique identifiers.
    4. Concurrency Control (Locks): Managing shared resource access when multiple processes or threads are running simultaneously.
  9. Explore Inter-Process Communication (IPC) implementations

    master

    The IPC section provides methods for allowing two processes to safely communicate with each other. The available implementations include:

    • Shared Memory: The simplest method, achieved by mapping the same physical memory into the address spaces of both processes.
    • Message Passing: A method that moves discrete packets of information between two processes.
  10. Explore the Virtual File System (VFS) module

    master

    The Virtual File System (VFS) module provides educational content on implementing a filesystem abstraction layer in an operating system. It covers theoretical foundations, internal component architecture, and practical implementations like a Tar-based filesystem for initramdisks.

    Key learning paths include:

    • High-level theory: Understanding why a VFS is necessary for OS design.
    • Internal mechanics: Detailed analysis of VFS components and implementation patterns.
    • Tar FS implementation: A practical example of a read-only, in-memory filesystem used for loading initial system files (initramdisk) from a tar archive provided by the bootloader.
  11. Curriculum and Chapter Roadmap

    master

    The guide is organized into several logical parts that follow the progression of OS development:

    • Part 0: Introduction: Assumed knowledge and author information.
    • Part 1: Building & Boot Protocols: Kernel building, bootloaders, Makefiles, Linker Scripts, and generating bootable ISOs.
    • Part 2: Architecture and Basic Drivers: GDT, Interrupts, ACPI, APIC, Timers, and PS2 Keyboard drivers.
    • Part 3: Video Output: Framebuffer implementation and text drawing.
    • Part 4: Memory Management: Physical memory, Paging, Virtual Memory Managers, and Heap Allocation.
    • Part 5: Scheduling: Schedulers, Processes, Threads, and Locks.
    • Part 6: Getting to Userspace: Mode switching, System Calls (ABI), and Resource Management.
    • Part 7: Inter-Process Communication: Shared Memory and Message Passing.
    • Part 8: File System: Virtual File Systems (VFS) and Tar File Systems.
    • Part 9: Loading & Executing ELFs: ELF theory and execution.
    • Part 10: Going Beyond: Advanced topics.
    • Appendices: Troubleshooting, C language info, NASM, Cross Compilers, Debugging, and Memory Protection.