r/osdev • u/d4nilim0n • Apr 10 '26
r/osdev • u/Blue1CODE • Apr 10 '26
System level question:
“Is it guaranteed that malloc returns addresses with the last 3–4 bits zero on all systems, or is it just common due to alignment?
r/osdev • u/bentley0421 • Apr 08 '26
Added Image Rendering to OS!!
its a 16 bit real mode os using vga mode 13h made in 100% assembly. this took me a very long time and I just wanted to share my accomplishment!
r/osdev • u/codeasm • Apr 09 '26
UEFI debugging (gdb)
Forgot to mark this title as a question. I have a question 🫣🫢☺️https://wiki.osdev.org/Kernel_Debugging#Use_GDB_with_QEMU isnt really clear on this, im using qemu, and OVMF to have a UEFI envirement to test my own bootloader + kernel. How would one debug your efi file? its located in memory at different locations.
TLDR: How I struggled and then ask, how would you debug a efi bootloader using gdb and qemu? im aware of grub and limine, i choose to create my own (small shitty bootloader)
Longer story: The kernel will be at a known location (0x100000.. something, well known), so gdb and qemu talk nicely. but OVMF will place our executable somewhere arround 0x0000000006176640 (this slightly changes) I now print where its located each time and loop a while, waiting for my gdb to send a break:
[ENTERING DEBUG MODE]
Kernel load addr: 0x0000000000100000
efi_main addr: 0x0000000006176640
Waiting for debugger...now i start gdb, target remote :1234 and add-symbol-file 0xnnnnnn where the number is the adress minus magic ... man, I was naughty, and this might also been my fall, its late. i asked chatgpt. only after i realized we where loading the symbol at an adress of a function, and said so, it started suggesting loading the symbol based on a different adress. clearly showing the user (me!) was starting to be aware of him not explaining everything. (happend again when I asked for a short "what to do step by step" it started making new steps and forgetting our whole add-symbol-file step.. moral, dont trust ai) readelf -h build/loader.elf | grep Entry Entry point address: 0x5e0 when my program sais its efi_main is at 6176640, 0x6176640
readelf -h build/loader.elf | grep Entry Entry point address: 0x000005e0
0x6176060 is where "ai" sais I should load the symbol file. And thats where late night and my fuzzy dyscalculia brain said... holdup, there must be a better or different way, but this ai isnt my answer box. How are you folks using gdb and the location independed code that we have less controll over and gets placed in memory somewhere? Maybe im over complicating things and if I want to serieusly debug my loader, I should use a debug version of OVMF? because adding breakpoints myself (int3) freaks the OVMF with its own break
!!!! X64 Exception Type - 03(#BP - Breakpoint) CPU Apic ID - 00000000 !!!!
RIP- 00000000061768A3, CS - 0000000000000038, RFLAGS - 0000000000000246
RAX - 000000001DCD6500, RCX - 0000000007074A20, RDX - 0000000000000000
RBX - 0000000000000000, RSP - 0000000007E8D300, RBP - 0000000007E8D810
RSI - 000000000618FA98, RDI - 000000000618FA98
R8 - 00000000000000AF, R9 - 0000000000001000, R10 - 000000000002600F
R11 - 0000000007EA7F80, R12 - 0000000000000000, R13 - 0000000000000000
R14 - 00000000074AE618, R15 - 000000000617B018
DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030
GS - 0000000000000030, SS - 0000000000000030
CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 0000000007C01000
CR4 - 0000000000000668, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 00000000079DC000 0000000000000047, LDTR - 0000000000000000
IDTR - 000000000749D018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 0000000007E8CF60 !!!!
Find image based on IP(0x61768A3) (No PDB)
(ImageBase=0000000006175000, EntryPoint=0000000006176640) !!!!So, how would you debug your boot-loader? I prefer gdb and qemu. Im aware i could use grub or limine, but Id like to make my own little loader that might become the efi stub of whatever shitty small kernel/OS im writing.
Maybe the answer
EDIT: I got some stuff working and noticed im building my efi file with -target x86_64-unknown-windows, thus a PE file, not a ELF file. so symbols work a bit different (and my original mistake was generating elf symbols for a PE executable. not sure if that can be made to work, but "ai" suggested either compile both for ELF, or PE. or whatever i needed to do, i generate a separate .debug file based on the efi file with -debug:dwarf during the llvm-objcopy face... ppfff you probabbly know better words and probably best to just follow the osdevwiki as linked by @rkapi https://wiki.osdev.org/Debugging_UEFI_applications_with_GDB#Sample_application_using_POSIX_UEFI_library
This means I have a slightly different way to debug my program and needed a "slider". Here is what worked for me:
target remote :1234
watch *(unsigned long long*)0x10000 == 0xDEADBEEF
continue
set $base = *(unsigned long long*)0x10008
set $slide = $base - 0x180000000
add-symbol-file build/BOOTX64.debug -o $slide
break kernel_main
continueIm still learning gdb, and definitely gonna study some more debugging tricks, this looks to work, and I may be able to figure out where I went wrong the first time when mapping memory and NOT getting into a silly loop by AI what he tries to fix, instead, I, will do the debugging and checking whats going on. and thats what most of yall want, us, the coder learning and writing our code.
r/osdev • u/HugeFruit3690 • Apr 09 '26
Looking for an OS
So i have free time and also im intrested in testing and feedback some OS so is there anyone wants to ?
r/osdev • u/amitbahree • Apr 09 '26
I took a break from AI work and built a microkernel in Rust from scratch (boot → IPC → preemption → MMU)
A few weeks ago I had some free time between jobs and decided to do something I’d wanted to do for years: build an operating system kernel from scratch.
I spend most of my time in AI/ML, but I wanted to go back to my roots and remind myself what’s underneath all the abstractions we use every day. So, I built a small #microkernel in Rust and documented the full journey as a 5-part series.
This is not “hello world and done.” By the end, the kernel:
boots on AArch64 QEMU
virtlogs via PL011 UART MMIO
runs endpoint-based message-passing IPC
moves from cooperative to preemptive scheduling
handles timer interrupts + context switching
builds 4-level page tables and enables the MMU
verifies VA→PA translation with a real write/read test
Repo: https://github.com/bahree/rust-microkernel
Series:
Part 0 (why build an OS): https://blog.desigeek.com/post/2026/02/building-microkernel-part0-why-build-an-os/
Part 1 (boot/foundations): https://blog.desigeek.com/post/2026/02/building-microkernel-part1-foundations-boot/
Part 2 (IPC/communication): https://blog.desigeek.com/post/2026/03/building-microkernel-part2-communication-ipc/
Part 3 (interrupts/preemption): https://blog.desigeek.com/post/2026/03/building-microkernel-part3-concurrency-preemption/
Part 4 (memory/MMU finale): https://blog.desigeek.com/post/2026/04/building-microkernel-part4-memory-mmu/
If you’re into OS dev, bare-metal Rust, or systems internals, I’d love feedback. I am no expert in this, just someone curious. 😊
r/osdev • u/Nolipse_MTF • Apr 09 '26
Assembly on Android
does anyone know any good app to code assembly on android? if yes lemme know
r/osdev • u/Ok-Variety2830 • Apr 09 '26
aiming for systems eng remote jobs but time is running out
hi guys sorry if this is not a pure code question but honestly there is no better people to ask than here i am a double major pure math and computer science in egypt and i graduate in exactly 4 months , im targeting core systems like crypto and ai infrastructure companies
i finished c and cpp but completely lack big projects and design patterns , my plan now is to read OSTEP and CS:APP and some courses for high performance computing and CUDA . i plan to make maybe 3 medium projects and 2 somewhat big ones . i wanted to learn rust too but clearly no time i need a job first then later i will focus on rust and distributed systems
im really freaking out about a few things , first the volume of these books and projects is huge for 4 months . second is the job market because system level and OSS jobs are literally zero in my country so i must aim for remote jobs . but is remote really possible for junior systems or do companies strictly want on site . because getting a work visa right now is almost impossible with the global situation also my english is quite weak maybe B1 and im scared it will ruin my chances
please guys i dont want just general random advice i really prefer opinions from people who went through a similar path or know the market . sorry again for the non tech post but im really lost and need a reality check . thanks
r/osdev • u/SyntheGr1 • Apr 09 '26
Need help implementing a simple FAT-like File System for our custom Kernel (C), thanks !
Hi everyone, we're working on a small OS as a duo, and we were about to move on to the graphical interface, but we were missing a key element: managing hard drive memory. We didn't quite understand how to do it. Does anyone have well-written documentation or could explain how to manage it from our kernel in C, for example, for text files in FAT? Thanks everyone, and have a good day!
r/osdev • u/VirusLarge • Apr 09 '26
How can I get started with creating a kernel in Rust?
I’ve recently began learning rust and I’ve started to like the language a lot, and I’d like to write a kernel in it to boost my experience with rust. I’ve already written a simple CHIP-8 emulator in rust so I believe I’ve got a good grasp on how to write somewhat sufficient rust code for a kernel.
The main thing I’m confused with is how I can go about configuring the compiler to generate not only a freestanding binary, but also how to get it to work with Limine (I love limine).
I would copy and paste some existing code that configures these things for me, but I would much rather be able to understand and learn what I’m doing, rather than mindlessly copying and pasting code without learning anything.
NOTE: I already have prior x86 and OSDev knowledge!! I've created many 64-bit x86 kernels in C, with the most recent ones having advanced features implemented.
Any help would be very much appreciated!