Compare commits

..

64 Commits

Author SHA1 Message Date
Roger Pau Monné
e29a99ac3b multiboot2: Clarify usage of the address tag
Add a note to spell out that if the address tag is not present the
file should be loaded using the elf header.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-06-23 21:32:03 +02:00
Daniel Kiper
d81931d0e5 multiboot2: Fix alignment of header tags
Header tags have to be 8-bytes aligned. So, fix it.
Additionally, mention header closing tag in the spec.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-03-10 16:53:39 +01:00
Daniel Kiper
4ca26ce6fb multiboot2: Bump version to 2.0
...and add 2016 to copyright.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:05:20 +01:00
Daniel Kiper
a2b54e2d25 multiboot2: Add me to authors
...and properly format author list.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:05:07 +01:00
Daniel Kiper
5409d17bd3 multiboot2: Add C structure members alignment and padding consideration section
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:46 +01:00
Daniel Kiper
2d064744b9 multiboot2: Say that memory maps may not be available on EFI platforms
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
7b35cf63f8 multiboot2: Add description of support for relocatable images
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
4f0405eeb3 multiboot2: Add description of EFI image handle tags
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
0c2a86c43c multiboot2: Add description of support for EFI boot services
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
e560b88901 multiboot2: Fix description of EFI boot services tag
Without this fix multiboot2 doc build fails. Additionally,
add missing full stop at the end of sentence.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
bf9199d49b multiboot2: Clarify meaning of information request header tag
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
ad6b6cdc4d multiboot2: Replace redundant if with the
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
97b01e441b multiboot2: Rename Multiboot to Multiboot2
Multiboot2 is proper name of the boot protocol. Multiboot is name of older boot
protocol. So, rename Multiboot to Multiboot2 to not confuse the reader.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
5e70f89fc2 multiboot2: Replace u_virt with u32
u_virt may sometimes confuse reader especially if description says something
completely different. Additionally, GRUB multiboot2 implementation does not
use u_virt anywhere. So, replace it with basic well defined and used in
implementation u32 type.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Daniel Kiper
397e44ae7e multiboot2: Replace u_phys with u32
u_phys is used just in two places and sometimes it may confuse reader.
Additionally, GRUB multiboot2 implementation does not use u_phys anywhere.
So, replace it with basic well defined and used in implementation u32 type.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2016-12-14 14:03:45 +01:00
Andrei Borzenkov
bb61b2b801 multiboot2.h: remove useless __attribute__((packed))
Adapted from 7f2a856fae.
2016-04-30 09:28:12 +03:00
Toomas Soome
0925f33b55 multiboot_header_tag_module_align fix to confirm multiboot specification 2015-06-04 20:01:26 +03:00
Vladimir Serbinenko
f5f7b125aa Introduce a possibility of not specifying load offset 2013-12-17 15:14:07 +01:00
Vladimir Serbinenko
28ac2370a5 EFI BS specification 2013-12-13 12:54:59 +01:00
Vladimir Serbinenko
14b4ef92f6 Add missing changelog entry 2013-10-28 15:58:18 +01:00
Vladimir Serbinenko
b1bd61d583 Add missing file boot_mips.S to the repo 2013-10-23 12:48:33 +02:00
Vladimir Serbinenko
b6ebeacbeb Import from bzr to git 2013-10-22 20:12:26 +02:00
Vladimir 'phcoder' Serbinenko
9dcda7e112 Add EFI mmap specification 2013-10-22 08:37:29 +02:00
Vladimir 'phcoder' Serbinenko
e8dd274c31 * doc/multiboot.texi: New type for badram. 2010-09-21 01:52:25 +02:00
Vladimir 'phcoder' Serbinenko
6038ec9ee1 * doc/multiboot.texi: New tags for EFI system table, DHCP ACK, SMBIOS
and RSDP.
2010-09-21 01:41:26 +02:00
Vladimir 'phcoder' Serbinenko
b915f0e9b0 Missing part of previous commit 2010-09-21 01:40:25 +02:00
Vladimir 'phcoder' Serbinenko
8f2b956726 * doc/multiboot.texi: Typo fix. 2010-07-02 00:49:40 +02:00
Vladimir 'phcoder' Serbinenko
2a040d5aa5 * doc/multiboot.texi (Memory map): Add a remark about type 1. 2010-04-09 19:22:12 +02:00
Vladimir 'phcoder' Serbinenko
5543c48538 * doc/multiboot.texi (Terminology): Add a remark that "kernel" may not
be a part of OS.
2010-04-03 15:05:06 +02:00
Vladimir 'phcoder' Serbinenko
50a4d243bd 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-04-03 14:25:31 +02:00
Vladimir 'phcoder' Serbinenko
971c0f24c2 * doc/multiboot.texi: Removed the promise of BIOS availability. 2010-03-28 17:24:06 +02:00
Vladimir 'phcoder' Serbinenko
3becbd0775 * 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-28 14:14:16 +02:00
Vladimir 'phcoder' Serbinenko
91c3452f92 Changelog. Remove few leftovers 2010-03-28 14:12:35 +02:00
Vladimir 'phcoder' Serbinenko
c841decd4d Merge multiboot2 into mbtag-spec 2010-03-28 13:59:16 +02:00
Vladimir 'phcoder' Serbinenko
23e384f800 Merge multiboot into multiboot2 2010-03-28 13:55:56 +02:00
Vladimir 'phcoder' Serbinenko
f44ccb3f5c Specify alignment requirements 2010-03-27 21:48:08 +01:00
Vladimir 'phcoder' Serbinenko
20ecfc61f1 Clarify size and offset of tags. Reported by: Seth Goldberg 2010-03-10 23:14:59 +01:00
Vladimir 'phcoder' Serbinenko
0dc138c770 merge multiboot into mbtag-spec 2010-03-10 22:58:13 +01:00
Vladimir 'phcoder' Serbinenko
6f07ef1b55 Selfishly added myself as author 2010-03-10 22:50:02 +01:00
Vladimir 'phcoder' Serbinenko
14d0f250e5 Change version to 1.6 2010-03-10 22:49:27 +01:00
Vladimir 'phcoder' Serbinenko
2ef365a7f7 Removed leftover sentence 2010-03-10 22:47:58 +01:00
Vladimir 'phcoder' Serbinenko
9a7d18426c Initial work on 64-bit systems. 2010-03-10 22:47:37 +01:00
Vladimir 'phcoder' Serbinenko
1d280f3b29 Useful definitions in multiboot2.h 2010-03-10 11:41:45 +01:00
Vladimir 'phcoder' Serbinenko
cd35f2089c Multiboot header tag cleanup 2010-03-07 16:37:04 +01:00
Vladimir 'phcoder' Serbinenko
fd393d45aa Compact header tags 2010-03-07 15:43:04 +01:00
Vladimir 'phcoder' Serbinenko
dc375d6161 Merge mbhtag into mbtag 2010-03-07 15:10:02 +01:00
Vladimir 'phcoder' Serbinenko
0f86518de8 Add alignment requirements 2010-03-07 14:59:38 +01:00
Vladimir 'phcoder' Serbinenko
0ddba31362 Fix a typo reported by Bogdan 2010-01-21 20:07:33 +01:00
Vladimir 'phcoder' Serbinenko
7b0a7c2675 Some tags redefined 2010-01-21 00:44:19 +01:00
Vladimir 'phcoder' Serbinenko
7521ec5fef Initial tag header 2010-01-21 00:20:37 +01:00
Vladimir 'phcoder' Serbinenko
68d4322ed7 merge multiboot2 into mbtaf-spec 2010-01-16 17:34:38 +01:00
Vladimir 'phcoder' Serbinenko
165a055fb8 merge multiboot into multiboot2 2010-01-16 17:27:35 +01:00
Vladimir 'phcoder' Serbinenko
dd2c93cb84 Fix mistakes in example kernel 2010-01-16 17:24:15 +01:00
Vladimir 'phcoder' Serbinenko
054d1faa5a cleanup tagged mbi 2010-01-16 17:18:22 +01:00
Vladimir 'phcoder' Serbinenko
bdae35caff Cleaned multiboot2.h 2010-01-16 16:26:13 +01:00
Vladimir 'phcoder' Serbinenko
98b3579549 merge multiboot2 into mbtag-spec 2010-01-16 15:38:00 +01:00
Robert Millan
9eaa21f055 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 20:13:26 +00:00
Vladimir 'phcoder' Serbinenko
81bbea0515 Tagged mbi 2010-01-04 22:05:52 +01:00
Vladimir 'phcoder' Serbinenko
cf0400f9e0 Merge mbvid-spec into mbtag-spec 2010-01-04 20:46:15 +01:00
Vladimir 'phcoder' Serbinenko
d10004e9f5 Clarifications requested by Robert. EGA text part. 2010-01-04 20:44:39 +01:00
Vladimir 'phcoder' Serbinenko
c1d6d3a00f Example kernel for tagged mbi 2010-01-02 23:08:47 +01:00
Vladimir 'phcoder' Serbinenko
4f12af3748 Define framebuffer video independently of VBE video 2010-01-02 18:52:11 +01:00
Vladimir 'phcoder' Serbinenko
b711494093 Merge multiboot into mbvid-spec 2010-01-02 13:32:13 +01:00
Vladimir 'phcoder' Serbinenko
bc194c0206 Document non-VBE video 2009-12-17 21:04:47 +01:00
13 changed files with 1604 additions and 1184 deletions

View File

@@ -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

View File

@@ -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

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], [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

View File

@@ -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) \

View File

@@ -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
View 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

View File

@@ -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. */

View File

@@ -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 */

File diff suppressed because it is too large Load Diff

417
doc/multiboot2.h Normal file
View 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 */

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}

View File

@@ -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=$@ ./$<

View File

@@ -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;
}