Merge branch 'vendor/OPENSSL'
[dragonfly.git] / sys / dev / acpica5 / Osd / OsdDebug.c
1 /*-
2  * Copyright (c) 2000 Michael Smith
3  * Copyright (c) 2000 BSDi
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD: src/sys/dev/acpica/Osd/OsdDebug.c,v 1.9 2004/09/02 04:28:05 njl Exp $
28  * $DragonFly: src/sys/dev/acpica5/Osd/OsdDebug.c,v 1.6 2007/01/17 17:31:19 y0netan1 Exp $
29  */
30
31 /*
32  * 6.8 : Debugging support
33  */
34
35 #include "opt_ddb.h"
36
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39 #include <sys/bus.h>
40 #include <ddb/ddb.h>
41 #include <ddb/db_output.h>
42
43 #include "acpi.h"
44 #include "accommon.h"
45 #include "acpivar.h"
46 #include "acdebug.h"
47
48 UINT32
49 AcpiOsGetLine(char *Buffer)
50 {
51 #ifdef DDB
52     char        *cp;
53
54     db_readline(Buffer, 80);
55     for (cp = Buffer; *cp != 0; cp++)
56         if (*cp == '\n')
57             *cp = 0;
58     return (AE_OK);
59 #else
60     kprintf("AcpiOsGetLine called but no input support");
61     return (AE_NOT_EXIST);
62 #endif /* DDB */
63 }
64
65 #if 0   /* unused for ages */
66 void
67 AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber,
68     char *Message)
69 {
70     kprintf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
71     kprintf("ACPI: assertion  %s\n", (char *)FailedAssertion);
72 }
73 #endif
74
75 ACPI_STATUS
76 AcpiOsSignal(UINT32 Function, void *Info)
77 {
78     ACPI_SIGNAL_FATAL_INFO      *fatal;
79     
80     switch (Function) {
81     case ACPI_SIGNAL_FATAL:
82         fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
83         kprintf("ACPI fatal signal, type 0x%x  code 0x%x  argument 0x%x",
84               fatal->Type, fatal->Code, fatal->Argument);
85         Debugger("AcpiOsSignal");
86         break;
87         
88     case ACPI_SIGNAL_BREAKPOINT:
89 #ifdef ACPI_DEBUG
90         Debugger((char *)Info);
91 #endif
92         break;
93
94     default:
95         return (AE_BAD_PARAMETER);
96     }
97     return (AE_OK);
98 }
99
100 #ifdef ACPI_DEBUGGER
101 void
102 acpi_EnterDebugger(void)
103 {
104     ACPI_PARSE_OBJECT   obj;
105     static int          initted = 0;
106
107     if (!initted) {
108         kprintf("Initialising ACPICA debugger...\n");
109         AcpiDbInitialize();
110         initted = 1;
111     }
112
113     kprintf("Entering ACPICA debugger...\n");
114     AcpiDbUserCommands('A', &obj);
115 }
116 #endif /* ACPI_DEBUGGER */