OsdDebug.c revision 80071
167760Smsmith/*-
267760Smsmith * Copyright (c) 2000 Michael Smith
367760Smsmith * Copyright (c) 2000 BSDi
467760Smsmith * All rights reserved.
567760Smsmith *
667760Smsmith * Redistribution and use in source and binary forms, with or without
767760Smsmith * modification, are permitted provided that the following conditions
867760Smsmith * are met:
967760Smsmith * 1. Redistributions of source code must retain the above copyright
1067760Smsmith *    notice, this list of conditions and the following disclaimer.
1167760Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1267760Smsmith *    notice, this list of conditions and the following disclaimer in the
1367760Smsmith *    documentation and/or other materials provided with the distribution.
1467760Smsmith *
1567760Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1667760Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1767760Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1867760Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1967760Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2067760Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2167760Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2267760Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2367760Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2467760Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2567760Smsmith * SUCH DAMAGE.
2667760Smsmith *
2767760Smsmith *	$FreeBSD: head/sys/dev/acpica/Osd/OsdDebug.c 80071 2001-07-21 04:10:01Z msmith $
2867760Smsmith */
2967760Smsmith
3067760Smsmith/*
3167760Smsmith * 6.8 : Debugging support
3267760Smsmith */
3367760Smsmith
3467760Smsmith#include "opt_ddb.h"
3567760Smsmith#include <sys/param.h>
3667760Smsmith#include <sys/systm.h>
3767760Smsmith#include <sys/cons.h>
3867760Smsmith#include <sys/kernel.h>
3967760Smsmith
4067760Smsmith#include <sys/bus.h>
4167760Smsmith#include <machine/resource.h>
4267760Smsmith#include <machine/bus.h>
4367760Smsmith#include <sys/rman.h>
4467760Smsmith
4567760Smsmith#include <ddb/ddb.h>
4667760Smsmith#include <ddb/db_output.h>
4767760Smsmith
4867760Smsmith#include "acpi.h"
4967760Smsmith#include "acdebug.h"
5067760Smsmith#include <dev/acpica/acpivar.h>
5167760Smsmith
5267760SmsmithUINT32
5367760SmsmithAcpiOsGetLine(NATIVE_CHAR *Buffer)
5467760Smsmith{
5567760Smsmith#ifdef DDB
5667760Smsmith    char	*cp;
5767760Smsmith
5867760Smsmith    db_readline(Buffer, 80);
5967760Smsmith    for (cp = Buffer; *cp != 0; cp++)
6067760Smsmith	if (*cp == '\n')
6167760Smsmith	    *cp = 0;
6267760Smsmith    return(AE_OK);
6367760Smsmith#else
6467760Smsmith    printf("AcpiOsGetLine called but no input support");
6567760Smsmith    return(AE_NOT_EXIST);
6667760Smsmith#endif
6767760Smsmith}
6867760Smsmith
6967760Smsmithvoid
7067760SmsmithAcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, NATIVE_CHAR *Message)
7167760Smsmith{
7267760Smsmith    printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message);
7367760Smsmith    printf("ACPI: assertion  %s\n", (char *)FailedAssertion);
7467760Smsmith}
7567760Smsmith
7680071SmsmithACPI_STATUS
7780071SmsmithAcpiOsSignal (
7880071Smsmith    UINT32                  Function,
7980071Smsmith    void                    *Info)
8080071Smsmith{
8180071Smsmith    ACPI_SIGNAL_FATAL_INFO	*fatal;
8280071Smsmith    NATIVE_CHAR			*message;
8380071Smsmith
8480071Smsmith    switch(Function) {
8580071Smsmith    case ACPI_SIGNAL_FATAL:
8680071Smsmith	fatal = (ACPI_SIGNAL_FATAL_INFO *)Info;
8780071Smsmith	panic("ACPI fatal signal, type 0x%x  code 0x%x  argument 0x%x",
8880071Smsmith	      fatal->Type, fatal->Code, fatal->Argument);
8980071Smsmith	break;
9080071Smsmith
9180071Smsmith    case ACPI_SIGNAL_BREAKPOINT:
9280071Smsmith	message = (NATIVE_CHAR *)Info;
9380071Smsmith	Debugger(message);
9480071Smsmith	break;
9580071Smsmith
9680071Smsmith    default:
9780071Smsmith	return(AE_BAD_PARAMETER);
9880071Smsmith    }
9980071Smsmith    return(AE_OK);
10080071Smsmith}
10180071Smsmith
10267760Smsmith#ifdef ENABLE_DEBUGGER
10367760Smsmithvoid
10467760Smsmithacpi_EnterDebugger(void)
10567760Smsmith{
10667760Smsmith    ACPI_PARSE_OBJECT	obj;
10767760Smsmith    static int		initted = 0;
10867760Smsmith
10967760Smsmith    if (!initted) {
11067760Smsmith	printf("Initialising ACPICA debugger...\n");
11167760Smsmith	AcpiDbInitialize();
11267760Smsmith	initted = 1;
11367760Smsmith    }
11467760Smsmith
11567760Smsmith    printf("Entering ACPICA debugger...\n");
11667760Smsmith    AcpiDbUserCommands('A', &obj);
11767760Smsmith}
11867760Smsmith#endif
119