Add new defines GRUB_RSDP_SIGNATURE_SIZE and GRUB_RSDP_SIGNATURE.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-05 10:56:43 +02:00
parent 52eab6562d
commit ce7d92a9f2
4 changed files with 17 additions and 10 deletions

View file

@ -1,3 +1,7 @@
2013-04-05 Vladimir Serbinenko <phcoder@gmail.com>
Add new defines GRUB_RSDP_SIGNATURE_SIZE and GRUB_RSDP_SIGNATURE.
2013-04-05 Vladimir Serbinenko <phcoder@gmail.com> 2013-04-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/verify.c: Use GRUB_CHAR_BIT. * grub-core/commands/verify.c: Use GRUB_CHAR_BIT.

View file

@ -217,7 +217,7 @@ grub_acpi_create_ebda (void)
{ {
grub_dprintf ("acpi", "Scanning EBDA for old rsdpv2\n"); grub_dprintf ("acpi", "Scanning EBDA for old rsdpv2\n");
for (; target < targetebda + 0x400 - v2->length; target += 0x10) for (; target < targetebda + 0x400 - v2->length; target += 0x10)
if (grub_memcmp (target, "RSD PTR ", 8) == 0 if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (target, && grub_byte_checksum (target,
sizeof (struct grub_acpi_rsdp_v10)) == 0 sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) target)->revision != 0 && ((struct grub_acpi_rsdp_v10 *) target)->revision != 0
@ -238,7 +238,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Scanning EBDA for old rsdpv1\n"); grub_dprintf ("acpi", "Scanning EBDA for old rsdpv1\n");
for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10); for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
target += 0x10) target += 0x10)
if (grub_memcmp (target, "RSD PTR ", 8) == 0 if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (target, && grub_byte_checksum (target,
sizeof (struct grub_acpi_rsdp_v10)) == 0) sizeof (struct grub_acpi_rsdp_v10)) == 0)
{ {
@ -299,7 +299,7 @@ grub_acpi_create_ebda (void)
for (target = targetebda; for (target = targetebda;
target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10); target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
target += 0x10) target += 0x10)
if (grub_memcmp (target, "RSD PTR ", 8) == 0 if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (target, && grub_byte_checksum (target,
sizeof (struct grub_acpi_rsdp_v10)) == 0 sizeof (struct grub_acpi_rsdp_v10)) == 0
&& target != v1inebda && target != v2inebda) && target != v1inebda && target != v2inebda)
@ -394,7 +394,7 @@ setv1table (void)
/* Create RSDP. */ /* Create RSDP. */
rsdpv1_new = (struct grub_acpi_rsdp_v10 *) playground_ptr; rsdpv1_new = (struct grub_acpi_rsdp_v10 *) playground_ptr;
playground_ptr += sizeof (struct grub_acpi_rsdp_v10); playground_ptr += sizeof (struct grub_acpi_rsdp_v10);
grub_memcpy (&(rsdpv1_new->signature), "RSD PTR ", grub_memcpy (&(rsdpv1_new->signature), GRUB_RSDP_SIGNATURE,
sizeof (rsdpv1_new->signature)); sizeof (rsdpv1_new->signature));
grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid)); grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof (rsdpv1_new->oemid));
rsdpv1_new->revision = 0; rsdpv1_new->revision = 0;
@ -438,7 +438,7 @@ setv2table (void)
/* Create RSDPv2. */ /* Create RSDPv2. */
rsdpv2_new = (struct grub_acpi_rsdp_v20 *) playground_ptr; rsdpv2_new = (struct grub_acpi_rsdp_v20 *) playground_ptr;
playground_ptr += sizeof (struct grub_acpi_rsdp_v20); playground_ptr += sizeof (struct grub_acpi_rsdp_v20);
grub_memcpy (&(rsdpv2_new->rsdpv1.signature), "RSD PTR ", grub_memcpy (&(rsdpv2_new->rsdpv1.signature), GRUB_RSDP_SIGNATURE,
sizeof (rsdpv2_new->rsdpv1.signature)); sizeof (rsdpv2_new->rsdpv1.signature));
grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid, grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
sizeof (rsdpv2_new->rsdpv1.oemid)); sizeof (rsdpv2_new->rsdpv1.oemid));

View file

@ -32,7 +32,7 @@ grub_machine_acpi_get_rsdpv1 (void)
if (! ebda_len) if (! ebda_len)
return 0; return 0;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0 if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
return (struct grub_acpi_rsdp_v10 *) ptr; return (struct grub_acpi_rsdp_v10 *) ptr;
@ -40,7 +40,7 @@ grub_machine_acpi_get_rsdpv1 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16) ptr += 16)
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0 if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
return (struct grub_acpi_rsdp_v10 *) ptr; return (struct grub_acpi_rsdp_v10 *) ptr;
@ -59,7 +59,7 @@ grub_machine_acpi_get_rsdpv2 (void)
if (! ebda_len) if (! ebda_len)
return 0; return 0;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0 if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0 && ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
&& ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024 && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
@ -70,7 +70,7 @@ grub_machine_acpi_get_rsdpv2 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16) ptr += 16)
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0 if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0 && ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
&& ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024 && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024

View file

@ -24,9 +24,12 @@
#include <grub/err.h> #include <grub/err.h>
#endif #endif
#define GRUB_RSDP_SIGNATURE "RSD PTR "
#define GRUB_RSDP_SIGNATURE_SIZE 8
struct grub_acpi_rsdp_v10 struct grub_acpi_rsdp_v10
{ {
grub_uint8_t signature[8]; grub_uint8_t signature[GRUB_RSDP_SIGNATURE_SIZE];
grub_uint8_t checksum; grub_uint8_t checksum;
grub_uint8_t oemid[6]; grub_uint8_t oemid[6];
grub_uint8_t revision; grub_uint8_t revision;