OsdDebug.c revision 128225
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 128225 2004-04-14 03:39:08Z njl $ 2867760Smsmith */ 2967760Smsmith 3067760Smsmith/* 3167760Smsmith * 6.8 : Debugging support 3267760Smsmith */ 3367760Smsmith 3467760Smsmith#include "opt_ddb.h" 3567760Smsmith#include <sys/param.h> 3667760Smsmith#include <sys/kernel.h> 3767760Smsmith#include <sys/bus.h> 3867760Smsmith#include <machine/bus.h> 3967760Smsmith 4067760Smsmith#include "acpi.h" 4167760Smsmith#include "acdebug.h" 4267760Smsmith#include <dev/acpica/acpivar.h> 4367760Smsmith 4467760SmsmithUINT32 45114246SnjlAcpiOsGetLine(char *Buffer) 4667760Smsmith{ 4767760Smsmith#ifdef DDB 4867760Smsmith char *cp; 4967760Smsmith 5067760Smsmith db_readline(Buffer, 80); 5167760Smsmith for (cp = Buffer; *cp != 0; cp++) 5267760Smsmith if (*cp == '\n') 5367760Smsmith *cp = 0; 54128225Snjl return (AE_OK); 5567760Smsmith#else 5667760Smsmith printf("AcpiOsGetLine called but no input support"); 57128225Snjl return (AE_NOT_EXIST); 58128225Snjl#endif /* DDB */ 5967760Smsmith} 6067760Smsmith 6167760Smsmithvoid 62128225SnjlAcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, 63128225Snjl char *Message) 6467760Smsmith{ 6567760Smsmith printf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message); 6667760Smsmith printf("ACPI: assertion %s\n", (char *)FailedAssertion); 6767760Smsmith} 6867760Smsmith 6980071SmsmithACPI_STATUS 70128225SnjlAcpiOsSignal(UINT32 Function, void *Info) 7180071Smsmith{ 7280071Smsmith ACPI_SIGNAL_FATAL_INFO *fatal; 73114246Snjl char *message; 7480071Smsmith 75128225Snjl switch (Function) { 7680071Smsmith case ACPI_SIGNAL_FATAL: 7780071Smsmith fatal = (ACPI_SIGNAL_FATAL_INFO *)Info; 7888420Siwasaki printf("ACPI fatal signal, type 0x%x code 0x%x argument 0x%x", 7980071Smsmith fatal->Type, fatal->Code, fatal->Argument); 8088420Siwasaki Debugger("AcpiOsSignal"); 8180071Smsmith break; 8280071Smsmith 8380071Smsmith case ACPI_SIGNAL_BREAKPOINT: 84114246Snjl message = (char *)Info; 8580071Smsmith Debugger(message); 8680071Smsmith break; 8780071Smsmith 8880071Smsmith default: 89128225Snjl return (AE_BAD_PARAMETER); 9080071Smsmith } 91128225Snjl 92128225Snjl return (AE_OK); 9380071Smsmith} 9480071Smsmith 95102553Siwasaki#ifdef ACPI_DEBUGGER 9667760Smsmithvoid 9767760Smsmithacpi_EnterDebugger(void) 9867760Smsmith{ 9967760Smsmith ACPI_PARSE_OBJECT obj; 10067760Smsmith static int initted = 0; 10167760Smsmith 10267760Smsmith if (!initted) { 10367760Smsmith printf("Initialising ACPICA debugger...\n"); 10467760Smsmith AcpiDbInitialize(); 10567760Smsmith initted = 1; 10667760Smsmith } 10767760Smsmith 10867760Smsmith printf("Entering ACPICA debugger...\n"); 10967760Smsmith AcpiDbUserCommands('A', &obj); 11067760Smsmith} 111128225Snjl#endif /* ACPI_DEBUGGER */ 112