xref: /dragonfly/sys/dev/acpica/Osd/OsdDebug.c (revision 71126e33)
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.5.4.1 2003/08/22 20:49:21 jhb Exp $
28  * 	$DragonFly: src/sys/dev/acpica/Osd/Attic/OsdDebug.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $
29  */
30 
31 /*
32  * 6.8 : Debugging support
33  */
34 
35 #include "opt_ddb.h"
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/cons.h>
39 #include <sys/kernel.h>
40 
41 #include <sys/bus.h>
42 #include <machine/resource.h>
43 #include <machine/bus.h>
44 #include <sys/rman.h>
45 
46 #include <ddb/ddb.h>
47 #include <ddb/db_output.h>
48 
49 #include "acpi.h"
50 #include "acdebug.h"
51 #include <dev/acpica/acpivar.h>
52 
53 UINT32
54 AcpiOsGetLine(char *Buffer)
55 {
56 #ifdef DDB
57     char	*cp;
58 
59     db_readline(Buffer, 80);
60     for (cp = Buffer; *cp != 0; cp++)
61 	if (*cp == '\n')
62 	    *cp = 0;
63     return(AE_OK);
64 #else
65     printf("AcpiOsGetLine called but no input support");
66     return(AE_NOT_EXIST);
67 #endif
68 }
69 
70 void
71 AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, char *Message)
72 {
73     printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
74     printf("ACPI: assertion  %s\n", (char *)FailedAssertion);
75 }
76 
77 ACPI_STATUS
78 AcpiOsSignal (
79     UINT32                  Function,
80     void                    *Info)
81 {
82     ACPI_SIGNAL_FATAL_INFO	*fatal;
83     char			*message;
84 
85     switch(Function) {
86     case ACPI_SIGNAL_FATAL:
87 	fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
88 	printf("ACPI fatal signal, type 0x%x  code 0x%x  argument 0x%x",
89 	      fatal->Type, fatal->Code, fatal->Argument);
90 	Debugger("AcpiOsSignal");
91 	break;
92 
93     case ACPI_SIGNAL_BREAKPOINT:
94 	message = (char *)Info;
95 	Debugger(message);
96 	break;
97 
98     default:
99 	return(AE_BAD_PARAMETER);
100     }
101     return(AE_OK);
102 }
103 
104 #ifdef ACPI_DEBUGGER
105 void
106 acpi_EnterDebugger(void)
107 {
108     ACPI_PARSE_OBJECT	obj;
109     static int		initted = 0;
110 
111     if (!initted) {
112 	printf("Initialising ACPICA debugger...\n");
113 	AcpiDbInitialize();
114 	initted = 1;
115     }
116 
117     printf("Entering ACPICA debugger...\n");
118     AcpiDbUserCommands('A', &obj);
119 }
120 #endif
121