1c2c66affSColin Finck /****************************************************************************** 2c2c66affSColin Finck * 3c2c66affSColin Finck * Name: acwin64.h - OS specific defines, etc. 4c2c66affSColin Finck * 5c2c66affSColin Finck *****************************************************************************/ 6c2c66affSColin Finck 7c2c66affSColin Finck /* 8*03b24380SThomas Faber * Copyright (C) 2000 - 2022, Intel Corp. 9c2c66affSColin Finck * All rights reserved. 10c2c66affSColin Finck * 11c2c66affSColin Finck * Redistribution and use in source and binary forms, with or without 12c2c66affSColin Finck * modification, are permitted provided that the following conditions 13c2c66affSColin Finck * are met: 14c2c66affSColin Finck * 1. Redistributions of source code must retain the above copyright 15c2c66affSColin Finck * notice, this list of conditions, and the following disclaimer, 16c2c66affSColin Finck * without modification. 17c2c66affSColin Finck * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18c2c66affSColin Finck * substantially similar to the "NO WARRANTY" disclaimer below 19c2c66affSColin Finck * ("Disclaimer") and any redistribution must be conditioned upon 20c2c66affSColin Finck * including a substantially similar Disclaimer requirement for further 21c2c66affSColin Finck * binary redistribution. 22c2c66affSColin Finck * 3. Neither the names of the above-listed copyright holders nor the names 23c2c66affSColin Finck * of any contributors may be used to endorse or promote products derived 24c2c66affSColin Finck * from this software without specific prior written permission. 25c2c66affSColin Finck * 26c2c66affSColin Finck * Alternatively, this software may be distributed under the terms of the 27c2c66affSColin Finck * GNU General Public License ("GPL") version 2 as published by the Free 28c2c66affSColin Finck * Software Foundation. 29c2c66affSColin Finck * 30c2c66affSColin Finck * NO WARRANTY 31c2c66affSColin Finck * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32c2c66affSColin Finck * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 336eb8cc49SThomas Faber * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 34c2c66affSColin Finck * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35c2c66affSColin Finck * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36c2c66affSColin Finck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37c2c66affSColin Finck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38c2c66affSColin Finck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39c2c66affSColin Finck * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40c2c66affSColin Finck * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41c2c66affSColin Finck * POSSIBILITY OF SUCH DAMAGES. 42c2c66affSColin Finck */ 43c2c66affSColin Finck 44c2c66affSColin Finck #ifndef __ACWIN64_H__ 45c2c66affSColin Finck #define __ACWIN64_H__ 46c2c66affSColin Finck 47c2c66affSColin Finck #define ACPI_USE_STANDARD_HEADERS 48c2c66affSColin Finck #define ACPI_USE_SYSTEM_CLIBRARY 49c2c66affSColin Finck 50aa46da57SThomas Faber /* Note: do not include any C library headers here */ 51aa46da57SThomas Faber 52aa46da57SThomas Faber /* 53aa46da57SThomas Faber * Note: MSVC project files should define ACPI_DEBUGGER and ACPI_DISASSEMBLER 54aa46da57SThomas Faber * as appropriate to enable editor functions like "Find all references". 55aa46da57SThomas Faber * The editor isn't smart enough to dig through the include files to find 56aa46da57SThomas Faber * out if these are actually defined. 57aa46da57SThomas Faber */ 58aa46da57SThomas Faber 59aa46da57SThomas Faber /* Eliminate warnings for "old" (non-secure) versions of clib functions */ 60aa46da57SThomas Faber 61aa46da57SThomas Faber #ifndef _CRT_SECURE_NO_WARNINGS 62aa46da57SThomas Faber #define _CRT_SECURE_NO_WARNINGS 63aa46da57SThomas Faber #endif 64aa46da57SThomas Faber 65aa46da57SThomas Faber /* Eliminate warnings for POSIX clib function names (open, write, etc.) */ 66aa46da57SThomas Faber 67aa46da57SThomas Faber #ifndef _CRT_NONSTDC_NO_DEPRECATE 68aa46da57SThomas Faber #define _CRT_NONSTDC_NO_DEPRECATE 69aa46da57SThomas Faber #endif 70aa46da57SThomas Faber 71aa46da57SThomas Faber 72c2c66affSColin Finck #define ACPI_MACHINE_WIDTH 64 73c2c66affSColin Finck 74c2c66affSColin Finck /* 75c2c66affSColin Finck * Map low I/O functions for MS. This allows us to disable MS language 76c2c66affSColin Finck * extensions for maximum portability. 77c2c66affSColin Finck */ 78c2c66affSColin Finck #define open _open 79c2c66affSColin Finck #define read _read 80c2c66affSColin Finck #define write _write 81c2c66affSColin Finck #define close _close 82c2c66affSColin Finck #define stat _stat 83c2c66affSColin Finck #define fstat _fstat 84c2c66affSColin Finck #define mkdir _mkdir 85c2c66affSColin Finck #define snprintf _snprintf 86c2c66affSColin Finck #if _MSC_VER <= 1200 /* Versions below VC++ 6 */ 87c2c66affSColin Finck #define vsnprintf _vsnprintf 88c2c66affSColin Finck #endif 89c2c66affSColin Finck #define O_RDONLY _O_RDONLY 90c2c66affSColin Finck #define O_BINARY _O_BINARY 91c2c66affSColin Finck #define O_CREAT _O_CREAT 92c2c66affSColin Finck #define O_WRONLY _O_WRONLY 93c2c66affSColin Finck #define O_TRUNC _O_TRUNC 94c2c66affSColin Finck #define S_IREAD _S_IREAD 95c2c66affSColin Finck #define S_IWRITE _S_IWRITE 96c2c66affSColin Finck #define S_IFDIR _S_IFDIR 97c2c66affSColin Finck 98c2c66affSColin Finck /* 99c2c66affSColin Finck * Handle platform- and compiler-specific assembly language differences. 100c2c66affSColin Finck * 101c2c66affSColin Finck * Notes: 102c2c66affSColin Finck * 1) Interrupt 3 is used to break into a debugger 103c2c66affSColin Finck * 2) Interrupts are turned off during ACPI register setup 104c2c66affSColin Finck */ 105c2c66affSColin Finck 106c2c66affSColin Finck /*! [Begin] no source code translation */ 107c2c66affSColin Finck 108ad607262STimo Kreuzer #ifndef __REACTOS__ 109c2c66affSColin Finck #define ACPI_FLUSH_CPU_CACHE() 110c2c66affSColin Finck 111c2c66affSColin Finck /* 112c2c66affSColin Finck * For Acpi applications, we don't want to try to access the global lock 113c2c66affSColin Finck */ 114c2c66affSColin Finck #ifdef ACPI_APPLICATION 115c2c66affSColin Finck #define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) if (AcpiGbl_GlobalLockPresent) {Acq = 0xFF;} else {Acq = 0;} 116c2c66affSColin Finck #define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) if (AcpiGbl_GlobalLockPresent) {Pnd = 0xFF;} else {Pnd = 0;} 117c2c66affSColin Finck #else 118c2c66affSColin Finck 119c2c66affSColin Finck #define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) 120c2c66affSColin Finck 121c2c66affSColin Finck #define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) 122c2c66affSColin Finck 123c2c66affSColin Finck #endif 124c2c66affSColin Finck 125ad607262STimo Kreuzer #else /* __REACTOS__ */ 126ad607262STimo Kreuzer 127ad607262STimo Kreuzer #ifdef ACPI_APPLICATION 128ad607262STimo Kreuzer #define ACPI_FLUSH_CPU_CACHE() 129ad607262STimo Kreuzer #else 130ad607262STimo Kreuzer #define ACPI_FLUSH_CPU_CACHE() __wbinvd() 131ad607262STimo Kreuzer #endif 132ad607262STimo Kreuzer 133ad607262STimo Kreuzer #define ACPI_ACQUIRE_GLOBAL_LOCK(FacsPtr, Acq) \ 134ad607262STimo Kreuzer { \ 135ad607262STimo Kreuzer BOOLEAN acquired = 0xFF; \ 136ad607262STimo Kreuzer \ 137ad607262STimo Kreuzer if ((FacsPtr) != 0) \ 138ad607262STimo Kreuzer { \ 139ad607262STimo Kreuzer UINT32 compare, prev, newval; \ 140ad607262STimo Kreuzer UINT32* lock = &((FacsPtr)->GlobalLock); \ 141ad607262STimo Kreuzer do \ 142ad607262STimo Kreuzer { \ 143ad607262STimo Kreuzer compare = *lock; \ 144ad607262STimo Kreuzer newval = (compare & ~1) | ((compare >> 1) & 1) | 2; \ 145ad607262STimo Kreuzer prev = InterlockedCompareExchange(lock, newval, compare); \ 146ad607262STimo Kreuzer } while (prev != compare); \ 147ad607262STimo Kreuzer acquired = ((newval & 0xFF) < 3) ? 0xFF : 0x00; \ 148ad607262STimo Kreuzer } \ 149ad607262STimo Kreuzer (Acq) = acquired; \ 150ad607262STimo Kreuzer } 151ad607262STimo Kreuzer 152ad607262STimo Kreuzer #define ACPI_RELEASE_GLOBAL_LOCK(FacsPtr, Pnd) \ 153ad607262STimo Kreuzer { \ 154ad607262STimo Kreuzer BOOLEAN pending = 0; \ 155ad607262STimo Kreuzer \ 156ad607262STimo Kreuzer if ((FacsPtr) != 0) \ 157ad607262STimo Kreuzer { \ 158ad607262STimo Kreuzer pending = InterlockedAnd(&(FacsPtr)->GlobalLock, ~3) & 1; \ 159ad607262STimo Kreuzer } \ 160ad607262STimo Kreuzer (Pnd) = pending; \ 161ad607262STimo Kreuzer } 162ad607262STimo Kreuzer 163ad607262STimo Kreuzer #endif /* __REACTOS__ */ 164ad607262STimo Kreuzer 165c2c66affSColin Finck /*! [End] no source code translation !*/ 166c2c66affSColin Finck 167c2c66affSColin Finck #endif /* __ACWIN_H__ */ 168