OSDev.org
https://forum.osdev.org/

Triple Fault when try to get Low Memory Map [SOLVED]
https://forum.osdev.org/viewtopic.php?f=1&t=33401
Page 1 of 1

Author:  moige [ Fri Dec 28, 2018 1:06 pm ]
Post subject:  Triple Fault when try to get Low Memory Map [SOLVED]

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:
// 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

Author:  Octocontrabass [ Fri Dec 28, 2018 2:28 pm ]
Post subject:  Re: Triple Fault when try to get Low Memory Map

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.

Author:  moige [ Fri Dec 28, 2018 4:29 pm ]
Post subject:  Re: Triple Fault when try to get Low Memory Map

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...

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/