Multiboot header tag cleanup

This commit is contained in:
Vladimir 'phcoder' Serbinenko committed 2010-03-07 16:37:04 +01:00
1 parent fd393d45aa
commit cd35f2089c
3 files changed
+113 -37

No files matched your search

+27 -15
View File
@@ -34,7 +34,6 @@
#else #else
# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE # define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE
#endif #endif
#define MULTIBOOT_HEADER_FLAGS MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE | AOUT_KLUDGE
.text .text
@@ -43,18 +42,24 @@ start:
_start: _start:
jmp multiboot_entry jmp multiboot_entry
/* Align 32 bits boundary. */ /* Align 64 bits boundary. */
.align 4 .align 8
/* Multiboot header. */ /* Multiboot header. */
multiboot_header: multiboot_header:
/* magic */ /* magic */
.long MULTIBOOT2_HEADER_MAGIC .long MULTIBOOT2_HEADER_MAGIC
/* flags */ /* ISA: i386 */
.long MULTIBOOT_HEADER_FLAGS .long GRUB_MULTIBOOT_ARCHITECTURE_I386
/* Header length. */
.long multiboot_header_end - multiboot_header
/* checksum */ /* checksum */
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) .long -(MULTIBOOT2_HEADER_MAGIC + GRUB_MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
#ifndef __ELF__ #ifndef __ELF__
address_tag_start:
.long MULTIBOOT_HEADER_TAG_ADDRESS
.long address_tag_end - address_tag_start
.long MULTIBOOT_HEADER_TAG_OPTIONAL
/* header_addr */ /* header_addr */
.long multiboot_header .long multiboot_header
/* load_addr */ /* load_addr */
@@ -63,20 +68,27 @@ multiboot_header:
.long _edata .long _edata
/* bss_end_addr */ /* bss_end_addr */
.long _end .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 */ /* entry_addr */
.long multiboot_entry .long multiboot_entry
#else /* ! __ELF__ */ entry_address_tag_end:
.long 0
.long 0
.long 0
.long 0
.long 0
#endif /* __ELF__ */ #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 1024
.long 768 .long 768
.long 32 .long 32
framebuffer_tag_end:
.long MULTIBOOT_HEADER_TAG_END
.long 12
.long 0
multiboot_header_end:
multiboot_entry: multiboot_entry:
/* Initialize the stack pointer. */ /* Initialize the stack pointer. */
movl $(stack + STACK_SIZE), %esp movl $(stack + STACK_SIZE), %esp
+16 -15
View File
@@ -335,8 +335,8 @@ not use shared libraries or other fancy features.
An OS image must contain an additional header called @dfn{Multiboot An OS image must contain an additional header called @dfn{Multiboot
header}, besides the headers of the format used by the OS image. The header}, besides the headers of the format used by the OS image. The
Multiboot header must be contained completely within the first 8192 Multiboot header must be contained completely within the first 32768
bytes of the OS image, and must be longword (32-bit) aligned. In bytes of the OS image, and must be 64-bit aligned. In
general, it should come @emph{as early as possible}, and may be general, it should come @emph{as early as possible}, and may be
embedded in the beginning of the text segment after the @emph{real} embedded in the beginning of the text segment after the @emph{real}
executable header. executable header.
@@ -408,14 +408,14 @@ Every structure has following format:
+-------------------+ +-------------------+
0 | type | 0 | type |
4 | size | 4 | size |
8-11 | optional | 8-11 | flags |
+-------------------+ +-------------------+
@end group @end group
@end example @end example
@samp{type} contains an identifier of contents of the rest of the tag. @samp{type} contains an identifier of contents of the rest of the tag.
@samp{size} contains the size of tag including header fields. @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. lacks relevant support.
Tags are terminated by a tag of type @samp{0} and size @samp{12}. 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 | 0 | type = 1 |
4 | size | 4 | size |
8 | optional | 8 | flags |
12-xx | mbi_tag_types | 12-xx | mbi_tag_types |
+-------------------+ +-------------------+
@end group @end group
@@ -451,11 +451,12 @@ actually be present. E.g. on a videoless system even if you requested tag
@group @group
+-------------------+ +-------------------+
0 | type = 2 | 0 | type = 2 |
4 | size = 24 | 4 | size = 28 |
8 | optional | 8 | flags |
12 | header_addr | 12 | header_addr |
16 | load_addr | 16 | load_addr |
20-23 | load_end_addr | 20 | load_end_addr |
24-27 | bss_end_addr |
+-------------------+ +-------------------+
@end group @end group
@end example @end example
@@ -500,7 +501,7 @@ assumes that no bss segment is present.
+-------------------+ +-------------------+
0 | type = 3 | 0 | type = 3 |
4 | size = 16 | 4 | size = 16 |
8 | optional | 8 | flags |
12-15 | entry_addr | 12-15 | entry_addr |
+-------------------+ +-------------------+
@end group @end group
@@ -524,15 +525,15 @@ start running the operating system.
+-------------------+ +-------------------+
0 | type = 4 | 0 | type = 4 |
4 | size = 16 | 4 | size = 16 |
8 | optional | 8 | flags |
12-15 | flags | 12-15 | console_flags |
+-------------------+ +-------------------+
@end group @end group
@end example @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. 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. indicates that the OS image has EGA text support.
@subsection The framebuffer tag of Multiboot header @subsection The framebuffer tag of Multiboot header
@@ -542,7 +543,7 @@ indicates that the OS image has EGA text support.
+-------------------+ +-------------------+
0 | type = 5 | 0 | type = 5 |
4 | size = 24 | 4 | size = 24 |
8 | optional | 8 | flags |
12 | width | 12 | width |
16 | height | 16 | height |
20-23 | depth | 20-23 | depth |
@@ -584,7 +585,7 @@ preference.
+-------------------+ +-------------------+
0 | type = 6 | 0 | type = 6 |
4 | size = 12 | 4 | size = 12 |
8-11 | optional | 8-11 | flags |
+-------------------+ +-------------------+
@end group @end group
@end example @end example
+70 -7
View File
@@ -23,7 +23,7 @@
#define MULTIBOOT_HEADER 1 #define MULTIBOOT_HEADER 1
/* How many bytes from the start of the file we search for the header. */ /* 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. */ /* The magic field should contain this. */
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 #define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
@@ -62,6 +62,17 @@
#define MULTIBOOT_TAG_TYPE_VBE 7 #define MULTIBOOT_TAG_TYPE_VBE 7
#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 #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 #ifndef ASM_FILE
typedef unsigned char multiboot_uint8_t; typedef unsigned char multiboot_uint8_t;
@@ -74,21 +85,73 @@ struct multiboot_header
/* Must be MULTIBOOT_MAGIC - see above. */ /* Must be MULTIBOOT_MAGIC - see above. */
multiboot_uint32_t magic; multiboot_uint32_t magic;
/* Feature flags. */ /* ISA */
multiboot_uint32_t flags; multiboot_uint32_t architecture;
/* Total header length. */
multiboot_uint32_t header_length;
/* The above fields plus this one must equal 0 mod 2^32. */ /* The above fields plus this one must equal 0 mod 2^32. */
multiboot_uint32_t checksum; multiboot_uint32_t checksum;
};
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ 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];
};
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 header_addr;
multiboot_uint32_t load_addr; multiboot_uint32_t load_addr;
multiboot_uint32_t load_end_addr; multiboot_uint32_t load_end_addr;
multiboot_uint32_t bss_end_addr; multiboot_uint32_t bss_end_addr;
multiboot_uint32_t entry_addr; };
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ struct multiboot_header_tag_entry_address
multiboot_uint32_t mode_type; {
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;
};
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 width;
multiboot_uint32_t height; multiboot_uint32_t height;
multiboot_uint32_t depth; multiboot_uint32_t depth;