/*
- * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <kern/sched_prim.h>
#include <kern/misc_protos.h>
#include <kern/clock.h>
+#include <kern/telemetry.h>
#include <vm/vm_kern.h>
#include <vm/pmap.h>
#include <stdarg.h>
unsigned int return_on_panic = 0;
unsigned long panic_caller;
-#if CONFIG_EMBEDDED
-#define DEBUG_BUF_SIZE (PAGE_SIZE)
-#else
#define DEBUG_BUF_SIZE (3 * PAGE_SIZE)
-#endif
char debug_buf[DEBUG_BUF_SIZE];
char *debug_buf_ptr = debug_buf;
unsigned int debug_buf_size = sizeof(debug_buf);
static char model_name[64];
-/* uuid_string_t */ char kernel_uuid[37];
+unsigned char *kernel_uuid;
+/* uuid_string_t */ char kernel_uuid_string[37];
static spl_t panic_prologue(const char *str);
static void panic_epilogue(spl_t s);
}
saved_return_on_panic = return_on_panic;
- return_on_panic = 1;
+
+ /*
+ * If we don't have a debugger configured, returning from an
+ * assert is a bad, bad idea; there is no guarantee that we
+ * didn't simply assert before we were able to restart the
+ * platform.
+ */
+ if (current_debugger != NO_CUR_DB)
+ return_on_panic = 1;
panic_plain("%s:%d Assertion failed: %s", file, line, expression);
simple_unlock(&panic_lock); \
MACRO_END
-
void
panic_init(void)
{
uuid = getuuidfromheader(&_mh_execute_header, &uuidlen);
if ((uuid != NULL) && (uuidlen == sizeof(uuid_t))) {
- uuid_unparse_upper(*(uuid_t *)uuid, kernel_uuid);
+ kernel_uuid = uuid;
+ uuid_unparse_upper(*(uuid_t *)uuid, kernel_uuid_string);
}
simple_lock_init(&panic_lock, 0);
spl_t s;
if (kdebug_enable) {
- ml_set_interrupts_enabled(TRUE);
- kdbg_dump_trace_to_file("/var/tmp/panic.trace");
+ if (get_preemption_level() == 0 && !ml_at_interrupt_context()) {
+ ml_set_interrupts_enabled(TRUE);
+ kdbg_dump_trace_to_file("/var/tmp/panic.trace");
+ }
}
s = splhigh();
va_list listp;
spl_t s;
+
/* panic_caller is initialized to 0. If set, don't change it */
if ( ! panic_caller )
panic_caller = (unsigned long)(char *)__builtin_return_address(0);
va_list listp;
spl_t s;
+
/* panic_caller is initialized to 0. If set, don't change it */
if ( ! panic_caller )
panic_caller = (unsigned long)(char *)__builtin_return_address(0);
}
static void panic_display_kernel_uuid(void) {
- char tmp_kernel_uuid[sizeof(kernel_uuid)];
+ char tmp_kernel_uuid[sizeof(kernel_uuid_string)];
- if (ml_nofault_copy((vm_offset_t) &kernel_uuid, (vm_offset_t) &tmp_kernel_uuid, sizeof(kernel_uuid)) != sizeof(kernel_uuid))
+ if (ml_nofault_copy((vm_offset_t) &kernel_uuid_string, (vm_offset_t) &tmp_kernel_uuid, sizeof(kernel_uuid_string)) != sizeof(kernel_uuid_string))
return;
if (tmp_kernel_uuid[0] != '\0')
kdb_printf("Kernel UUID: %s\n", tmp_kernel_uuid);
}
-static void panic_display_kernel_aslr(void) {
-#if defined(__x86_64__)
+void panic_display_kernel_aslr(void) {
if (vm_kernel_slide) {
- kdb_printf("Kernel slide: 0x%016lx\n", vm_kernel_slide);
+ kdb_printf("Kernel slide: 0x%016lx\n", (unsigned long) vm_kernel_slide);
kdb_printf("Kernel text base: %p\n", (void *) vm_kernel_stext);
}
-#endif
}
static void panic_display_uptime(void) {
#endif /* CONFIG_ZLEAKS */
#if !MACH_KDP
-static struct ether_addr kdp_current_mac_address = {{0, 0, 0, 0, 0, 0}};
+static struct kdp_ether_addr kdp_current_mac_address = {{0, 0, 0, 0, 0, 0}};
/* XXX ugly forward declares to stop warnings */
void *kdp_get_interface(void);
-void kdp_set_ip_and_mac_addresses(struct in_addr *, struct ether_addr *);
+void kdp_set_ip_and_mac_addresses(struct kdp_in_addr *, struct kdp_ether_addr *);
void kdp_set_gateway_mac(void *);
void kdp_set_interface(void *);
void kdp_register_send_receive(void *, void *);
kdp_get_ip_address(void )
{ return 0; }
-struct ether_addr
+struct kdp_ether_addr
kdp_get_mac_addr(void)
{
return kdp_current_mac_address;
void
kdp_set_ip_and_mac_addresses(
- __unused struct in_addr *ipaddr,
- __unused struct ether_addr *macaddr)
+ __unused struct kdp_in_addr *ipaddr,
+ __unused struct kdp_ether_addr *macaddr)
{}
void
}
#endif
+
+#if !CONFIG_TELEMETRY
+int telemetry_gather(user_addr_t buffer __unused, uint32_t *length __unused, boolean_t mark __unused)
+{
+ return KERN_NOT_SUPPORTED;
+}
+#endif