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.
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.
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]
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25 #include "intr_common.h"
29 /* Macros for reading/writing the IOAPIC RDT entries */
30 #define APIC_READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix, ipin) \
31 apic_ioapic_read(ioapic_ix, APIC_RDT_CMD + (2 * (ipin)))
33 #define APIC_READ_IOAPIC_RDT_ENTRY_HIGH_DWORD(ioapic_ix, ipin) \
34 apic_ioapic_read(ioapic_ix, APIC_RDT_CMD2 + (2 * (ipin)))
36 static uint32_t *ioapic_adr
[MAX_IO_APIC
];
39 apic_ioapic_read(int ioapic_ix
, uint32_t reg
)
41 volatile uint32_t *ioapic
;
43 ioapic
= ioapic_adr
[ioapic_ix
];
44 ioapic
[APIC_IO_REG
] = reg
;
45 return (ioapic
[APIC_IO_DATA
]);
49 * ioapic dcmd - Print out the ioapic registers, nicely formatted.
53 ioapic(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
61 if ((flags
& DCMD_ADDRSPEC
) || argc
!= 0)
64 if (mdb_readvar(&ioapic_adr
, "apicioadr") == -1) {
66 * If the mdb_warn string does not end in a \n, mdb will
67 * automatically append the reason for the failure.
69 mdb_warn("failed to read ioapicadr");
73 if (mdb_readvar(&apic_io_max
, "apic_io_max") == -1) {
75 * If the mdb_warn string does not end in a \n, mdb will
76 * automatically append the reason for the failure.
78 mdb_warn("failed to read apic_io_max");
82 mdb_printf("ioapicadr\t%p\n", ioapic_adr
);
84 for (i
= 0; i
< apic_io_max
; i
++) {
85 /* Bits 23-16 define the maximum redirection entries */
86 reg_max
= apic_ioapic_read(i
, APIC_VERS_CMD
);
87 reg_max
= (reg_max
>> 16) & 0xff;
89 mdb_printf("%4s %8s %8s\n", "reg", "high", " low");
90 for (reg
= 0; reg
<= reg_max
; reg
++) {
93 high
= APIC_READ_IOAPIC_RDT_ENTRY_HIGH_DWORD(i
, reg
);
94 low
= APIC_READ_IOAPIC_RDT_ENTRY_LOW_DWORD(i
, reg
);
96 mdb_printf("%2d %8x %8x\n", reg
, high
, low
);
108 * apic dcmd - Print out the apic registers, nicely formatted.
112 apic(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
116 if ((flags
& DCMD_ADDRSPEC
) || argc
!= 0)
119 if (mdb_readvar(&papic
, "apicadr") == -1) {
121 * If the mdb_warn string does not end in a \n, mdb will
122 * automatically append the reason for the failure.
124 mdb_warn("failed to read apicadr");
128 mdb_printf("apicadr\t%p\n", papic
);
129 mdb_printf("as_task_reg\t%x\n", papic
[APIC_TASK_REG
]);
130 mdb_printf("as_dest_reg\t%x\n", papic
[APIC_DEST_REG
]);
131 mdb_printf("as_format_reg\t%x\n", papic
[APIC_FORMAT_REG
]);
132 mdb_printf("as_local_timer\t%x\n", papic
[APIC_LOCAL_TIMER
]);
133 mdb_printf("as_pcint_vect\t%x\n", papic
[APIC_PCINT_VECT
]);
134 mdb_printf("as_int_vect0\t%x\n", papic
[APIC_INT_VECT0
]);
135 mdb_printf("as_int_vect1\t%x\n", papic
[APIC_INT_VECT1
]);
136 mdb_printf("as_err_vect\t%x\n", papic
[APIC_ERR_VECT
]);
137 mdb_printf("as_init_count\t%x\n", papic
[APIC_INIT_COUNT
]);
138 mdb_printf("as_divide_reg\t%x\n", papic
[APIC_DIVIDE_REG
]);
139 mdb_printf("as_spur_int_reg\t%x\n", papic
[APIC_SPUR_INT_REG
]);