]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/panic_notify.c
2 * Copyright (c) 2000-2020 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <architecture/i386/pio.h>
30 #include <i386/panic_notify.h>
31 #include <kern/assert.h>
32 #include <pexpert/pexpert.h>
36 * An I/O port to issue a read from, in the event of a panic.
37 * Useful for triggering logic analyzers.
39 static uint16_t panic_io_port
= 0;
42 * Similar to the panic_io_port, the pvpanic_io_port is used to notify
43 * interested parties (in this case the host/hypervisor), that a panic
45 * Where it differs from panic_io_port is that it is written and read
46 * according to the pvpanic specification:
47 * https://raw.githubusercontent.com/qemu/qemu/master/docs/specs/pvpanic.txt
49 static uint16_t pvpanic_io_port
= 0;
52 panic_notify_init(void)
54 (void) PE_parse_boot_argn("panic_io_port", &panic_io_port
, sizeof(panic_io_port
));
58 * Defer reading the notifcation bit until panic time. This maintains
59 * backwards compatibility with Apple's QEMU. Once backwards
60 * compatibilty is no longer needed the check should be performed here
61 * before setting pvpanic_io_port.
63 (void) PE_parse_boot_argn("pvpanic_io_port", &pvpanic_io_port
, sizeof(pvpanic_io_port
));
69 if (panic_io_port
!= 0) {
70 (void) inb(panic_io_port
);
73 if (pvpanic_io_port
!= 0 &&
74 (inb(pvpanic_io_port
) & PVPANIC_NOTIFICATION_BIT
) != 0) {
75 outb(pvpanic_io_port
, PVPANIC_NOTIFICATION_BIT
);