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

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