hi, I am tring to use GRUB to load some images in the memory.
as I read in Multiboot specification, I shlould set bit 3 so that Information about modules will be includes in the header information.
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_MODULE_INFO equ 1<<3
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE | MULTIBOOT_MODULE_INFO
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; aout kludge. These must be PHYSICAL addresses
dd mboot
dd code
dd bss
dd end
dd entry
then I receive this message when, GRUB try to load my kernel: "Unsupported Mutiboot features requested".
note that I use GRUB version 0.93
GRUB and Multiboot header Problem?
Re:GRUB and Multiboot header Problem?
You don't need so much stuff (actually, I'm too lazy to check what the MULTBOOT_MODULE_INFO is supposed to mean).
Just use this here:
Now the Multiboot specification tells you that ebx contains the Multiboot info structure:
So in your assembly code, you just check if you are booted by GRUB (by a Multiboot boot loader respectively) and pass the multiboot info to a structure:
Hope this helps...
Just use this here:
Code: Select all
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1 MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) ; The Multiboot header (in NASM syntax)
align 4
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd CHECKSUM
Code: Select all
/* The Multiboot information. */
typedef struct multiboot_info
{
unsigned long flags;
unsigned long mem_lower;
unsigned long mem_upper;
unsigned long boot_device;
unsigned long cmdline;
unsigned long mods_count;
unsigned long mods_addr;
union
{
aout_symbol_table_t aout_sym;
elf_section_header_table_t elf_sec;
} u;
unsigned long mmap_length;
unsigned long mmap_addr;
} multiboot_info_t;
Code: Select all
cmp eax, 0x2BADB002 ; are we booted by GRUB?
jne no_multiboot
mov [mboot_info], ebx
sete [mboot_valid]
jmp go_on
no_multiboot:
; do error handling or anything else here
go_on:
...
section .data
mboot_valid: dd 0
mboot_info: dd 0
Re:GRUB and Multiboot header Problem?
thanks, it work.
I have supposed that I must the set bit 3, so that GruB write the information about the loaded modules.
I have supposed that I must the set bit 3, so that GruB write the information about the loaded modules.
Re:GRUB and Multiboot header Problem?
still there something I don't understand. in the Multiboot header information I have set the begin of the code and the end of data and the end of my kernel as end of bss, so that it does not load modules before those address, but still it load it between them.
; these are in the linker script file
EXTERN _code, _bss, _end
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; aout kludge. These must be PHYSICAL addresses
dd mboot
dd _code // begin of text segment
dd _bss // begin of bss is end of data segment
dd _end // end of my kernel image
dd entry
_code at 0x100000
_bss at 0x109000
_end at 0x119AE3
the module has been loaded at 0x10E000. normal it should load 0x11A000!!!
; these are in the linker script file
EXTERN _code, _bss, _end
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; aout kludge. These must be PHYSICAL addresses
dd mboot
dd _code // begin of text segment
dd _bss // begin of bss is end of data segment
dd _end // end of my kernel image
dd entry
_code at 0x100000
_bss at 0x109000
_end at 0x119AE3
the module has been loaded at 0x10E000. normal it should load 0x11A000!!!