* configure.ac: Bump version to 1.6.

* doc/boot.S: Use tagged multiboot header.
	* doc/kernel.c (cmain): Parse tagged mbi.
	* doc/multiboot.texi: Selfishly added myself to authors.
	(Terminology): New types u_virt and u_phys.
	(Header address fields): Removed.
	(Header graphics fields): Likewise.
	(Header tags): New section.
	(Information request header tag): Likewise.
	(Address header tag): Likewise.
	(Console header tags): Likewise.
	(Module alignment tag): Likewise.
	(Header layout): Specify new common header part.
	(Header magic fields): Likewise.
	(Machine state): Updated magic value.
	(Boot information format): Changed to tagged structure.
	* doc/multiboot2.h: Changed to tagged format.
	* doc/src2texi: Handle more comments correctly.
This commit is contained in:
Vladimir 'phcoder' Serbinenko committed 2010-03-28 14:14:16 +02:00
commit 3becbd0775
7 files changed
+675 -579

No files matched your search

+21
View File
@@ -1,3 +1,24 @@
2010-03-28 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Bump version to 1.6.
* doc/boot.S: Use tagged multiboot header.
* doc/kernel.c (cmain): Parse tagged mbi.
* doc/multiboot.texi: Selfishly added myself to authors.
(Terminology): New types u_virt and u_phys.
(Header address fields): Removed.
(Header graphics fields): Likewise.
(Header tags): New section.
(Information request header tag): Likewise.
(Address header tag): Likewise.
(Console header tags): Likewise.
(Module alignment tag): Likewise.
(Header layout): Specify new common header part.
(Header magic fields): Likewise.
(Machine state): Updated magic value.
(Boot information format): Changed to tagged structure.
* doc/multiboot2.h: Changed to tagged format.
* doc/src2texi: Handle more comments correctly.
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
* doc/kernel.c (cmain): Use padding to properly display 64-bit
+1 -1
View File
@@ -13,7 +13,7 @@ dnl LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
dnl USE OF THIS SOFTWARE.
AC_PREREQ(2.59)
AC_INIT([Multiboot], [0.6.96], [bug-grub@gnu.org])
AC_INIT([Multiboot], [1.6], [bug-grub@gnu.org])
AC_CONFIG_SRCDIR([doc/multiboot.texi])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
+26 -14
View File
@@ -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:
.short MULTIBOOT_HEADER_TAG_ADDRESS
.short MULTIBOOT_HEADER_TAG_OPTIONAL
.long address_tag_end - address_tag_start
/* 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:
.short MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS
.short MULTIBOOT_HEADER_TAG_OPTIONAL
.long entry_address_tag_end - entry_address_tag_start
/* entry_addr */
.long multiboot_entry
#else /* ! __ELF__ */
.long 0
.long 0
.long 0
.long 0
.long 0
entry_address_tag_end:
#endif /* __ELF__ */
.long 0
framebuffer_tag_start:
.short MULTIBOOT_HEADER_TAG_FRAMEBUFFER
.short MULTIBOOT_HEADER_TAG_OPTIONAL
.long framebuffer_tag_end - framebuffer_tag_start
.long 1024
.long 768
.long 32
framebuffer_tag_end:
.short MULTIBOOT_HEADER_TAG_END
.short 0
.long 8
multiboot_header_end:
multiboot_entry:
/* Initialize the stack pointer. */
movl $(stack + STACK_SIZE), %esp
+76 -93
View File
@@ -15,13 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <multiboot2.h>
#include "multiboot2.h"
/* Macros. */
/* Check if the bit BIT in FLAGS is set. */
#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit)))
/* Some screen stuff. */
/* The number of columns. */
#define COLUMNS 80
@@ -52,7 +49,8 @@ void printf (const char *format, ...);
void
cmain (unsigned long magic, unsigned long addr)
{
multiboot_info_t *mbi;
struct multiboot_tag *tag;
unsigned size;
/* Clear the screen. */
cls ();
@@ -64,115 +62,92 @@ cmain (unsigned long magic, unsigned long addr)
return;
}
/* Set MBI to the address of the Multiboot information structure. */
mbi = (multiboot_info_t *) addr;
/* Print out the flags. */
printf ("flags = 0x%x\n", (unsigned) mbi->flags);
/* Are mem_* valid? */
if (CHECK_FLAG (mbi->flags, 0))
printf ("mem_lower = %uKB, mem_upper = %uKB\n",
(unsigned) mbi->mem_lower, (unsigned) mbi->mem_upper);
/* Is boot_device valid? */
if (CHECK_FLAG (mbi->flags, 1))
printf ("boot_device = 0x%x\n", (unsigned) mbi->boot_device);
/* Is the command line passed? */
if (CHECK_FLAG (mbi->flags, 2))
printf ("cmdline = %s\n", (char *) mbi->cmdline);
/* Are mods_* valid? */
if (CHECK_FLAG (mbi->flags, 3))
if (addr & 7)
{
multiboot_module_t *mod;
int i;
printf ("mods_count = %d, mods_addr = 0x%x\n",
(int) mbi->mods_count, (int) mbi->mods_addr);
for (i = 0, mod = (multiboot_module_t *) mbi->mods_addr;
i < mbi->mods_count;
i++, mod++)
printf (" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
(unsigned) mod->mod_start,
(unsigned) mod->mod_end,
(char *) mod->cmdline);
}
/* Bits 4 and 5 are mutually exclusive! */
if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG (mbi->flags, 5))
{
printf ("Both bits 4 and 5 are set.\n");
printf ("Unaligned mbi: 0x%x\n", addr);
return;
}
/* Is the symbol table of a.out valid? */
if (CHECK_FLAG (mbi->flags, 4))
size = *(unsigned *) addr;
printf ("Announced mbi size 0x%x\n", size);
for (tag = (struct multiboot_tag *) (addr + 8);
tag->type != MULTIBOOT_TAG_TYPE_END;
tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag
+ ((tag->size + 7) & ~7)))
{
multiboot_aout_symbol_table_t *multiboot_aout_sym = &(mbi->u.aout_sym);
printf ("multiboot_aout_symbol_table: tabsize = 0x%0x, "
"strsize = 0x%x, addr = 0x%x\n",
(unsigned) multiboot_aout_sym->tabsize,
(unsigned) multiboot_aout_sym->strsize,
(unsigned) multiboot_aout_sym->addr);
}
/* Is the section header table of ELF valid? */
if (CHECK_FLAG (mbi->flags, 5))
printf ("Tag 0x%x, Size 0x%x\n", tag->type, tag->size);
switch (tag->type)
{
multiboot_elf_section_header_table_t *multiboot_elf_sec = &(mbi->u.elf_sec);
printf ("multiboot_elf_sec: num = %u, size = 0x%x,"
" addr = 0x%x, shndx = 0x%x\n",
(unsigned) multiboot_elf_sec->num, (unsigned) multiboot_elf_sec->size,
(unsigned) multiboot_elf_sec->addr, (unsigned) multiboot_elf_sec->shndx);
}
/* Are mmap_* valid? */
if (CHECK_FLAG (mbi->flags, 6))
case MULTIBOOT_TAG_TYPE_CMDLINE:
printf ("Command line = %s\n",
((struct multiboot_tag_string *) tag)->string);
break;
case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
printf ("Boot loader name = %s\n",
((struct multiboot_tag_string *) tag)->string);
break;
case MULTIBOOT_TAG_TYPE_MODULE:
printf ("Module at 0x%x-0x%x. Command line %s\n",
((struct multiboot_tag_module *) tag)->mod_start,
((struct multiboot_tag_module *) tag)->mod_end,
((struct multiboot_tag_module *) tag)->cmdline);
break;
case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
printf ("mem_lower = %uKB, mem_upper = %uKB\n",
((struct multiboot_tag_basic_meminfo *) tag)->mem_lower,
((struct multiboot_tag_basic_meminfo *) tag)->mem_upper);
break;
case MULTIBOOT_TAG_TYPE_BOOTDEV:
printf ("Boot device 0x%x,%u,%u\n",
((struct multiboot_tag_bootdev *) tag)->biosdev,
((struct multiboot_tag_bootdev *) tag)->slice,
((struct multiboot_tag_bootdev *) tag)->part);
break;
case MULTIBOOT_TAG_TYPE_MMAP:
{
multiboot_memory_map_t *mmap;
printf ("mmap_addr = 0x%x, mmap_length = 0x%x\n",
(unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
for (mmap = (multiboot_memory_map_t *) mbi->mmap_addr;
(unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
+ mmap->size + sizeof (mmap->size)))
printf (" size = 0x%x, base_addr = 0x%x%08x,"
" length = 0x%x%08x, type = 0x%x\n",
(unsigned) mmap->size,
printf ("mmap\n");
for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;
(multiboot_uint8_t *) mmap
< (multiboot_uint8_t *) tag + tag->size;
mmap = (multiboot_memory_map_t *)
((unsigned long) mmap
+ ((struct multiboot_tag_mmap *) tag)->entry_size))
printf (" base_addr = 0x%x%x,"
" length = 0x%x%x, type = 0x%x\n",
(unsigned) (mmap->addr >> 32),
(unsigned) (mmap->addr & 0xffffffff),
(unsigned) (mmap->len >> 32),
(unsigned) (mmap->len & 0xffffffff),
(unsigned) mmap->type);
}
/* Draw diagonal blue line. */
if (CHECK_FLAG (mbi->flags, 12))
break;
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
{
multiboot_uint32_t color;
unsigned i;
void *fb = (void *) (unsigned long) mbi->framebuffer_addr;
struct multiboot_tag_framebuffer *tagfb
= (struct multiboot_tag_framebuffer *) tag;
void *fb = (void *) (unsigned long) tagfb->common.framebuffer_addr;
switch (mbi->framebuffer_type)
switch (tagfb->common.framebuffer_type)
{
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
{
unsigned best_distance, distance;
struct multiboot_color *palette;
palette = (struct multiboot_color *) mbi->framebuffer_palette_addr;
palette = tagfb->framebuffer_palette;
color = 0;
best_distance = 4*256*256;
for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
for (i = 0; i < tagfb->framebuffer_palette_num_colors; i++)
{
distance = (0xff - palette[i].blue) * (0xff - palette[i].blue)
distance = (0xff - palette[i].blue)
* (0xff - palette[i].blue)
+ palette[i].red * palette[i].red
+ palette[i].green * palette[i].green;
if (distance < best_distance)
@@ -185,8 +160,8 @@ cmain (unsigned long magic, unsigned long addr)
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
color = ((1 << mbi->framebuffer_blue_mask_size) - 1)
<< mbi->framebuffer_blue_field_position;
color = ((1 << tagfb->framebuffer_blue_mask_size) - 1)
<< tagfb->framebuffer_blue_field_position;
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
@@ -197,14 +172,16 @@ cmain (unsigned long magic, unsigned long addr)
color = 0xffffffff;
break;
}
for (i = 0; i < mbi->framebuffer_width
&& i < mbi->framebuffer_height; i++)
for (i = 0; i < tagfb->common.framebuffer_width
&& i < tagfb->common.framebuffer_height; i++)
{
switch (mbi->framebuffer_bpp)
switch (tagfb->common.framebuffer_bpp)
{
case 8:
{
multiboot_uint8_t *pixel = fb + mbi->framebuffer_pitch * i + i;
multiboot_uint8_t *pixel = fb
+ tagfb->common.framebuffer_pitch * i + i;
*pixel = color;
}
break;
@@ -212,14 +189,14 @@ cmain (unsigned long magic, unsigned long addr)
case 16:
{
multiboot_uint16_t *pixel
= fb + mbi->framebuffer_pitch * i + 2 * i;
= fb + tagfb->common.framebuffer_pitch * i + 2 * i;
*pixel = color;
}
break;
case 24:
{
multiboot_uint32_t *pixel
= fb + mbi->framebuffer_pitch * i + 3 * i;
= fb + tagfb->common.framebuffer_pitch * i + 3 * i;
*pixel = (color & 0xffffff) | (*pixel & 0xff000000);
}
break;
@@ -227,15 +204,21 @@ cmain (unsigned long magic, unsigned long addr)
case 32:
{
multiboot_uint32_t *pixel
= fb + mbi->framebuffer_pitch * i + 4 * i;
= fb + tagfb->common.framebuffer_pitch * i + 4 * i;
*pixel = color;
}
break;
}
}
break;
}
}
}
tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag
+ ((tag->size + 7) & ~7));
printf ("Total mbi size 0x%x\n", (unsigned) tag - addr);
}
/* Clear the screen and initialize VIDEO, XPOS and YPOS. */
static void
+363 -335
View File
@@ -53,7 +53,7 @@ versions.
@titlepage
@sp 10
@title The Multiboot Specification version @value{VERSION}
@author Yoshinori K. Okuji, Bryan Ford, Erich Stefan Boleyn, Kunihiro Ishiguro
@author Yoshinori K. Okuji, Bryan Ford, Erich Stefan Boleyn, Kunihiro Ishiguro, Vladimir 'phcoder' Serbinenko
@page
@vskip 0pt plus 1filll
@insertcopying
@@ -296,6 +296,13 @@ little-endian, u32 is coded in little-endian.
@item u64
The type of unsigned 64-bit data. Because the target architecture is
little-endian, u64 is coded in little-endian.
@item u_phys
The type of unsigned data of the same size as target architecture physical address size.
@item u_virt
The type of unsigned data of the same size as target architecture virtual address size.
@end table
@@ -335,8 +342,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.
@@ -344,8 +351,12 @@ executable header.
@menu
* Header layout:: The layout of Multiboot header
* Header magic fields:: The magic fields of Multiboot header
* Header address fields::
* Header graphics fields::
* Header tags::
* Information request header tag::
* Address header tag::
* Console header tags::
* Module alignment tag::
@end menu
@@ -357,25 +368,15 @@ The layout of the Multiboot header must be as follows:
@multitable @columnfractions .1 .1 .2 .5
@item Offset @tab Type @tab Field Name @tab Note
@item 0 @tab u32 @tab magic @tab required
@item 4 @tab u32 @tab flags @tab required
@item 8 @tab u32 @tab checksum @tab required
@item 12 @tab u32 @tab header_addr @tab if flags[16] is set
@item 16 @tab u32 @tab load_addr @tab if flags[16] is set
@item 20 @tab u32 @tab load_end_addr @tab if flags[16] is set
@item 24 @tab u32 @tab bss_end_addr @tab if flags[16] is set
@item 28 @tab u32 @tab entry_addr @tab if flags[16] is set
@item 32 @tab u32 @tab mode_type @tab if flags[2] is set
@item 36 @tab u32 @tab width @tab if flags[2] is set
@item 40 @tab u32 @tab height @tab if flags[2] is set
@item 44 @tab u32 @tab depth @tab if flags[2] is set
@item 4 @tab u32 @tab architecture @tab required
@item 8 @tab u32 @tab header_length @tab required
@item 12 @tab u32 @tab checksum @tab required
@item 16-XX @tab @tab tags @tab required
@end multitable
The fields @samp{magic}, @samp{flags} and @samp{checksum} are defined in
@ref{Header magic fields}, the fields @samp{header_addr},
@samp{load_addr}, @samp{load_end_addr}, @samp{bss_end_addr} and
@samp{entry_addr} are defined in @ref{Header address fields}, and the
fields @samp{mode_type}, @samp{width}, @samp{height} and @samp{depth} are
defined in @ref{Header graphics fields}.
The fields @samp{magic}, @samp{architecture}, @samp{header_length} and @samp{checksum} are defined in @ref{Header magic fields}, @samp{tags}
are defined in @ref{Header tags}. All fields are in native endianness.
On bi-endian platforms native-endianness means the endiannes OS image starts in.
@node Header magic fields
@@ -384,58 +385,90 @@ defined in @ref{Header graphics fields}.
@table @samp
@item magic
The field @samp{magic} is the magic number identifying the header,
which must be the hexadecimal value @code{0x1BADB002}.
which must be the hexadecimal value @code{0xE85250D6}.
@item flags
The field @samp{flags} specifies features that the OS image requests or
requires of an boot loader. Bits 0-15 indicate requirements; if the
boot loader sees any of these bits set but doesn't understand the flag
or can't fulfill the requirements it indicates for some reason, it must
notify the user and fail to load the OS image. Bits 16-31 indicate
optional features; if any bits in this range are set but the boot loader
doesn't understand them, it may simply ignore them and proceed as
usual. Naturally, all as-yet-undefined bits in the @samp{flags} word
must be set to zero in OS images. This way, the @samp{flags} fields
serves for version control as well as simple feature selection.
@item architecture
The field @samp{architecture} specifies the Central Processing Unit
Instruction Set Architecture. Since @samp{magic} isn't a palindrome
it already specifies the endianness ISAs differing only in endianness
recieve the same ID. @samp{0} means 32-bit (protected) mode of i386.
If bit 0 in the @samp{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.
@item header_length
The field @samp{header_length} specifies the Length of multiboot header
in bytes including magic fields.
If bit 1 in the @samp{flags} word is set, then information on available
memory via at least the @samp{mem_*} fields of the Multiboot information
structure (@pxref{Boot information format}) must be included. If the
boot loader is capable of passing a memory map (the @samp{mmap_*} fields)
and one exists, then it may be included as well.
If bit 2 in the @samp{flags} word is set, information about the video
mode table (@pxref{Boot information format}) must be available to the
kernel.
If bit 16 in the @samp{flags} word is set, then the fields at offsets
12-28 in the Multiboot header are valid, and the boot loader should use
them instead of the fields in the actual executable header to calculate
where to load the OS image. This information does not need to be
provided if the kernel image is in @sc{elf} format, but it @emph{must}
be provided if the images is in a.out format or in some other
format. Compliant boot loaders must be able to load images that either
are in @sc{elf} format or contain the load address information embedded
in the Multiboot header; they may also directly support other executable
formats, such as particular a.out variants, but are not required to.
@item checksum
The field @samp{checksum} is a 32-bit unsigned value which, when added
to the other magic fields (i.e. @samp{magic} and @samp{flags}), must
have a 32-bit unsigned sum of zero.
to the other magic fields (i.e. @samp{magic}, @samp{architecture}
and @samp{header_length}), must have a 32-bit unsigned sum of zero.
@end table
@node Header address fields
@subsection The address fields of Multiboot header
@node Header tags
@subsection General tag structure
Tags constitutes a buffer of structures following each other padded on @samp{u_virt} size.
Every structure has following format:
All of the address fields enabled by flag bit 16 are physical addresses.
@example
@group
+-------------------+
u16 | type |
u16 | flags |
u32 | size |
+-------------------+
@end group
@end example
@samp{type} is divided into 2 parts. Lower contains an identifier of contents of the rest of the tag.
@samp{size} contains the size of tag including header fields.
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{8}.
@node Information request header tag
@subsection Multiboot information request
@example
@group
+-------------------+
u16 | type = 1 |
u16 | flags |
u32 | size |
u32[n] | mbi_tag_types |
+-------------------+
@end group
@end example
@samp{mbi_tag_types} is an array of u32 each one representing an information
request
If this tag is present and @samp{optional} is set to @samp{0} information
conveyed by requested tag types must be present. If bootloader is unable
to supply this information it must fail with an error
Note: it doesn't garantee that any tags of type @samp{mbi_tag_types} will
actually be present. E.g. on a videoless system even if you requested tag
@samp{8} no tags of type @samp{8} will be present in mbi.
@node Address header tag
@subsection The address tag of Multiboot header
@example
@group
+-------------------+
u16 | type = 2 |
u16 | flags |
u32 | size |
u_virt | header_addr |
u_virt | load_addr |
u_virt | load_end_addr |
u_virt | bss_end_addr |
+-------------------+
@end group
@end example
All of the address fields in this tag are physical addresses.
The meaning of each is as follows:
@table @code
@@ -466,29 +499,74 @@ occupies to avoid placing boot modules and other data relevant to the
operating system in that area. If this field is zero, the boot loader
assumes that no bss segment is present.
@end table
@subsection The entry address tag of Multiboot header
@example
@group
+-------------------+
u16 | type = 3 |
u16 | flags |
u32 | size |
u_virt | entry_addr |
+-------------------+
@end group
@end example
All of the address fields in this tag are physical addresses.
The meaning of each is as follows:
@table @code
@item entry_addr
The physical address to which the boot loader should jump in order to
start running the operating system.
@end table
@node Console header tags
@subsection Flags tag
@node Header graphics fields
@subsection The graphics fields of Multiboot header
@example
@group
+-------------------+
u16 | type = 4 |
u16 | flags |
u32 | size = 12 |
u32 | console_flags |
+-------------------+
@end group
@end example
All of the graphics fields are enabled by flag bit 2. They specify the
preferred graphics mode. Note that that is only a @emph{recommended}
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{console_flags} is set it
indicates that the OS image has EGA text support.
@subsection The framebuffer tag of Multiboot header
@example
@group
+-------------------+
u16 | type = 5 |
u16 | flags |
u32 | size = 20 |
u32 | width |
u32 | height |
u32 | depth |
+-------------------+
@end group
@end example
This tag specifies the preferred graphics mode. If this tag is present
bootloader assumes that the payload has framebuffer support.
Note that that is only a @emph{recommended}
mode by the OS image. Boot loader may choose a different mode if it sees fit.
The meaning of each is as follows:
@table @code
@item mode_type
Contains @samp{0} for linear graphics mode or @samp{1} for
EGA-standard text mode. Everything else is reserved for future
expansion. Note that the boot loader may set a text mode even if this
field contains @samp{0}, or set a video mode even if this field contains
@samp{1}.
@item width
Contains the number of the columns. This is specified in pixels in a
graphics mode, and in characters in a text mode. The value zero
@@ -506,6 +584,22 @@ preference.
@end table
@node Module alignment tag
@subsection Module alignment tag
@example
@group
+-------------------+
u16 | type = 6 |
u16 | flags |
u32 | size = 12 |
+-------------------+
@end group
@end example
If this tag is present modules must be page aligned.
@node Machine state
@section Machine state
@@ -514,7 +608,7 @@ must have the following state:
@table @samp
@item EAX
Must contain the magic value @samp{0x2BADB002}; the presence of this
Must contain the magic value @samp{0x36d76289}; the presence of this
value indicates to the operating system that it was loaded by a
Multiboot-compliant boot loader (e.g. as opposed to another type of
boot loader that the operating system can also be loaded from).
@@ -577,9 +671,8 @@ changed them during the switch to 32-bit mode.
@node Boot information format
@section Boot information format
FIXME: Split this chapter like the chapter ``OS image format''.
@section Boot information
@subsection Boot information format
Upon entry to the operating system, the @code{EBX} register contains the
physical address of a @dfn{Multiboot information} data structure,
@@ -594,317 +687,238 @@ memory reserved for the kernel and boot modules, of course). It is the
operating system's responsibility to avoid overwriting this memory until
it is done using it.
The format of the Multiboot information structure (as defined so far)
follows:
@subsection Basic tags structure
Boot information consists of fixed part and a series of tags. Its start is 8-bytes aligned. Fixed part is as following:
@example
@group
+-------------------+
u32 | total_size |
u32 | reserved |
+-------------------+
@end group
@end example
@samp{total_size} contains the total size of boot information including
this field and terminating tag in bytes
@samp{reserved} is always set to zero and must be ignored by OS image
Every tag begins with following fields:
@example
@group
+-------------------+
0 | flags | (required)
u32 | type |
u32 | size |
+-------------------+
4 | mem_lower | (present if flags[0] is set)
8 | mem_upper | (present if flags[0] is set)
+-------------------+
12 | boot_device | (present if flags[1] is set)
+-------------------+
16 | cmdline | (present if flags[2] is set)
+-------------------+
20 | mods_count | (present if flags[3] is set)
24 | mods_addr | (present if flags[3] is set)
+-------------------+
28 - 40 | syms | (present if flags[4] or
| | flags[5] is set)
+-------------------+
44 | mmap_length | (present if flags[6] is set)
48 | mmap_addr | (present if flags[6] is set)
+-------------------+
52 | drives_length | (present if flags[7] is set)
56 | drives_addr | (present if flags[7] is set)
+-------------------+
60 | config_table | (present if flags[8] is set)
+-------------------+
64 | boot_loader_name | (present if flags[9] is set)
+-------------------+
68 | apm_table | (present if flags[10] is set)
+-------------------+
72 | vbe_control_info | (present if flags[11] is set)
76 | vbe_mode_info |
80 | vbe_mode |
82 | vbe_interface_seg |
84 | vbe_interface_off |
86 | vbe_interface_len |
+-------------------+
88 | framebuffer_addr | (present if flags[12] is set)
96 | framebuffer_pitch |
100 | framebuffer_width |
104 | framebuffer_height|
108 | framebuffer_bpp |
109 | framebuffer_type |
110-115 | color_info |
+-------------------+
@end group
@end example
The first longword indicates the presence and validity of other fields
in the Multiboot information structure. All as-yet-undefined bits must
be set to zero by the boot loader. Any set bits that the operating
system does not understand should be ignored. Thus, the @samp{flags}
field also functions as a version indicator, allowing the Multiboot
information structure to be expanded in the future without breaking
anything.
@samp{type} contains an identifier of contents of the rest of the tag.
@samp{size} contains the size of tag including header fields but not including padding.
Tags follow one another padded when necessary in order for each tag to start at 8-bytes aligned address. Tags are terminated by a tag of type @samp{0} and size @samp{8}.
If bit 0 in the @samp{flags} word is set, then the @samp{mem_*} fields
are valid. @samp{mem_lower} and @samp{mem_upper} indicate the amount of
@subsection Basic memory information
@example
@group
+-------------------+
u32 | type = 4 |
u32 | size = 16 |
u32 | mem_lower |
u32 | mem_upper |
+-------------------+
@end group
@end example
@samp{mem_lower} and @samp{mem_upper} indicate the amount of
lower and upper memory, respectively, in kilobytes. Lower memory starts
at address 0, and upper memory starts at address 1 megabyte. The maximum
possible value for lower memory is 640 kilobytes. The value returned for
upper memory is maximally the address of the first upper memory hole
minus 1 megabyte. It is not guaranteed to be this value.
If bit 1 in the @samp{flags} word is set, then the @samp{boot_device}
field is valid, and indicates which @sc{bios} disk device the boot
loader loaded the OS image from. If the OS image was not loaded from a
@sc{bios} disk, then this field must not be present (bit 3 must be
clear). The operating system may use this field as a hint for
determining its own @dfn{root} device, but is not required to. The
@samp{boot_device} field is laid out in four one-byte subfields as
follows:
@subsection BIOS Boot device
@example
@group
+-------+-------+-------+-------+
| part3 | part2 | part1 | drive |
+-------+-------+-------+-------+
+-------------------+
u32 | type = 5 |
u32 | size = 20 |
u32 | biosdev |
u32 | partition |
u32 | sub_parition |
+-------------------+
@end group
@end example
The first byte contains the @sc{bios} drive number as understood by the
This tag indicates which @sc{bios} disk device the boot
loader loaded the OS image from. If the OS image was not loaded from a
@sc{bios} disk, then this tag must not be present. The operating system may
use this field as a hint for determining its own @dfn{root} device,
but is not required to.
The @samp{biosdev} contains the @sc{bios} drive number as understood by the
@sc{bios} INT 0x13 low-level disk interface: e.g. 0x00 for the first
floppy disk or 0x80 for the first hard disk.
The three remaining bytes specify the boot partition. @samp{part1}
specifies the @dfn{top-level} partition number, @samp{part2} specifies a
The three remaining bytes specify the boot partition. @samp{partition}
specifies the @dfn{top-level} partition number, @samp{sub_partition} specifies a
@dfn{sub-partition} in the top-level partition, etc. Partition numbers
always start from zero. Unused partition bytes must be set to 0xFF. For
always start from zero. Unused partition bytes must be set to 0xFFFFFFFF. For
example, if the disk is partitioned using a simple one-level DOS
partitioning scheme, then @samp{part1} contains the DOS partition
number, and @samp{part2} and @samp{part3} are both 0xFF. As another
partitioning scheme, then @samp{partition} contains the DOS partition
number, and @samp{sub_partition} if 0xFFFFFF. As another
example, if a disk is partitioned first into DOS partitions, and then
one of those DOS partitions is subdivided into several BSD partitions
using BSD's @dfn{disklabel} strategy, then @samp{part1} contains the DOS
partition number, @samp{part2} contains the BSD sub-partition within
that DOS partition, and @samp{part3} is 0xFF.
using BSD's @dfn{disklabel} strategy, then @samp{partition} contains the DOS
partition number and @samp{sub_partition} contains the BSD sub-partition within
that DOS partition.
DOS extended partitions are indicated as partition numbers starting from
4 and increasing, rather than as nested sub-partitions, even though the
underlying disk layout of extended partitions is hierarchical in
nature. For example, if the boot loader boots from the second extended
partition on a disk partitioned in conventional DOS style, then
@samp{part1} will be 5, and @samp{part2} and @samp{part3} will both be
0xFF.
@samp{partition} will be 5, and @samp{sub_partiton} will be 0xFFFFFFFF.
If bit 2 of the @samp{flags} longword is set, the @samp{cmdline} field
is valid, and contains the physical address of the command line to
be passed to the kernel. The command line is a normal C-style
zero-terminated string.
If bit 3 of the @samp{flags} is set, then the @samp{mods} fields
indicate to the kernel what boot modules were loaded along with the
kernel image, and where they can be found. @samp{mods_count} contains
the number of modules loaded; @samp{mods_addr} contains the physical
address of the first module structure. @samp{mods_count} may be zero,
indicating no boot modules were loaded, even if bit 3 of @samp{flags} is
set. Each module structure is formatted as follows:
@subsection Boot command line
@example
@group
+-------------------+
0 | mod_start |
4 | mod_end |
+-------------------+
8 | string |
+-------------------+
12 | reserved (0) |
u32 | type = 1 |
u32 | size |
u8[n] | string |
+-------------------+
@end group
@end example
The first two fields contain the start and end addresses of the boot
@samp{string} contains command line. The command line is a normal C-style
zero-terminated UTF-8 string.
@subsection Modules
@example
@group
+-------------------+
u32 | type = 3 |
u32 | size |
u_phys | mod_start |
u_phys | mod_end |
u8[n] | string |
+-------------------+
@end group
@end example
This tag indicates to the kernel what boot module was loaded along with the
kernel image, and where it can be found.
The @samp{mod_start} and @samp{mod_end} contain the start and end addresses of the boot
module itself. The @samp{string} field provides an arbitrary string to
be associated with that particular boot module; it is a zero-terminated
ASCII string, just like the kernel command line. The @samp{string} field
may be 0 if there is no string associated with the module. Typically the
UTF-8 string, just like the kernel command line. Typically the
string might be a command line (e.g. if the operating system treats boot
modules as executable programs), or a pathname (e.g. if the operating
system treats boot modules as files in a file system), but its exact use
is specific to the operating system. The @samp{reserved} field must be
set to 0 by the boot loader and ignored by the operating system.
is specific to the operating system.
@strong{Caution:} Bits 4 & 5 are mutually exclusive.
If bit 4 in the @samp{flags} word is set, then the following fields in
the Multiboot information structure starting at byte 28 are valid:
One tag appears per module. This tag type may appear multiple times.
@subsection ELF-Symbols
@example
@group
+-------------------+
28 | tabsize |
32 | strsize |
36 | addr |
40 | reserved (0) |
u32 | type = 9 |
u32 | size |
u16 | num |
u16 | entsize |
u16 | shndx |
u16 | reserved |
varies | section headers |
+-------------------+
@end group
@end example
These indicate where the symbol table from an a.out kernel image can be
found. @samp{addr} is the physical address of the size (4-byte unsigned
long) of an array of a.out format @dfn{nlist} structures, followed
immediately by the array itself, then the size (4-byte unsigned long) of
a set of zero-terminated @sc{ascii} strings (plus sizeof(unsigned long) in
this case), and finally the set of strings itself. @samp{tabsize} is
equal to its size parameter (found at the beginning of the symbol
section), and @samp{strsize} is equal to its size parameter (found at
the beginning of the string section) of the following string table to
which the symbol table refers. Note that @samp{tabsize} may be 0,
indicating no symbols, even if bit 4 in the @samp{flags} word is set.
If bit 5 in the @samp{flags} word is set, then the following fields in
the Multiboot information structure starting at byte 28 are valid:
@example
@group
+-------------------+
28 | num |
32 | size |
36 | addr |
40 | shndx |
+-------------------+
@end group
@end example
These indicate where the section header table from an ELF kernel is, the
This tag contains section header table from an ELF kernel, the
size of each entry, number of entries, and the string table used as the
index of names. They correspond to the @samp{shdr_*} entries
(@samp{shdr_num}, etc.) in the Executable and Linkable Format (@sc{elf})
specification in the program header. All sections are loaded, and the
physical address fields of the @sc{elf} section header then refer to where
the sections are in memory (refer to the i386 @sc{elf} documentation for
details as to how to read the section header(s)). Note that
@samp{shdr_num} may be 0, indicating no symbols, even if bit 5 in the
@samp{flags} word is set.
details as to how to read the section header(s)).
If bit 6 in the @samp{flags} word is set, then the @samp{mmap_*} fields
are valid, and indicate the address and length of a buffer containing a
memory map of the machine provided by the @sc{bios}. @samp{mmap_addr} is
the address, and @samp{mmap_length} is the total size of the buffer. The
buffer consists of one or more of the following size/structure pairs
(@samp{size} is really used for skipping to the next pair):
@subsection Memory map
This tag provides memory map.
@example
@group
+-------------------+
-4 | size |
+-------------------+
0 | base_addr |
8 | length |
16 | type |
u32 | type = 6 |
u32 | size |
u32 | entry_size |
u32 | entry_version |
varies | entries |
+-------------------+
@end group
@end example
where @samp{size} is the size of the associated structure in bytes, which
can be greater than the minimum of 20 bytes. @samp{base_addr} is the
starting address. @samp{length} is the size of the memory region in bytes.
@samp{entry_size} contains the size of one entry so that in future new fields may be added to it. It's guaranteed to be a multiple of 8. @samp{entry_version} is currently set at @samp{0}. Future versions will increment this field. Future version are guranteed to be backward compatible with older format. Each entry has the following structure:
@example
@group
+-------------------+
u64 | base_addr |
u64 | length |
u32 | type |
u32 | reserved |
+-------------------+
@end group
@end example
@samp{size} contains the size of current entry including this field itself. It may be bigger than 24 bytes in future versions but is guaranteed to be
@samp{base_addr} is the starting physical address. @samp{length} is the size of the memory region in bytes.
@samp{type} is the variety of address range represented, where a
value of 1 indicates available @sc{ram}, value of 3 indicates usable memory
holding ACPI information, value of 4 indicates reserved memory which needs to
be preserved on hibernation and all other values currently
indicated a reserved area.
@samp{reserved} is set to @samp{0} by bootloader and must be ignored by the OS image.
The map provided is guaranteed to list all standard @sc{ram} that should
be available for normal use.
If bit 7 in the @samp{flags} is set, then the @samp{drives_*} fields
are valid, and indicate the address of the physical address of the first
drive structure and the size of drive structures. @samp{drives_addr}
is the address, and @samp{drives_length} is the total size of drive
structures. Note that @samp{drives_length} may be zero. Each drive
structure is formatted as follows:
@subsection Boot loader name
@example
@group
+-------------------+
0 | size |
+-------------------+
4 | drive_number |
+-------------------+
5 | drive_mode |
+-------------------+
6 | drive_cylinders |
8 | drive_heads |
9 | drive_sectors |
+-------------------+
10 - xx | drive_ports |
u32 | type = 2 |
u32 | size |
u8[n] | string |
+-------------------+
@end group
@end example
The @samp{size} field specifies the size of this structure. The size
varies, depending on the number of ports. Note that the size may not be
equal to (10 + 2 * the number of ports), because of an alignment.
The @samp{drive_number} field contains the BIOS drive number. The
@samp{drive_mode} field represents the access mode used by the boot
loader. Currently, the following modes are defined:
@table @samp
@item 0
CHS mode (traditional cylinder/head/sector addressing mode).
@item 1
LBA mode (Logical Block Addressing mode).
@end table
The three fields, @samp{drive_cylinders}, @samp{drive_heads} and
@samp{drive_sectors}, indicate the geometry of the drive detected by the
@sc{bios}. @samp{drive_cylinders} contains the number of the
cylinders. @samp{drive_heads} contains the number of the
heads. @samp{drive_sectors} contains the number of the sectors per
track.
The @samp{drive_ports} field contains the array of the I/O ports used
for the drive in the @sc{bios} code. The array consists of zero or more
unsigned two-bytes integers, and is terminated with zero. Note that the
array may contain any number of I/O ports that are not related to the
drive actually (such as @sc{dma} controller's ports).
If bit 8 in the @samp{flags} is set, then the @samp{config_table} field
is valid, and indicates the address of the @sc{rom} configuration table
returned by the @dfn{GET CONFIGURATION} @sc{bios} call. If the @sc{bios}
call fails, then the size of the table must be @emph{zero}.
If bit 9 in the @samp{flags} is set, the @samp{boot_loader_name} field
is valid, and contains the physical address of the name of a boot
loader booting the kernel. The name is a normal C-style zero-terminated
@samp{string} contains the name of a boot
loader booting the kernel. The name is a normal C-style UTF-8 zero-terminated
string.
If bit 10 in the @samp{flags} is set, the @samp{apm_table} field is
valid, and contains the physical address of an @sc{apm} table defined as
below:
@subsection APM table
The tag type 10 contains @sc{apm} table
@example
@group
+----------------------+
0 | version |
2 | cseg |
4 | offset |
8 | cseg_16 |
10 | dseg |
12 | flags |
14 | cseg_len |
16 | cseg_16_len |
18 | dseg_len |
u32 | type = 10 |
u32 | size = 28 |
u16 | version |
u16 | cseg |
u32 | offset |
u16 | cseg_16 |
u16 | dseg |
u16 | flags |
u16 | cseg_len |
u16 | cseg_16_len |
u16 | dseg_len |
+----------------------+
@end group
@end example
@@ -921,10 +935,24 @@ bytes, and the others are 2 bytes. See
@uref{http://www.microsoft.com/hwdev/busbios/amp_12.htm, Advanced Power
Management (APM) BIOS Interface Specification}, for more information.
If bit 11 in the @samp{flags} is set, the @sc{vbe} table is available.
@subsection VBE info
@example
@group
+-------------------+
u32 | type = 7 |
u32 | size = 784 |
u16 | vbe_mode |
u16 | vbe_interface_seg |
u16 | vbe_interface_off |
u16 | vbe_interface_len |
u8[512] | vbe_control_info |
u8[256] | vbe_mode_info |
+-------------------+
@end group
@end example
The fields @samp{vbe_control_info} and @samp{vbe_mode_info} contain
the physical addresses of @sc{vbe} control information returned by the
@sc{vbe} control information returned by the
@sc{vbe} Function 00h and @sc{vbe} mode information returned by the
@sc{vbe} Function 01h, respectively.
@@ -939,62 +967,62 @@ mode interface which is incompatible with the old one. If you want to
use the new protected mode interface, you will have to find the table
yourself.
The fields for the graphics table are designed for @sc{vbe}, but
Multiboot boot loaders may simulate @sc{vbe} on non-@sc{vbe} modes, as
if they were @sc{vbe} modes.
@subsection Framebuffer info
@example
@group
+--------------------+
u32 | type = 8 |
u32 | size |
u64 | framebuffer_addr |
u32 | framebuffer_pitch |
u32 | framebuffer_width |
u32 | framebuffer_height |
u8 | framebuffer_bpp |
u8 | framebuffer_type |
u8 | reserved |
varies | color_info |
+--------------------+
@end group
@end example
If bit 12 in the @samp{flags} is set, the @sc{Framebuffer} table is available.
The field @samp{framebuffer_addr} contains framebuffer physical address. This
field is 64-bit wide but bootloader @dfn{should} set it under 4 GiB if possible
for compatibility with kernels which aren't aware of PAE or AMD64. The field
@samp{framebuffer_pitch} contains the framebuffer pitch in bytes. The fields
@samp{framebuffer_width}, @samp{framebuffer_height} contain the framebuffer
dimensions in pixels. The field @samp{framebuffer_bpp} contains the number of
bits per pixel. If @samp{framebuffer_type} is set to @samp{0} it means
indexed color will be used. In this case color_info is defined as follows:
The field @samp{framebuffer_addr} contains framebuffer physical address. This field is 64-bit wide but bootloader @dfn{should} set it under 4GiB if possible for compatibility with payloads which aren't aware of PAE or amd64. The field @samp{framebuffer_pitch} contains pitch in bytes. The fields @samp{framebuffer_width}, @samp{framebuffer_height} contain framebuffer dimensions in pixels. The field @samp{framebuffer_bpp} contains number of bits per pixel. @samp{reserved} always contains 0 in current version of specification and must be ignored by OS image. If @samp{framebuffer_type} is set to 0 it means indexed color. In this case color_info is defined as follows:
@example
@group
+----------------------------------+
110 | framebuffer_palette_addr |
114 | framebuffer_palette_num_colors |
u32 | framebuffer_palette_num_colors |
varies | framebuffer_palette |
+----------------------------------+
@end group
@end example
@samp{framebuffer_palette_addr} contains the address of the color palette,
which is an array of color descriptors. Each color descriptor has the
following structure:
@samp{framebuffer_palette} is an array of colour descriptors.
Each colour descriptor has following structure:
@example
@group
+-------------+
0 | red_value |
1 | green_value |
2 | blue_value |
u8 | red_value |
u8 | green_value |
u8 | blue_value |
+-------------+
@end group
@end example
If @samp{framebuffer_type} is set to @samp{1} it means direct RGB color will
be used. Then color_type is defined as follows:
If @samp{framebuffer_type} is set to @samp{1} it means direct RGB color.
Then color_type is defined as follows:
@example
@group
+----------------------------------+
110 | framebuffer_red_field_position |
111 | framebuffer_red_mask_size |
112 | framebuffer_green_field_position |
113 | framebuffer_green_mask_size |
114 | framebuffer_blue_field_position |
115 | framebuffer_blue_mask_size |
u8 | framebuffer_red_field_position |
u8 | framebuffer_red_mask_size |
u8 | framebuffer_green_field_position |
u8 | framebuffer_green_mask_size |
u8 | framebuffer_blue_field_position |
u8 | framebuffer_blue_mask_size |
+----------------------------------+
@end group
@end example
If @samp{framebuffer_type} is set to @samp{2} it means EGA-standard text mode
will be used. In this case @samp{framebuffer_width} and
@samp{framebuffer_height} are expressed in characters instead of pixels.
@samp{framebuffer_bpp} is equal to 16 (bits per character) and
@samp{framebuffer_pitch} is expressed in bytes per text line.
All further values of @samp{framebuffer_type} are reserved for future expansion.
If @samp{framebuffer_type} is set to @samp{2} it means EGA text. In this case @samp{framebuffer_width} and @samp{framebuffer_height} are expressed in characters and not in pixels. @samp{framebuffer_bpp} is equal 16 (16 bits per character) and @samp{framebuffer_pitch} is expressed in bytes per text line.
All further values of @samp{framebuffer_type} are reserved for future expansion
@node Examples
@chapter Examples
+187 -135
View File
@@ -23,7 +23,8 @@
#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
#define MULTIBOOT_HEADER_ALIGN 8
/* The magic field should contain this. */
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
@@ -35,58 +36,36 @@
#define MULTIBOOT_MOD_ALIGN 0x00001000
/* Alignment of the multiboot info structure. */
#define MULTIBOOT_INFO_ALIGN 0x00000004
#define MULTIBOOT_INFO_ALIGN 0x00000008
/* Flags set in the 'flags' member of the multiboot header. */
/* Align all boot modules on i386 page (4KB) boundaries. */
#define MULTIBOOT_PAGE_ALIGN 0x00000001
#define MULTIBOOT_TAG_ALIGN 8
#define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
#define MULTIBOOT_TAG_TYPE_MODULE 3
#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
#define MULTIBOOT_TAG_TYPE_BOOTDEV 5
#define MULTIBOOT_TAG_TYPE_MMAP 6
#define MULTIBOOT_TAG_TYPE_VBE 7
#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
#define MULTIBOOT_TAG_TYPE_APM 10
/* Must pass memory information to OS. */
#define MULTIBOOT_MEMORY_INFO 0x00000002
#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
/* Must pass video information to OS. */
#define MULTIBOOT_VIDEO_MODE 0x00000004
#define GRUB_MULTIBOOT_ARCHITECTURE_I386 0
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
/* This flag indicates the use of the address fields in the header. */
#define MULTIBOOT_AOUT_KLUDGE 0x00010000
/* Flags to be set in the 'flags' member of the multiboot info structure. */
/* is there basic lower/upper memory information? */
#define MULTIBOOT_INFO_MEMORY 0x00000001
/* is there a boot device set? */
#define MULTIBOOT_INFO_BOOTDEV 0x00000002
/* is the command-line defined? */
#define MULTIBOOT_INFO_CMDLINE 0x00000004
/* are there modules to do something with? */
#define MULTIBOOT_INFO_MODS 0x00000008
/* These next two are mutually exclusive */
/* is there a symbol table loaded? */
#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
/* is there an ELF section header table? */
#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
/* is there a full memory map? */
#define MULTIBOOT_INFO_MEM_MAP 0x00000040
/* Is there drive info? */
#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
/* Is there a config table? */
#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
/* Is there a boot loader name? */
#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
/* Is there a APM table? */
#define MULTIBOOT_INFO_APM_TABLE 0x00000400
/* Is there video information? */
#define MULTIBOOT_INFO_VBE_INFO 0x00000800
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
#ifndef ASM_FILE
@@ -100,45 +79,77 @@ 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;
};
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
struct multiboot_header_tag
{
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
};
struct multiboot_header_tag_information_request
{
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
multiboot_uint32_t requests[0];
};
struct multiboot_header_tag_address
{
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
multiboot_uint32_t header_addr;
multiboot_uint32_t load_addr;
multiboot_uint32_t load_end_addr;
multiboot_uint32_t bss_end_addr;
multiboot_uint32_t entry_addr;
};
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
multiboot_uint32_t mode_type;
struct multiboot_header_tag_entry_address
{
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
multiboot_uint32_t entry_addr;
};
struct multiboot_header_tag_console_flags
{
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
multiboot_uint32_t console_flags;
};
struct multiboot_header_tag_framebuffer
{
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
multiboot_uint32_t width;
multiboot_uint32_t height;
multiboot_uint32_t depth;
};
/* The symbol table for a.out. */
struct multiboot_aout_symbol_table
struct multiboot_header_tag_module_align
{
multiboot_uint32_t tabsize;
multiboot_uint32_t strsize;
multiboot_uint32_t addr;
multiboot_uint32_t reserved;
};
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
/* The section header table for ELF. */
struct multiboot_elf_section_header_table
{
multiboot_uint32_t num;
multiboot_uint16_t type;
multiboot_uint16_t flags;
multiboot_uint32_t size;
multiboot_uint32_t addr;
multiboot_uint32_t shndx;
multiboot_uint32_t width;
multiboot_uint32_t height;
multiboot_uint32_t depth;
};
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
struct multiboot_color
{
@@ -147,56 +158,96 @@ struct multiboot_color
multiboot_uint8_t blue;
};
struct multiboot_info
struct multiboot_mmap_entry
{
/* Multiboot info version number */
multiboot_uint32_t flags;
multiboot_uint64_t addr;
multiboot_uint64_t len;
#define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4
multiboot_uint32_t type;
multiboot_uint32_t zero;
} __attribute__((packed));
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
/* Available memory from BIOS */
struct multiboot_tag
{
multiboot_uint32_t type;
multiboot_uint32_t size;
};
struct multiboot_tag_string
{
multiboot_uint32_t type;
multiboot_uint32_t size;
char string[0];
};
struct multiboot_tag_module
{
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint32_t mod_start;
multiboot_uint32_t mod_end;
char cmdline[0];
};
struct multiboot_tag_basic_meminfo
{
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint32_t mem_lower;
multiboot_uint32_t mem_upper;
};
/* "root" partition */
multiboot_uint32_t boot_device;
/* Kernel command line */
multiboot_uint32_t cmdline;
/* Boot-Module list */
multiboot_uint32_t mods_count;
multiboot_uint32_t mods_addr;
union
struct multiboot_tag_bootdev
{
multiboot_aout_symbol_table_t aout_sym;
multiboot_elf_section_header_table_t elf_sec;
} u;
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint32_t biosdev;
multiboot_uint32_t slice;
multiboot_uint32_t part;
};
/* Memory Mapping buffer */
multiboot_uint32_t mmap_length;
multiboot_uint32_t mmap_addr;
struct multiboot_tag_mmap
{
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint32_t entry_size;
multiboot_uint32_t entry_version;
struct multiboot_mmap_entry entries[0];
};
/* Drive Info buffer */
multiboot_uint32_t drives_length;
multiboot_uint32_t drives_addr;
struct multiboot_vbe_info_block
{
multiboot_uint8_t external_specification[512];
};
/* ROM configuration table */
multiboot_uint32_t config_table;
struct multiboot_vbe_mode_info_block
{
multiboot_uint8_t external_specification[256];
};
/* Boot Loader Name */
multiboot_uint32_t boot_loader_name;
struct multiboot_tag_vbe
{
multiboot_uint32_t type;
multiboot_uint32_t size;
/* APM table */
multiboot_uint32_t apm_table;
/* Video */
multiboot_uint32_t vbe_control_info;
multiboot_uint32_t vbe_mode_info;
multiboot_uint16_t vbe_mode;
multiboot_uint16_t vbe_interface_seg;
multiboot_uint16_t vbe_interface_off;
multiboot_uint16_t vbe_interface_len;
struct multiboot_vbe_info_block vbe_control_info;
struct multiboot_vbe_mode_info_block vbe_mode_info;
};
struct multiboot_tag_framebuffer_common
{
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint64_t framebuffer_addr;
multiboot_uint32_t framebuffer_pitch;
multiboot_uint32_t framebuffer_width;
@@ -206,16 +257,20 @@ struct multiboot_info
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
multiboot_uint8_t framebuffer_type;
union
{
/* Indexed color. */
struct
{
struct multiboot_color *framebuffer_palette_addr;
multiboot_uint16_t framebuffer_palette_num_colors;
multiboot_uint16_t reserved;
};
/* Direct RGB color. */
struct multiboot_tag_framebuffer
{
struct multiboot_tag_framebuffer_common common;
union
{
struct
{
multiboot_uint16_t framebuffer_palette_num_colors;
struct multiboot_color framebuffer_palette[0];
};
struct
{
multiboot_uint8_t framebuffer_red_field_position;
@@ -227,34 +282,31 @@ struct multiboot_info
};
};
};
typedef struct multiboot_info multiboot_info_t;
struct multiboot_mmap_entry
struct multiboot_tag_elf_sections
{
multiboot_uint32_t size;
multiboot_uint64_t addr;
multiboot_uint64_t len;
#define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4
multiboot_uint32_t type;
} __attribute__((packed));
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_mod_list
{
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
multiboot_uint32_t mod_start;
multiboot_uint32_t mod_end;
/* Module command line */
multiboot_uint32_t cmdline;
/* padding to take it to 16 bytes (must be zero) */
multiboot_uint32_t pad;
multiboot_uint32_t size;
multiboot_uint32_t num;
multiboot_uint32_t entsize;
multiboot_uint32_t shndx;
char sections[0];
};
struct multiboot_tag_apm
{
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint16_t version;
multiboot_uint16_t cseg;
multiboot_uint32_t offset;
multiboot_uint16_t cseg_16;
multiboot_uint16_t dseg;
multiboot_uint16_t flags;
multiboot_uint16_t cseg_len;
multiboot_uint16_t cseg_16_len;
multiboot_uint16_t dseg_len;
};
typedef struct multiboot_mod_list multiboot_module_t;
#endif /* ! ASM_FILE */
+1 -1
View File
@@ -10,7 +10,7 @@ texi=`basename $3`
sed -e 's,[{}],@&,g' \
-e 's,/\*\(@.*\)\*/,\1,g' \
-e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \
-e 's,/\*,/* @r{,g' -e 's, *\*/,} */,' \
-e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g' \
${dir}/${src} | expand > ${texi}.new
mv -f ${texi}.new ${dir}/${texi}