mirror of
http://cgit.git.savannah.gnu.org/git/grub.git
synced 2026-04-28 14:33:34 +00:00
Compare commits
64 Commits
multiboot
...
multiboot2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e29a99ac3b | ||
|
|
d81931d0e5 | ||
|
|
4ca26ce6fb | ||
|
|
a2b54e2d25 | ||
|
|
5409d17bd3 | ||
|
|
2d064744b9 | ||
|
|
7b35cf63f8 | ||
|
|
4f0405eeb3 | ||
|
|
0c2a86c43c | ||
|
|
e560b88901 | ||
|
|
bf9199d49b | ||
|
|
ad6b6cdc4d | ||
|
|
97b01e441b | ||
|
|
5e70f89fc2 | ||
|
|
397e44ae7e | ||
|
|
bb61b2b801 | ||
|
|
0925f33b55 | ||
|
|
f5f7b125aa | ||
|
|
28ac2370a5 | ||
|
|
14b4ef92f6 | ||
|
|
b1bd61d583 | ||
|
|
b6ebeacbeb | ||
|
|
9dcda7e112 | ||
|
|
e8dd274c31 | ||
|
|
6038ec9ee1 | ||
|
|
b915f0e9b0 | ||
|
|
8f2b956726 | ||
|
|
2a040d5aa5 | ||
|
|
5543c48538 | ||
|
|
50a4d243bd | ||
|
|
971c0f24c2 | ||
|
|
3becbd0775 | ||
|
|
91c3452f92 | ||
|
|
c841decd4d | ||
|
|
23e384f800 | ||
|
|
f44ccb3f5c | ||
|
|
20ecfc61f1 | ||
|
|
0dc138c770 | ||
|
|
6f07ef1b55 | ||
|
|
14d0f250e5 | ||
|
|
2ef365a7f7 | ||
|
|
9a7d18426c | ||
|
|
1d280f3b29 | ||
|
|
cd35f2089c | ||
|
|
fd393d45aa | ||
|
|
dc375d6161 | ||
|
|
0f86518de8 | ||
|
|
0ddba31362 | ||
|
|
7b0a7c2675 | ||
|
|
7521ec5fef | ||
|
|
68d4322ed7 | ||
|
|
165a055fb8 | ||
|
|
dd2c93cb84 | ||
|
|
054d1faa5a | ||
|
|
bdae35caff | ||
|
|
98b3579549 | ||
|
|
9eaa21f055 | ||
|
|
81bbea0515 | ||
|
|
cf0400f9e0 | ||
|
|
d10004e9f5 | ||
|
|
c1d6d3a00f | ||
|
|
4f12af3748 | ||
|
|
b711494093 | ||
|
|
bc194c0206 |
90
ChangeLog
90
ChangeLog
@@ -1,45 +1,63 @@
|
||||
2010-11-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
2013-10-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi (BIOS drive): Replace ambigious "first" byte with
|
||||
"most significant" byte.
|
||||
Reported by: Mike Kasick.
|
||||
|
||||
2010-10-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/Makefile.am (kernel_LDFLAGS): Add -m32.
|
||||
(kernel_CFLAGS): Changed from this ...
|
||||
(kernel_CPPFLAGS): ... to this.
|
||||
|
||||
2010-10-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.h (multiboot_apm_info): Use multiboot and not GRUB
|
||||
integer types.
|
||||
Add EFI mmap specification
|
||||
|
||||
2010-09-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.h: Stylistic improvements. Add APM declarations.
|
||||
* doc/multiboot.texi: New type for badram.
|
||||
|
||||
2010-09-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi: Add new memory type for badram.
|
||||
* doc/multiboot.texi: New tags for EFI system table, DHCP ACK, SMBIOS
|
||||
and RSDP.
|
||||
|
||||
2010-09-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
2010-07-02 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi: Clarify command line format.
|
||||
* doc/multiboot.texi: Typo fix.
|
||||
|
||||
2010-09-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
2010-04-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Reimport mbchk.
|
||||
* doc/multiboot.texi (Memory map): Add a remark about type 1.
|
||||
|
||||
* util/Makefile.am: New file.
|
||||
* util/mbchk.c: Likewise.
|
||||
* Makefile.am (SUBDIRS): Add util.
|
||||
* configure.ac: New options --enable-mbchk. Check for HELP2MAN.
|
||||
(CFLAGS): Don't alter.
|
||||
(COND_MAN_PAGES): New conditional.
|
||||
(AC_CONFIG_FILES): Add util/Makefile.
|
||||
* doc/Makefile.am (kernel_CFLAGS): Add -m32 and -nostdlib.
|
||||
* doc/multiboot.texi (Invoking mbchk): New chapter.
|
||||
2010-04-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi (Terminology): Add a remark that "kernel" may not
|
||||
be a part of OS.
|
||||
|
||||
2010-04-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
MIPS support.
|
||||
|
||||
* doc/multiboot2.h (GRUB_MULTIBOOT_ARCHITECTURE_I386): Removed leftover
|
||||
GRUB_ prefix.
|
||||
(MULTIBOOT_ARCHITECTURE_MIPS32): New constant.
|
||||
* doc/multiboot.texi (MIPS machine state): New section.
|
||||
(Header magic fields): New possible value of arcitecture field.
|
||||
|
||||
2010-03-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi: Removed the promise of BIOS availability.
|
||||
|
||||
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>
|
||||
|
||||
@@ -96,6 +114,18 @@
|
||||
* doc/kernel.c (cmain): Draw a blue diagonal line when video mode
|
||||
information is provided.
|
||||
|
||||
2010-01-07 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
Kick out Multiboot 2 draft as a branch. Initially it is
|
||||
identical to Multiboot 1, except for the magic numbers.
|
||||
|
||||
* doc/multiboot.h: Rename to ...
|
||||
* doc/multiboot2.h: ... this. Update all users.
|
||||
(MULTIBOOT_HEADER_MAGIC): Replace with ...
|
||||
(MULTIBOOT2_HEADER_MAGIC): ... this. Update all users.
|
||||
(MULTIBOOT_BOOTLOADER_MAGIC): Replace with ...
|
||||
(MULTIBOOT2_BOOTLOADER_MAGIC): ... this. Update all users.
|
||||
|
||||
2010-01-07 Robert Millan <rmh.grub@aybabtu.com>
|
||||
|
||||
* doc/multiboot.h (MULTIBOOT_UNSUPPORTED): Remove macro (moved to
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Do not change this order if you don't know what you are doing.
|
||||
AUTOMAKE_OPTIONS = 1.7 gnu
|
||||
SUBDIRS = doc util
|
||||
SUBDIRS = doc
|
||||
|
||||
.PHONY: web-manual
|
||||
web-manual: all
|
||||
|
||||
15
configure.ac
15
configure.ac
@@ -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], [2.0], [bug-grub@gnu.org])
|
||||
AC_CONFIG_SRCDIR([doc/multiboot.texi])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -42,17 +42,8 @@ dnl Because recent automake complains about CCASFLAGS, set it here.
|
||||
CCASFLAGS='$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)'
|
||||
AC_SUBST(CCASFLAGS)
|
||||
|
||||
AC_ARG_ENABLE(mbchk,
|
||||
[ --enable-mbchk
|
||||
build the mbchk (multiboot checker)])
|
||||
AM_CONDITIONAL(BUILD_MBCHK, test "x$enable_mbchk" = xyes)
|
||||
|
||||
if test "x$enable_mbchk" = xyes; then
|
||||
AC_PATH_PROG(HELP2MAN, help2man)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([COND_MAN_PAGES], [test x$enable_mbchk = xyes -a x$HELP2MAN != x])
|
||||
CFLAGS="-nostdlib $CFLAGS"
|
||||
|
||||
dnl Output.
|
||||
AC_CONFIG_FILES([Makefile doc/Makefile util/Makefile])
|
||||
AC_CONFIG_FILES([Makefile doc/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
info_TEXINFOS = multiboot.texi
|
||||
EXAMPLES = boot.S kernel.c multiboot.h
|
||||
multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi
|
||||
EXAMPLES = boot_mips.S kernel.c multiboot2.h
|
||||
multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot2.h.texi
|
||||
SRC2TEXI = src2texi
|
||||
noinst_SCRIPTS = $(SRC2TEXI)
|
||||
EXTRA_PROGRAMS = kernel
|
||||
pkginclude_HEADERS = multiboot.h
|
||||
pkginclude_HEADERS = multiboot2.h
|
||||
|
||||
# The example kernel is built if you specify --enable-example-kernel.
|
||||
if BUILD_EXAMPLE_KERNEL
|
||||
noinst_PROGRAMS = kernel
|
||||
kernel_SOURCES = $(EXAMPLES)
|
||||
kernel_CPPFLAGS = -m32 -nostdlib -fno-builtin -nostdinc -O -g -Wall \
|
||||
kernel_CFLAGS = -fno-builtin -nostdinc -O -g -Wall \
|
||||
-imacros $(top_builddir)/config.h
|
||||
kernel_LDFLAGS = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -Wl,--build-id=none
|
||||
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
|
||||
|
||||
boot.o: multiboot.h
|
||||
boot.o: multiboot2.h
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
|
||||
|
||||
46
doc/boot.S
46
doc/boot.S
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#define ASM_FILE 1
|
||||
#include <multiboot.h>
|
||||
#include <multiboot2.h>
|
||||
|
||||
/* C symbol format. HAVE_ASM_USCORE is defined by configure. */
|
||||
#ifdef HAVE_ASM_USCORE
|
||||
@@ -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 MULTIBOOT_HEADER_MAGIC
|
||||
/* flags */
|
||||
.long MULTIBOOT_HEADER_FLAGS
|
||||
.long MULTIBOOT2_HEADER_MAGIC
|
||||
/* ISA: i386 */
|
||||
.long GRUB_MULTIBOOT_ARCHITECTURE_I386
|
||||
/* Header length. */
|
||||
.long multiboot_header_end - multiboot_header
|
||||
/* checksum */
|
||||
.long -(MULTIBOOT_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
|
||||
.long multiboot_entry
|
||||
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
|
||||
|
||||
119
doc/boot_mips.S
Normal file
119
doc/boot_mips.S
Normal file
@@ -0,0 +1,119 @@
|
||||
/* boot.S - bootstrap the kernel */
|
||||
/* Copyright (C) 1999, 2001, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define ASM_FILE 1
|
||||
#include <multiboot2.h>
|
||||
|
||||
/* C symbol format. HAVE_ASM_USCORE is defined by configure. */
|
||||
#ifdef HAVE_ASM_USCORE
|
||||
# define EXT_C(sym) _ ## sym
|
||||
#else
|
||||
# define EXT_C(sym) sym
|
||||
#endif
|
||||
|
||||
/* The size of our stack (16KB). */
|
||||
#define STACK_SIZE 0x4000
|
||||
|
||||
/* The flags for the Multiboot header. */
|
||||
#ifdef __ELF__
|
||||
# define AOUT_KLUDGE 0
|
||||
#else
|
||||
# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE
|
||||
#endif
|
||||
|
||||
.text
|
||||
.set noreorder
|
||||
.set nomacro
|
||||
|
||||
.globl start, _start
|
||||
start:
|
||||
_start:
|
||||
b multiboot_entry
|
||||
nop
|
||||
|
||||
/* Align 64 bits boundary. */
|
||||
.align 8
|
||||
|
||||
/* Multiboot header. */
|
||||
multiboot_header:
|
||||
/* magic */
|
||||
.long MULTIBOOT2_HEADER_MAGIC
|
||||
/* ISA: mips32 */
|
||||
.long MULTIBOOT_ARCHITECTURE_MIPS32
|
||||
/* Header length. */
|
||||
.long multiboot_header_end - multiboot_header
|
||||
/* checksum */
|
||||
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_MIPS32 + (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 */
|
||||
.long _start
|
||||
/* load_end_addr */
|
||||
.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
|
||||
entry_address_tag_end:
|
||||
#endif /* __ELF__ */
|
||||
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. */
|
||||
lui $sp, %hi (stack + STACK_SIZE)
|
||||
addiu $sp, $sp, %lo (stack + STACK_SIZE)
|
||||
|
||||
/* Now enter the C main function... */
|
||||
bal EXT_C(cmain)
|
||||
nop
|
||||
|
||||
/* Halt. */
|
||||
lui $a0, %hi (halt_message)
|
||||
addiu $a0, $a0, %lo (halt_message)
|
||||
bal EXT_C(printf)
|
||||
nop
|
||||
|
||||
loop: nop
|
||||
b loop
|
||||
nop
|
||||
|
||||
halt_message:
|
||||
.asciz "Halted."
|
||||
|
||||
.align 8
|
||||
/* Our stack area. */
|
||||
.comm stack, STACK_SIZE
|
||||
307
doc/kernel.c
307
doc/kernel.c
@@ -15,13 +15,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <multiboot.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
|
||||
@@ -51,190 +48,176 @@ void printf (const char *format, ...);
|
||||
pointed by ADDR. */
|
||||
void
|
||||
cmain (unsigned long magic, unsigned long addr)
|
||||
{
|
||||
multiboot_info_t *mbi;
|
||||
|
||||
{
|
||||
struct multiboot_tag *tag;
|
||||
unsigned size;
|
||||
|
||||
/* Clear the screen. */
|
||||
cls ();
|
||||
|
||||
/* Am I booted by a Multiboot-compliant boot loader? */
|
||||
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
|
||||
if (magic != MULTIBOOT2_BOOTLOADER_MAGIC)
|
||||
{
|
||||
printf ("Invalid magic number: 0x%x\n", (unsigned) magic);
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
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,
|
||||
(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))
|
||||
{
|
||||
multiboot_uint32_t color;
|
||||
unsigned i;
|
||||
void *fb = (void *) (unsigned long) mbi->framebuffer_addr;
|
||||
|
||||
switch (mbi->framebuffer_type)
|
||||
printf ("Tag 0x%x, Size 0x%x\n", tag->type, tag->size);
|
||||
switch (tag->type)
|
||||
{
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
|
||||
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:
|
||||
{
|
||||
unsigned best_distance, distance;
|
||||
struct multiboot_color *palette;
|
||||
|
||||
palette = (struct multiboot_color *) mbi->framebuffer_palette_addr;
|
||||
multiboot_memory_map_t *mmap;
|
||||
|
||||
color = 0;
|
||||
best_distance = 4*256*256;
|
||||
|
||||
for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
color = i;
|
||||
best_distance = distance;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
|
||||
{
|
||||
multiboot_uint32_t color;
|
||||
unsigned i;
|
||||
struct multiboot_tag_framebuffer *tagfb
|
||||
= (struct multiboot_tag_framebuffer *) tag;
|
||||
void *fb = (void *) (unsigned long) tagfb->common.framebuffer_addr;
|
||||
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
|
||||
color = ((1 << mbi->framebuffer_blue_mask_size) - 1)
|
||||
<< mbi->framebuffer_blue_field_position;
|
||||
break;
|
||||
switch (tagfb->common.framebuffer_type)
|
||||
{
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
|
||||
{
|
||||
unsigned best_distance, distance;
|
||||
struct multiboot_color *palette;
|
||||
|
||||
palette = tagfb->framebuffer_palette;
|
||||
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
|
||||
color = '\\' | 0x0100;
|
||||
break;
|
||||
color = 0;
|
||||
best_distance = 4*256*256;
|
||||
|
||||
for (i = 0; i < tagfb->framebuffer_palette_num_colors; i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
color = i;
|
||||
best_distance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
color = 0xffffffff;
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < mbi->framebuffer_width
|
||||
&& i < mbi->framebuffer_height; i++)
|
||||
{
|
||||
switch (mbi->framebuffer_bpp)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
multiboot_uint8_t *pixel = fb + mbi->framebuffer_pitch * i + i;
|
||||
*pixel = color;
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
{
|
||||
multiboot_uint16_t *pixel
|
||||
= fb + mbi->framebuffer_pitch * i + 2 * i;
|
||||
*pixel = color;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
{
|
||||
multiboot_uint32_t *pixel
|
||||
= fb + mbi->framebuffer_pitch * i + 3 * i;
|
||||
*pixel = (color & 0xffffff) | (*pixel & 0xff000000);
|
||||
}
|
||||
break;
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
|
||||
color = ((1 << tagfb->framebuffer_blue_mask_size) - 1)
|
||||
<< tagfb->framebuffer_blue_field_position;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
{
|
||||
multiboot_uint32_t *pixel
|
||||
= fb + mbi->framebuffer_pitch * i + 4 * i;
|
||||
*pixel = color;
|
||||
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
|
||||
color = '\\' | 0x0100;
|
||||
break;
|
||||
|
||||
default:
|
||||
color = 0xffffffff;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < tagfb->common.framebuffer_width
|
||||
&& i < tagfb->common.framebuffer_height; i++)
|
||||
{
|
||||
switch (tagfb->common.framebuffer_bpp)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
multiboot_uint8_t *pixel = fb
|
||||
+ tagfb->common.framebuffer_pitch * i + i;
|
||||
*pixel = color;
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
{
|
||||
multiboot_uint16_t *pixel
|
||||
= fb + tagfb->common.framebuffer_pitch * i + 2 * i;
|
||||
*pixel = color;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
{
|
||||
multiboot_uint32_t *pixel
|
||||
= fb + tagfb->common.framebuffer_pitch * i + 3 * i;
|
||||
*pixel = (color & 0xffffff) | (*pixel & 0xff000000);
|
||||
}
|
||||
break;
|
||||
|
||||
case 32:
|
||||
{
|
||||
multiboot_uint32_t *pixel
|
||||
= 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. */
|
||||
|
||||
274
doc/multiboot.h
274
doc/multiboot.h
@@ -1,274 +0,0 @@
|
||||
/* multiboot.h - Multiboot header file. */
|
||||
/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
|
||||
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MULTIBOOT_HEADER
|
||||
#define MULTIBOOT_HEADER 1
|
||||
|
||||
/* How many bytes from the start of the file we search for the header. */
|
||||
#define MULTIBOOT_SEARCH 8192
|
||||
#define MULTIBOOT_HEADER_ALIGN 4
|
||||
|
||||
/* The magic field should contain this. */
|
||||
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
||||
|
||||
/* This should be in %eax. */
|
||||
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
|
||||
|
||||
/* Alignment of multiboot modules. */
|
||||
#define MULTIBOOT_MOD_ALIGN 0x00001000
|
||||
|
||||
/* Alignment of the multiboot info structure. */
|
||||
#define MULTIBOOT_INFO_ALIGN 0x00000004
|
||||
|
||||
/* Flags set in the 'flags' member of the multiboot header. */
|
||||
|
||||
/* Align all boot modules on i386 page (4KB) boundaries. */
|
||||
#define MULTIBOOT_PAGE_ALIGN 0x00000001
|
||||
|
||||
/* Must pass memory information to OS. */
|
||||
#define MULTIBOOT_MEMORY_INFO 0x00000002
|
||||
|
||||
/* Must pass video information to OS. */
|
||||
#define MULTIBOOT_VIDEO_MODE 0x00000004
|
||||
|
||||
/* 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
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
typedef unsigned char multiboot_uint8_t;
|
||||
typedef unsigned short multiboot_uint16_t;
|
||||
typedef unsigned int multiboot_uint32_t;
|
||||
typedef unsigned long long multiboot_uint64_t;
|
||||
|
||||
struct multiboot_header
|
||||
{
|
||||
/* Must be MULTIBOOT_MAGIC - see above. */
|
||||
multiboot_uint32_t magic;
|
||||
|
||||
/* Feature flags. */
|
||||
multiboot_uint32_t flags;
|
||||
|
||||
/* 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. */
|
||||
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;
|
||||
multiboot_uint32_t width;
|
||||
multiboot_uint32_t height;
|
||||
multiboot_uint32_t depth;
|
||||
};
|
||||
|
||||
/* The symbol table for a.out. */
|
||||
struct multiboot_aout_symbol_table
|
||||
{
|
||||
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_uint32_t size;
|
||||
multiboot_uint32_t addr;
|
||||
multiboot_uint32_t shndx;
|
||||
};
|
||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
||||
|
||||
struct multiboot_info
|
||||
{
|
||||
/* Multiboot info version number */
|
||||
multiboot_uint32_t flags;
|
||||
|
||||
/* Available memory from BIOS */
|
||||
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
|
||||
{
|
||||
multiboot_aout_symbol_table_t aout_sym;
|
||||
multiboot_elf_section_header_table_t elf_sec;
|
||||
} u;
|
||||
|
||||
/* Memory Mapping buffer */
|
||||
multiboot_uint32_t mmap_length;
|
||||
multiboot_uint32_t mmap_addr;
|
||||
|
||||
/* Drive Info buffer */
|
||||
multiboot_uint32_t drives_length;
|
||||
multiboot_uint32_t drives_addr;
|
||||
|
||||
/* ROM configuration table */
|
||||
multiboot_uint32_t config_table;
|
||||
|
||||
/* Boot Loader Name */
|
||||
multiboot_uint32_t boot_loader_name;
|
||||
|
||||
/* 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;
|
||||
|
||||
multiboot_uint64_t framebuffer_addr;
|
||||
multiboot_uint32_t framebuffer_pitch;
|
||||
multiboot_uint32_t framebuffer_width;
|
||||
multiboot_uint32_t framebuffer_height;
|
||||
multiboot_uint8_t framebuffer_bpp;
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||
multiboot_uint8_t framebuffer_type;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
multiboot_uint32_t framebuffer_palette_addr;
|
||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
||||
};
|
||||
struct
|
||||
{
|
||||
multiboot_uint8_t framebuffer_red_field_position;
|
||||
multiboot_uint8_t framebuffer_red_mask_size;
|
||||
multiboot_uint8_t framebuffer_green_field_position;
|
||||
multiboot_uint8_t framebuffer_green_mask_size;
|
||||
multiboot_uint8_t framebuffer_blue_field_position;
|
||||
multiboot_uint8_t framebuffer_blue_mask_size;
|
||||
};
|
||||
};
|
||||
};
|
||||
typedef struct multiboot_info multiboot_info_t;
|
||||
|
||||
struct multiboot_color
|
||||
{
|
||||
multiboot_uint8_t red;
|
||||
multiboot_uint8_t green;
|
||||
multiboot_uint8_t blue;
|
||||
};
|
||||
|
||||
struct multiboot_mmap_entry
|
||||
{
|
||||
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
|
||||
#define MULTIBOOT_MEMORY_BADRAM 5
|
||||
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;
|
||||
};
|
||||
typedef struct multiboot_mod_list multiboot_module_t;
|
||||
|
||||
/* APM BIOS info. */
|
||||
struct multiboot_apm_info
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! MULTIBOOT_HEADER */
|
||||
1257
doc/multiboot.texi
1257
doc/multiboot.texi
File diff suppressed because it is too large
Load Diff
417
doc/multiboot2.h
Normal file
417
doc/multiboot2.h
Normal file
@@ -0,0 +1,417 @@
|
||||
/* multiboot2.h - Multiboot 2 header file. */
|
||||
/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
|
||||
* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MULTIBOOT_HEADER
|
||||
#define MULTIBOOT_HEADER 1
|
||||
|
||||
/* How many bytes from the start of the file we search for the header. */
|
||||
#define MULTIBOOT_SEARCH 32768
|
||||
#define MULTIBOOT_HEADER_ALIGN 8
|
||||
|
||||
/* The magic field should contain this. */
|
||||
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
|
||||
|
||||
/* This should be in %eax. */
|
||||
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
|
||||
|
||||
/* Alignment of multiboot modules. */
|
||||
#define MULTIBOOT_MOD_ALIGN 0x00001000
|
||||
|
||||
/* Alignment of the multiboot info structure. */
|
||||
#define MULTIBOOT_INFO_ALIGN 0x00000008
|
||||
|
||||
/* Flags set in the 'flags' member of the multiboot header. */
|
||||
|
||||
#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
|
||||
#define MULTIBOOT_TAG_TYPE_EFI32 11
|
||||
#define MULTIBOOT_TAG_TYPE_EFI64 12
|
||||
#define MULTIBOOT_TAG_TYPE_SMBIOS 13
|
||||
#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
|
||||
#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
|
||||
#define MULTIBOOT_TAG_TYPE_NETWORK 16
|
||||
#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17
|
||||
#define MULTIBOOT_TAG_TYPE_EFI_BS 18
|
||||
#define MULTIBOOT_TAG_TYPE_EFI32_IH 19
|
||||
#define MULTIBOOT_TAG_TYPE_EFI64_IH 20
|
||||
#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
|
||||
|
||||
#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 MULTIBOOT_HEADER_TAG_EFI_BS 7
|
||||
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8
|
||||
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
|
||||
#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
|
||||
|
||||
#define MULTIBOOT_ARCHITECTURE_I386 0
|
||||
#define MULTIBOOT_ARCHITECTURE_MIPS32 4
|
||||
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
|
||||
|
||||
#define MULTIBOOT_LOAD_PREFERENCE_NONE 0
|
||||
#define MULTIBOOT_LOAD_PREFERENCE_LOW 1
|
||||
#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
|
||||
|
||||
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
|
||||
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
typedef unsigned char multiboot_uint8_t;
|
||||
typedef unsigned short multiboot_uint16_t;
|
||||
typedef unsigned int multiboot_uint32_t;
|
||||
typedef unsigned long long multiboot_uint64_t;
|
||||
|
||||
struct multiboot_header
|
||||
{
|
||||
/* Must be MULTIBOOT_MAGIC - see above. */
|
||||
multiboot_uint32_t magic;
|
||||
|
||||
/* 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_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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
struct multiboot_header_tag_module_align
|
||||
{
|
||||
multiboot_uint16_t type;
|
||||
multiboot_uint16_t flags;
|
||||
multiboot_uint32_t size;
|
||||
};
|
||||
|
||||
struct multiboot_header_tag_relocatable
|
||||
{
|
||||
multiboot_uint16_t type;
|
||||
multiboot_uint16_t flags;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t min_addr;
|
||||
multiboot_uint32_t max_addr;
|
||||
multiboot_uint32_t align;
|
||||
multiboot_uint32_t preference;
|
||||
};
|
||||
|
||||
struct multiboot_color
|
||||
{
|
||||
multiboot_uint8_t red;
|
||||
multiboot_uint8_t green;
|
||||
multiboot_uint8_t blue;
|
||||
};
|
||||
|
||||
struct multiboot_mmap_entry
|
||||
{
|
||||
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
|
||||
#define MULTIBOOT_MEMORY_BADRAM 5
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t zero;
|
||||
};
|
||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
struct multiboot_tag_bootdev
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t biosdev;
|
||||
multiboot_uint32_t slice;
|
||||
multiboot_uint32_t part;
|
||||
};
|
||||
|
||||
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];
|
||||
};
|
||||
|
||||
struct multiboot_vbe_info_block
|
||||
{
|
||||
multiboot_uint8_t external_specification[512];
|
||||
};
|
||||
|
||||
struct multiboot_vbe_mode_info_block
|
||||
{
|
||||
multiboot_uint8_t external_specification[256];
|
||||
};
|
||||
|
||||
struct multiboot_tag_vbe
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
|
||||
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;
|
||||
multiboot_uint32_t framebuffer_height;
|
||||
multiboot_uint8_t framebuffer_bpp;
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||
multiboot_uint8_t framebuffer_type;
|
||||
multiboot_uint16_t reserved;
|
||||
};
|
||||
|
||||
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;
|
||||
multiboot_uint8_t framebuffer_red_mask_size;
|
||||
multiboot_uint8_t framebuffer_green_field_position;
|
||||
multiboot_uint8_t framebuffer_green_mask_size;
|
||||
multiboot_uint8_t framebuffer_blue_field_position;
|
||||
multiboot_uint8_t framebuffer_blue_mask_size;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
struct multiboot_tag_elf_sections
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
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;
|
||||
};
|
||||
|
||||
struct multiboot_tag_efi32
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t pointer;
|
||||
};
|
||||
|
||||
struct multiboot_tag_efi64
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint64_t pointer;
|
||||
};
|
||||
|
||||
struct multiboot_tag_smbios
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint8_t major;
|
||||
multiboot_uint8_t minor;
|
||||
multiboot_uint8_t reserved[6];
|
||||
multiboot_uint8_t tables[0];
|
||||
};
|
||||
|
||||
struct multiboot_tag_old_acpi
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint8_t rsdp[0];
|
||||
};
|
||||
|
||||
struct multiboot_tag_new_acpi
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint8_t rsdp[0];
|
||||
};
|
||||
|
||||
struct multiboot_tag_network
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint8_t dhcpack[0];
|
||||
};
|
||||
|
||||
struct multiboot_tag_efi_mmap
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t descr_size;
|
||||
multiboot_uint32_t descr_vers;
|
||||
multiboot_uint8_t efi_mmap[0];
|
||||
};
|
||||
|
||||
struct multiboot_tag_efi32_ih
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t pointer;
|
||||
};
|
||||
|
||||
struct multiboot_tag_efi64_ih
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint64_t pointer;
|
||||
};
|
||||
|
||||
struct multiboot_tag_load_base_addr
|
||||
{
|
||||
multiboot_uint32_t type;
|
||||
multiboot_uint32_t size;
|
||||
multiboot_uint32_t load_base_addr;
|
||||
};
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! MULTIBOOT_HEADER */
|
||||
@@ -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}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
HELP2MAN = @HELP2MAN@
|
||||
if COND_MAN_PAGES
|
||||
man_MANS = mbchk.1
|
||||
endif
|
||||
|
||||
if BUILD_MBCHK
|
||||
bin_PROGRAMS = mbchk
|
||||
endif
|
||||
|
||||
mbchk_SOURCES = mbchk.c
|
||||
mbchk_CPPFLAGS = -I$(top_srcdir)/doc
|
||||
|
||||
$(srcdir)/mbchk.1: ./mbchk
|
||||
$(HELP2MAN) \
|
||||
--name="check the format of a Multiboot kernel" \
|
||||
--section=1 --output=$@ ./$<
|
||||
230
util/mbchk.c
230
util/mbchk.c
@@ -1,230 +0,0 @@
|
||||
/* mbchk - a simple checker for the format of a Multiboot kernel */
|
||||
/*
|
||||
* Copyright (C) 1999,2001,2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <multiboot.h>
|
||||
|
||||
static int quiet = 0;
|
||||
static char *optstring = "hvq";
|
||||
static struct option longopts[] =
|
||||
{
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{0}
|
||||
};
|
||||
|
||||
static void
|
||||
usage (int status)
|
||||
{
|
||||
if (status)
|
||||
fprintf (stderr, "Try ``mbchk --help'' for more information.\n");
|
||||
else
|
||||
printf ("Usage: mbchk [OPTION]... [FILE]...\n"
|
||||
"Check if the format of FILE complies with the Multiboot Specification.\n"
|
||||
"\n"
|
||||
"-q, --quiet suppress all normal output\n"
|
||||
"-h, --help display this help and exit\n"
|
||||
"-v, --version output version information and exit.\n"
|
||||
"\n"
|
||||
"Report bugs to <bug-grub@gnu.org>.\n");
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
||||
static int
|
||||
check_multiboot (const char *filename, FILE *fp)
|
||||
{
|
||||
struct multiboot_header *mbh = 0;
|
||||
int i;
|
||||
char buf[8192];
|
||||
|
||||
if (fread (buf, 1, 8192, fp) < 0)
|
||||
{
|
||||
fprintf (stderr, "%s: Read error.\n", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 8192 - sizeof (struct multiboot_header); i++)
|
||||
{
|
||||
mbh = (struct multiboot_header *) (buf + i);
|
||||
if (mbh->magic == MULTIBOOT_HEADER_MAGIC)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 8192 - sizeof (struct multiboot_header))
|
||||
{
|
||||
fprintf (stderr, "%s: No Multiboot header.\n", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! quiet)
|
||||
printf ("%s: The Multiboot header is found at the offset %d.\n",
|
||||
filename, i);
|
||||
|
||||
/* Check for the checksum. */
|
||||
if (mbh->magic + mbh->flags + mbh->checksum != 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: Bad checksum (0x%lx).\n",
|
||||
filename, mbh->checksum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reserved flags must be zero. */
|
||||
if (mbh->flags & ~0x00010003)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: Non-zero is found in reserved flags (0x%lx).\n",
|
||||
filename, mbh->flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! quiet)
|
||||
{
|
||||
printf ("%s: Page alignment is turned %s.\n",
|
||||
filename, (mbh->flags & 0x1)? "on" : "off");
|
||||
printf ("%s: Memory information is turned %s.\n",
|
||||
filename, (mbh->flags & 0x2)? "on" : "off");
|
||||
printf ("%s: Address fields is turned %s.\n",
|
||||
filename, (mbh->flags & 0x10000)? "on" : "off");
|
||||
}
|
||||
|
||||
/* Check for the address fields. */
|
||||
if (mbh->flags & 0x10000)
|
||||
{
|
||||
if (mbh->header_addr < mbh->load_addr)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: header_addr is less than "
|
||||
"load_addr (0x%lx > 0x%lx).\n",
|
||||
filename, mbh->header_addr, mbh->load_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbh->load_end_addr && mbh->load_addr >= mbh->load_end_addr)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: load_addr is not less than load_end_addr"
|
||||
" (0x%lx >= 0x%lx).\n",
|
||||
filename, mbh->load_addr, mbh->load_end_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbh->bss_end_addr && mbh->load_end_addr > mbh->bss_end_addr)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: load_end_addr is greater than bss_end_addr"
|
||||
" (0x%lx > 0x%lx).\n",
|
||||
filename, mbh->load_end_addr, mbh->bss_end_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbh->load_addr > mbh->entry_addr)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: load_addr is greater than entry_addr"
|
||||
" (0x%lx > 0x%lx).\n",
|
||||
filename, mbh->load_addr, mbh->entry_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: It is better to check if the entry address is within the
|
||||
file, especially when the load end address is zero. */
|
||||
if (mbh->load_end_addr && mbh->load_end_addr <= mbh->entry_addr)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: load_end_addr is not greater than entry_addr"
|
||||
" (0x%lx <= 0x%lx).\n",
|
||||
filename, mbh->load_end_addr, mbh->entry_addr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (! quiet)
|
||||
printf ("%s: All checks passed.\n", filename);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
do
|
||||
{
|
||||
c = getopt_long (argc, argv, optstring, longopts, 0);
|
||||
switch (c)
|
||||
{
|
||||
case EOF:
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage (0);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printf ("mbchk (GNU GRUB " VERSION ")\n");
|
||||
exit (0);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (c != EOF);
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
while (optind < argc)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen (argv[optind], "r");
|
||||
if (! fp)
|
||||
{
|
||||
fprintf (stderr, "%s: No such file.\n", argv[optind]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (! check_multiboot (argv[optind], fp))
|
||||
exit (1);
|
||||
|
||||
fclose (fp);
|
||||
optind++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! check_multiboot ("<stdin>", stdin))
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user