7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases/*
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * CDDL HEADER START
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases *
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * The contents of this file are subject to the terms of the
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * Common Development and Distribution License (the "License").
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * You may not use this file except in compliance with the License.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases *
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * or http://www.opensolaris.org/os/licensing.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * See the License for the specific language governing permissions
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * and limitations under the License.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases *
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * When distributing Covered Code, include this CDDL HEADER in each
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * If applicable, add the following below this CDDL HEADER, with the
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * fields enclosed by brackets "[]" replaced with your own identifying
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * information: Portions Copyright [yyyy] [name of copyright owner]
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases *
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * CDDL HEADER END
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases/*
5cd376e8b7030707d78315f63adb4bb2b4d9963eJimmy Vetayases * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases#include "intr_common.h"
41afdfa77f9af46beb3aaab2eccc0d9afe660d31Krishnendu Sadhukhan - Sun Microsystems#include <sys/apic_timer.h>
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases/*
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * Globals
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesstatic struct av_head avec_tbl[APIC_MAX_VECTOR+1];
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesstatic apic_irq_t *irq_tbl[APIC_MAX_VECTOR+1], airq;
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesstatic char level_tbl[APIC_MAX_VECTOR+1];
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases/*
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * Dump interrupt information for pcplusmp PSM.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases/* ARGSUSED */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesint
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesinterrupt_dump_apic(uintptr_t addr, uint_t flags, int argc,
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases const mdb_arg_t *argv)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases{
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases int i;
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases option_flags = 0;
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (mdb_getopts(argc, argv,
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases 'd', MDB_OPT_SETBITS, INTR_DISPLAY_DRVR_INST, &option_flags,
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases 'i', MDB_OPT_SETBITS, INTR_DISPLAY_INTRSTAT, &option_flags,
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases NULL) != argc)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases return (DCMD_USAGE);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (mdb_readvar(&irq_tbl, "apic_irq_table") == -1) {
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases mdb_warn("failed to read apic_irq_table");
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases return (DCMD_ERR);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases }
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (mdb_readvar(&level_tbl, "apic_level_intr") == -1) {
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases mdb_warn("failed to read apic_level_intr");
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases return (DCMD_ERR);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases }
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (mdb_readvar(&avec_tbl, "autovect") == -1) {
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases mdb_warn("failed to read autovect");
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases return (DCMD_ERR);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases }
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases /* Print the header first */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (option_flags & INTR_DISPLAY_INTRSTAT)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases mdb_printf("%<u>CPU ");
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases else
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases mdb_printf(
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases "%<u>IRQ Vect IPL Bus Trg Type CPU Share APIC/INT# ");
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases mdb_printf("%s %</u>\n", option_flags & INTR_DISPLAY_DRVR_INST ?
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases "Driver Name(s)" : "ISR(s)");
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases /* Walk all the entries */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases for (i = 0; i < APIC_MAX_VECTOR + 1; i++) {
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases /* Read the entry */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (mdb_vread(&airq, sizeof (apic_irq_t),
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases (uintptr_t)irq_tbl[i]) == -1)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases continue;
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases apic_interrupt_dump(&airq, &avec_tbl[i], i, NULL, level_tbl[i]);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases }
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases return (DCMD_OK);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases}
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases/*
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * MDB module linkage information:
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases *
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * We declare a list of structures describing our dcmds, and a function
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases * named _mdb_init to return a pointer to our module information.
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesstatic const mdb_dcmd_t dcmds[] = {
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases { "interrupts", "?[-di]", "print interrupts", interrupt_dump_apic,
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases interrupt_help},
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases { "softint", "?[-d]", "print soft interrupts", soft_interrupt_dump,
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases soft_interrupt_help},
5cd376e8b7030707d78315f63adb4bb2b4d9963eJimmy Vetayases#ifdef _KMDB
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases { "apic", NULL, "print apic register contents", apic },
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases { "ioapic", NULL, "print ioapic register contents", ioapic },
5cd376e8b7030707d78315f63adb4bb2b4d9963eJimmy Vetayases#endif /* _KMDB */
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases { NULL }
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases};
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesstatic const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, NULL };
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayasesconst mdb_modinfo_t *
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases_mdb_init(void)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases{
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases GElf_Sym sym;
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (mdb_lookup_by_name("gld_intr", &sym) != -1)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases if (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases gld_intr_addr = (uintptr_t)sym.st_value;
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases return (&modinfo);
7ff178cd8db129d385d3177eb20744d3b6efc59bJimmy Vetayases}