/*
- * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <i386/ucode.h>
#include <kern/clock.h>
#include <libkern/libkern.h>
+#include <i386/lapic.h>
static int
_i386_cpu_info SYSCTL_HANDLER_ARGS
return _i386_cpu_info(oidp, ptr, arg2, req);
}
+
static int
cpu_features SYSCTL_HANDLER_ARGS
{
return SYSCTL_OUT(req, buf, strlen(buf) + 1);
}
+static int
+cpu_leaf7_features SYSCTL_HANDLER_ARGS
+{
+ __unused struct sysctl_oid *unused_oidp = oidp;
+ __unused void *unused_arg1 = arg1;
+ __unused int unused_arg2 = arg2;
+ char buf[512];
+
+ uint32_t leaf7_features = cpuid_info()->cpuid_leaf7_features;
+ if (leaf7_features == 0)
+ return ENOENT;
+
+ buf[0] = '\0';
+ cpuid_get_leaf7_feature_names(leaf7_features, buf, sizeof(buf));
+
+ return SYSCTL_OUT(req, buf, strlen(buf) + 1);
+}
+
static int
cpu_logical_per_package SYSCTL_HANDLER_ARGS
{
return error;
}
+/*
+ * Triggers a machine-check exception - for a suitably configured kernel only.
+ */
+extern void mca_exception_panic(void);
+static int
+misc_machine_check_panic(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ int changed = 0, error;
+ char buf[128];
+ buf[0] = '\0';
+
+ error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
+
+ if (error == 0 && changed) {
+ mca_exception_panic();
+ }
+ return error;
+}
+
+
SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
"CPU info");
(void *)offsetof(i386_cpu_info_t, cpuid_features), sizeof(uint64_t),
i386_cpu_info, "IU", "CPU features");
+SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_feature_bits,
+ CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
+ (void *)offsetof(i386_cpu_info_t, cpuid_leaf7_features),
+ sizeof(uint32_t),
+ i386_cpu_info_nonzero, "IU", "CPU Leaf7 features");
+
SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_LOCKED,
(void *)offsetof(i386_cpu_info_t, cpuid_extfeatures), sizeof(uint64_t),
i386_cpu_info, "IU", "CPU extended features");
0, 0,
cpu_features, "A", "CPU feature names");
+SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_features,
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
+ 0, 0,
+ cpu_leaf7_features, "A", "CPU Leaf7 feature names");
+
SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeatures, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
0, 0,
cpu_extfeatures, "A", "CPU extended feature names");
CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
(void *)offsetof(cpuid_thermal_leaf_t, package_thermal_intr),
sizeof(boolean_t),
- cpu_thermal, "I", "Packge Thermal interrupt and Status");
+ cpu_thermal, "I", "Package Thermal interrupt and Status");
SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, hardware_feedback,
CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_LOCKED, 0, 0,
cpu_ucode_update, "S", "Microcode update interface");
+static const uint32_t apic_timer_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_TIMER_INTERRUPT);
+static const uint32_t apic_IPI_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_INTERPROCESSOR_INTERRUPT);
+
+SYSCTL_NODE(_machdep, OID_AUTO, vectors, CTLFLAG_RD | CTLFLAG_LOCKED, 0,
+ "Interrupt vector assignments");
+
+SYSCTL_UINT (_machdep_vectors, OID_AUTO, timer, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (uint32_t *)&apic_timer_vector, 0, "");
+SYSCTL_UINT (_machdep_vectors, OID_AUTO, IPI, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (uint32_t *)&apic_IPI_vector, 0, "");
+
uint64_t pmap_pv_hashlist_walks;
uint64_t pmap_pv_hashlist_cnts;
uint32_t pmap_pv_hashlist_max;
0, 0,
panic_set_restart_timeout, "I", "Panic restart timeout in seconds");
-SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max, CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
+SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
0, 0,
misc_interrupt_latency_max, "A", "Maximum Interrupt latency");
+
+SYSCTL_PROC(_machdep_misc, OID_AUTO, machine_check_panic,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
+ 0, 0,
+ misc_machine_check_panic, "A", "Machine-check exception test");
+