acfreebsd.h revision 126372
1230897Spfg/******************************************************************************
2230897Spfg *
3230897Spfg * Name: acfreebsd.h - OS specific defines, etc.
4230897Spfg *       $Revision: 13 $
5230897Spfg *
6230897Spfg *****************************************************************************/
7230897Spfg
8230897Spfg/******************************************************************************
9230897Spfg *
10230897Spfg * 1. Copyright Notice
11230897Spfg *
12230897Spfg * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13230897Spfg * All rights reserved.
14230897Spfg *
15230897Spfg * 2. License
16230897Spfg *
17230897Spfg * 2.1. This is your license from Intel Corp. under its intellectual property
18230897Spfg * rights.  You may have additional license terms from the party that provided
19230897Spfg * you this software, covering your right to use that party's intellectual
20230897Spfg * property rights.
21230897Spfg *
22230897Spfg * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23230897Spfg * copy of the source code appearing in this file ("Covered Code") an
24230897Spfg * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25230897Spfg * base code distributed originally by Intel ("Original Intel Code") to copy,
26230897Spfg * make derivatives, distribute, use and display any portion of the Covered
27230897Spfg * Code in any form, with the right to sublicense such rights; and
28230897Spfg *
29230897Spfg * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30230897Spfg * license (with the right to sublicense), under only those claims of Intel
31230897Spfg * patents that are infringed by the Original Intel Code, to make, use, sell,
32230897Spfg * offer to sell, and import the Covered Code and derivative works thereof
33230897Spfg * solely to the minimum extent necessary to exercise the above copyright
34230897Spfg * license, and in no event shall the patent license extend to any additions
35230897Spfg * to or modifications of the Original Intel Code.  No other license or right
36230897Spfg * is granted directly or by implication, estoppel or otherwise;
37230897Spfg *
38230897Spfg * The above copyright and patent license is granted only if the following
39230897Spfg * conditions are met:
40230897Spfg *
41230897Spfg * 3. Conditions
42230897Spfg *
43230897Spfg * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44230897Spfg * Redistribution of source code of any substantial portion of the Covered
45230897Spfg * Code or modification with rights to further distribute source must include
46230897Spfg * the above Copyright Notice, the above License, this list of Conditions,
47230897Spfg * and the following Disclaimer and Export Compliance provision.  In addition,
48230897Spfg * Licensee must cause all Covered Code to which Licensee contributes to
49230897Spfg * contain a file documenting the changes Licensee made to create that Covered
50230897Spfg * Code and the date of any change.  Licensee must include in that file the
51230897Spfg * documentation of any changes made by any predecessor Licensee.  Licensee
52230897Spfg * must include a prominent statement that the modification is derived,
53230897Spfg * directly or indirectly, from Original Intel Code.
54230897Spfg *
55230897Spfg * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56230897Spfg * Redistribution of source code of any substantial portion of the Covered
57230897Spfg * Code or modification without rights to further distribute source must
58230897Spfg * include the following Disclaimer and Export Compliance provision in the
59230897Spfg * documentation and/or other materials provided with distribution.  In
60230897Spfg * addition, Licensee may not authorize further sublicense of source of any
61230897Spfg * portion of the Covered Code, and must include terms to the effect that the
62230897Spfg * license from Licensee to its licensee is limited to the intellectual
63230897Spfg * property embodied in the software Licensee provides to its licensee, and
64230897Spfg * not to intellectual property embodied in modifications its licensee may
65230897Spfg * make.
66230897Spfg *
67230897Spfg * 3.3. Redistribution of Executable. Redistribution in executable form of any
68230897Spfg * substantial portion of the Covered Code or modification must reproduce the
69230897Spfg * above Copyright Notice, and the following Disclaimer and Export Compliance
70230897Spfg * provision in the documentation and/or other materials provided with the
71230897Spfg * distribution.
72230897Spfg *
73230897Spfg * 3.4. Intel retains all right, title, and interest in and to the Original
74230897Spfg * Intel Code.
75230897Spfg *
76230897Spfg * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77230897Spfg * Intel shall be used in advertising or otherwise to promote the sale, use or
78230897Spfg * other dealings in products derived from or relating to the Covered Code
79230897Spfg * without prior written authorization from Intel.
80230897Spfg *
81230897Spfg * 4. Disclaimer and Export Compliance
82230897Spfg *
83230897Spfg * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84230897Spfg * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85230897Spfg * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86230897Spfg * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87230897Spfg * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88230897Spfg * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89230897Spfg * PARTICULAR PURPOSE.
90230897Spfg *
91230897Spfg * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92230897Spfg * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93230897Spfg * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94230897Spfg * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95230897Spfg * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96230897Spfg * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97230897Spfg * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98230897Spfg * LIMITED REMEDY.
99230897Spfg *
100230897Spfg * 4.3. Licensee shall not export, either directly or indirectly, any of this
101230897Spfg * software or system incorporating such software without first obtaining any
102230897Spfg * required license or other approval from the U. S. Department of Commerce or
103230897Spfg * any other agency or department of the United States Government.  In the
104230897Spfg * event Licensee exports any such software from the United States or
105230897Spfg * re-exports any such software from a foreign destination, Licensee shall
106230897Spfg * ensure that the distribution and export/re-export of the software is in
107230897Spfg * compliance with all laws, regulations, orders, or other restrictions of the
108230897Spfg * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109230897Spfg * any of its subsidiaries will export/re-export any technical data, process,
110230897Spfg * software, or service, directly or indirectly, to any country for which the
111230897Spfg * United States government or any agency thereof requires an export license,
112230897Spfg * other governmental approval, or letter of assurance, without first obtaining
113230897Spfg * such license, approval or letter.
114230897Spfg *
115230897Spfg *****************************************************************************/
116230897Spfg
117230897Spfg#ifndef __ACFREEBSD_H__
118230897Spfg#define __ACFREEBSD_H__
119230897Spfg
120230897Spfg/*
121230897Spfg * Some systems' ASL may have problems because they look for names
122230897Spfg * of Microsoft operating systems.  To override this, set hw.acpi.os_name
123230897Spfg * to the appropriate string.
124230897Spfg */
125230897Spfg#define ACPI_OS_NAME                "FreeBSD"
126230897Spfg
127230897Spfg/* FreeBSD uses GCC */
128230897Spfg
129230897Spfg#include "acgcc.h"
130230897Spfg#include <machine/acpica_machdep.h>
131230897Spfg
132230897Spfg#ifdef _KERNEL
133230897Spfg#include "opt_acpi.h"
134230897Spfg#endif
135230897Spfg
136230897Spfg#ifdef ACPI_DEBUG
137230897Spfg#define ACPI_DEBUG_OUTPUT   /* for backward compatibility */
138230897Spfg#define ACPI_DISASSEMBLER
139230897Spfg#endif
140230897Spfg
141230897Spfg#ifdef _KERNEL
142230897Spfg#include <sys/ctype.h>
143230897Spfg#include <sys/param.h>
144230897Spfg#include <sys/systm.h>
145230897Spfg#include <sys/libkern.h>
146230897Spfg#include <machine/stdarg.h>
147230897Spfg
148230897Spfg#ifdef DEBUGGER_THREADING
149230897Spfg#undef DEBUGGER_THREADING
150230897Spfg#endif /* DEBUGGER_THREADING */
151230897Spfg#define DEBUGGER_THREADING 0    /* integrated with DDB */
152230897Spfg#ifdef ACPI_DEBUG_OUTPUT
153230897Spfg#include "opt_ddb.h"
154230897Spfg#ifdef DDB
155230897Spfg#define ACPI_DEBUGGER
156230897Spfg#endif /* DDB */
157230897Spfg#endif /* ACPI_DEBUG_OUTPUT */
158230897Spfg
159230897Spfg#else /* _KERNEL */
160230897Spfg
161230897Spfg/* Not building kernel code, so use libc */
162230897Spfg#define ACPI_USE_STANDARD_HEADERS
163230897Spfg#define ACPI_FLUSH_CPU_CACHE()
164230897Spfg#include <sys/types.h>
165230897Spfg
166230897Spfg#define __cli()
167230897Spfg#define __sti()
168230897Spfg
169230897Spfg#endif /* _KERNEL */
170230897Spfg
171230897Spfg/* Always use FreeBSD code over our local versions */
172230897Spfg#define ACPI_USE_SYSTEM_CLIBRARY
173230897Spfg
174230897Spfg/* FreeBSD doesn't have strupr, should be fixed. (move to libkern) */
175230897Spfgstatic __inline char *
176230897Spfgstrupr(char *str)
177230897Spfg{
178230897Spfg    char *c = str;
179230897Spfg    while(*c) {
180230897Spfg    *c = toupper(*c);
181230897Spfg    c++;
182230897Spfg    }
183230897Spfg    return(str);
184230897Spfg}
185230897Spfg
186230897Spfg#ifdef _KERNEL
187230897Spfg/* Or strstr (used in debugging mode, also move to libkern) */
188230897Spfgstatic __inline char *
189230897Spfgstrstr(char *s, char *find)
190230897Spfg{
191230897Spfg    char c, sc;
192230897Spfg    size_t len;
193230897Spfg
194230897Spfg    if ((c = *find++) != 0) {
195230897Spfg    len = strlen(find);
196230897Spfg    do {
197230897Spfg        do {
198230897Spfg        if ((sc = *s++) == 0)
199230897Spfg            return (NULL);
200230897Spfg        } while (sc != c);
201230897Spfg    } while (strncmp(s, find, len) != 0);
202230897Spfg    s--;
203230897Spfg    }
204230897Spfg    return ((char *)s);
205230897Spfg}
206230897Spfg#endif /* _KERNEL */
207230897Spfg
208230897Spfg#endif /* __ACFREEBSD_H__ */
209230897Spfg