merge multiboot2 into mbtag-spec

This commit is contained in:
Vladimir 'phcoder' Serbinenko committed 2010-01-16 15:38:00 +01:00
commit 98b3579549
7 files changed
+73 -226

No files matched your search

+35
View File
@@ -1,3 +1,38 @@
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
GRUB).
2010-01-03 Robert Millan <rmh.grub@aybabtu.com>
Install multiboot.h system-wide.
* doc/Makefile.am (pkginclude_HEADERS): New variable.
2010-01-03 Robert Millan <rmh.grub@aybabtu.com>
* doc/boot.S (MULTIBOOT_HEADER_FLAGS): Redefine using macros.
2010-01-03 Robert Millan <rmh.grub@aybabtu.com>
* Makefile.am (web-manual): Add `all' as dependency.
2010-01-02 Vladimir Serbinenko <phcoder@gmail.com>
* doc/kernel.c (cmain): Add missing cast.
2010-01-01 Robert Millan <rmh.grub@aybabtu.com>
* autogen.sh: Use `gnulib-tool' to install gendocs.sh.
+1 -1
View File
@@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = 1.7 gnu
SUBDIRS = doc
.PHONY: web-manual
web-manual:
web-manual: all
@cd '$(srcdir)/doc' ; \
$(SHELL) ../gendocs.sh -o '$(abs_builddir)/doc/manual' \
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \
+4 -3
View File
@@ -1,9 +1,10 @@
info_TEXINFOS = multiboot.texi
EXAMPLES = boot.S kernel.c multiboot.h
multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi
EXAMPLES = boot.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 = multiboot2.h
# The example kernel is built if you specify --enable-example-kernel.
if BUILD_EXAMPLE_KERNEL
@@ -13,7 +14,7 @@ kernel_CFLAGS = -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -Wl,--build-id=none
boot.o: multiboot.h
boot.o: multiboot2.h
endif
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
+6 -5
View File
@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define ASM_FILE 1
#include <multiboot.h>
#include <multiboot2.h>
/* C symbol format. HAVE_ASM_USCORE is defined by configure. */
#ifdef HAVE_ASM_USCORE
@@ -30,10 +30,11 @@
/* The flags for the Multiboot header. */
#ifdef __ELF__
# define MULTIBOOT_HEADER_FLAGS 0x0000000f
# define AOUT_KLUDGE 0
#else
# define MULTIBOOT_HEADER_FLAGS 0x0001000f
# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE
#endif
#define MULTIBOOT_HEADER_FLAGS MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | AOUT_KLUDGE
.text
@@ -48,11 +49,11 @@ _start:
/* Multiboot header. */
multiboot_header:
/* magic */
.long MULTIBOOT_HEADER_MAGIC
.long MULTIBOOT2_HEADER_MAGIC
/* flags */
.long MULTIBOOT_HEADER_FLAGS
/* checksum */
.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
#ifndef __ELF__
/* header_addr */
.long multiboot_header
+16 -200
View File
@@ -15,13 +15,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#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
@@ -47,11 +44,23 @@ static void itoa (char *buf, int base, int d);
static void putchar (int c);
void printf (const char *format, ...);
static void
tagged (unsigned long addr)
{
/* Check if MAGIC is valid and print the Multiboot information structure
pointed by ADDR. */
void
cmain (unsigned long magic, unsigned long addr)
{
struct multiboot_tag *tag;
/* Clear the screen. */
cls ();
/* Am I booted by a Multiboot-compliant boot loader? */
if (magic != MULTIBOOT2_BOOTLOADER_MAGIC)
{
printf ("Invalid magic number: 0x%x\n", (unsigned) magic);
return;
}
for (tag = (struct multiboot_tag *) addr; tag->type != MULTIBOOT_TAG_TYPE_END;
tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag + tag->size))
{
@@ -191,199 +200,6 @@ tagged (unsigned long addr)
}
}
}
}
/* Check if MAGIC is valid and print the Multiboot information structure
pointed by ADDR. */
void
cmain (unsigned long magic, unsigned long addr)
{
multiboot_info_t *mbi;
/* Clear the screen. */
cls ();
if (magic == MULTIBOOT_BOOTLOADER_MAGIC_TAGGED)
{
tagged (addr);
return;
}
/* Am I booted by a Multiboot-compliant boot loader? */
if (magic != MULTIBOOT_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))
{
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");
return;
}
/* Is the symbol table of a.out valid? */
if (CHECK_FLAG (mbi->flags, 4))
{
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%x,"
" length = 0x%x%x, type = 0x%x\n",
(unsigned) mmap->size,
mmap->addr >> 32,
mmap->addr & 0xffffffff,
mmap->len >> 32,
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)
{
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
{
unsigned best_distance, distance;
struct multiboot_color *palette;
palette = (struct multiboot_color *) mbi->framebuffer_palette_addr;
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;
}
}
}
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
color = ((1 << mbi->framebuffer_blue_mask_size) - 1)
<< mbi->framebuffer_blue_field_position;
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 32:
{
multiboot_uint32_t *pixel
= fb + mbi->framebuffer_pitch * i + 4 * i;
*pixel = color;
}
break;
}
}
}
}
/* Clear the screen and initialize VIDEO, XPOS and YPOS. */
+7 -7
View File
@@ -1289,7 +1289,7 @@ Multiboot kernel. The source files can be found under the directory
@file{doc} in the Multiboot source distribution.
The kernel @file{kernel} consists of only three files: @file{boot.S},
@file{kernel.c} and @file{multiboot.h}. The assembly source
@file{kernel.c} and @file{multiboot2.h}. The assembly source
@file{boot.S} is written in GAS (@pxref{Top, , GNU assembler, as.info,
The GNU assembler}), and contains the Multiboot information structure to
comply with the specification. When a Multiboot-compliant boot loader
@@ -1300,25 +1300,25 @@ the user of the halt state and stops forever until you push the reset
key. The file @file{kernel.c} contains the function @code{cmain},
which checks if the magic number passed by the boot loader is valid and
so on, and some functions to print messages on the screen. The file
@file{multiboot.h} defines some macros, such as the magic number for the
@file{multiboot2.h} defines some macros, such as the magic number for the
Multiboot header, the Multiboot header structure and the Multiboot
information structure.
@menu
* multiboot.h::
* multiboot2.h::
* boot.S::
* kernel.c::
* Other Multiboot kernels::
@end menu
@node multiboot.h
@subsection multiboot.h
@node multiboot2.h
@subsection multiboot2.h
This is the source code in the file @file{multiboot.h}:
This is the source code in the file @file{multiboot2.h}:
@example
@include multiboot.h.texi
@include multiboot2.h.texi
@end example
+4 -10
View File
@@ -1,5 +1,5 @@
/* multiboot.h - Multiboot header file. */
/* Copyright (C) 1999,2003,2007,2008,2009 Free Software Foundation, Inc.
/* 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
@@ -26,16 +26,10 @@
#define MULTIBOOT_SEARCH 8192
/* The magic field should contain this. */
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
/* This should be in %eax. */
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
/* This should be in %eax. */
#define MULTIBOOT_BOOTLOADER_MAGIC_TAGGED 0x3BADB002
/* The bits in the required part of flags field we don't support. */
#define MULTIBOOT_UNSUPPORTED 0x0000fff0
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
/* Alignment of multiboot modules. */
#define MULTIBOOT_MOD_ALIGN 0x00001000