acpi.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include <grub/acpi.h>
  20. #include <grub/misc.h>
  21. #include <grub/efi/efi.h>
  22. #include <grub/efi/api.h>
  23. struct grub_acpi_rsdp_v10 *
  24. grub_machine_acpi_get_rsdpv1 (void)
  25. {
  26. unsigned i;
  27. static grub_efi_packed_guid_t acpi_guid = GRUB_EFI_ACPI_TABLE_GUID;
  28. for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
  29. {
  30. grub_efi_packed_guid_t *guid =
  31. &grub_efi_system_table->configuration_table[i].vendor_guid;
  32. if (! grub_memcmp (guid, &acpi_guid, sizeof (grub_efi_packed_guid_t)))
  33. return (struct grub_acpi_rsdp_v10 *)
  34. grub_efi_system_table->configuration_table[i].vendor_table;
  35. }
  36. return 0;
  37. }
  38. struct grub_acpi_rsdp_v20 *
  39. grub_machine_acpi_get_rsdpv2 (void)
  40. {
  41. unsigned i;
  42. static grub_efi_packed_guid_t acpi20_guid = GRUB_EFI_ACPI_20_TABLE_GUID;
  43. for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
  44. {
  45. grub_efi_packed_guid_t *guid =
  46. &grub_efi_system_table->configuration_table[i].vendor_guid;
  47. if (! grub_memcmp (guid, &acpi20_guid, sizeof (grub_efi_packed_guid_t)))
  48. return (struct grub_acpi_rsdp_v20 *)
  49. grub_efi_system_table->configuration_table[i].vendor_table;
  50. }
  51. return 0;
  52. }