1 /****************************************************************************** 2 * 3 * Name: acnetbsd.h - OS specific defines, etc. 4 * $Revision: 1.25 $ 5 * 6 *****************************************************************************/ 7 8 /* 9 * Copyright (C) 2000 - 2022, Intel Corp. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions, and the following disclaimer, 17 * without modification. 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19 * substantially similar to the "NO WARRANTY" disclaimer below 20 * ("Disclaimer") and any redistribution must be conditioned upon 21 * including a substantially similar Disclaimer requirement for further 22 * binary redistribution. 23 * 3. Neither the names of the above-listed copyright holders nor the names 24 * of any contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * Alternatively, this software may be distributed under the terms of the 28 * GNU General Public License ("GPL") version 2 as published by the Free 29 * Software Foundation. 30 * 31 * NO WARRANTY 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42 * POSSIBILITY OF SUCH DAMAGES. 43 */ 44 45 #ifndef __ACNETBSD_H__ 46 #define __ACNETBSD_H__ 47 48 #define ACPI_UINTPTR_T uintptr_t 49 #define ACPI_USE_LOCAL_CACHE 50 #define ACPI_CAST_PTHREAD_T(x) ((ACPI_THREAD_ID) ACPI_TO_INTEGER (x)) 51 52 #ifdef _LP64 53 #define ACPI_MACHINE_WIDTH 64 54 #else 55 #define ACPI_MACHINE_WIDTH 32 56 #endif 57 58 #define COMPILER_DEPENDENT_INT64 int64_t 59 #define COMPILER_DEPENDENT_UINT64 uint64_t 60 61 #if defined(_KERNEL) || defined(_STANDALONE) 62 #ifdef _KERNEL_OPT 63 #include "opt_acpi.h" /* collect build-time options here */ 64 #endif /* _KERNEL_OPT */ 65 66 #include <sys/param.h> 67 #include <sys/systm.h> 68 #include <sys/reboot.h> 69 #include <sys/endian.h> 70 #include <dev/acpi/acpica/acpi_func.h> 71 72 #define asm __asm 73 74 #if BYTE_ORDER == BIG_ENDIAN 75 #define ACPI_BIG_ENDIAN 76 #endif 77 78 #define ACPI_USE_NATIVE_DIVIDE 79 #define ACPI_USE_NATIVE_MATH64 80 81 #define ACPI_ASM_MACROS /* tell acenv.h */ 82 83 #define ACPI_SYSTEM_XFACE 84 #define ACPI_EXTERNAL_XFACE 85 #define ACPI_INTERNAL_XFACE 86 #define ACPI_INTERNAL_VAR_XFACE 87 88 #if defined(_KERNEL) 89 /* Suppress ACPI_INFO level log messages in the kernel when this is true */ 90 #define ACPI_QUIET_BOOT \ 91 ((boothowto & (AB_QUIET|AB_SILENT)) != 0) 92 #endif 93 94 /* 95 * XXX: The internal memory tracking of ACPICA, available when 96 * ACPI_DBG_TRACK_ALLOCATIONS is defined, has been removed 97 * from ACPI_DEBUG. 98 * 99 * This is due to the instability of the ABI of ACPICA. 100 * 101 * If the memory tracking is enabled, ACPICA will insert a header 102 * to each memory allocation. As a consequence, when ACPI specific 103 * code is loaded as a kernel module and the running kernel has 104 * been compiled with ACPI_DEBUG, the result is an instant panic. 105 * This happens because of unaligned memory access when the code 106 * tries to use ACPI_FREE for a buffer obtained via ACPI_ALLOCATE, 107 * AcpiEvaluateObject(), and related calls. 108 * 109 * If the involved memory statistics are required, a separate constant 110 * ACPI_DEBUG_ALLOC is available in options(4) for ACPI_DEBUG kernels. 111 */ 112 113 #ifdef ACPI_DEBUG 114 #define ACPI_DEBUG_OUTPUT 115 #ifdef ACPI_DEBUG_ALLOC 116 #define ACPI_DBG_TRACK_ALLOCATIONS 117 #endif 118 #ifdef DEBUGGER_THREADING 119 #undef DEBUGGER_THREADING 120 #endif /* DEBUGGER_THREADING */ 121 #define DEBUGGER_THREADING 0 /* integrated with DDB */ 122 #include "opt_ddb.h" 123 #ifdef DDB 124 #define ACPI_DISASSEMBLER 125 #define ACPI_DEBUGGER 126 #endif /* DDB */ 127 #endif /* ACPI_DEBUG */ 128 129 #ifdef ACPI_REDUCED_HW 130 #define ACPI_REDUCED_HARDWARE TRUE 131 #endif /* ACPI_REDUCED_HW */ 132 133 #else /* defined(_KERNEL) || defined(_STANDALONE) */ 134 135 #include <ctype.h> 136 #include <stdint.h> 137 138 /* Not building kernel code, so use libc */ 139 #define ACPI_USE_STANDARD_HEADERS 140 141 #define __cli() 142 #define __sti() 143 #define __cdecl 144 145 /* XXX */ 146 #define __inline inline 147 #endif /* defined(_KERNEL) || defined(_STANDALONE) */ 148 149 /* Always use NetBSD code over our local versions */ 150 #define ACPI_USE_SYSTEM_CLIBRARY 151 #define ACPI_USE_NATIVE_DIVIDE 152 #define ACPI_USE_NATIVE_MATH64 153 154 #endif /* __ACNETBSD_H__ */ 155