Bit 2 in GRUB flags
Posted: Fri Apr 09, 2010 2:18 am
Hi, and first thanks to everyone working on this site and on the wiki !
I have some issues with GRUB : if I take a look at the Multiboot doc, it reads :
Here's the assembly code :
And here's the C code it runs (It reads multiboot info flags and displays what they mean using debug routines) :
But something went wrong, apparently : since I did that, mbchk keeps warning me about reserved flags being set...
I don't understand : why won't grub (0.97) have a look at bit 2 of my flags ?
I have some issues with GRUB : if I take a look at the Multiboot doc, it reads :
I used to set flags = 3, but now I want to take a look at VBE modes, so I set flags = 1+2+4 = 7If bit 0 in the `flags' word is set, then all boot modules loaded
along with the operating system must be aligned on page (4KB)
boundaries. Some operating systems expect to be able to map the
pages containing boot modules directly into a paged address space
during startup, and thus need the boot modules to be page-aligned.
If bit 1 in the `flags' word is set, then information on available
memory via at least the `mem_*' fields of the Multiboot information
structure (*note Boot information format::) must be included. If
the boot loader is capable of passing a memory map (the `mmap_*'
fields) and one exists, then it may be included as well.
If bit 2 in the `flags' word is set, information about the video
mode table (*note Boot information format::) must be available to
the kernel.
Here's the assembly code :
Code: Select all
.text
.globl bootstrap
bootstrap:
jmp multiboot_entry
/* Align 32 bits boundary. */
.align 4
/* Multiboot header. */
multiboot_header:
/* magic */
.long 0x1BADB002
/* flags */
.long 0x00000007
/* checksum */
.long -(0x1BADB002 + 0x00000007)
/* reserved */
.long 0x0
.long 0x0
.long 0x0
.long 0x0
.long 0x0
/* Graphics mode. 0 = linear graphics
1 = EGA color text */
.long 0x00000001
/* Preferred width in pixels/characters of the screen : 80 */
.long 0x00000050
/* Preferred height in pixels/characters of the screen : 25 */
.long 0x00000019
/* Color depth of the screen. 0 in text mode */
.long 0x00000000
multiboot_entry:
/* Initialize the stack pointer. */
movl $(stack + 0x4000), %esp
/* Reset EFLAGS. */
pushl $0
popf
/* Push the pointer to the Multiboot information structure. */
pushl %eax
/* Push the magic value. */
pushl %ebx
/* Now enter the C main function... */
call bootstrap_longmode
loop: hlt
jmp loop
stack:
/* Our stack area (16kB). */
.space 0x4000
Code: Select all
#include "../include/multiboot.h"
#include "../debug/txt_videomem.h"
#include "../debug/wait.h"
int bootstrap_longmode(multiboot_info_t* mbd, unsigned int magic) {
dbg_init_videomem();
dbg_clear_screen();
if(magic!=MULTIBOOT_BOOTLOADER_MAGIC) {
//Not launched by GRUB. Freezing...
dbg_print_str("Error : GRUB not found !");
return -1;
}
dbg_print_str("Hello and welcome to ");
dbg_set_attr(DBG_TXT_LIGHTBLUE);
dbg_print_str("SpockOS\n\n");
dbg_set_attr(DBG_TXT_LIGHTGRAY);
dbg_print_str("Here's what GRUB tells us :\n");
if((mbd->flags & 1) == 1) dbg_print_str("*We know how much memory we have\n");
else dbg_print_str("*We don't know how much memory we have\n");
if((mbd->flags & 2) == 2) dbg_print_str("*We know where we boot from\n");
else dbg_print_str("*We don't know where we boot from\n");
if((mbd->flags & 4) == 4) dbg_print_str("*We know the command line\n");
else dbg_print_str("*We don't know the command line\n");
if((mbd->flags & 8) == 8) dbg_print_str("*We know about modules\n");
else dbg_print_str("*We don't know about modules\n");
if((mbd->flags & 16) == 16) dbg_print_str("*HORROR ! GRUB has mistaken us for an a.out kernel !\n");
else dbg_print_str("*Grub knows we're not an a.out kernel\n");
if((mbd->flags & 32) == 32) dbg_print_str("*We know anything about our symbol table\n");
else dbg_print_str("*We don't know anything about our symbol table\n");
if((mbd->flags & 64) == 64) dbg_print_str("*We have a map of memory\n");
else dbg_print_str("*We don't have a map of memory\n");
if((mbd->flags & 128) == 128) dbg_print_str("*We know about physical drives\n");
else dbg_print_str("*We don't know about physical drives\n");
if((mbd->flags & 256) == 256) dbg_print_str("*We know about ROM configuration\n");
else dbg_print_str("*We don't know about ROM configuration\n");
if((mbd->flags & 512) == 512) dbg_print_str("*We know our bootloader by name\n");
else dbg_print_str("*We don't know our bootloader by name\n");
if((mbd->flags & 1024) == 1024) dbg_print_str("*We know about the APM table\n");
else dbg_print_str("*We don't know about the APM table\n");
if((mbd->flags & 2048) == 2048) dbg_print_str("*We know about VBE graphics capabilities\n");
else dbg_print_str("*We don't know about VBE graphics capabilities\n");
dbg_print_str("\nAnd for the rest, ");
dbg_set_attr(DBG_TXT_RED);
dbg_print_str("we're on our own...");
dbg_set_attr(DBG_TXT_LIGHTGRAY);
//Done ^_^
return 0;
}
...and GRUB doesn't seem to care about what I say (see attachment).gralouf@nutella-pardus Code $ mbchk bin/bs_kernel.bin
bin/bs_kernel.bin: The Multiboot header is found at the offset 4100.
bin/bs_kernel.bin: Non-zero is found in reserved flags (0x7).
I don't understand : why won't grub (0.97) have a look at bit 2 of my flags ?