1
/* acpi.c - get acpi tables. */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2009 Free Software Foundation, Inc.
6
* GRUB is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20
#include <grub/acpi.h>
21
#include <grub/misc.h>
23
struct grub_acpi_rsdp_v10 *
24
grub_machine_acpi_get_rsdpv1 (void)
27
grub_uint8_t *ebda, *ptr;
29
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
30
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
31
ebda_len = * (grub_uint16_t *) ebda;
34
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
35
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
36
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
37
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
38
return (struct grub_acpi_rsdp_v10 *) ptr;
40
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
41
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
43
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
44
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
45
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
46
return (struct grub_acpi_rsdp_v10 *) ptr;
50
struct grub_acpi_rsdp_v20 *
51
grub_machine_acpi_get_rsdpv2 (void)
54
grub_uint8_t *ebda, *ptr;
56
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
57
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
58
ebda_len = * (grub_uint16_t *) ebda;
61
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
62
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
63
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
64
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
65
&& ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
66
&& grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length)
68
return (struct grub_acpi_rsdp_v20 *) ptr;
70
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
71
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
73
if (grub_memcmp (ptr, "RSD PTR ", 8) == 0
74
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
75
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
76
&& ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
77
&& grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length)
79
return (struct grub_acpi_rsdp_v20 *) ptr;