aclinuxex.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /******************************************************************************
  2. *
  3. * Name: aclinuxex.h - Extra OS specific defines, etc. for Linux
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2014, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #ifndef __ACLINUXEX_H__
  43. #define __ACLINUXEX_H__
  44. #ifdef __KERNEL__
  45. /*
  46. * Overrides for in-kernel ACPICA
  47. */
  48. acpi_status __init acpi_os_initialize(void);
  49. acpi_status acpi_os_terminate(void);
  50. /*
  51. * The irqs_disabled() check is for resume from RAM.
  52. * Interrupts are off during resume, just like they are for boot.
  53. * However, boot has (system_state != SYSTEM_RUNNING)
  54. * to quiet __might_sleep() in kmalloc() and resume does not.
  55. */
  56. static inline void *acpi_os_allocate(acpi_size size)
  57. {
  58. return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
  59. }
  60. static inline void *acpi_os_allocate_zeroed(acpi_size size)
  61. {
  62. return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
  63. }
  64. static inline void acpi_os_free(void *memory)
  65. {
  66. kfree(memory);
  67. }
  68. static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
  69. {
  70. return kmem_cache_zalloc(cache,
  71. irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
  72. }
  73. static inline acpi_thread_id acpi_os_get_thread_id(void)
  74. {
  75. return (acpi_thread_id) (unsigned long)current;
  76. }
  77. /*
  78. * When lockdep is enabled, the spin_lock_init() macro stringifies it's
  79. * argument and uses that as a name for the lock in debugging.
  80. * By executing spin_lock_init() in a macro the key changes from "lock" for
  81. * all locks to the name of the argument of acpi_os_create_lock(), which
  82. * prevents lockdep from reporting false positives for ACPICA locks.
  83. */
  84. #define acpi_os_create_lock(__handle) \
  85. ({ \
  86. spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
  87. if (lock) { \
  88. *(__handle) = lock; \
  89. spin_lock_init(*(__handle)); \
  90. } \
  91. lock ? AE_OK : AE_NO_MEMORY; \
  92. })
  93. /*
  94. * OSL interfaces added by Linux
  95. */
  96. void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
  97. #endif /* __KERNEL__ */
  98. #endif /* __ACLINUXEX_H__ */