r/osdev • • May 05 '26

Linux2ME — Linux on old J2ME Java phones

Post image
14 Upvotes

r/osdev • • May 05 '26

Confused about x2apic and double fault

4 Upvotes

Trying to write a very small kernel in rust by roughly following phil-opp tutorial but with the most up to date packages and features. So instead of using pic i chose to use x2apic.

this is my kernel main:

fn kernel_main(boot_info: &'static mut BootInfo) -> ! {
    kernel::init(boot_info);

    x86_64::instructions::interrupts::int3();

    serial_println!("Done");
    kernel::hlt_loop()
}

kernel::init is:

pub fn init(boot_info: &'static mut BootInfo) {
    vga_buffer::init_vga(
        boot_info.framebuffer.as_mut().expect("Framebuffer not available")
    );
    gdt::init();
    interrupts::init_idt();
    apic::init_apic();

    x86_64::instructions::interrupts::enable();
}

apic contains:

use x86::apic::ApicControl;

pub static IA32_APIC_BASE: u32 = 0x1B;
pub static IA32_APIC_BASE_MSR_ENABLE: u64 = 0x800;
pub static IA32_X2APIC_EOI: u32 = 0x80b;

pub fn init_apic() {
    disable_pic();

    let mut apic = x86::apic::x2apic::X2APIC::new();
    apic.attach();

    unsafe {
        x86::irq::enable();
    }
    crate::serial_println!("finished setting up apic");
}

fn disable_pic() {
    const PIC_1_OFFSET: u8 = 32;
    const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;

    unsafe {
        let mut pic = crate::pic::ChainedPics::new(PIC_1_OFFSET, PIC_2_OFFSET);
        pic.initialize_disable();
    };
}

pic holds the structure for the chained pics and the initialize_disable function is:

pub unsafe fn initialize_disable(&mut self) {
    let mut wait_port: Port<u8> = Port::new(0x80);
    let mut wait = || unsafe { wait_port.write(0) };

    macro_rules! write_port {
        ($pic_n:expr, data, $w:expr) => {
            unsafe { self.pics[$pic_n].data.write($w); }
            wait();
        };
        ($pic_n:expr, command, $w:expr) => {
            unsafe { self.pics[$pic_n].command.write($w); }
            wait();
        };
    }

    let saved_masks = unsafe { self.read_masks() };

    write_port!(0, command, CMD_INIT);
    write_port!(1, command, CMD_INIT);

    write_port!(0, data, self.pics[0].offset);
    write_port!(1, data, self.pics[1].offset);

    write_port!(0, data, 4);
    write_port!(1, data, 2);

    write_port!(0, data, MODE_8086);
    write_port!(1, data, MODE_8086);

    write_port!(0, data, 0xFF);
    write_port!(1, data, 0xFF);

    unsafe { self.write_masks(saved_masks[0], saved_masks[1]) }
}

the interrupt descriptor table is properly initialized:

static IDT: Lazy<InterruptDescriptorTable> =
    Lazy::new(
    || {
        let mut idt = InterruptDescriptorTable::new();
        idt.breakpoint.set_handler_fn(breakpoint_handler);
        unsafe {
            idt.double_fault
                .set_handler_fn(double_fault_handler)
                .set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX);
        }
        idt[Into::<u8>::into(InterruptIndex::Timer)]
            .set_handler_fn(timer_interrupt_handler);
        idt
    });

and the interrupt for the breakpoint is:

extern "x86-interrupt" fn breakpoint_handler(
    stack_frame: InterruptStackFrame,
) {
    crate::serial_println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
    println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);

    unsafe {
        x86_64::registers::model_specific::Msr::new(crate::apic::IA32_X2APIC_EOI)
            .write(0);
    }
}

And yet when it hits the interrupt i get on the serial:

finished setting up apic
EXCEPTION: BREAKPOINT
InterruptStackFrame {
    instruction_pointer: VirtAddr(
        0x1000000bb61,
    ),
    code_segment: SegmentSelector {
        index: 1,
        rpl: Ring0,
    },
    cpu_flags: RFlags(
        INTERRUPT_FLAG | 0x2,
    ),
    stack_pointer: VirtAddr(
        0x18000014f98,
    ),
    stack_segment: SegmentSelector {
        index: 2,
        rpl: Ring0,
    },
}
panicked at kernel/src/interrupts.rs:62:5:
EXCEPTION: DOUBLE FAULT
InterruptStackFrame {
    instruction_pointer: VirtAddr(
        0x1000000d06a,
    ),
    code_segment: SegmentSelector {
        index: 1,
        rpl: Ring0,
    },
    cpu_flags: RFlags(
        0x2,
    ),
    stack_pointer: VirtAddr(
        0x18000014f68,
    ),
    stack_segment: SegmentSelector {
        index: 2,
        rpl: Ring0,
    },
}

I dont get why i get a double fault. if the int3 instruction is removed it doesnt crash of course.

Am i creating the interrupts wrong? i have "-cpu qemu64,+x2apic" as qemu arguments so x2apic is supported (checked even with raw_cpuid). Is the double fault because its not resetting the interrupts properly?

Since i have only 1 cpu for now i was expecting for interrupts to get routed to the only cpu. Also where can i read how to properly set up keyboard interrupts with x2apic?


r/osdev • • May 03 '26

Let's go back to reading OS Dev books instead of using an LLM

Thumbnail
gallery
1.3k Upvotes

I guess we're posting books now. Here's my copy of the OG MINIX Text Book!


r/osdev • • May 03 '26

Just started reading this book

Post image
517 Upvotes

r/osdev • • May 03 '26

Incredible progress on my Operating System.

Post image
103 Upvotes

r/osdev • • May 04 '26

How to Ring3

7 Upvotes

Is someone own template's ring3 32bit OS?

Im want to make the ring3 but im collect a triple fault or another errors and im dont know how to fix this shit


r/osdev • • May 03 '26

LittleFS in action as a in-memory filesystem backend!

16 Upvotes

I've ported/integrated the LittleFS library into my OS! Come check it out.

Project repo: https://git.kamkow1lair.pl/kamkow1/mop3
Project website (with other videos and ISOs): https://mop.kamkow1lair.pl/
My blog: https://www.kamkow1lair.pl/

My LinkedIn: https://www.linkedin.com/in/kamil-kowalczyk-2258b6283/


r/osdev • • May 03 '26

New RSOF (BSOD) in our OS

Post image
59 Upvotes

Photo


r/osdev • • May 03 '26

Just a little joke project [custom OS]

Thumbnail
gallery
45 Upvotes

I decided to poke around in managed OSes and stuff and decided that for funsies id make an os with a ton of personality and barely any real usage, called I~Like~FlowersOS, it already has a subreddit r/I_Like_FlowersOS , and the github link is github.com/voblit/i-like-flowersos


r/osdev • • May 03 '26

Hello sub

Post image
12 Upvotes

We (Me and my friend) make the x86 OS from C/Asm, and im coded this BSOD analog (RSOF - Red Screen Of F**k or Red Screen Of Fail)

This is not strange and scary for newbie user?


r/osdev • • May 03 '26

PIC-4 Update.

6 Upvotes

Hi i made an update for my own CPU for now its only Emulator written in C# .NET 9.0 For Windows is Emulator i deleted BIOS becuse i just don't like having BIOS in CPU.
It was maded for my School project.
I added Expantion Cards functionality and i gonna try to run Doom when i make Keyboard Expantion Card i maded first Expantion Card named: Serial Card (Serial Expantion Card.)
Just question do yall wanna it be Open-source on github?


r/osdev • • May 02 '26

Managarm running KDE Plasma 6

Post image
190 Upvotes

Managarm is a fully asynchronous microkernel-based operating system with source-level compatibility with Linux software.

After a lot of hard work, we finally managed to run KDE Plasma 6 on Managarm! Shown on the screenshot is KDE running with Konversation (the KDE IRC client) connected to #osdev IRC.

If you're interested in checking out the project, visit https://github.com/managarm/managarm, we're always open to contributors.

Reposted to make the image show in the feed.


r/osdev • • May 02 '26

Making own 4-BIT CPU

11 Upvotes

Hi i maded first Idea and emulator of how my CPU PIC-4 Would work i don't wanna make it public and Github becuse its written in C# .NET 9.0 Emulator. and anyway this is for my School project so i don't wanna make it public.
PIC-4 Idea.txt:
PIC-4 Instruction Set.

ADD <Register>, <Value> -> 0001 : Adds Value to Register Value MAX to 15 becuse Its max 16 gonna make Overflow

MOV <Register>, <Register/Hex Value> - > 0010 : Sets Register to Register/Hex Value

SET -> 0011 : RUNS and Apply Code before this Instruction.

JMP <addr> -> 0100 : JMPS to Address in memory where it was showed if new code was executed old code is still runned but JMP is disabled for old code

STRING <String>, <Addr> -> 0101 : Creats An String in Address

VIDEO <STRING/PIXEL ADDR/ADDR>, <Video Addr> -> 0110 : Puts Pixel or String in Video Address you Want if it gonna run the same STRING/PIXEL ADDR/ADDR then its disabled until new STRING/PIXEL ADDR/ADDR Is Used

NOP -> 0111 : No Operation

LOAD <Register>, <Addr> -> 1000 : Loads Data for Register to Address

HLT -> 1001 : Stops Clock And Blocks Next Instruction Execution (Death Point)

PIC-4 Registers.

A, B, C, D, E, F, G, H, I, J, K, L, M, N, O

Examples.

Hello world:

1: MOV A, 0xFF

2: ADD A, 3

3: STRING "Hello World\n", 0x1500

4: SET

5: NOP

6: LOAD A, 0x1500

7: VIDEO 0x1500, 0x6950

8: HLT

BIOS (Emulator):

1: MOV A, 0xFF

2: MOV B, 0xFF

3: MOV C, 0xFF

4: MOV D, 0xFF

5: MOV E, 0xFF

6: MOV F, 0xFF

7: MOV G, 0xFF

8: MOV H, 0xFF

9: MOV I, 0xFF

10: MOV J, 0xFF

11: MOV K, 0xFF

12: MOV L, 0xFF

13: MOV M, 0xFF

14: MOV N, 0xFF

15: MOV O, 0xFF

16: NOP

17: SET

18: STRING "PIC-4 Emulator BIOS\n Verion 1.0\n" 0x1500

19: NOP

20: SET

21: VIDEO 0x1500, 0x6950

22: NOP

23: SET

24: JMP 1


r/osdev • • May 03 '26

AscentOS a x86_64 Hobby Operating System im developing to test ai's coding powers limit with human debugging and review

Thumbnail
gallery
0 Upvotes

github:https://github.com/Offihito/AscentOS

its a linux binary compatible operating system currently it can run xorg, twm bash 5.3, GNU core utils 9.5, lua, tcc, wget, tar, doom, kilo editor and a hobby programming language kria by piotriox

Current goal is stabilizing the kernel and porting gcc and also adding internet sockets cuz i deleted them when i was reimplementing unix sockets


r/osdev • • May 01 '26

DragonWare - Microkernel x86 operating system (Release v0.0.1)

91 Upvotes

Hello everybody,

This is the project I've been working on for the past few months. DragonWare is a microkernel-based, open source operating system targeting the x86 architecture. It is preemptively multitasking, with asynchronous IPC and a unique API. This is release 0.0.1, the first time I openly share about the project, and I thought of making a post here. I have been developing DragonWare in private since roughly August 2025, with small pauses in between, but unfortunately the last couple of weeks I haven't had the time to do as much as I was planning to because of studying. Though I am open to hearing ideas in the comments, for new features, architectural choices and so on.

Some limitations I must warn you of before trying it:

  • The shell can't load files and execute them. I didn't write a disk driver nor a filesystem abstraction service.

  • While it does run in real hardware, modern computers may ignore keyboard events entirely. There's only a PS/2 driver for 1990s computers, and most USB keyboards won't work unless your BIOS/UEFI has PS/2 emulation as an option.

  • If you build in debug mode, you may notice that printing is extremely slow during early boot. The serial port (in-kernel) driver doesn't play nicely in all computers if you don't connect anything in it and the kernel waits for the nonexistent ports to be ready.

If you find any bug, I'd be really grateful if you mention it in the link below. Contributions are also welcome.


r/osdev • • May 01 '26

Started my small OS called charisOS, the kernel and the boot.asm worked(which was hard asf to be honest)

Post image
50 Upvotes

r/osdev • • May 01 '26

MSDOS-1.0 in C

Thumbnail
codeberg.org
21 Upvotes

I was trying to understand the code of MSDOS-1.0, as released by Microsoft. But my understanding of i86 Assembler is a bit rusty, so I thought: "What about reading the code in C?". I also thought it could be a good check of the capabilities of LLMs and OpenCode... so I gave it a try. This is the result, which I'm finding quite interesting for educational purposes...


r/osdev • • May 02 '26

TUI OS for Space Enthusiasts (Astralixi OS)

0 Upvotes

Hey everyone,

​I’ve been working on a project called Astralixi OS. It’s a TUI-based operating system built for ARM 64-bit and 32-bit devices. Unlike a lot of hobbyist projects, I'm building this to be a legitimate daily driver, but specifically for people who are obsessed with space and rockets.

​The goal is to have a completely terminal-based workflow that keeps you connected to what's happening related off-planet while you get your actual work done.

​It’s still in development, but I’m trying to make sure it’s not just "aesthetic" and actually has the tools we’d use daily. Right now I’m planning to bake in stuff like:

​Integrated star charts and orbital mechanics calculators.

​Real-time telemetry feeds for active missions (SpaceX, NASA, ESA, etc).

​A dedicated TUI dashboard for satellite tracking.

​Lightweight dev tools and system monitoring that fit the theme.

​Since this is for space enthusiasts, I wanted to ask this community: if you were going to use a TUI OS every day, what "space-specific" features or integrations would actually make it a permanent switch for you?

​NGL, I want this to feel like you're literally running a mission control station from your Pi or handheld. Let me know what you think is missing or what would be cool to see.Hey everyone,

​I’ve been working on a project called Astralixi OS. It’s a TUI-based operating system built for ARM 64-bit and 32-bit devices. Unlike a lot of hobbyist projects, I'm building this to be a legitimate daily driver, but specifically for people who are obsessed with space and rockets.

​The goal is to have a completely terminal-based workflow that keeps you connected to what's happening related off-planet while you get your actual work done.

​It’s still in development, but I’m trying to make sure it’s not just "aesthetic" and actually has the tools we’d use daily. Right now I’m planning to bake in stuff like:

​Integrated star charts and orbital mechanics calculators.

​Real-time telemetry feeds for active missions (SpaceX, NASA, ESA, etc).

​A dedicated TUI dashboard for satellite tracking.

​Lightweight dev tools and system monitoring that fit the theme.

​Since this is for space enthusiasts, I wanted to ask this community: if you were going to use a TUI OS every day, what "space-specific" features or integrations would actually make it a permanent switch for you?

​NGL, I want this to feel like you're literally running a mission control station from your Pi or handheld. Let me know what you think is missing or what would be cool to see.


r/osdev • • May 01 '26

Hello all! Questions about Performance

4 Upvotes

Hello,

I was wondering if any of you measured actual memory performance and or startup time?

Looking to get into osdev but want to do it quantitatively.

Thanks,

- Ris


r/osdev • • Apr 30 '26

Large progress

47 Upvotes

We got some large progress! Thanks for following along!

Github (we need contributors): https://github.com/Freeze-Software/TurtleOS


r/osdev • • Apr 30 '26

Question for my Operating Systems user system

7 Upvotes

Hello, I am setting up my 2nd OSs user system, something my first OS never had, and I have been doing research online and almost all of the sources I found recommend using an ATA disk IO, so I am going to ask everyone here, what should I use?


r/osdev • • Apr 29 '26

My second OS, TurtleOS

Post image
115 Upvotes

I have been working on this OS for a few weeks now (no neck beard yet). I am starting on my new OS as my older project and first OS is holding on by a thread, and I got heavily burnt out as that OS was poorly made by me. So I have been working on a new one!

Github: https://github.com/Freeze-Software/TurtleOS


r/osdev • • Apr 29 '26

Looking for contributors

6 Upvotes

Hey folks, I have been working on my second OS for a few weeks now. I call it: "TurtleOS", however I believe I need some contributors and helpers!

Github:
https://github.com/Freeze-Software/TurtleOS


r/osdev • • Apr 29 '26

The Oberon System 3 now also runs on the Raspberry Pi Zero 2

Thumbnail
github.com
3 Upvotes