|
|
1.1 root 1: /* acpi.c - get acpi tables. */
2: /*
3: * GRUB -- GRand Unified Bootloader
4: * Copyright (C) 2009 Free Software Foundation, Inc.
5: *
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.
10: *
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.
15: *
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/>.
18: */
19:
20: #include <grub/glue.h>
21: #include <grub/acpi.h>
22: #include <grub/misc.h>
23:
24: struct grub_acpi_rsdp_v10 *
25: grub_machine_acpi_get_rsdpv1 (void)
26: {
27: int ebda_len;
28: grub_uint8_t *ebda, *ptr;
29:
30: grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
31: ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4);
32: ebda_len = * (grub_uint16_t *) ebda;
33: if (! ebda_len)
34: return 0;
35: for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
36: if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
37: && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
38: && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
39: return (struct grub_acpi_rsdp_v10 *) ptr;
40:
41: grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
42: for (ptr = (grub_uint8_t *) phystokv (0xe0000); ptr < (grub_uint8_t *) phystokv (0x100000);
43: ptr += 16)
44: if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
45: && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
46: && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
47: return (struct grub_acpi_rsdp_v10 *) ptr;
48: return 0;
49: }
50:
51: struct grub_acpi_rsdp_v20 *
52: grub_machine_acpi_get_rsdpv2 (void)
53: {
54: int ebda_len;
55: grub_uint8_t *ebda, *ptr;
56:
57: grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
58: ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4);
59: ebda_len = * (grub_uint16_t *) ebda;
60: if (! ebda_len)
61: return 0;
62: for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
63: if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
64: && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
65: && ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
66: && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
67: && grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length)
68: == 0)
69: return (struct grub_acpi_rsdp_v20 *) ptr;
70:
71: grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
72: for (ptr = (grub_uint8_t *) phystokv (0xe0000); ptr < (grub_uint8_t *) phystokv (0x100000);
73: ptr += 16)
74: if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
75: && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
76: && ((struct grub_acpi_rsdp_v10 *) ptr)->revision != 0
77: && ((struct grub_acpi_rsdp_v20 *) ptr)->length < 1024
78: && grub_byte_checksum (ptr, ((struct grub_acpi_rsdp_v20 *) ptr)->length)
79: == 0)
80: return (struct grub_acpi_rsdp_v20 *) ptr;
81: return 0;
82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.