You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

acpi.c 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. #include <errno.h>
  21. #include <ipxe/acpi.h>
  22. #include <ipxe/interface.h>
  23. /** @file
  24. *
  25. * ACPI support functions
  26. *
  27. */
  28. /******************************************************************************
  29. *
  30. * Utility functions
  31. *
  32. ******************************************************************************
  33. */
  34. /**
  35. * Fix up ACPI table checksum
  36. *
  37. * @v acpi ACPI table header
  38. */
  39. void acpi_fix_checksum ( struct acpi_description_header *acpi ) {
  40. unsigned int i = 0;
  41. uint8_t sum = 0;
  42. for ( i = 0 ; i < acpi->length ; i++ ) {
  43. sum += *( ( ( uint8_t * ) acpi ) + i );
  44. }
  45. acpi->checksum -= sum;
  46. }
  47. /******************************************************************************
  48. *
  49. * Interface methods
  50. *
  51. ******************************************************************************
  52. */
  53. /**
  54. * Describe object in an ACPI table
  55. *
  56. * @v intf Interface
  57. * @v acpi ACPI table
  58. * @v len Length of ACPI table
  59. * @ret rc Return status code
  60. */
  61. int acpi_describe ( struct interface *intf,
  62. struct acpi_description_header *acpi, size_t len ) {
  63. struct interface *dest;
  64. acpi_describe_TYPE ( void * ) *op =
  65. intf_get_dest_op ( intf, acpi_describe, &dest );
  66. void *object = intf_object ( dest );
  67. int rc;
  68. if ( op ) {
  69. rc = op ( object, acpi, len );
  70. } else {
  71. /* Default is to fail to describe */
  72. rc = -EOPNOTSUPP;
  73. }
  74. intf_put ( dest );
  75. return rc;
  76. }