Page 1 of 1

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

Posted: Fri Dec 28, 2018 1:06 pm
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

Re: Triple Fault when try to get Low Memory Map

Posted: Fri Dec 28, 2018 2:28 pm
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.

Re: Triple Fault when try to get Low Memory Map

Posted: Fri Dec 28, 2018 4:29 pm
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...