Trying to get multiboot info(memory map) from grub2 in 64bi.
Posted: Mon Feb 01, 2021 7:06 am
Trying to get multiboot info(memory map) from grub2 in 64-bit long mode but always get strange wrong data.
github link: https://github.com/JustVic/kernel_grub_multiboot_info
in the _start function I copied multiboot2 magic number and info addres to variables:
varieables declaration:
after this I setup the 64-bit long mode and call _start64 function according to calling conventions mov magic number and info numbers to rdi and rsi:
and trying to get this data from c:
and parse it like multiboot2 gnu example.
What I did wrong? And How to send memory map data to c lang after 64-bit long mode setup from grub multiboot info?
Screenshot of the wrong data:
https://pixelfed-prod.nyc3.cdn.digitalo ... w2VOio.png
github link: https://github.com/JustVic/kernel_grub_multiboot_info
in the _start function I copied multiboot2 magic number and info addres to variables:
Code: Select all
_start:
movl $stack_top, %esp
movl %eax, multiboot_magic
movl %ebx, multiboot_info
Code: Select all
.data
multiboot_magic:
.long 0
multiboot_info:
.long 0
Code: Select all
.code64
.global _start64
.type _start64, @function
_start64:
// Setup segment selectors
movw $0, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
mov multiboot_magic, %rsi
mov multiboot_info, %rdi
call cmain
Code: Select all
int cmain(unsigned long addr, unsigned long magic)
{
}
What I did wrong? And How to send memory map data to c lang after 64-bit long mode setup from grub multiboot info?
Screenshot of the wrong data:
https://pixelfed-prod.nyc3.cdn.digitalo ... w2VOio.png