a5bd9f6
From ef226c0cc274e70d8a2be3798a1c7ae3e96dbdce Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Fri, 5 Apr 2013 10:56:43 +0200
a5bd9f6
Subject: [PATCH 261/364] 	Add new defines GRUB_RSDP_SIGNATURE_SIZE and
a5bd9f6
 GRUB_RSDP_SIGNATURE.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog                         |  4 ++++
a5bd9f6
 grub-core/commands/acpi.c         | 10 +++++-----
a5bd9f6
 grub-core/commands/i386/pc/acpi.c |  8 ++++----
a5bd9f6
 include/grub/acpi.h               |  5 ++++-
a5bd9f6
 4 files changed, 17 insertions(+), 10 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index e52e7ee..3431895 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,5 +1,9 @@
a5bd9f6
 2013-04-05  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
+	Add new defines GRUB_RSDP_SIGNATURE_SIZE and GRUB_RSDP_SIGNATURE.
a5bd9f6
+
a5bd9f6
+2013-04-05  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
 	* grub-core/commands/verify.c: Use GRUB_CHAR_BIT.
a5bd9f6
 
a5bd9f6
 2013-04-05  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
a5bd9f6
index 8000873..4ca8cf7 100644
a5bd9f6
--- a/grub-core/commands/acpi.c
a5bd9f6
+++ b/grub-core/commands/acpi.c
a5bd9f6
@@ -217,7 +217,7 @@ grub_acpi_create_ebda (void)
a5bd9f6
     {
a5bd9f6
       grub_dprintf ("acpi", "Scanning EBDA for old rsdpv2\n");
a5bd9f6
       for (; target < targetebda + 0x400 - v2->length; target += 0x10)
a5bd9f6
-	if (grub_memcmp (target, "RSD PTR ", 8) == 0
a5bd9f6
+	if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	    && grub_byte_checksum (target,
a5bd9f6
 				   sizeof (struct grub_acpi_rsdp_v10)) == 0
a5bd9f6
 	    && ((struct grub_acpi_rsdp_v10 *) target)->revision != 0
a5bd9f6
@@ -238,7 +238,7 @@ grub_acpi_create_ebda (void)
a5bd9f6
       grub_dprintf ("acpi", "Scanning EBDA for old rsdpv1\n");
a5bd9f6
       for (; target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
a5bd9f6
 	   target += 0x10)
a5bd9f6
-	if (grub_memcmp (target, "RSD PTR ", 8) == 0
a5bd9f6
+	if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	    && grub_byte_checksum (target,
a5bd9f6
 				   sizeof (struct grub_acpi_rsdp_v10)) == 0)
a5bd9f6
 	  {
a5bd9f6
@@ -299,7 +299,7 @@ grub_acpi_create_ebda (void)
a5bd9f6
   for (target = targetebda;
a5bd9f6
        target < targetebda + 0x400 - sizeof (struct grub_acpi_rsdp_v10);
a5bd9f6
        target += 0x10)
a5bd9f6
-    if (grub_memcmp (target, "RSD PTR ", 8) == 0
a5bd9f6
+    if (grub_memcmp (target, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	&& grub_byte_checksum (target,
a5bd9f6
 			       sizeof (struct grub_acpi_rsdp_v10)) == 0
a5bd9f6
 	&& target != v1inebda && target != v2inebda)
a5bd9f6
@@ -394,7 +394,7 @@ setv1table (void)
a5bd9f6
   /* Create RSDP. */
a5bd9f6
   rsdpv1_new = (struct grub_acpi_rsdp_v10 *) playground_ptr;
a5bd9f6
   playground_ptr += sizeof (struct grub_acpi_rsdp_v10);
a5bd9f6
-  grub_memcpy (&(rsdpv1_new->signature), "RSD PTR ",
a5bd9f6
+  grub_memcpy (&(rsdpv1_new->signature), GRUB_RSDP_SIGNATURE,
a5bd9f6
 	       sizeof (rsdpv1_new->signature));
a5bd9f6
   grub_memcpy (&(rsdpv1_new->oemid), root_oemid, sizeof  (rsdpv1_new->oemid));
a5bd9f6
   rsdpv1_new->revision = 0;
a5bd9f6
@@ -438,7 +438,7 @@ setv2table (void)
a5bd9f6
   /* Create RSDPv2. */
a5bd9f6
   rsdpv2_new = (struct grub_acpi_rsdp_v20 *) playground_ptr;
a5bd9f6
   playground_ptr += sizeof (struct grub_acpi_rsdp_v20);
a5bd9f6
-  grub_memcpy (&(rsdpv2_new->rsdpv1.signature), "RSD PTR ",
a5bd9f6
+  grub_memcpy (&(rsdpv2_new->rsdpv1.signature), GRUB_RSDP_SIGNATURE,
a5bd9f6
 	       sizeof (rsdpv2_new->rsdpv1.signature));
a5bd9f6
   grub_memcpy (&(rsdpv2_new->rsdpv1.oemid), root_oemid,
a5bd9f6
 	       sizeof (rsdpv2_new->rsdpv1.oemid));
a5bd9f6
diff --git a/grub-core/commands/i386/pc/acpi.c b/grub-core/commands/i386/pc/acpi.c
a5bd9f6
index 88e4f55..d415d23 100644
a5bd9f6
--- a/grub-core/commands/i386/pc/acpi.c
a5bd9f6
+++ b/grub-core/commands/i386/pc/acpi.c
a5bd9f6
@@ -32,7 +32,7 @@ grub_machine_acpi_get_rsdpv1 (void)
a5bd9f6
   if (! ebda_len)
a5bd9f6
     return 0;
a5bd9f6
   for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
a5bd9f6
-    if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
a5bd9f6
+    if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
a5bd9f6
 	&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
a5bd9f6
       return (struct grub_acpi_rsdp_v10 *) ptr;
a5bd9f6
@@ -40,7 +40,7 @@ grub_machine_acpi_get_rsdpv1 (void)
a5bd9f6
   grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
a5bd9f6
   for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
a5bd9f6
        ptr += 16)
a5bd9f6
-    if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
a5bd9f6
+    if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
a5bd9f6
 	&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
a5bd9f6
       return (struct grub_acpi_rsdp_v10 *) ptr;
a5bd9f6
@@ -59,7 +59,7 @@ grub_machine_acpi_get_rsdpv2 (void)
a5bd9f6
   if (! ebda_len)
a5bd9f6
     return 0;
a5bd9f6
   for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
a5bd9f6
-    if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
a5bd9f6
+    if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
a5bd9f6
 	&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
a5bd9f6
 	&& ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
a5bd9f6
@@ -70,7 +70,7 @@ grub_machine_acpi_get_rsdpv2 (void)
a5bd9f6
   grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
a5bd9f6
   for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
a5bd9f6
        ptr += 16)
a5bd9f6
-    if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
a5bd9f6
+    if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
a5bd9f6
 	&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
a5bd9f6
 	&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
a5bd9f6
 	&& ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
a5bd9f6
diff --git a/include/grub/acpi.h b/include/grub/acpi.h
a5bd9f6
index 8fa957d..32bb95c 100644
a5bd9f6
--- a/include/grub/acpi.h
a5bd9f6
+++ b/include/grub/acpi.h
a5bd9f6
@@ -24,9 +24,12 @@
a5bd9f6
 #include <grub/err.h>
a5bd9f6
 #endif
a5bd9f6
 
a5bd9f6
+#define GRUB_RSDP_SIGNATURE "RSD PTR "
a5bd9f6
+#define GRUB_RSDP_SIGNATURE_SIZE 8
a5bd9f6
+
a5bd9f6
 struct grub_acpi_rsdp_v10
a5bd9f6
 {
a5bd9f6
-  grub_uint8_t signature[8];
a5bd9f6
+  grub_uint8_t signature[GRUB_RSDP_SIGNATURE_SIZE];
a5bd9f6
   grub_uint8_t checksum;
a5bd9f6
   grub_uint8_t oemid[6];
a5bd9f6
   grub_uint8_t revision;
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6