OsdDebug.c revision 128225
1218792Snp/*-
2218792Snp * Copyright (c) 2000 Michael Smith
3218792Snp * Copyright (c) 2000 BSDi
4218792Snp * All rights reserved.
5218792Snp *
6218792Snp * Redistribution and use in source and binary forms, with or without
7218792Snp * modification, are permitted provided that the following conditions
8218792Snp * are met:
9218792Snp * 1. Redistributions of source code must retain the above copyright
10218792Snp *    notice, this list of conditions and the following disclaimer.
11218792Snp * 2. Redistributions in binary form must reproduce the above copyright
12218792Snp *    notice, this list of conditions and the following disclaimer in the
13218792Snp *    documentation and/or other materials provided with the distribution.
14218792Snp *
15218792Snp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16218792Snp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17218792Snp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18218792Snp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19218792Snp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20218792Snp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21218792Snp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22218792Snp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23218792Snp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24218792Snp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25218792Snp * SUCH DAMAGE.
26218792Snp *
27218792Snp *	$FreeBSD: head/sys/dev/acpica/Osd/OsdDebug.c 128225 2004-04-14 03:39:08Z njl $
28218792Snp */
29218792Snp
30218792Snp/*
31218792Snp * 6.8 : Debugging support
32218792Snp */
33218792Snp
34218792Snp#include "opt_ddb.h"
35218792Snp#include <sys/param.h>
36248925Snp#include <sys/kernel.h>
37248925Snp#include <sys/bus.h>
38248925Snp#include <machine/bus.h>
39248925Snp
40248925Snp#include "acpi.h"
41248925Snp#include "acdebug.h"
42248925Snp#include <dev/acpica/acpivar.h>
43248925Snp
44248925SnpUINT32
45248925SnpAcpiOsGetLine(char *Buffer)
46248925Snp{
47248925Snp#ifdef DDB
48253691Snp    char	*cp;
49248925Snp
50248925Snp    db_readline(Buffer, 80);
51248925Snp    for (cp = Buffer; *cp != 0; cp++)
52248925Snp	if (*cp == '\n')
53248925Snp	    *cp = 0;
54248925Snp    return (AE_OK);
55248925Snp#else
56248925Snp    printf("AcpiOsGetLine called but no input support");
57218792Snp    return (AE_NOT_EXIST);
58218792Snp#endif /* DDB */
59218792Snp}
60218792Snp
61218792Snpvoid
62248925SnpAcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber,
63218792Snp    char *Message)
64218792Snp{
65218792Snp    printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
66218792Snp    printf("ACPI: assertion  %s\n", (char *)FailedAssertion);
67247122Snp}
68218792Snp
69218792SnpACPI_STATUS
70218792SnpAcpiOsSignal(UINT32 Function, void *Info)
71218792Snp{
72218792Snp    ACPI_SIGNAL_FATAL_INFO	*fatal;
73218792Snp    char			*message;
74218792Snp
75218792Snp    switch (Function) {
76218792Snp    case ACPI_SIGNAL_FATAL:
77218792Snp	fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
78218792Snp	printf("ACPI fatal signal, type 0x%x  code 0x%x  argument 0x%x",
79218792Snp	      fatal->Type, fatal->Code, fatal->Argument);
80218792Snp	Debugger("AcpiOsSignal");
81218792Snp	break;
82218792Snp
83218792Snp    case ACPI_SIGNAL_BREAKPOINT:
84218792Snp	message = (char *)Info;
85218792Snp	Debugger(message);
86218792Snp	break;
87218792Snp
88218792Snp    default:
89248925Snp	return (AE_BAD_PARAMETER);
90265425Snp    }
91218792Snp
92218792Snp    return (AE_OK);
93218792Snp}
94218792Snp
95218792Snp#ifdef ACPI_DEBUGGER
96218792Snpvoid
97218792Snpacpi_EnterDebugger(void)
98218792Snp{
99218792Snp    ACPI_PARSE_OBJECT	obj;
100218792Snp    static int		initted = 0;
101218792Snp
102218792Snp    if (!initted) {
103218792Snp	printf("Initialising ACPICA debugger...\n");
104218792Snp	AcpiDbInitialize();
105218792Snp	initted = 1;
106218792Snp    }
107218792Snp
108218792Snp    printf("Entering ACPICA debugger...\n");
109218792Snp    AcpiDbUserCommands('A', &obj);
110218792Snp}
111218792Snp#endif /* ACPI_DEBUGGER */
112218792Snp