Triple Fault when try to get Low Memory Map [SOLVED]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
moige
Posts: 4
Joined: Thu Dec 27, 2018 1:45 pm
Libera.chat IRC: moige

Triple Fault when try to get Low Memory Map [SOLVED]

Post by moige »

Hi,

I'm getting Triple Fault when trying to get Low Memory Map described in this wiki post on OSDev.
The section describe the code in assembler, but I wrote it in GCC asm inline, like this:

Code: Select all

// Top of the file
__asm__(".code16gcc\n");
[...]
uint16_t __noinline SMAP_DetectLowMemory(void)
{
        uint16_t mem = 0;

        asm volatile
        (
                "clc\n\t"
                "int $0x12"
                : "=a"(mem)
        );

        return mem;
}
P.D: "__noinline" is a macro to "__attribute__((noinline))"

When I compile it, linked to my kernel and called it on kernel_main(), my system enter in triple fault. I dump the cpu_reset on qemu, but I'm begginer and I'm not realy sure how to read the dump and get on the root of the problem.
Here is the dump generated by qemu with the "-d cpu_reset" option.
P.D: I boot my system with -kernel option in qemu

How can I handle this? And how can I better read the dump?

ENV:
i686-elf-gcc 8.2.0
i686-elf-as 2.31.1
i686-elf-ld 2.31.1
qemu-system-i386 3.1.0
Last edited by moige on Fri Dec 28, 2018 4:38 pm, edited 1 time in total.
Octocontrabass
Member
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: Triple Fault when try to get Low Memory Map

Post by Octocontrabass »

The -kernel option in QEMU is multiboot-compatible. Your kernel is already running in protected mode, so you can't call BIOS interrupts. The multiboot structures provide all of the information you need, so you shouldn't be trying to call BIOS interrupts anyway.

You can find links to the multiboot specification here, including header files you can use to help parse the structures.
moige
Posts: 4
Joined: Thu Dec 27, 2018 1:45 pm
Libera.chat IRC: moige

Re: Triple Fault when try to get Low Memory Map

Post by moige »

Octocontrabass wrote:The -kernel option in QEMU is multiboot-compatible. Your kernel is already running in protected mode, so you can't call BIOS interrupts. The multiboot structures provide all of the information you need, so you shouldn't be trying to call BIOS interrupts anyway.

You can find links to the multiboot specification here, including header files you can use to help parse the structures.
Thanks! I didn't know that -kernel pass to protected mode. Or maybe I had to supposed it...
Post Reply