https://github.com/ecomaikgolf/alma
toy kernel written in C++ for x86-64 machines with the mere purpose of learning OS development
https://github.com/ecomaikgolf/alma
academic-project cmake cpp kernel make nasm qemu qemu-x86 stivale stivale2 x86-64
Last synced: about 2 months ago
JSON representation
toy kernel written in C++ for x86-64 machines with the mere purpose of learning OS development
- Host: GitHub
- URL: https://github.com/ecomaikgolf/alma
- Owner: ecomaikgolf
- Created: 2021-04-29T00:26:11.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-12T17:00:29.000Z (almost 3 years ago)
- Last Synced: 2025-03-21T22:22:09.063Z (2 months ago)
- Topics: academic-project, cmake, cpp, kernel, make, nasm, qemu, qemu-x86, stivale, stivale2, x86-64
- Language: C++
- Homepage:
- Size: 32 MB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
alma is a toy kernel written in C++ for x86_64 machines with the mere purpose of learning OS development# alma
> 6. f. Sustancia o parte principal de cualquier cosa.
## Features
_Note: GIF quality is vastly reduced and native executions look clear_
alma build system
-
Setup toolchain
- apt install ...
- make -C toolchain
- alma build vm
-
Configure with cmake
- Out of source builds
- Recompile only what is needed
-
Build with make or ninja
- default target (build iso)
- target run (qemu)
- target debug (remote gdb)
- target doc (doxygen)
- Speedup with ccache if found

alma kernel
- Tested in real hardware
- Stivale2 specification
- Call ctors and dtors
-
Rendering
- simple rendering
- fast console rendering
- PSF1 fonts
-
Segmentation
- Naive GDT
-
Paging
- Virtual Memory
- Page Allocation
-
Keyboard
- PS2 Keyboard Support
- symbols & mayus
-
Networking
- RTL8139 Driver
-
ACPI
- Query Tables
-
PCI
- MCFG From ACPI
- MMIO Configuration
- Enumerate dev/bus/func
-
Interrupts
- Manage IDT
- Register Interrupts
-
Dynamic Memory
- malloc
- free


alma bootloader
-
Deprecated
- alma uses stivale2
- ships with the limine botloader ย
- posix-uefi
-
Load ELF
- Parse headers
- Load segments
- Initialization tasks
- GOP
- Memory Map
- RSDP
- PSF1
- Kernel launch
- Call ctors
- Exit UEFI Services
- Jump to entry point

## Run
1. Install qemu:
**Ubuntu**:
```bash
apt install qemu-system-x86 qemu-system-gui
```
**Arch Linux**:
```bash
pacman -S qemu qemu-arch-extra
```
2. Find a build to test https://ls.ecomaikgolf.com/alma/builds/
3. Download a build with wget:
```bash
wget https://ls.ecomaikgolf.com/alma/builds/CHANGEME.tar.gz
tar xf CHANGEME.tar.gz
cd CHANGEME
```
4. Run
```bash
qemu-system-x86_64 -machine q35 -cpu qemu64 -m 256M -bios bios.bin -netdev user,id=user.0 -device rtl8139,netdev=user.0,mac=ca:fe:c0:ff:ee:00 -object filter-dump,id=f1,netdev=user.0,file=log.pcap -boot d -cdrom alma.iso
```
If you want to run it in real hardware, flash it to a USB device:
```bash
sudo dd bs=4M if=alma.iso of=/dev/CHANGEME conv=fdatasync status=progress
```
Remember that you must have certain hardware for it to work (PS2 keyboard, RTL8139 NIC, PCIe...). Even with that, running in real hardware is a dark dark place... things can go wrong.
## Build
### Virtual Machine (Method 1)
1. Download the alma build vm [.ova](https://drive.google.com/file/d/1ip2HidddB_fMC8Du4VQKbizl_cyselMz/view?usp=sharing) (a 6.31GB Xubuntu 20.04 virtualbox VM ready to compile)
2. Compile with the "Build Alma" icon
3. Run with the "Run Alma" icon
3. Update (pull) with the "Update Alma" icon
### Manual (Method 2)
_Note: Instructions tested on `Ubuntu 20.04`_
1. Install dependencies
```bash
apt install nasm iasl cmake make qemu-system-x86 qemu-system-gui git uuid-dev python python3-distutils bash texinfo bison flex build-essential mtools
```
2. `make -C toolchain/`
* EDKII build can be manually disabled if a compiled binary is provided or not using UEFI
* posix-uefi build can be manually disabled if bootloader is not going to be built (default behaviour)
3. `cmake -B build` or `cmake -B build -GNinja`
4. `make -C build run` or `ninja -C build run`
## Mirrors
* Github: `[email protected]:ecomaikgolf/alma.git`, `https://github.com/ecomaikgolf/alma.git`
* Gitlab: `[email protected]:ecomaikgolf/os-dev.git`, `https://gitlab.com/ecomaikgolf/os-dev.git`
* Selfhost: `[email protected]:alma.git`
## Bugs
Please explain them to me: [me ๐๐ ecomaikgolf ๊ฯ๐ c0m](https://ecomaikgolf.com/contact.html)
Take into acccount this is a Bachelor Final Project and has been developed under the pressure of a deadline among other subjects. Some things could be improved, for example, with better (and more complex) data structures, but it's not the goal of the project.
## FAQ
> Q: Muh tons of dependencies
>
> A: I'm compiling binutils, gdb, edk2 and posix-uefi from source
> Q: 6.31GB VM
>
> A: I can't do more. Xubuntu + "zeroed" free memory before exporting so it can be compressed.
> Q: Frequently asked questions?
>
> A: More like preanswered questions
## Bibliography
* https://wiki.osdev.org/Main_Page
* https://youtu.be/NpcGMuI7hxk
* https://0xax.gitbooks.io/linux-insides/content/Interrupts/
* https://youtu.be/mpPbKEeWIHU
* https://www.iaik.tugraz.at/teaching/materials/os/tutorials/paging-on-intel-x86-64/
* https://git.musl-libc.org/cgit/musl/tree
* https://maskray.me/blog/2021-11-07-init-ctors-init-array
* https://blog.llandsmeer.com/tech/2019/07/21/uefi-x64-userland.html
_The list is longer but I can't put each site where I read something. This list is a good place to start_
## Author
Ernesto Martรญnez Garcรญa
* [me ๐๐ ecomaikgolf ๊ฯ๐ c0m](https://ecomaikgolf.com/contact.html) `C79F 01CE 017F 57A4 FBBB 4E22 33DD FB0A EB94 20CB`
* https://ecomaikgolf.com/
* https://twitter.com/ecomaikgolf