|
IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
|
IgrOS-Kernel is a hobby operating system kernel written in modern C++20 with a thin layer of assembly. It boots via Multiboot (GRUB) on i386 and x86_64, sets up the CPU (GDT, IDT, exceptions, interrupts, paging), manages physical memory and drives basic PC hardware: VGA text mode, serial port, PIT timer, keyboard and CMOS clock.
| CI/CD | |
| Codacy | |
| SonarCloud |
| Area | Implemented | Planned |
|---|---|---|
| Boot | Multiboot (GRUB), protected mode (i386), long mode switch (x86_64) | Multiboot 2, custom bootloader |
| CPU | GDT, IDT, exceptions, hardware interrupts (8259 PIC) | APIC |
| Memory | Physical page allocator, paging | Virtual memory allocator |
| Drivers | VGA text mode, serial port (UART), keyboard (read), CMOS RTC (read), PIT timer (off by default) | Loadable kernel drivers |
| User space | User mode, user programs, GUI |
Linux host with:
On Ubuntu:
Build, run and test scripts take <i386|x86_64> [clang++|g++] [debug|release] (defaults: clang++ debug).
The ISO is placed at install/<Debug|Release>/config-linux-<compiler>-<arch>-<type>/kernel.iso.
You can also build with CMake presets directly:
The image contains only the toolchain; sources are mounted from the host, so code changes don't require rebuilding it:
The analysis image adds analyzers (ClangTidy from apt.llvm.org, newer than Ubuntu's, as in CI), gcovr, QEMU and CodeQL to the toolchain and runs all analysis at once:
GitHub Actions and GitLab CI run both for every compiler/architecture combination; Azure Pipelines runs the boot test. Coverage is reported to Codacy and SonarCloud. Locally, a coverage build of the tests has a coverage target (needs gcovr), HTML report in build/tests/reports/coverage/.
cmake/modules/EnableAnalysis.cmake adds options and on-demand report targets to the kernel build (reports go to <build dir>/reports/):
| Option / target | What it does |
|---|---|
| IGROS_CXX_CLANG_TIDY=ON | ClangTidy pass during the build |
| IGROS_CXX_STRICT_WARNINGS=ON | Extra warnings (-Wconversion, -Wshadow, -Wold-style-cast, -Wframe-larger-than=1024...), reported but not fatal |
| IGROS_KERNEL_UBSAN=ON | UndefinedBehaviorSanitizer in trap mode: UB raises #UD (vector 6), no runtime library needed |
| --target clang-tidy | ClangTidy over all C++ sources with .clang-tidy checks → clang-tidy-report.txt (needs run-clang-tidy) |
| --target cppcheck | Cppcheck over the compile database (inconclusive, exhaustive) → cppcheck-report.txt |
| --target codeql | CodeQL database from a separate clean build → codeql-results.sarif (needs codeql CLI) |
| --target compiler-warnings | Compiler diagnostics of all C++ sources, recompiled to a temporary directory → compiler-warnings.txt |
| --target documentation | Doxygen HTML of kernel sources (architecture of the build, README as main page) → <build dir>/docs/html; documentation errors → reports/doxygen-warnings.txt (needs doxygen, dot for diagrams) |
| --target analysis-report | HTML page with findings of the reports above → index.html (needs Python 3) |
config/script/analysis.sh runs everything for all (or given) configs: a debug build with strict warnings and UBSan, QEMU boot test, all report targets (CodeQL for the first config only, IGROS_ANALYSIS_CODEQL=all|none to change), host tests coverage and ClangTidy over test sources (with tests/.clang-tidy adjustments, findings under config tests). The report in build/analysis/index.html merges findings of every tool and config (the same issue reported by several tools or configs is one entry), shows them per file with source lines, build and boot status per config and coverage.
An open report page updates itself whenever the report is regenerated (it reloads index.data.js), also while analysis.sh is still running.
In CI the Analysis workflow runs analysis.sh (CodeQL goes to code scanning instead) and deploys the master results to GitHub Pages: igr2014.github.io/IgrOS-Kernel is the main page (latest analysis summary, config/pages/index.html) with the report under /analysis/ and the documentation under /docs/; a pull request gets the report as a workflow artifact (kept 14 days), linked from a summary comment in the PR. The code is kept free of findings, so any finding fails the workflow (after the report is published), as do a config that doesn't build or boot and failing host tests. A finding that doesn't apply is suppressed where it is, with a reason (// NOLINT(<check>): <reason>, // cppcheck-suppress <id>); a check that doesn't fit the kernel at all is disabled in .clang-tidy with the reason next to it.
A UBSan trap before the IDT is loaded ends in a triple fault without a message. analysis.sh resolves it into the report; by hand, boot with qemu-system-x86_64 ... -no-reboot -d int, take IP= of the v=06 line and resolve it with addr2line -f -C -i -e kernel.bin <IP>.
ASan and gcov coverage need a hosted runtime the kernel doesn't have: coverage comes from the host unit tests, SonarCloud and Codacy run in CI.
Declarations are documented with Doxygen comments: /// @brief, @param, @tparam and @return above functions and types, ///< after fields, constants and enumerators (comments inside function bodies stay //); namespaces are described in config/doxygen/namespaces.dox. cmake --build <build dir> --target documentation builds the HTML; CI publishes it at igr2014.github.io/IgrOS-Kernel/docs, and documentation errors (wrong parameter names, broken references) are analysis findings like other warnings.
| Directory | Contents |
|---|---|
| arch/ | CPU support: common x86 code and i386 / x86_64 boot code, GDT, IDT |
| drivers/ | VGA, serial (UART), PIT, CMOS RTC, keyboard |
| klib/ | Freestanding kernel library: memory, strings, printing, math |
| mem/ | Physical memory allocator |
| multiboot/ | Multiboot information parsing |
| platform/ | Platform initialization |
| dev/, sys/ | Device abstraction, ELF definitions |
| config/ | Build/run scripts, linker scripts, CMake toolchain configs |
| tests/ | Unit and boot tests |
| kmain.cpp | Kernel entry point |
See CONTRIBUTING.md and the Code of Conduct.
The repository is mirrored on GitHub, GitLab and Azure DevOps.
MIT © 2017 - 2026 Igor Baklykov