acpica_machdep.h revision 120347
1100969Siwasaki/*- 2100969Siwasaki * Copyright (c) 2002 Mitsuru IWASAKI 3100969Siwasaki * All rights reserved. 4100969Siwasaki * 5100969Siwasaki * Redistribution and use in source and binary forms, with or without 6100969Siwasaki * modification, are permitted provided that the following conditions 7100969Siwasaki * are met: 8100969Siwasaki * 1. Redistributions of source code must retain the above copyright 9100969Siwasaki * notice, this list of conditions and the following disclaimer. 10100969Siwasaki * 2. Redistributions in binary form must reproduce the above copyright 11100969Siwasaki * notice, this list of conditions and the following disclaimer in the 12100969Siwasaki * documentation and/or other materials provided with the distribution. 13100969Siwasaki * 14100969Siwasaki * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15100969Siwasaki * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16100969Siwasaki * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17100969Siwasaki * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18100969Siwasaki * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19100969Siwasaki * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20100969Siwasaki * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21100969Siwasaki * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22100969Siwasaki * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23100969Siwasaki * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24100969Siwasaki * SUCH DAMAGE. 25100969Siwasaki * 26100969Siwasaki * $FreeBSD: head/sys/amd64/include/acpica_machdep.h 120347 2003-09-22 22:12:46Z peter $ 27100969Siwasaki */ 28100969Siwasaki 29100969Siwasaki/****************************************************************************** 30100969Siwasaki * 31100969Siwasaki * Name: acpica_machdep.h - arch-specific defines, etc. 32100969Siwasaki * $Revision$ 33100969Siwasaki * 34100969Siwasaki *****************************************************************************/ 35100969Siwasaki 36100969Siwasaki#ifndef __ACPICA_MACHDEP_H__ 37100969Siwasaki#define __ACPICA_MACHDEP_H__ 38100969Siwasaki 39100969Siwasaki#ifdef _KERNEL 40100969Siwasaki/* 41100969Siwasaki * Calling conventions: 42100969Siwasaki * 43100969Siwasaki * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) 44100969Siwasaki * ACPI_EXTERNAL_XFACE - External ACPI interfaces 45100969Siwasaki * ACPI_INTERNAL_XFACE - Internal ACPI interfaces 46100969Siwasaki * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces 47100969Siwasaki */ 48100969Siwasaki#define ACPI_SYSTEM_XFACE 49100969Siwasaki#define ACPI_EXTERNAL_XFACE 50100969Siwasaki#define ACPI_INTERNAL_XFACE 51100969Siwasaki#define ACPI_INTERNAL_VAR_XFACE 52100969Siwasaki 53100969Siwasaki/* Asm macros */ 54100969Siwasaki 55100969Siwasaki#define ACPI_ASM_MACROS 56100969Siwasaki#define BREAKPOINT3 57100969Siwasaki#define ACPI_DISABLE_IRQS() disable_intr() 58100969Siwasaki#define ACPI_ENABLE_IRQS() enable_intr() 59100969Siwasaki 60100969Siwasaki#define ACPI_FLUSH_CPU_CACHE() wbinvd() 61100969Siwasaki 62100969Siwasaki#define asm __asm 63100969Siwasaki/*! [Begin] no source code translation 64100969Siwasaki * 65100969Siwasaki * A brief explanation as GNU inline assembly is a bit hairy 66100969Siwasaki * %0 is the output parameter in EAX ("=a") 67100969Siwasaki * %1 and %2 are the input parameters in ECX ("c") 68100969Siwasaki * and an immediate value ("i") respectively 69100969Siwasaki * All actual register references are preceded with "%%" as in "%%edx" 70100969Siwasaki * Immediate values in the assembly are preceded by "$" as in "$0x1" 71100969Siwasaki * The final asm parameter are the operation altered non-output registers. 72100969Siwasaki */ 73100969Siwasaki#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ 74100969Siwasaki do { \ 75115426Speter asm("1: movl %1,%%eax;" \ 76100969Siwasaki "movl %%eax,%%edx;" \ 77100969Siwasaki "andl %2,%%edx;" \ 78100969Siwasaki "btsl $0x1,%%edx;" \ 79100969Siwasaki "adcl $0x0,%%edx;" \ 80115426Speter "lock; cmpxchgl %%edx,%1;" \ 81100969Siwasaki "jnz 1b;" \ 82100969Siwasaki "cmpb $0x3,%%dl;" \ 83100969Siwasaki "sbbl %%eax,%%eax" \ 84115426Speter : "=a" (Acq), "+m" (GLptr) : "i" (~1L) : "edx"); \ 85100969Siwasaki } while(0) 86100969Siwasaki 87100969Siwasaki#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ 88100969Siwasaki do { \ 89115426Speter asm("1: movl %1,%%eax;" \ 90100969Siwasaki "movl %%eax,%%edx;" \ 91100969Siwasaki "andl %2,%%edx;" \ 92115426Speter "lock; cmpxchgl %%edx,%1;" \ 93100969Siwasaki "jnz 1b;" \ 94100969Siwasaki "andl $0x1,%%eax" \ 95115426Speter : "=a" (Acq), "+m" (GLptr) : "i" (~3L) : "edx"); \ 96100969Siwasaki } while(0) 97100969Siwasaki 98100969Siwasaki 99100969Siwasaki/*! [End] no source code translation !*/ 100100969Siwasaki#endif /* _KERNEL */ 101100969Siwasaki 102115426Speter#define ACPI_MACHINE_WIDTH 64 103115426Speter#define COMPILER_DEPENDENT_INT64 long 104115426Speter#define COMPILER_DEPENDENT_UINT64 unsigned long 105100969Siwasaki 106120347Spetervoid acpi_SetDefaultIntrModel(int model); 107120347Speter 108100969Siwasaki#endif /* __ACPICA_MACHDEP_H__ */ 109