Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

acpi.c 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. #include <errno.h>
  25. #include <ipxe/acpi.h>
  26. #include <ipxe/interface.h>
  27. /** @file
  28. *
  29. * ACPI support functions
  30. *
  31. */
  32. /******************************************************************************
  33. *
  34. * Utility functions
  35. *
  36. ******************************************************************************
  37. */
  38. /**
  39. * Fix up ACPI table checksum
  40. *
  41. * @v acpi ACPI table header
  42. */
  43. void acpi_fix_checksum ( struct acpi_description_header *acpi ) {
  44. unsigned int i = 0;
  45. uint8_t sum = 0;
  46. for ( i = 0 ; i < acpi->length ; i++ ) {
  47. sum += *( ( ( uint8_t * ) acpi ) + i );
  48. }
  49. acpi->checksum -= sum;
  50. }
  51. /******************************************************************************
  52. *
  53. * Interface methods
  54. *
  55. ******************************************************************************
  56. */
  57. /**
  58. * Describe object in an ACPI table
  59. *
  60. * @v intf Interface
  61. * @v acpi ACPI table
  62. * @v len Length of ACPI table
  63. * @ret rc Return status code
  64. */
  65. int acpi_describe ( struct interface *intf,
  66. struct acpi_description_header *acpi, size_t len ) {
  67. struct interface *dest;
  68. acpi_describe_TYPE ( void * ) *op =
  69. intf_get_dest_op ( intf, acpi_describe, &dest );
  70. void *object = intf_object ( dest );
  71. int rc;
  72. if ( op ) {
  73. rc = op ( object, acpi, len );
  74. } else {
  75. /* Default is to fail to describe */
  76. rc = -EOPNOTSUPP;
  77. }
  78. intf_put ( dest );
  79. return rc;
  80. }