+ * The default (non-functional) PE_poll_input handler.
+ */
+static int
+PE_stub_poll_input(__unused unsigned int options, char * c)
+{
+ *c = 0xff;
+ return 1; /* 0 for success, 1 for unsupported */
+}
+
+/*
+ * Called by the kernel debugger to poll for keyboard input.
+ * Keyboard drivers may replace the default stub function
+ * with their polled-mode input function.
+ */
+int (*PE_poll_input)(unsigned int options, char * c)
+ = PE_stub_poll_input;
+
+boolean_t
+PE_reboot_on_panic(void)
+{
+ boot_args *args = (boot_args *)PE_state.bootArgs;
+
+ if (args->flags & kBootArgsFlagRebootOnPanic)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+void
+PE_sync_panic_buffers(void)
+{
+}
+
+/* rdar://problem/21244753 */
+uint32_t
+PE_i_can_has_debugger(uint32_t *debug_flags)
+{
+#if DEVELOPMENT || DEBUG
+ if (debug_flags) {
+ assert(debug_boot_arg_inited);
+ }
+#endif
+
+#if CONFIG_CSR
+ if (csr_check(CSR_ALLOW_KERNEL_DEBUGGER) != 0) {
+ if (debug_flags)
+ *debug_flags = 0;
+ return FALSE;
+ }
+#endif
+ if (debug_flags) {
+ *debug_flags = debug_boot_arg;
+ }
+ return TRUE;
+}
+
+uint32_t
+PE_get_offset_into_panic_region(char *location)
+{
+ assert(panic_info != NULL);
+ assert(location > (char *) panic_info);
+
+ return (uint32_t) (location - (char *) panic_info);
+}
+
+void
+PE_init_panicheader()
+{
+ bzero(panic_info, offsetof(struct macos_panic_header, mph_data));
+ panic_info->mph_panic_log_offset = PE_get_offset_into_panic_region(debug_buf_base);
+
+ panic_info->mph_magic = MACOS_PANIC_MAGIC;
+ panic_info->mph_version = MACOS_PANIC_HEADER_CURRENT_VERSION;
+
+ return;
+}
+
+/*
+ * Tries to update the panic header to keep it consistent on nested panics.
+ *
+ * NOTE: The purpose of this function is NOT to detect/correct corruption in the panic region,
+ * it is to update the panic header to make it consistent when we nest panics.
+ *
+ * We try to avoid nested panics/asserts on x86 because they are difficult to debug, so log any
+ * inconsistencies we find.