| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: OsdMisc.c,v 1.15 2016/01/09 21:14:42 christos Exp $ */ | | 1 | /* $NetBSD: OsdMisc.c,v 1.16 2017/01/25 13:38:40 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2001 Wasabi Systems, Inc. | | 4 | * Copyright 2001 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -26,49 +26,88 @@ | | | @@ -26,49 +26,88 @@ |
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | /* | | 38 | /* |
| | | 39 | * Copyright (C) 2000 - 2017, Intel Corp. |
| | | 40 | * All rights reserved. |
| | | 41 | * |
| | | 42 | * Redistribution and use in source and binary forms, with or without |
| | | 43 | * modification, are permitted provided that the following conditions |
| | | 44 | * are met: |
| | | 45 | * 1. Redistributions of source code must retain the above copyright |
| | | 46 | * notice, this list of conditions, and the following disclaimer, |
| | | 47 | * without modification. |
| | | 48 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| | | 49 | * substantially similar to the "NO WARRANTY" disclaimer below |
| | | 50 | * ("Disclaimer") and any redistribution must be conditioned upon |
| | | 51 | * including a substantially similar Disclaimer requirement for further |
| | | 52 | * binary redistribution. |
| | | 53 | * 3. Neither the names of the above-listed copyright holders nor the names |
| | | 54 | * of any contributors may be used to endorse or promote products derived |
| | | 55 | * from this software without specific prior written permission. |
| | | 56 | * |
| | | 57 | * Alternatively, this software may be distributed under the terms of the |
| | | 58 | * GNU General Public License ("GPL") version 2 as published by the Free |
| | | 59 | * Software Foundation. |
| | | 60 | * |
| | | 61 | * NO WARRANTY |
| | | 62 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| | | 63 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| | | 64 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| | | 65 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| | | 66 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| | | 67 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| | | 68 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| | | 69 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| | | 70 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| | | 71 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| | | 72 | * POSSIBILITY OF SUCH DAMAGES. |
| | | 73 | */ |
| | | 74 | |
| | | 75 | /* |
39 | * OS Services Layer | | 76 | * OS Services Layer |
40 | * | | 77 | * |
41 | * 6.10: Miscellaneous | | 78 | * 6.10: Miscellaneous |
42 | */ | | 79 | */ |
43 | | | 80 | |
44 | #include <sys/cdefs.h> | | 81 | #include <sys/cdefs.h> |
45 | __KERNEL_RCSID(0, "$NetBSD: OsdMisc.c,v 1.15 2016/01/09 21:14:42 christos Exp $"); | | 82 | __KERNEL_RCSID(0, "$NetBSD: OsdMisc.c,v 1.16 2017/01/25 13:38:40 christos Exp $"); |
46 | | | 83 | |
47 | #include "opt_acpi.h" | | 84 | #include "opt_acpi.h" |
48 | #include "opt_ddb.h" | | 85 | #include "opt_ddb.h" |
49 | | | 86 | |
50 | #include <sys/param.h> | | 87 | #include <sys/param.h> |
51 | #include <sys/systm.h> | | 88 | #include <sys/systm.h> |
52 | | | 89 | |
53 | #include <machine/db_machdep.h> | | 90 | #include <machine/db_machdep.h> |
54 | | | 91 | |
55 | #include <ddb/db_extern.h> | | 92 | #include <ddb/db_extern.h> |
56 | #include <ddb/db_output.h> | | 93 | #include <ddb/db_output.h> |
57 | | | 94 | |
58 | #include <dev/acpi/acpica.h> | | 95 | #include <dev/acpi/acpica.h> |
59 | #include <dev/acpi/acpi_osd.h> | | 96 | #include <dev/acpi/acpi_osd.h> |
60 | | | 97 | |
61 | #ifdef ACPI_DEBUG | | 98 | #ifdef ACPI_DEBUG |
| | | 99 | #include <external/bsd/acpica/dist/include/acpi.h> |
| | | 100 | #include <external/bsd/acpica/dist/include/accommon.h> |
62 | #include <external/bsd/acpica/dist/include/acdebug.h> | | 101 | #include <external/bsd/acpica/dist/include/acdebug.h> |
63 | #endif | | 102 | #endif |
64 | | | 103 | |
65 | #ifdef ACPI_DSDT_OVERRIDE | | 104 | #ifdef ACPI_DSDT_OVERRIDE |
66 | #ifndef ACPI_DSDT_FILE | | 105 | #ifndef ACPI_DSDT_FILE |
67 | #define ACPI_DSDT_FILE "dsdt.hex" | | 106 | #define ACPI_DSDT_FILE "dsdt.hex" |
68 | #endif | | 107 | #endif |
69 | #include ACPI_DSDT_FILE | | 108 | #include ACPI_DSDT_FILE |
70 | #endif | | 109 | #endif |
71 | | | 110 | |
72 | int acpi_indebugger; | | 111 | int acpi_indebugger; |
73 | | | 112 | |
74 | /* | | 113 | /* |
| @@ -179,40 +218,203 @@ AcpiOsPredefinedOverride(const ACPI_PRED | | | @@ -179,40 +218,203 @@ AcpiOsPredefinedOverride(const ACPI_PRED |
179 | * | | 218 | * |
180 | * DESCRIPTION: Returns AE_SUPPORT, function not used in user space. | | 219 | * DESCRIPTION: Returns AE_SUPPORT, function not used in user space. |
181 | */ | | 220 | */ |
182 | ACPI_STATUS | | 221 | ACPI_STATUS |
183 | AcpiOsPhysicalTableOverride ( | | 222 | AcpiOsPhysicalTableOverride ( |
184 | ACPI_TABLE_HEADER *ExistingTable, | | 223 | ACPI_TABLE_HEADER *ExistingTable, |
185 | ACPI_PHYSICAL_ADDRESS *NewAddress, | | 224 | ACPI_PHYSICAL_ADDRESS *NewAddress, |
186 | UINT32 *NewTableLength) | | 225 | UINT32 *NewTableLength) |
187 | { | | 226 | { |
188 | | | 227 | |
189 | return AE_SUPPORT; | | 228 | return AE_SUPPORT; |
190 | } | | 229 | } |
191 | | | 230 | |
| | | 231 | /****************************************************************************** |
| | | 232 | * |
| | | 233 | * FUNCTION: AcpiOsEnterSleep |
| | | 234 | * |
| | | 235 | * PARAMETERS: SleepState - Which sleep state to enter |
| | | 236 | * RegaValue - Register A value |
| | | 237 | * RegbValue - Register B value |
| | | 238 | * |
| | | 239 | * RETURN: Status |
| | | 240 | * |
| | | 241 | * DESCRIPTION: A hook before writing sleep registers to enter the sleep |
| | | 242 | * state. Return AE_CTRL_TERMINATE to skip further sleep register |
| | | 243 | * writes. |
| | | 244 | * |
| | | 245 | *****************************************************************************/ |
| | | 246 | |
| | | 247 | ACPI_STATUS |
| | | 248 | AcpiOsEnterSleep ( |
| | | 249 | UINT8 SleepState, |
| | | 250 | UINT32 RegaValue, |
| | | 251 | UINT32 RegbValue) |
| | | 252 | { |
| | | 253 | |
| | | 254 | return AE_OK; |
| | | 255 | } |
| | | 256 | |
| | | 257 | |
192 | /* | | 258 | /* |
193 | * acpi_osd_debugger: | | 259 | * acpi_osd_debugger: |
194 | * | | 260 | * |
195 | * Enter the ACPICA debugger. | | 261 | * Enter the ACPICA debugger. |
196 | */ | | 262 | */ |
197 | void | | 263 | void |
198 | acpi_osd_debugger(void) | | 264 | acpi_osd_debugger(void) |
199 | { | | 265 | { |
200 | #ifdef ACPI_DEBUG | | 266 | #ifdef ACPI_DEBUG |
201 | ACPI_PARSE_OBJECT obj; | | | |
202 | label_t acpi_jmpbuf; | | 267 | label_t acpi_jmpbuf; |
203 | label_t *savejmp; | | 268 | label_t *savejmp; |
204 | | | 269 | |
205 | printf("Entering ACPICA debugger...\n"); | | 270 | printf("Entering ACPICA debugger...\n"); |
206 | savejmp = db_recover; | | 271 | savejmp = db_recover; |
207 | setjmp(&acpi_jmpbuf); | | 272 | setjmp(&acpi_jmpbuf); |
208 | db_recover = &acpi_jmpbuf; | | 273 | db_recover = &acpi_jmpbuf; |
209 | | | 274 | |
210 | acpi_indebugger = 1; | | 275 | acpi_indebugger = 1; |
211 | AcpiDbUserCommands('A', &obj); | | 276 | AcpiDbUserCommands(); |
212 | acpi_indebugger = 0; | | 277 | acpi_indebugger = 0; |
213 | | | 278 | |
214 | db_recover = savejmp; | | 279 | db_recover = savejmp; |
215 | #else | | 280 | #else |
216 | printf("ACPI: WARNING: ACPICA debugger not present.\n"); | | 281 | printf("ACPI: WARNING: ACPICA debugger not present.\n"); |
217 | #endif | | 282 | #endif |
218 | } | | 283 | } |
| | | 284 | |
| | | 285 | #ifdef ACPI_DEBUG |
| | | 286 | |
| | | 287 | #define _COMPONENT ACPI_CA_DEBUGGER |
| | | 288 | ACPI_MODULE_NAME ("osnetbsdbg") |
| | | 289 | |
| | | 290 | |
| | | 291 | /****************************************************************************** |
| | | 292 | * |
| | | 293 | * FUNCTION: AcpiOsWaitCommandReady |
| | | 294 | * |
| | | 295 | * PARAMETERS: None |
| | | 296 | * |
| | | 297 | * RETURN: Status |
| | | 298 | * |
| | | 299 | * DESCRIPTION: Negotiate with the debugger foreground thread (the user |
| | | 300 | * thread) to wait the readiness of a command. |
| | | 301 | * |
| | | 302 | *****************************************************************************/ |
| | | 303 | |
| | | 304 | ACPI_STATUS |
| | | 305 | AcpiOsWaitCommandReady ( |
| | | 306 | void) |
| | | 307 | { |
| | | 308 | ACPI_STATUS Status; |
| | | 309 | /* Force output to console until a command is entered */ |
| | | 310 | |
| | | 311 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
| | | 312 | |
| | | 313 | /* Different prompt if method is executing */ |
| | | 314 | |
| | | 315 | if (!AcpiGbl_MethodExecuting) |
| | | 316 | { |
| | | 317 | AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); |
| | | 318 | } |
| | | 319 | else |
| | | 320 | { |
| | | 321 | AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); |
| | | 322 | } |
| | | 323 | |
| | | 324 | /* Get the user input line */ |
| | | 325 | |
| | | 326 | Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, |
| | | 327 | ACPI_DB_LINE_BUFFER_SIZE, NULL); |
| | | 328 | |
| | | 329 | if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE) |
| | | 330 | { |
| | | 331 | ACPI_EXCEPTION ((AE_INFO, Status, |
| | | 332 | "While parsing/handling command line")); |
| | | 333 | } |
| | | 334 | return (Status); |
| | | 335 | } |
| | | 336 | |
| | | 337 | |
| | | 338 | /****************************************************************************** |
| | | 339 | * |
| | | 340 | * FUNCTION: AcpiOsNotifyCommandComplete |
| | | 341 | * |
| | | 342 | * PARAMETERS: void |
| | | 343 | * |
| | | 344 | * RETURN: Status |
| | | 345 | * |
| | | 346 | * DESCRIPTION: Negotiate with the debugger foreground thread (the user |
| | | 347 | * thread) to notify the completion of a command. |
| | | 348 | * |
| | | 349 | *****************************************************************************/ |
| | | 350 | |
| | | 351 | ACPI_STATUS |
| | | 352 | AcpiOsNotifyCommandComplete ( |
| | | 353 | void) |
| | | 354 | { |
| | | 355 | |
| | | 356 | return AE_OK; |
| | | 357 | } |
| | | 358 | |
| | | 359 | |
| | | 360 | /****************************************************************************** |
| | | 361 | * |
| | | 362 | * FUNCTION: AcpiOsInitializeDebugger |
| | | 363 | * |
| | | 364 | * PARAMETERS: None |
| | | 365 | * |
| | | 366 | * RETURN: Status |
| | | 367 | * |
| | | 368 | * DESCRIPTION: Initialize OSPM specific part of the debugger |
| | | 369 | * |
| | | 370 | *****************************************************************************/ |
| | | 371 | |
| | | 372 | ACPI_STATUS |
| | | 373 | AcpiOsInitializeDebugger ( |
| | | 374 | void) |
| | | 375 | { |
| | | 376 | return AE_OK; |
| | | 377 | } |
| | | 378 | |
| | | 379 | |
| | | 380 | /****************************************************************************** |
| | | 381 | * |
| | | 382 | * FUNCTION: AcpiOsTerminateDebugger |
| | | 383 | * |
| | | 384 | * PARAMETERS: None |
| | | 385 | * |
| | | 386 | * RETURN: None |
| | | 387 | * |
| | | 388 | * DESCRIPTION: Terminate signals used by the multi-threading debugger |
| | | 389 | * |
| | | 390 | *****************************************************************************/ |
| | | 391 | |
| | | 392 | void |
| | | 393 | AcpiOsTerminateDebugger ( |
| | | 394 | void) |
| | | 395 | { |
| | | 396 | } |
| | | 397 | |
| | | 398 | |
| | | 399 | /****************************************************************************** |
| | | 400 | * |
| | | 401 | * FUNCTION: AcpiRunDebugger |
| | | 402 | * |
| | | 403 | * PARAMETERS: BatchBuffer - Buffer containing commands running in |
| | | 404 | * the batch mode |
| | | 405 | * |
| | | 406 | * RETURN: None |
| | | 407 | * |
| | | 408 | * DESCRIPTION: Run a local/remote debugger |
| | | 409 | * |
| | | 410 | *****************************************************************************/ |
| | | 411 | |
| | | 412 | void |
| | | 413 | AcpiRunDebugger ( |
| | | 414 | char *BatchBuffer) |
| | | 415 | { |
| | | 416 | AcpiDbUserCommands (); |
| | | 417 | } |
| | | 418 | |
| | | 419 | ACPI_EXPORT_SYMBOL (AcpiRunDebugger) |
| | | 420 | #endif |