Autor Thema: Multiboot-Informationen falsch  (Gelesen 4434 mal)

üäpöol

  • Beiträge: 110
    • Profil anzeigen
Gespeichert
« am: 16. December 2012, 18:47 »
Hi,
ich versuche gerade die Multiboot-Informationen zuzugreifen, was aber nicht funktioniert.
Die Ausgabe ist angehängt.
Hier der Code:
kernel.asm
[BITS 32]
FLAGS    equ 0x2
MAGIC    equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
 
align 4
MultiBootHeader:
dd MAGIC
dd FLAGS
dd CHECKSUM

[GLOBAL start]
start:
mov esp, 0x200000
[EXTERN set_multiboot_information]
push ebx
call set_multiboot_information
; ...

system.c
// ...
void set_multiboot_information(unsigned int* pointer_mb_info){
global_multiboot_mb_info.mbs_flags = (unsigned int)*(pointer_mb_info+(0));
global_multiboot_mb_info.mbs_mem_lower = (unsigned int)*(pointer_mb_info+4);
global_multiboot_mb_info.mbs_mem_upper = (unsigned int)*(pointer_mb_info+2*4);
global_multiboot_mb_info.mbs_bootdevice = (unsigned int)*(pointer_mb_info+3*4);
global_multiboot_mb_info.mbs_cmdline = (unsigned int)*(pointer_mb_info+4*4);
global_multiboot_mb_info.mbs_mods_count = (unsigned int)*(pointer_mb_info+5*4);
global_multiboot_mb_info.mbs_mods_addr = (unsigned int)*(pointer_mb_info+6*4);
global_multiboot_mb_info.mbs_syms[0] = (unsigned int)*(pointer_mb_info+7*4);
global_multiboot_mb_info.mbs_syms[1] = (unsigned int)*(pointer_mb_info+8*4);
global_multiboot_mb_info.mbs_syms[2] = (unsigned int)*(pointer_mb_info+9*4);
global_multiboot_mb_info.mbs_syms[3] = (unsigned int)*(pointer_mb_info+10*4);
global_multiboot_mb_info.mbs_mmap_length = (unsigned int)*(pointer_mb_info+11*4);
global_multiboot_mb_info.mbs_mmap_addr = (unsigned int)*(pointer_mb_info+12*4);
global_multiboot_mb_info.mbs_drives_length = (unsigned int)*(pointer_mb_info+13*4);
global_multiboot_mb_info.mbs_drives_addr = (unsigned int)*(pointer_mb_info+14*4);
global_multiboot_mb_info.mbs_config_table = (unsigned int)*(pointer_mb_info+15*4);
global_multiboot_mb_info.mbs_boot_loader_name = (unsigned int)*(pointer_mb_info+16*4);
global_multiboot_mb_info.mbs_apm_table = (unsigned int)*(pointer_mb_info+17*4);
global_multiboot_mb_info.mbs_vbe_control_info = (unsigned int)*(pointer_mb_info+18*4);
global_multiboot_mb_info.mbs_vbe_mode_info = (unsigned int)*(pointer_mb_info+19*4);
global_multiboot_mb_info.mbs_vbe_mode = (unsigned short)*(pointer_mb_info+20*4);
global_multiboot_mb_info.mbs_vbe_interface_seg = (unsigned short)*(pointer_mb_info+20*4+2);
global_multiboot_mb_info.mbs_vbe_interface_off = (unsigned short)*(pointer_mb_info+20*4+4);
global_multiboot_mb_info.mbs_vbe_interface_len = (unsigned short)*(pointer_mb_info+20*4+6);
}
// ...

main.c
int main(){
install_start();
print("mbs_flags", 0, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_flags), 40, 0xF);
print("mbs_mem_lower", 1*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_mem_lower), 1*80+40, 0xF);
print("mbs_mem_upper", 2*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_mem_upper), 2*80+40, 0xF);
print("mbs_bootdevice", 3*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_bootdevice), 3*80+40, 0xF);
print("mbs_cmdline", 4*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_cmdline), 4*80+40, 0xF);
print("mbs_mods_count", 5*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_mods_count), 5*80+40, 0xF);
print("mbs_mods_addr", 6*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_mods_addr), 6*80+40, 0xF);
print("mbs_mmap_length", 7*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_mmap_length), 7*80+40, 0xF);
print("mbs_mmap_addr", 8*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_mmap_addr), 8*80+40, 0xF);
print("mbs_drives_length", 9*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_drives_length), 9*80+40, 0xF);
print("mbs_drives_addr", 10*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_drives_addr), 10*80+40, 0xF);
print("mbs_config_table", 11*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_config_table), 11*80+40, 0xF);
print("mbs_boot_loader_name", 12*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_boot_loader_name), 12*80+40, 0xF);
print("mbs_apm_table", 13*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_apm_table), 13*80+40, 0xF);
print("mbs_vbe_control_info", 14*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_vbe_control_info), 14*80+40, 0xF);
print("mbs_vbe_mode_info", 15*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_vbe_mode_info), 15*80+40, 0xF);
print("mbs_vbe_mode", 16*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_vbe_mode), 16*80+40, 0xF);
print("mbs_vbe_interface_seg", 17*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_vbe_interface_seg), 17*80+40, 0xF);
print("mbs_vbe_interface_off", 18*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_vbe_interface_off), 18*80+40, 0xF);
print("mbs_vbe_interface_len", 19*80, 0xF);
print(itoa_p(global_multiboot_mb_info.mbs_vbe_interface_len), 19*80+40, 0xF);
while(1);
return 0;
}
Die Ausgabe ist dezimal.
Es macht einfach keinen Sinn, was da steht.

Danke schon mal.

kevin

  • Administrator
  • Beiträge: 2 767
    • Profil anzeigen
Gespeichert
« Antwort #1 am: 16. December 2012, 21:02 »
Pointerarithmetik. Das *4 ist schon automagisch drin, wenn du auf einem int* rechnest.
Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end.

 

Einloggen