OsdDebug.c revision 88420
138032Speter/*- 298125Sgshapiro * Copyright (c) 2000 Michael Smith 364565Sgshapiro * Copyright (c) 2000 BSDi 438032Speter * All rights reserved. 538032Speter * 638032Speter * Redistribution and use in source and binary forms, with or without 738032Speter * modification, are permitted provided that the following conditions 838032Speter * are met: 938032Speter * 1. Redistributions of source code must retain the above copyright 1038032Speter * notice, this list of conditions and the following disclaimer. 1138032Speter * 2. Redistributions in binary form must reproduce the above copyright 12121826Sgshapiro * notice, this list of conditions and the following disclaimer in the 1338032Speter * documentation and/or other materials provided with the distribution. 1438032Speter * 1590795Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1690795Sgshapiro * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1790795Sgshapiro * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1873191Sgshapiro * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1964565Sgshapiro * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2064565Sgshapiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2164565Sgshapiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2290795Sgshapiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2338032Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24110563Sgshapiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2564565Sgshapiro * SUCH DAMAGE. 2638032Speter * 2738032Speter * $FreeBSD: head/sys/dev/acpica/Osd/OsdDebug.c 88420 2001-12-22 16:05:41Z iwasaki $ 2838032Speter */ 2938032Speter 3038032Speter/* 3138032Speter * 6.8 : Debugging support 3238032Speter */ 3338032Speter 3438032Speter#include "opt_ddb.h" 3538032Speter#include <sys/param.h> 3638032Speter#include <sys/systm.h> 3738032Speter#include <sys/cons.h> 3838032Speter#include <sys/kernel.h> 3938032Speter 4038032Speter#include <sys/bus.h> 4138081Speter#include <machine/resource.h> 4238032Speter#include <machine/bus.h> 4338032Speter#include <sys/rman.h> 4464565Sgshapiro 4564565Sgshapiro#include <ddb/ddb.h> 4664565Sgshapiro#include <ddb/db_output.h> 4738032Speter 4838032Speter#include "acpi.h" 4964565Sgshapiro#include "acdebug.h" 5038032Speter#include <dev/acpica/acpivar.h> 5138032Speter 5238032SpeterUINT32 5338032SpeterAcpiOsGetLine(NATIVE_CHAR *Buffer) 5438032Speter{ 5538032Speter#ifdef DDB 5638032Speter char *cp; 5790795Sgshapiro 5898125Sgshapiro db_readline(Buffer, 80); 5990795Sgshapiro for (cp = Buffer; *cp != 0; cp++) 6038032Speter if (*cp == '\n') 61105016Sgshapiro *cp = 0; 62105016Sgshapiro return(AE_OK); 6338032Speter#else 6438032Speter printf("AcpiOsGetLine called but no input support"); 6564565Sgshapiro return(AE_NOT_EXIST); 6638032Speter#endif 6738032Speter} 6864565Sgshapiro 6938032Spetervoid 7038032SpeterAcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, NATIVE_CHAR *Message) 7138032Speter{ 7238032Speter printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message); 7390795Sgshapiro printf("ACPI: assertion %s\n", (char *)FailedAssertion); 7490795Sgshapiro} 7564565Sgshapiro 7638032SpeterACPI_STATUS 7738032SpeterAcpiOsSignal ( 7890795Sgshapiro UINT32 Function, 7990795Sgshapiro void *Info) 8090795Sgshapiro{ 8190795Sgshapiro ACPI_SIGNAL_FATAL_INFO *fatal; 8290795Sgshapiro NATIVE_CHAR *message; 8364565Sgshapiro 8438032Speter switch(Function) { 8538032Speter case ACPI_SIGNAL_FATAL: 8638032Speter fatal = (ACPI_SIGNAL_FATAL_INFO *)Info; 8738032Speter printf("ACPI fatal signal, type 0x%x code 0x%x argument 0x%x", 8838032Speter fatal->Type, fatal->Code, fatal->Argument); 8938032Speter Debugger("AcpiOsSignal"); 9090795Sgshapiro break; 9190795Sgshapiro 9290795Sgshapiro case ACPI_SIGNAL_BREAKPOINT: 9390795Sgshapiro message = (NATIVE_CHAR *)Info; 9490795Sgshapiro Debugger(message); 9564565Sgshapiro break; 9638032Speter 9764565Sgshapiro default: 9864565Sgshapiro return(AE_BAD_PARAMETER); 9964565Sgshapiro } 10064565Sgshapiro return(AE_OK); 10164565Sgshapiro} 10264565Sgshapiro 10364565Sgshapiro#ifdef ENABLE_DEBUGGER 10464565Sgshapirovoid 10564565Sgshapiroacpi_EnterDebugger(void) 10664565Sgshapiro{ 10764565Sgshapiro ACPI_PARSE_OBJECT obj; 10864565Sgshapiro static int initted = 0; 10964565Sgshapiro 11064565Sgshapiro if (!initted) { 11164565Sgshapiro printf("Initialising ACPICA debugger...\n"); 11264565Sgshapiro AcpiDbInitialize(); 11364565Sgshapiro initted = 1; 11464565Sgshapiro } 11564565Sgshapiro 11690795Sgshapiro printf("Entering ACPICA debugger...\n"); 11790795Sgshapiro AcpiDbUserCommands('A', &obj); 11864565Sgshapiro} 11964565Sgshapiro#endif 12064565Sgshapiro