Thank for your answers!
For be clear, I'm confused by how to use the multiboot2.h header file suggested on the gnu website.
I want to get the framebuffer address for working in graphics mode. I think I have to get some others information too.
If I understand I can do this by implement a multiboot header.
My confused is that I can't find how to properly implement the multiboot2 specification in my project.
At the moment I use the grub2 bootloader.
Here is my kernel.c code:
Code:
// multiboot2 file found on the gnu website
// https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#multiboot2_002eh
#include "multiboot2.h"
// .multiboot_header is defined in the linker.ld file below
struct multiboot_header test __attribute__((section(".multiboot_header"))) = {
MULTIBOOT2_HEADER_MAGIC,
MULTIBOOT_ARCHITECTURE_I386,
// don't know how to get header size by c code
0,
0x100000000 - (MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + 0)
};
struct multiboot_header_tag test_2 __attribute__((section(".multiboot_header"))) = {
.type = 0,
.flags = 0,
.size = 8
};
void kernel_start () {
// 0xa0000 address is used for example
// the above code is incorrect
unsigned int *buffer = (unsigned int *) 0xa0000;
for (int i = 0; i < 640 * 480; i++) {
buffer[i] = 0x4398DE19;
}
while (1) {}
}
Here is my linker.ld file if it can help to understand:
Code:
ENTRY(kernel_start)
SECTIONS {
. = 1M;
.boot : ALIGN(0x1000)
{
*(.multiboot_header)
}
.text : ALIGN(0x1000)
{
*(.text)
}
}