2008-11-07 Robert Millan <rmh@aybabtu.com>

* include/multiboot2.h (struct multiboot_header): Add `flags' member as
        per specification.
        * loader/multiboot2.c (grub_multiboot2): Fix Multiboot2 header check.
        * loader/multiboot_loader.c (find_multi_boot2_header): New function
        (based on find_multi_boot1_header).
        (grub_rescue_cmd_multiboot_loader): Check for Multiboot2 header,
        using find_multi_boot2_header(), and abort if neither Multiboot or
        Multiboot headers were found.
This commit is contained in:
robertmh 2008-11-07 19:53:25 +00:00
parent 9f3af64471
commit c32ee8c9a8
4 changed files with 47 additions and 9 deletions

View file

@ -1,3 +1,14 @@
2008-11-07 Robert Millan <rmh@aybabtu.com>
* include/multiboot2.h (struct multiboot_header): Add `flags' member as
per specification.
* loader/multiboot2.c (grub_multiboot2): Fix Multiboot2 header check.
* loader/multiboot_loader.c (find_multi_boot2_header): New function
(based on find_multi_boot1_header).
(grub_rescue_cmd_multiboot_loader): Check for Multiboot2 header,
using find_multi_boot2_header(), and abort if neither Multiboot or
Multiboot headers were found.
2008-11-07 Robert Millan <rmh@aybabtu.com>
Modularize at_keyboard.mod:

View file

@ -46,6 +46,7 @@ typedef uint32_t multiboot_word;
struct multiboot_header
{
uint32_t magic;
uint32_t flags;
};
struct multiboot_tag_header

View file

@ -342,8 +342,8 @@ grub_multiboot2 (int argc, char *argv[])
}
/* Look for the multiboot header in the buffer. The header should
be at least 12 bytes and aligned on a 4-byte boundary. */
for (p = buffer; p <= buffer + len - 12; p += 4)
be at least 8 bytes and aligned on a 8-byte boundary. */
for (p = buffer; p <= buffer + len - 8; p += 8)
{
header = (struct multiboot_header *) p;
if (header->magic == MULTIBOOT2_HEADER_MAGIC)

View file

@ -71,6 +71,34 @@ find_multi_boot1_header (grub_file_t file)
return found_status;
}
static int
find_multi_boot2_header (grub_file_t file)
{
struct multiboot_header *header;
char buffer[MULTIBOOT_SEARCH];
int found_status = 0;
grub_ssize_t len;
len = grub_file_read (file, buffer, MULTIBOOT_SEARCH);
if (len < 32)
return found_status;
/* Look for the multiboot header in the buffer. The header should
be at least 8 bytes and aligned on a 8-byte boundary. */
for (header = (struct multiboot_header *) buffer;
((char *) header <= buffer + len - 8) || (header = 0);
header = (struct multiboot_header *) ((char *) header + 8))
{
if (header->magic == MULTIBOOT2_HEADER_MAGIC)
{
found_status = 1;
break;
}
}
return found_status;
}
void
grub_rescue_cmd_multiboot_loader (int argc, char *argv[])
{
@ -94,16 +122,14 @@ grub_rescue_cmd_multiboot_loader (int argc, char *argv[])
}
/* find which header is in the file */
if (find_multi_boot1_header(file))
if (find_multi_boot1_header (file))
header_multi_ver_found = 1;
else if (find_multi_boot2_header (file))
header_multi_ver_found = 2;
else
{
/* The behavior is that if you don't find a multiboot 1 header
use multiboot 2 loader (as you do not have to have a header
to use multiboot 2 */
grub_dprintf ("multiboot_loader", "No multiboot 1 header found. \n \
Using multiboot 2 loader\n");
header_multi_ver_found = 0;
grub_error (GRUB_ERR_BAD_OS, "Multiboot header not found");
goto fail;
}
/* close file before calling functions */