xref: /titanic_50/usr/src/cmd/mdb/i86pc/modules/pcplusmp/pcplusmp.c (revision 5cd376e8b7030707d78315f63adb4bb2b4d9963e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #include "intr_common.h"
26 
27 /*
28  * Globals
29  */
30 static struct av_head	avec_tbl[APIC_MAX_VECTOR+1];
31 static apic_irq_t	*irq_tbl[APIC_MAX_VECTOR+1], airq;
32 static char		level_tbl[APIC_MAX_VECTOR+1];
33 
34 /*
35  * Dump interrupt information for pcplusmp PSM.
36  */
37 /* ARGSUSED */
38 int
39 interrupt_dump_apic(uintptr_t addr, uint_t flags, int argc,
40     const mdb_arg_t *argv)
41 {
42 	int		i;
43 
44 	option_flags = 0;
45 	if (mdb_getopts(argc, argv,
46 	    'd', MDB_OPT_SETBITS, INTR_DISPLAY_DRVR_INST, &option_flags,
47 	    'i', MDB_OPT_SETBITS, INTR_DISPLAY_INTRSTAT, &option_flags,
48 	    NULL) != argc)
49 		return (DCMD_USAGE);
50 
51 	if (mdb_readvar(&irq_tbl, "apic_irq_table") == -1) {
52 		mdb_warn("failed to read apic_irq_table");
53 		return (DCMD_ERR);
54 	}
55 
56 	if (mdb_readvar(&level_tbl, "apic_level_intr") == -1) {
57 		mdb_warn("failed to read apic_level_intr");
58 		return (DCMD_ERR);
59 	}
60 
61 	if (mdb_readvar(&avec_tbl, "autovect") == -1) {
62 		mdb_warn("failed to read autovect");
63 		return (DCMD_ERR);
64 	}
65 
66 	/* Print the header first */
67 	if (option_flags & INTR_DISPLAY_INTRSTAT)
68 		mdb_printf("%<u>CPU ");
69 	else
70 		mdb_printf(
71 		    "%<u>IRQ  Vect IPL Bus    Trg Type   CPU Share APIC/INT# ");
72 	mdb_printf("%s %</u>\n", option_flags & INTR_DISPLAY_DRVR_INST ?
73 	    "Driver Name(s)" : "ISR(s)");
74 
75 	/* Walk all the entries */
76 	for (i = 0; i < APIC_MAX_VECTOR + 1; i++) {
77 		/* Read the entry */
78 		if (mdb_vread(&airq, sizeof (apic_irq_t),
79 		    (uintptr_t)irq_tbl[i]) == -1)
80 			continue;
81 
82 		apic_interrupt_dump(&airq, &avec_tbl[i], i, NULL, level_tbl[i]);
83 	}
84 
85 	return (DCMD_OK);
86 }
87 
88 
89 /*
90  * MDB module linkage information:
91  *
92  * We declare a list of structures describing our dcmds, and a function
93  * named _mdb_init to return a pointer to our module information.
94  */
95 static const mdb_dcmd_t dcmds[] = {
96 	{ "interrupts", "?[-di]", "print interrupts", interrupt_dump_apic,
97 	    interrupt_help},
98 	{ "softint", "?[-d]", "print soft interrupts", soft_interrupt_dump,
99 	    soft_interrupt_help},
100 #ifdef _KMDB
101 	{ "apic", NULL, "print apic register contents", apic },
102 	{ "ioapic", NULL, "print ioapic register contents", ioapic },
103 #endif /* _KMDB */
104 	{ NULL }
105 };
106 
107 static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, NULL };
108 
109 const mdb_modinfo_t *
110 _mdb_init(void)
111 {
112 	GElf_Sym	sym;
113 
114 	if (mdb_lookup_by_name("gld_intr", &sym) != -1)
115 		if (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
116 			gld_intr_addr = (uintptr_t)sym.st_value;
117 
118 	return (&modinfo);
119 }
120