mirror of
http://cgit.git.savannah.gnu.org/git/grub.git
synced 2026-04-28 14:33:34 +00:00
Compare commits
9 Commits
multiboot2
...
multiboot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45f169e63d | ||
|
|
0858c88185 | ||
|
|
66fe504794 | ||
|
|
f416453ad6 | ||
|
|
4ce17d9ec9 | ||
|
|
d0577852a8 | ||
|
|
fce58cb280 | ||
|
|
6ae974e435 | ||
|
|
2ee333d020 |
43
ChangeLog
43
ChangeLog
@@ -1,3 +1,46 @@
|
||||
2010-11-13 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.
|
||||
|
||||
2010-09-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.h: Stylistic improvements. Add APM declarations.
|
||||
|
||||
2010-09-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi: Add new memory type for badram.
|
||||
|
||||
2010-09-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/multiboot.texi: Clarify command line format.
|
||||
|
||||
2010-09-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Reimport mbchk.
|
||||
|
||||
* 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-03-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* doc/kernel.c (cmain): Use padding to properly display 64-bit
|
||||
|
||||
@@ -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
|
||||
SUBDIRS = doc util
|
||||
|
||||
.PHONY: web-manual
|
||||
web-manual: all
|
||||
|
||||
13
configure.ac
13
configure.ac
@@ -42,8 +42,17 @@ dnl Because recent automake complains about CCASFLAGS, set it here.
|
||||
CCASFLAGS='$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)'
|
||||
AC_SUBST(CCASFLAGS)
|
||||
|
||||
CFLAGS="-m32 -nostdlib $CFLAGS"
|
||||
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])
|
||||
|
||||
dnl Output.
|
||||
AC_CONFIG_FILES([Makefile doc/Makefile])
|
||||
AC_CONFIG_FILES([Makefile doc/Makefile util/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -10,9 +10,9 @@ pkginclude_HEADERS = multiboot.h
|
||||
if BUILD_EXAMPLE_KERNEL
|
||||
noinst_PROGRAMS = kernel
|
||||
kernel_SOURCES = $(EXAMPLES)
|
||||
kernel_CFLAGS = -fno-builtin -nostdinc -O -g -Wall \
|
||||
kernel_CPPFLAGS = -m32 -nostdlib -fno-builtin -nostdinc -O -g -Wall \
|
||||
-imacros $(top_builddir)/config.h
|
||||
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -Wl,--build-id=none
|
||||
kernel_LDFLAGS = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 -Wl,--build-id=none
|
||||
|
||||
boot.o: multiboot.h
|
||||
endif
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
/* 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
|
||||
@@ -140,13 +141,6 @@ struct multiboot_elf_section_header_table
|
||||
};
|
||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
||||
|
||||
struct multiboot_color
|
||||
{
|
||||
multiboot_uint8_t red;
|
||||
multiboot_uint8_t green;
|
||||
multiboot_uint8_t blue;
|
||||
};
|
||||
|
||||
struct multiboot_info
|
||||
{
|
||||
/* Multiboot info version number */
|
||||
@@ -202,20 +196,17 @@ struct multiboot_info
|
||||
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_INDEXED 0
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||
multiboot_uint8_t framebuffer_type;
|
||||
union
|
||||
{
|
||||
/* Indexed color. */
|
||||
struct
|
||||
{
|
||||
struct multiboot_color *framebuffer_palette_addr;
|
||||
multiboot_uint32_t framebuffer_palette_addr;
|
||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
||||
};
|
||||
|
||||
/* Direct RGB color. */
|
||||
struct
|
||||
{
|
||||
multiboot_uint8_t framebuffer_red_field_position;
|
||||
@@ -229,6 +220,13 @@ struct multiboot_info
|
||||
};
|
||||
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;
|
||||
@@ -238,6 +236,7 @@ struct multiboot_mmap_entry
|
||||
#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;
|
||||
@@ -256,6 +255,20 @@ struct multiboot_mod_list
|
||||
};
|
||||
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 */
|
||||
|
||||
@@ -77,8 +77,9 @@ sequence standard. This edition documents version @value{VERSION}.
|
||||
* Terminology::
|
||||
* Specification::
|
||||
* Examples::
|
||||
* History::
|
||||
* Index::
|
||||
* History::
|
||||
* Invoking mbchk:: How to use the Multiboot checker
|
||||
* Index::
|
||||
@end menu
|
||||
|
||||
|
||||
@@ -676,10 +677,12 @@ follows:
|
||||
+-------+-------+-------+-------+
|
||||
| part3 | part2 | part1 | drive |
|
||||
+-------+-------+-------+-------+
|
||||
Least significant Most significant
|
||||
@end group
|
||||
@end example
|
||||
|
||||
The first byte contains the @sc{bios} drive number as understood by the
|
||||
The most significant byte contains the @sc{bios} drive number
|
||||
as understood by the
|
||||
@sc{bios} INT 0x13 low-level disk interface: e.g. 0x00 for the first
|
||||
floppy disk or 0x80 for the first hard disk.
|
||||
|
||||
@@ -707,7 +710,11 @@ partition on a disk partitioned in conventional DOS style, then
|
||||
If bit 2 of the @samp{flags} longword is set, the @samp{cmdline} field
|
||||
is valid, and contains the physical address of the command line to
|
||||
be passed to the kernel. The command line is a normal C-style
|
||||
zero-terminated string.
|
||||
zero-terminated string. The exact format of command line is left to
|
||||
OS developpers. General-purpose boot loaders should allow user a complete
|
||||
control on command line independently of other factors like image name.
|
||||
Boot loaders with specific payload in mind may completely or partially generate
|
||||
it algorithmically.
|
||||
|
||||
If bit 3 of the @samp{flags} is set, then the @samp{mods} fields
|
||||
indicate to the kernel what boot modules were loaded along with the
|
||||
@@ -819,7 +826,7 @@ starting address. @samp{length} is the size of the memory region in bytes.
|
||||
@samp{type} is the variety of address range represented, where a
|
||||
value of 1 indicates available @sc{ram}, value of 3 indicates usable memory
|
||||
holding ACPI information, value of 4 indicates reserved memory which needs to
|
||||
be preserved on hibernation and all other values currently
|
||||
be preserved on hibernation, value of 5 indicates a memory which is occupied by defective RAM modules and all other values currently
|
||||
indicated a reserved area.
|
||||
|
||||
The map provided is guaranteed to list all standard @sc{ram} that should
|
||||
@@ -1279,6 +1286,26 @@ Major changes plus HTMLification.
|
||||
@end itemize
|
||||
@end table
|
||||
|
||||
@node Invoking mbchk
|
||||
@chapter Invoking mbchk
|
||||
|
||||
The program @command{mbchk} checks for the format of a Multiboot
|
||||
kernel. We recommend using this program before booting your own kernel.
|
||||
|
||||
@command{mbchk} accepts the following options:
|
||||
|
||||
@table @option
|
||||
@item --help
|
||||
Print a summary of the command-line options and exit.
|
||||
|
||||
@item --version
|
||||
Print the version number of GRUB and exit.
|
||||
|
||||
@item --quiet
|
||||
Suppress all normal output.
|
||||
@end table
|
||||
|
||||
|
||||
|
||||
@node Index
|
||||
@unnumbered Index
|
||||
|
||||
17
util/Makefile.am
Normal file
17
util/Makefile.am
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
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
Normal file
230
util/mbchk.c
Normal file
@@ -0,0 +1,230 @@
|
||||
/* 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