1 /*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * $FreeBSD: src/sys/dev/acpica/Osd/OsdDebug.c,v 1.9 2004/09/02 04:28:05 njl Exp $ 28 */ 29 30 /* 31 * 6.8 : Debugging support 32 */ 33 34 #include "opt_ddb.h" 35 36 #include <sys/param.h> 37 #include <sys/kernel.h> 38 #include <sys/bus.h> 39 #include <ddb/ddb.h> 40 #include <ddb/db_output.h> 41 42 #include "acpi.h" 43 #include "accommon.h" 44 #include "acpivar.h" 45 #include "acdebug.h" 46 47 ACPI_STATUS 48 AcpiOsGetLine(char *Buffer, UINT32 BufferLength, UINT32 *BytesRead) 49 { 50 #ifdef DDB 51 char *cp; 52 53 cp = Buffer; 54 if (db_readline(Buffer, BufferLength) > 0) 55 while (*cp != '\0' && *cp != '\n' && *cp != '\r') 56 cp++; 57 *cp = '\0'; 58 if (BytesRead != NULL) 59 *BytesRead = cp - Buffer; 60 return (AE_OK); 61 #else 62 kprintf("AcpiOsGetLine called but no input support"); 63 return (AE_NOT_EXIST); 64 #endif /* DDB */ 65 } 66 67 #if 0 /* unused for ages */ 68 void 69 AcpiOsDbgAssert(void *FailedAssertion, void *FileName, UINT32 LineNumber, 70 char *Message) 71 { 72 kprintf("ACPI: %s:%d - %s\n", (char *)FileName, LineNumber, Message); 73 kprintf("ACPI: assertion %s\n", (char *)FailedAssertion); 74 } 75 #endif 76 77 ACPI_STATUS 78 AcpiOsSignal(UINT32 Function, void *Info) 79 { 80 ACPI_SIGNAL_FATAL_INFO *fatal; 81 82 switch (Function) { 83 case ACPI_SIGNAL_FATAL: 84 fatal = (ACPI_SIGNAL_FATAL_INFO *)Info; 85 kprintf("ACPI fatal signal, type 0x%x code 0x%x argument 0x%x", 86 fatal->Type, fatal->Code, fatal->Argument); 87 Debugger("AcpiOsSignal"); 88 break; 89 90 case ACPI_SIGNAL_BREAKPOINT: 91 #ifdef ACPI_DEBUG 92 Debugger((char *)Info); 93 #endif 94 break; 95 96 default: 97 return (AE_BAD_PARAMETER); 98 } 99 return (AE_OK); 100 } 101 102 #ifdef ACPI_DEBUGGER 103 void 104 acpi_EnterDebugger(void) 105 { 106 ACPI_PARSE_OBJECT obj; 107 static int initted = 0; 108 109 if (!initted) { 110 kprintf("Initialising ACPICA debugger...\n"); 111 AcpiDbInitialize(); 112 initted = 1; 113 } 114 115 kprintf("Entering ACPICA debugger...\n"); 116 AcpiDbUserCommands('A', &obj); 117 } 118 #endif /* ACPI_DEBUGGER */ 119