Skip to content

Monolithic kernel and support libraries for riscv64 and x86_64.

License

Notifications You must be signed in to change notification settings

DeanoBurrito/northport

Repository files navigation

Huge stylish northport banner

All builds CI badge Latest Release Version

Northport is a monolithic kernel, written in C++ and booted via the Limine protocol. It currently supports x86_64 and riscv64 machines. This repo also contains a completely standalone support library (see libs/np-syslib).

Instructions for building it yourself are available here, and a more in-depth manual can be found under the releases tab or by cloning this repository and running make docs.

A brief summary of the current goals and features are listed below, or check the roadmap for a more granular view. Pre-built isos are made available at major feature milestones, but for the latest and greatest it's recommended to build from the master branch.

Project Goals

  1. To build a usable, extensible and relatively complete kernel. This means an smp-aware scheduler with support for heterogeneous processors, media stacks (graphics, audio and network) and a flexible driver infrastructure.
  2. Support for multiple architectures: the current targets are x86_64 and riscv64, but this may expand over time.
  3. Be self hosting, this includes cross compiling the system.
  4. Clean code and useful documentation.
  5. Usable on both virtual machines and real hardware.

An extended goal (previously goal #5) is to add a comfortable user experience: a window manager, basic programs like a text editor and file explorer.

Current Project Features

Kernel:

  • Support for multiple architectures: riscv64, x86_64.
  • Memory management:
    • Hybrid PMM, freelist for single page allocations and a slow path for allocations with constraints.
    • Modular and portable VMM, with demand paging options for anon and vfs backed memory. Inspired by the old SunOS design.
    • General purpose heap provided by slabs for smaller objects and a freelist for larger objects. Slab allocation can be accelerated by core-local caches, and several debug features are available.
  • Time management:
    • Global software clock, driven by a number of hardware timers: LAPIC, TSC, HPET, PIT, SBI timer.
    • Run levels, allowing kernel to selectively mask groups of interrupts and prevent execution being hoisted by the scheduler. This also means support for DPCs and APCs.
    • Scheduler with core-local and shared work queues, and work stealing.
    • Waitable events, with support for cancelling, timeouts and waiting on multiple events at once.
  • Filesystem:
    • File contents and metadata are sparsely cached in memory as needed. VFS nodes can also be destroyed and re-created as needed.
    • Robust tempfs driver provided within the kernel.
  • Drivers:
    • Loaded (and dynamically linked) on-demand, based on load conditions described in driver metadata.
    • Drivers, device descriptors and device APIs are organised in a tree, allowing parent drivers to provide functionality to child drivers and device nodes.
    • Dedicated driver API functions, based on C-language API for the target platform - meaning drivers can be written in any language, although all first-party drivers are C++.
  • Debugging:
    • Lock-free logging infrastructure, with per-core log buffers for maximum speed. Support for early log outputs via simple devices like uart chips or the built-in graphical terminal (based on gterm for Limine).
    • UB sanitizer, helpful for catching bugs or increasing code size.
    • Stack walker and symbol lookup, including symbols of loaded drivers. De-mangling C++ names not currently supported.

Build System:

  • Uses stock core tools and GNU make, runs anywhere (tm).
  • Xorriso is needed for generating bootable isos.

Glorious Screenshots

14/02/2024: Status bar showing virtual memory and driver statistics

14/02/2024: Device node tree being printed shortly after adding the IO manager.

Older Screenshots

11/10/2023: Kernel panic while loading a malformed driver from the initdisk.

20/11/2022: x86 and riscv kernels running side by side in qemu.

Related Projects

  • DreamOS64: another 64-bit OS by one of the northport contributors, Ivan G.
  • OSdev notes: a repository of notes about various osdev topics. Feel free to contribute!

This is a complete rewrite of the original. If you're looking for that, it's available on the archive-2022-version branch.