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
28fd660059SMike Smith /*
29fd660059SMike Smith * 6.8 : Debugging support
30fd660059SMike Smith */
31fd660059SMike Smith
32a3ab9d1eSNate Lawson #include <sys/cdefs.h>
33fd660059SMike Smith #include "opt_ddb.h"
34fd660059SMike Smith #include <sys/param.h>
35124ea6b5SMarcel Moolenaar #include <sys/kdb.h>
36fd660059SMike Smith #include <sys/kernel.h>
37fd660059SMike Smith #include <sys/bus.h>
38fd660059SMike Smith #include <machine/bus.h>
390f4f8be3SNate Lawson #include <ddb/ddb.h>
400f4f8be3SNate Lawson #include <ddb/db_output.h>
41fd660059SMike Smith
42129d3046SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
43129d3046SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
44129d3046SJung-uk Kim #include <contrib/dev/acpica/include/acdebug.h>
45129d3046SJung-uk Kim
46fd660059SMike Smith #include <dev/acpica/acpivar.h>
47fd660059SMike Smith
4842e58c03SJung-uk Kim ACPI_STATUS
AcpiOsGetLine(char * Buffer,UINT32 BufferLength,UINT32 * BytesRead)4942e58c03SJung-uk Kim AcpiOsGetLine(char *Buffer, UINT32 BufferLength, UINT32 *BytesRead)
50fd660059SMike Smith {
51fd660059SMike Smith #ifdef DDB
52fd660059SMike Smith char *cp;
53fd660059SMike Smith
5442e58c03SJung-uk Kim cp = Buffer;
5542e58c03SJung-uk Kim if (db_readline(Buffer, BufferLength) > 0)
5642e58c03SJung-uk Kim while (*cp != '\0' && *cp != '\n' && *cp != '\r')
5742e58c03SJung-uk Kim cp++;
5842e58c03SJung-uk Kim *cp = '\0';
5942e58c03SJung-uk Kim if (BytesRead != NULL)
6042e58c03SJung-uk Kim *BytesRead = cp - Buffer;
61fd660059SMike Smith return (AE_OK);
62fd660059SMike Smith #else
63fd660059SMike Smith printf("AcpiOsGetLine called but no input support");
64fd660059SMike Smith return (AE_NOT_EXIST);
65c871a6daSNate Lawson #endif /* DDB */
66fd660059SMike Smith }
67fd660059SMike Smith
689d839ea8SMike Smith ACPI_STATUS
AcpiOsSignal(UINT32 Function,void * Info)69c871a6daSNate Lawson AcpiOsSignal(UINT32 Function, void *Info)
709d839ea8SMike Smith {
719d839ea8SMike Smith ACPI_SIGNAL_FATAL_INFO *fatal;
729d839ea8SMike Smith
739d839ea8SMike Smith switch (Function) {
749d839ea8SMike Smith case ACPI_SIGNAL_FATAL:
759d839ea8SMike Smith fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
76c573e654SMitsuru IWASAKI printf("ACPI fatal signal, type 0x%x code 0x%x argument 0x%x",
779d839ea8SMike Smith fatal->Type, fatal->Code, fatal->Argument);
78929a5cf6SNate Lawson #ifdef ACPI_DEBUG
793de213ccSRobert Watson kdb_enter(KDB_WHY_ACPI, "AcpiOsSignal");
80929a5cf6SNate Lawson #endif
819d839ea8SMike Smith break;
829d839ea8SMike Smith
839d839ea8SMike Smith case ACPI_SIGNAL_BREAKPOINT:
842df0b34bSNate Lawson #ifdef ACPI_DEBUG
853de213ccSRobert Watson kdb_enter(KDB_WHY_ACPI, (char *)Info);
862df0b34bSNate Lawson #endif
879d839ea8SMike Smith break;
889d839ea8SMike Smith
899d839ea8SMike Smith default:
909d839ea8SMike Smith return (AE_BAD_PARAMETER);
919d839ea8SMike Smith }
92c871a6daSNate Lawson
939d839ea8SMike Smith return (AE_OK);
949d839ea8SMike Smith }
959d839ea8SMike Smith
96d62ab2f4SMitsuru IWASAKI #ifdef ACPI_DEBUGGER
97fd660059SMike Smith void
acpi_EnterDebugger(void)98fd660059SMike Smith acpi_EnterDebugger(void)
99fd660059SMike Smith {
100fd660059SMike Smith static int initted = 0;
101fd660059SMike Smith
102fd660059SMike Smith if (!initted) {
103fd660059SMike Smith printf("Initialising ACPICA debugger...\n");
10470e6ab8fSJung-uk Kim AcpiInitializeDebugger();
105fd660059SMike Smith initted = 1;
106fd660059SMike Smith }
107fd660059SMike Smith
108fd660059SMike Smith printf("Entering ACPICA debugger...\n");
109*28482948SJung-uk Kim AcpiDbUserCommands();
110fd660059SMike Smith }
111c871a6daSNate Lawson #endif /* ACPI_DEBUGGER */
112