+
+
+boolean_t ml_is64bit(void) {
+
+ return (cpu_mode_is64bit());
+}
+
+
+boolean_t ml_thread_is64bit(thread_t thread) {
+
+ return (thread_is_64bit(thread));
+}
+
+
+boolean_t ml_state_is64bit(void *saved_state) {
+
+ return is_saved_state64(saved_state);
+}
+
+void ml_cpu_set_ldt(int selector)
+{
+ /*
+ * Avoid loading the LDT
+ * if we're setting the KERNEL LDT and it's already set.
+ */
+ if (selector == KERNEL_LDT &&
+ current_cpu_datap()->cpu_ldt == KERNEL_LDT)
+ return;
+
+#if defined(__i386__)
+ /*
+ * If 64bit this requires a mode switch (and back).
+ */
+ if (cpu_mode_is64bit())
+ ml_64bit_lldt(selector);
+ else
+ lldt(selector);
+#else
+ lldt(selector);
+#endif
+ current_cpu_datap()->cpu_ldt = selector;
+}
+
+void ml_fp_setvalid(boolean_t value)
+{
+ fp_setvalid(value);
+}
+
+uint64_t ml_cpu_int_event_time(void)
+{
+ return current_cpu_datap()->cpu_int_event_time;
+}
+
+vm_offset_t ml_stack_remaining(void)
+{
+ uintptr_t local = (uintptr_t) &local;
+
+ if (ml_at_interrupt_context() != 0) {
+ return (local - (current_cpu_datap()->cpu_int_stack_top - INTSTACK_SIZE));
+ } else {
+ return (local - current_thread()->kernel_stack);
+ }
+}
+
+#if MACH_KDB
+
+/*
+ * Display the global msrs
+ * *
+ * ms
+ */
+void
+db_msr(__unused db_expr_t addr,
+ __unused int have_addr,
+ __unused db_expr_t count,
+ __unused char *modif)
+{
+
+ uint32_t i, msrlow, msrhigh;
+
+ /* Try all of the first 4096 msrs */
+ for (i = 0; i < 4096; i++) {
+ if (!rdmsr_carefully(i, &msrlow, &msrhigh)) {
+ db_printf("%08X - %08X.%08X\n", i, msrhigh, msrlow);
+ }
+ }
+
+ /* Try all of the 4096 msrs at 0x0C000000 */
+ for (i = 0; i < 4096; i++) {
+ if (!rdmsr_carefully(0x0C000000 | i, &msrlow, &msrhigh)) {
+ db_printf("%08X - %08X.%08X\n",
+ 0x0C000000 | i, msrhigh, msrlow);
+ }
+ }
+
+ /* Try all of the 4096 msrs at 0xC0000000 */
+ for (i = 0; i < 4096; i++) {
+ if (!rdmsr_carefully(0xC0000000 | i, &msrlow, &msrhigh)) {
+ db_printf("%08X - %08X.%08X\n",
+ 0xC0000000 | i, msrhigh, msrlow);
+ }
+ }
+}
+
+#endif