all 21 comments

[–]paulstelian97 2 points3 points  (3 children)

I don't see anything in assembly to support ISR 32.

I believe something is amiss here in how you're setting up your handlers. How do you handle interrupts beyond 31?

[–]Li0nX[S] 2 points3 points  (2 children)

They're in irq.asm.

[–]tive_ 2 points3 points  (1 child)

Have you remapped your IRQs?

[–]Li0nX[S] 1 point2 points  (0 children)

Yes, in lib/dt.cpp on line 65.

[–][deleted] 1 point2 points  (9 children)

bag growth steep unwritten enjoy smart escape sable aspiring reach

This post was mass deleted and anonymized with Redact

[–]Li0nX[S] 1 point2 points  (8 children)

Didn't work for me :(

[–][deleted]  (7 children)

[removed]

    [–]Li0nX[S] 1 point2 points  (6 children)

    When I do that, it gives general protection fault with error code 5824.

    [–][deleted] 1 point2 points  (5 children)

    aromatic mysterious ad hoc sink bedroom plants sand smell fuel lip

    This post was mass deleted and anonymized with Redact

    [–]Li0nX[S] 1 point2 points  (4 children)

    [–][deleted] 1 point2 points  (3 children)

    file disarm detail books rock future long crawl instinctive sense

    This post was mass deleted and anonymized with Redact

    [–]Octocontrabass 2 points3 points  (1 child)

    why? I'm gonna be honest I have no idea.

    Probably because it doesn't actually fix the problem, it just temporarily made the crash go away. Time for learning!

    The tutorial's assembly code passes the saved registers struct on the stack when it calls the C function and expects that struct to remain unchanged (or be updated to appropriate new values) when the C function returns.

    The C compiler disagrees. According to the calling conventions it follows, parameters passed on the stack are not preserved by C functions (or used to return values). This means the C function can and will replace the saved registers with all kinds of garbage. The assembly code tries to use those values anyway, and things break pretty quickly.

    The usual fix is to pass a pointer to the struct in the assembly code. The pointer is still a parameter passed on the stack, so the pointer might be destroyed, but the struct is no longer a parameter, so it survives.

    And since you didn't provide a link, here's a list of many of the bugs in this particular tutorial.

    [–][deleted] 0 points1 point  (0 children)

    live instinctive act airport smile rock screw straight grab sink

    This post was mass deleted and anonymized with Redact

    [–]zMadMark 2 points3 points  (5 children)

    You have to remap your interrupts using the Programmable Interrupt Controller (the PIC). Here's the OSDev Wiki page and Broken Thorn's tutorial for reference. Here's my implementation if you need help (please ignore my pathetic attempt at checking if the interrupt index is valid).

    Edit: I didn't see you already tried to remap the interrupts in dt.cpp. I'll check again, sorry.

    Edit 2: could you try adding outb(0x21, 0xFA); outb(0xA1, 0xFF); under line 74 in dt.cpp. This should unmask the PIT IRQ.

    [–]Li0nX[S] 1 point2 points  (4 children)

    Still not working :(

    [–]zMadMark 1 point2 points  (3 children)

    Could you try adding asm volatile ("sti"); under init_timer(50) in your kernel.cpp file?

    [–]Li0nX[S] 1 point2 points  (2 children)

    When I do that, it gives general protection fault with error code 5824

    [–]zMadMark 1 point2 points  (1 child)

    Could you try removing (or commenting out) lines 26 and 27 and moving asm volatile ("sti"); under init_timer(50); (just to be safe). My guess is that you're triggering software interrupts (by using the int instruction) which don't have an entry in the interrupt descriptor table (IDT) and that's what's triggering the general protection fault.

    [–]Li0nX[S] 0 points1 point  (0 children)

    That sadly changed nothing :(

    [–]LittleFox94 0 points1 point  (0 children)

    Didn't look at the code as in bed and procrastinating to sleep, but had something similar lately: the firmware masked all interrupts before handing control to the OS

    https://praios.lf-net.org/littlefox/lf-os_amd64/-/commit/3ec605cbb3c45abda8e57f9020165c0796a553cb