From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Mar 2010 15:37:04 +0000 (+0100) Subject: Multiboot header tag cleanup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd35f2089c86b8f67cf6f046d20cc3bc3938ce60;p=thirdparty%2Fgrub.git Multiboot header tag cleanup --- diff --git a/doc/boot.S b/doc/boot.S index 80a4381fa..90edbdb80 100644 --- a/doc/boot.S +++ b/doc/boot.S @@ -34,7 +34,6 @@ #else # define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE #endif -#define MULTIBOOT_HEADER_FLAGS MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE | AOUT_KLUDGE .text @@ -43,18 +42,24 @@ start: _start: jmp multiboot_entry - /* Align 32 bits boundary. */ - .align 4 + /* Align 64 bits boundary. */ + .align 8 /* Multiboot header. */ multiboot_header: /* magic */ .long MULTIBOOT2_HEADER_MAGIC - /* flags */ - .long MULTIBOOT_HEADER_FLAGS + /* ISA: i386 */ + .long GRUB_MULTIBOOT_ARCHITECTURE_I386 + /* Header length. */ + .long multiboot_header_end - multiboot_header /* checksum */ - .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) + .long -(MULTIBOOT2_HEADER_MAGIC + GRUB_MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header)) #ifndef __ELF__ +address_tag_start: + .long MULTIBOOT_HEADER_TAG_ADDRESS + .long address_tag_end - address_tag_start + .long MULTIBOOT_HEADER_TAG_OPTIONAL /* header_addr */ .long multiboot_header /* load_addr */ @@ -63,20 +68,27 @@ multiboot_header: .long _edata /* bss_end_addr */ .long _end +address_tag_end: +entry_address_tag_start: + .long MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS + .long entry_address_tag_end - entry_address_tag_start + .long MULTIBOOT_HEADER_TAG_OPTIONAL /* entry_addr */ - .long multiboot_entry -#else /* ! __ELF__ */ - .long 0 - .long 0 - .long 0 - .long 0 - .long 0 + .long multiboot_entry +entry_address_tag_end: #endif /* __ELF__ */ - .long 0 +framebuffer_tag_start: + .long MULTIBOOT_HEADER_TAG_FRAMEBUFFER + .long framebuffer_tag_end - framebuffer_tag_start + .long MULTIBOOT_HEADER_TAG_OPTIONAL .long 1024 .long 768 .long 32 - +framebuffer_tag_end: + .long MULTIBOOT_HEADER_TAG_END + .long 12 + .long 0 +multiboot_header_end: multiboot_entry: /* Initialize the stack pointer. */ movl $(stack + STACK_SIZE), %esp diff --git a/doc/multiboot.texi b/doc/multiboot.texi index dab8210b8..db06539ca 100644 --- a/doc/multiboot.texi +++ b/doc/multiboot.texi @@ -335,8 +335,8 @@ not use shared libraries or other fancy features. An OS image must contain an additional header called @dfn{Multiboot header}, besides the headers of the format used by the OS image. The -Multiboot header must be contained completely within the first 8192 -bytes of the OS image, and must be longword (32-bit) aligned. In +Multiboot header must be contained completely within the first 32768 +bytes of the OS image, and must be 64-bit aligned. In general, it should come @emph{as early as possible}, and may be embedded in the beginning of the text segment after the @emph{real} executable header. @@ -408,14 +408,14 @@ Every structure has following format: +-------------------+ 0 | type | 4 | size | -8-11 | optional | +8-11 | flags | +-------------------+ @end group @end example @samp{type} contains an identifier of contents of the rest of the tag. @samp{size} contains the size of tag including header fields. -@samp{optional} is set to 1 if bootloader may ignore this tag if it +If bit @samp{0} of @samp{flags} (also known as @samp{optional}) is set if bootloader may ignore this tag if it lacks relevant support. Tags are terminated by a tag of type @samp{0} and size @samp{12}. @@ -427,7 +427,7 @@ Tags are terminated by a tag of type @samp{0} and size @samp{12}. +-------------------+ 0 | type = 1 | 4 | size | -8 | optional | +8 | flags | 12-xx | mbi_tag_types | +-------------------+ @end group @@ -451,11 +451,12 @@ actually be present. E.g. on a videoless system even if you requested tag @group +-------------------+ 0 | type = 2 | -4 | size = 24 | -8 | optional | +4 | size = 28 | +8 | flags | 12 | header_addr | 16 | load_addr | -20-23 | load_end_addr | +20 | load_end_addr | +24-27 | bss_end_addr | +-------------------+ @end group @end example @@ -500,7 +501,7 @@ assumes that no bss segment is present. +-------------------+ 0 | type = 3 | 4 | size = 16 | -8 | optional | +8 | flags | 12-15 | entry_addr | +-------------------+ @end group @@ -524,15 +525,15 @@ start running the operating system. +-------------------+ 0 | type = 4 | 4 | size = 16 | -8 | optional | -12-15 | flags | +8 | flags | +12-15 | console_flags | +-------------------+ @end group @end example -If this tag is present and bit 0 of @samp{flags} is set +If this tag is present and bit 0 of @samp{console_flags} is set at least one of supported consoles must be present and information about it must be available in mbi. -If bit @samp{1} of @samp{flags} is set it +If bit @samp{1} of @samp{console_flags} is set it indicates that the OS image has EGA text support. @subsection The framebuffer tag of Multiboot header @@ -542,7 +543,7 @@ indicates that the OS image has EGA text support. +-------------------+ 0 | type = 5 | 4 | size = 24 | -8 | optional | +8 | flags | 12 | width | 16 | height | 20-23 | depth | @@ -584,7 +585,7 @@ preference. +-------------------+ 0 | type = 6 | 4 | size = 12 | -8-11 | optional | +8-11 | flags | +-------------------+ @end group @end example diff --git a/doc/multiboot2.h b/doc/multiboot2.h index 36710ddf6..4fe803fee 100644 --- a/doc/multiboot2.h +++ b/doc/multiboot2.h @@ -23,7 +23,7 @@ #define MULTIBOOT_HEADER 1 /* How many bytes from the start of the file we search for the header. */ -#define MULTIBOOT_SEARCH 8192 +#define MULTIBOOT_SEARCH 32768 /* The magic field should contain this. */ #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 @@ -62,6 +62,17 @@ #define MULTIBOOT_TAG_TYPE_VBE 7 #define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 +#define MULTIBOOT_HEADER_TAG_END 0 +#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 +#define MULTIBOOT_HEADER_TAG_ADDRESS 2 +#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 +#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 +#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 +#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 + +#define GRUB_MULTIBOOT_ARCHITECTURE_I386 0 +#define MULTIBOOT_HEADER_TAG_OPTIONAL 1 + #ifndef ASM_FILE typedef unsigned char multiboot_uint8_t; @@ -74,21 +85,73 @@ struct multiboot_header /* Must be MULTIBOOT_MAGIC - see above. */ multiboot_uint32_t magic; - /* Feature flags. */ - multiboot_uint32_t flags; + /* ISA */ + multiboot_uint32_t architecture; + + /* Total header length. */ + multiboot_uint32_t header_length; /* The above fields plus this one must equal 0 mod 2^32. */ multiboot_uint32_t checksum; +}; + +struct multiboot_header_tag +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; +}; + +struct multiboot_header_tag_information_request +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; + multiboot_uint32_t requests[0]; +}; - /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ +struct multiboot_header_tag_address +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; multiboot_uint32_t header_addr; multiboot_uint32_t load_addr; multiboot_uint32_t load_end_addr; multiboot_uint32_t bss_end_addr; +}; + +struct multiboot_header_tag_entry_address +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; multiboot_uint32_t entry_addr; +}; + +struct multiboot_header_tag_console_flags +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; + multiboot_uint32_t console_flags; +}; - /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ - multiboot_uint32_t mode_type; +struct multiboot_header_tag_framebuffer +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; + multiboot_uint32_t width; + multiboot_uint32_t height; + multiboot_uint32_t depth; +}; + +struct multiboot_header_tag_module_align +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t flags; multiboot_uint32_t width; multiboot_uint32_t height; multiboot_uint32_t depth;