xref: /freebsd/sys/dev/acpica/Osd/OsdDebug.c (revision 9d839ea8e4a9327a06de07eb9427eec4357a93e3)
1fd660059SMike Smith /*-
2fd660059SMike Smith  * Copyright (c) 2000 Michael Smith
3fd660059SMike Smith  * Copyright (c) 2000 BSDi
4fd660059SMike Smith  * All rights reserved.
5fd660059SMike Smith  *
6fd660059SMike Smith  * Redistribution and use in source and binary forms, with or without
7fd660059SMike Smith  * modification, are permitted provided that the following conditions
8fd660059SMike Smith  * are met:
9fd660059SMike Smith  * 1. Redistributions of source code must retain the above copyright
10fd660059SMike Smith  *    notice, this list of conditions and the following disclaimer.
11fd660059SMike Smith  * 2. Redistributions in binary form must reproduce the above copyright
12fd660059SMike Smith  *    notice, this list of conditions and the following disclaimer in the
13fd660059SMike Smith  *    documentation and/or other materials provided with the distribution.
14fd660059SMike Smith  *
15fd660059SMike Smith  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16fd660059SMike Smith  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17fd660059SMike Smith  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18fd660059SMike Smith  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19fd660059SMike Smith  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20fd660059SMike Smith  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21fd660059SMike Smith  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22fd660059SMike Smith  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23fd660059SMike Smith  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24fd660059SMike Smith  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25fd660059SMike Smith  * SUCH DAMAGE.
26fd660059SMike Smith  *
27fd660059SMike Smith  *	$FreeBSD$
28fd660059SMike Smith  */
29fd660059SMike Smith 
30fd660059SMike Smith /*
31fd660059SMike Smith  * 6.8 : Debugging support
32fd660059SMike Smith  */
33fd660059SMike Smith 
34fd660059SMike Smith #include "opt_ddb.h"
35fd660059SMike Smith #include <sys/param.h>
36fd660059SMike Smith #include <sys/systm.h>
37fd660059SMike Smith #include <sys/cons.h>
38fd660059SMike Smith #include <sys/kernel.h>
39fd660059SMike Smith 
40fd660059SMike Smith #include <sys/bus.h>
41fd660059SMike Smith #include <machine/resource.h>
42fd660059SMike Smith #include <machine/bus.h>
43fd660059SMike Smith #include <sys/rman.h>
44fd660059SMike Smith 
45fd660059SMike Smith #include <ddb/ddb.h>
46fd660059SMike Smith #include <ddb/db_output.h>
47fd660059SMike Smith 
48fd660059SMike Smith #include "acpi.h"
49fd660059SMike Smith #include "acdebug.h"
50fd660059SMike Smith #include <dev/acpica/acpivar.h>
51fd660059SMike Smith 
52fd660059SMike Smith UINT32
53fd660059SMike Smith AcpiOsGetLine(NATIVE_CHAR *Buffer)
54fd660059SMike Smith {
55fd660059SMike Smith #ifdef DDB
56fd660059SMike Smith     char	*cp;
57fd660059SMike Smith 
58fd660059SMike Smith     db_readline(Buffer, 80);
59fd660059SMike Smith     for (cp = Buffer; *cp != 0; cp++)
60fd660059SMike Smith 	if (*cp == '\n')
61fd660059SMike Smith 	    *cp = 0;
62fd660059SMike Smith     return(AE_OK);
63fd660059SMike Smith #else
64fd660059SMike Smith     printf("AcpiOsGetLine called but no input support");
65fd660059SMike Smith     return(AE_NOT_EXIST);
66fd660059SMike Smith #endif
67fd660059SMike Smith }
68fd660059SMike Smith 
69fd660059SMike Smith void
70fd660059SMike Smith AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, NATIVE_CHAR *Message)
71fd660059SMike Smith {
72fd660059SMike Smith     printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
73fd660059SMike Smith     printf("ACPI: assertion  %s\n", (char *)FailedAssertion);
74fd660059SMike Smith }
75fd660059SMike Smith 
769d839ea8SMike Smith ACPI_STATUS
779d839ea8SMike Smith AcpiOsSignal (
789d839ea8SMike Smith     UINT32                  Function,
799d839ea8SMike Smith     void                    *Info)
809d839ea8SMike Smith {
819d839ea8SMike Smith     ACPI_SIGNAL_FATAL_INFO	*fatal;
829d839ea8SMike Smith     NATIVE_CHAR			*message;
839d839ea8SMike Smith 
849d839ea8SMike Smith     switch(Function) {
859d839ea8SMike Smith     case ACPI_SIGNAL_FATAL:
869d839ea8SMike Smith 	fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
879d839ea8SMike Smith 	panic("ACPI fatal signal, type 0x%x  code 0x%x  argument 0x%x",
889d839ea8SMike Smith 	      fatal->Type, fatal->Code, fatal->Argument);
899d839ea8SMike Smith 	break;
909d839ea8SMike Smith 
919d839ea8SMike Smith     case ACPI_SIGNAL_BREAKPOINT:
929d839ea8SMike Smith 	message = (NATIVE_CHAR *)Info;
939d839ea8SMike Smith 	Debugger(message);
949d839ea8SMike Smith 	break;
959d839ea8SMike Smith 
969d839ea8SMike Smith     default:
979d839ea8SMike Smith 	return(AE_BAD_PARAMETER);
989d839ea8SMike Smith     }
999d839ea8SMike Smith     return(AE_OK);
1009d839ea8SMike Smith }
1019d839ea8SMike Smith 
102fd660059SMike Smith #ifdef ENABLE_DEBUGGER
103fd660059SMike Smith void
104fd660059SMike Smith acpi_EnterDebugger(void)
105fd660059SMike Smith {
106fd660059SMike Smith     ACPI_PARSE_OBJECT	obj;
107fd660059SMike Smith     static int		initted = 0;
108fd660059SMike Smith 
109fd660059SMike Smith     if (!initted) {
110fd660059SMike Smith 	printf("Initialising ACPICA debugger...\n");
111fd660059SMike Smith 	AcpiDbInitialize();
112fd660059SMike Smith 	initted = 1;
113fd660059SMike Smith     }
114fd660059SMike Smith 
115fd660059SMike Smith     printf("Entering ACPICA debugger...\n");
116fd660059SMike Smith     AcpiDbUserCommands('A', &obj);
117fd660059SMike Smith }
118fd660059SMike Smith #endif
119