9 #include "jdb_module.h"
10 #include "jdb_screen.h"
11 #include "static_init.h"
16 * Private 'exit' module.
18 * This module handles the 'exit' or '^' command that
19 * makes a call to exit() and virtually reboots the system.
21 class Jdb_io_apic_module : public Jdb_module
24 Jdb_io_apic_module() FIASCO_INIT;
27 static Jdb_io_apic_module jdb_io_apic_module INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
31 Jdb_io_apic_module::print_lapic(unsigned cpu, void *)
33 printf("\nLocal APIC [%u, %08x]: tpr=%2x ppr=%2x\n", cpu, Apic::get_id(), Apic::tpr(),
34 Apic::reg_read(0xa0));
35 printf(" Running: tpr=%02x\n", Jdb::apic_tpr.cpu(cpu));
37 unsigned const regs[] = { 0x200, 0x100, 0x180 };
38 char const *const regn[] = { "IRR", "ISR", "TMR" };
39 for (unsigned r = 0; r < 3; ++r)
41 printf(" %s:", regn[r]);
42 for (int i = 3; i >= 0; --i)
44 unsigned long v = Apic::reg_read(regs[r] + i * 0x10);
53 Jdb_io_apic_module::remote_print_lapic(unsigned cpu)
55 Jdb::remote_work(cpu, print_lapic, 0);
59 Jdb_module::Action_code
60 Jdb_io_apic_module::action (int cmd, void *&, char const *&, int &)
65 if (!Io_apic::active())
67 printf("\nIO APIC not present!\n");
70 printf("\nState of IO APIC\n");
71 for (Io_apic *a = Io_apic::_first; a; a = a->_next)
74 // print global LAPIC state
78 strcpy (apic_state, "N/A");
79 if ((apic_disabled = Apic::test_present_but_disabled()))
80 strcpy (apic_state, "disabled by BIOS");
81 if ((khz = Apic::get_frequency_khz()))
83 unsigned mhz = khz / 1000;
85 snprintf(apic_state, sizeof(apic_state), "yes (%d.%03d MHz)"
86 "\n local APIC spurious interrupts/bug/error: %d/%d/%d",
88 apic_spurious_interrupt_cnt,
89 apic_spurious_interrupt_bug_cnt,
92 printf("\nLocal APIC (general): %s"
101 ? "not supported (Local APIC disabled)"
102 : "not supported (no Local APIC)"
104 Jdb::foreach_cpu(&remote_print_lapic);
111 Jdb_io_apic_module::num_cmds() const
117 Jdb_module::Cmd const *
118 Jdb_io_apic_module::cmds() const
121 { { 0, "A", "apic", "", "apic\tdump state of IOAPIC", (void*)0 } };
127 Jdb_io_apic_module::Jdb_io_apic_module()