1 /* $NetBSD: OsdMisc.c,v 1.6 2009/07/06 12:36:31 joerg Exp $ */
4 * Copyright 2001 Wasabi Systems, Inc.
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: OsdMisc.c,v 1.6 2009/07/06 12:36:31 joerg Exp $");
50 #include <sys/param.h>
51 #include <sys/systm.h>
53 #include <machine/db_machdep.h>
55 #include <ddb/db_extern.h>
56 #include <ddb/db_output.h>
58 #include <dev/acpi/acpica.h>
59 #include <dev/acpi/acpi_osd.h>
61 #include <external/intel-public/acpica/dist/include/accommon.h>
62 #include <external/intel-public/acpica/dist/include/acdebug.h>
64 * for debugging DSDT (try this at your own risk!):
66 * 1. dump your raw DSDT (with acpidump(*1) etc.)
67 * 2. disassemble with iasl -d (*2)
68 * 3. modify the ASL file
69 * 4. compile it with iasl -tc
70 * 5. copy *.hex to src/sys/dev/acpi/acpica/Osd/dsdt.hex
72 * options ACPI_DSDT_FILE="\"yourdsdt.hex\"" in
73 * your config file and yourdsdt.hex in the build directory
74 * 6. options ACPI_DSDT_OVERRIDE in your kernel config file
75 * and rebuild the kernel
77 * (*1) /usr/pkgsrc/sysutils/acpidump
78 * (*2) /usr/pkgsrc/sysutils/acpi-iasl
81 #ifdef ACPI_DSDT_OVERRIDE
82 #ifndef ACPI_DSDT_FILE
83 #define ACPI_DSDT_FILE "dsdt.hex"
85 #include ACPI_DSDT_FILE
93 * Break to the debugger or display a breakpoint message.
96 AcpiOsSignal(UINT32 Function
, void *Info
)
99 * the upper layer might call with Info = NULL,
100 * which makes little sense.
106 case ACPI_SIGNAL_FATAL
:
108 ACPI_SIGNAL_FATAL_INFO
*info
= Info
;
110 panic("ACPI fatal signal: "
111 "Type 0x%08x, Code 0x%08x, Argument 0x%08x",
112 info
->Type
, info
->Code
, info
->Argument
);
117 case ACPI_SIGNAL_BREAKPOINT
:
119 #ifdef ACPI_BREAKPOINT
122 printf("%s\n", info
);
126 printf("ACPI: WARNING: DDB not configured into kernel.\n");
134 return AE_BAD_PARAMETER
;
141 AcpiOsGetLine(char *Buffer
)
146 db_readline(Buffer
, 80);
147 for (cp
= Buffer
; *cp
!= 0; cp
++)
148 if (*cp
== '\n' || *cp
== '\r')
153 printf("ACPI: WARNING: DDB not configured into kernel.\n");
159 AcpiOsTableOverride(ACPI_TABLE_HEADER
*ExistingTable
,
160 ACPI_TABLE_HEADER
**NewTable
)
162 #ifndef ACPI_DSDT_OVERRIDE
165 if (strncmp(ExistingTable
->Signature
, "DSDT", 4) == 0)
166 *NewTable
= (ACPI_TABLE_HEADER
*)AmlCode
;
174 AcpiOsPredefinedOverride(const ACPI_PREDEFINED_NAMES
*InitVal
,
177 if (!InitVal
|| !NewVal
)
178 return AE_BAD_PARAMETER
;
187 * Enter the ACPICA debugger.
190 acpi_osd_debugger(void)
194 ACPI_PARSE_OBJECT obj
;
199 printf("Initializing ACPICA debugger...\n");
204 printf("Entering ACPICA debugger...\n");
205 savejmp
= db_recover
;
206 setjmp(&acpi_jmpbuf
);
207 db_recover
= &acpi_jmpbuf
;
210 AcpiDbUserCommands('A', &obj
);
213 db_recover
= savejmp
;
215 printf("ACPI: WARNING: ACPICA debugger not present.\n");