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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28/* 29 * Companion to kdi_idt.c - the implementation of the trap and interrupt 30 * handlers. For the most part, these handlers do the same thing - they 31 * push a trap number onto the stack, followed by a jump to kdi_cmnint. 32 * Each trap and interrupt has its own handler because each one pushes a 33 * different number. 34 */ 35 36#include <sys/asm_linkage.h> 37#include <sys/kdi_regs.h> 38 39/* Nothing in this file is of interest to lint. */ 40#if !defined(__lint) 41 42/* 43 * The default ASM_ENTRY_ALIGN (16) wastes far too much space. Pay no 44 * attention to the fleet of nop's we're adding to each handler. 45 */ 46#undef ASM_ENTRY_ALIGN 47#define ASM_ENTRY_ALIGN 8 48 49/* 50 * We need the .align in ENTRY_NP (defined to be ASM_ENTRY_ALIGN) to match our 51 * manual .align (KDI_MSR_PATCHOFF) in order to ensure that the space reserved 52 * at the beginning of the handler for code is exactly KDI_MSR_PATCHOFF bytes 53 * long. Note that the #error below isn't supported by the preprocessor invoked 54 * by as(1), and won't stop the build, but it'll emit a noticeable error message 55 * which won't escape the filters. 56 */ 57#if ASM_ENTRY_ALIGN != KDI_MSR_PATCHOFF 58#error "ASM_ENTRY_ALIGN != KDI_MSR_PATCHOFF" 59this won't assemble 60#endif 61 62/* 63 * kdi_idt_patch will, on certain processors, replace the patch points below 64 * with MSR-clearing code. kdi_id_patch has intimate knowledge of the size of 65 * the nop hole, as well as the structure of the handlers. Do not change 66 * anything here without also changing kdi_idt_patch. 67 */ 68 69/* 70 * Generic trap and interrupt handlers. 71 */ 72 73#define TRAP_NOERR(trapno) \ 74 push $trapno 75 76#define TRAP_ERR(trapno) \ 77 push $0; \ 78 push $trapno 79 80#define MKIVCT(n) \ 81 ENTRY_NP(kdi_ivct/**/n/**/); \ 82 TRAP_ERR(n); \ 83 .align KDI_MSR_PATCHOFF; \ 84 KDI_MSR_PATCH; \ 85 jmp kdi_cmnint; \ 86 SET_SIZE(kdi_ivct/**/n/**/) 87 88#define MKTRAPHDLR(n) \ 89 ENTRY_NP(kdi_trap/**/n); \ 90 TRAP_ERR(n); \ 91 .align KDI_MSR_PATCHOFF; \ 92 KDI_MSR_PATCH; \ 93 jmp kdi_cmnint; \ 94 SET_SIZE(kdi_trap/**/n/**/) 95 96#define MKTRAPERRHDLR(n) \ 97 ENTRY_NP(kdi_traperr/**/n); \ 98 TRAP_NOERR(n); \ 99 .align KDI_MSR_PATCHOFF; \ 100 KDI_MSR_PATCH; \ 101 jmp kdi_cmnint; \ 102 SET_SIZE(kdi_traperr/**/n) 103 104#define MKNMIHDLR \ 105 ENTRY_NP(kdi_int2); \ 106 TRAP_NOERR(2); \ 107 .align KDI_MSR_PATCHOFF; \ 108 KDI_MSR_PATCH; \ 109 jmp kdi_nmiint; \ 110 SET_SIZE(kdi_int2) 111 112#define MKINVALHDLR \ 113 ENTRY_NP(kdi_invaltrap); \ 114 TRAP_NOERR(255); \ 115 .align KDI_MSR_PATCHOFF; \ 116 KDI_MSR_PATCH; \ 117 jmp kdi_cmnint; \ 118 SET_SIZE(kdi_invaltrap) 119 120/* 121 * The handlers themselves 122 */ 123 124 MKINVALHDLR 125 MKTRAPHDLR(0) 126 MKTRAPHDLR(1) 127 MKNMIHDLR/*2*/ 128 MKTRAPHDLR(3) 129 MKTRAPHDLR(4) 130 MKTRAPHDLR(5) 131 MKTRAPHDLR(6) 132 MKTRAPHDLR(7) 133 MKTRAPHDLR(9) 134 MKTRAPHDLR(15) 135 MKTRAPHDLR(16) 136 MKTRAPHDLR(17) 137 MKTRAPHDLR(18) 138 MKTRAPHDLR(19) 139 MKTRAPHDLR(20) 140 141 MKTRAPERRHDLR(8) 142 MKTRAPERRHDLR(10) 143 MKTRAPERRHDLR(11) 144 MKTRAPERRHDLR(12) 145 MKTRAPERRHDLR(13) 146 MKTRAPERRHDLR(14) 147 148 .globl kdi_ivct_size 149kdi_ivct_size: 150 .NWORD [kdi_ivct33-kdi_ivct32] 151 152 /* 10 billion and one interrupt handlers */ 153kdi_ivct_base: 154 MKIVCT(32); MKIVCT(33); MKIVCT(34); MKIVCT(35); 155 MKIVCT(36); MKIVCT(37); MKIVCT(38); MKIVCT(39); 156 MKIVCT(40); MKIVCT(41); MKIVCT(42); MKIVCT(43); 157 MKIVCT(44); MKIVCT(45); MKIVCT(46); MKIVCT(47); 158 MKIVCT(48); MKIVCT(49); MKIVCT(50); MKIVCT(51); 159 MKIVCT(52); MKIVCT(53); MKIVCT(54); MKIVCT(55); 160 MKIVCT(56); MKIVCT(57); MKIVCT(58); MKIVCT(59); 161 MKIVCT(60); MKIVCT(61); MKIVCT(62); MKIVCT(63); 162 MKIVCT(64); MKIVCT(65); MKIVCT(66); MKIVCT(67); 163 MKIVCT(68); MKIVCT(69); MKIVCT(70); MKIVCT(71); 164 MKIVCT(72); MKIVCT(73); MKIVCT(74); MKIVCT(75); 165 MKIVCT(76); MKIVCT(77); MKIVCT(78); MKIVCT(79); 166 MKIVCT(80); MKIVCT(81); MKIVCT(82); MKIVCT(83); 167 MKIVCT(84); MKIVCT(85); MKIVCT(86); MKIVCT(87); 168 MKIVCT(88); MKIVCT(89); MKIVCT(90); MKIVCT(91); 169 MKIVCT(92); MKIVCT(93); MKIVCT(94); MKIVCT(95); 170 MKIVCT(96); MKIVCT(97); MKIVCT(98); MKIVCT(99); 171 MKIVCT(100); MKIVCT(101); MKIVCT(102); MKIVCT(103); 172 MKIVCT(104); MKIVCT(105); MKIVCT(106); MKIVCT(107); 173 MKIVCT(108); MKIVCT(109); MKIVCT(110); MKIVCT(111); 174 MKIVCT(112); MKIVCT(113); MKIVCT(114); MKIVCT(115); 175 MKIVCT(116); MKIVCT(117); MKIVCT(118); MKIVCT(119); 176 MKIVCT(120); MKIVCT(121); MKIVCT(122); MKIVCT(123); 177 MKIVCT(124); MKIVCT(125); MKIVCT(126); MKIVCT(127); 178 MKIVCT(128); MKIVCT(129); MKIVCT(130); MKIVCT(131); 179 MKIVCT(132); MKIVCT(133); MKIVCT(134); MKIVCT(135); 180 MKIVCT(136); MKIVCT(137); MKIVCT(138); MKIVCT(139); 181 MKIVCT(140); MKIVCT(141); MKIVCT(142); MKIVCT(143); 182 MKIVCT(144); MKIVCT(145); MKIVCT(146); MKIVCT(147); 183 MKIVCT(148); MKIVCT(149); MKIVCT(150); MKIVCT(151); 184 MKIVCT(152); MKIVCT(153); MKIVCT(154); MKIVCT(155); 185 MKIVCT(156); MKIVCT(157); MKIVCT(158); MKIVCT(159); 186 MKIVCT(160); MKIVCT(161); MKIVCT(162); MKIVCT(163); 187 MKIVCT(164); MKIVCT(165); MKIVCT(166); MKIVCT(167); 188 MKIVCT(168); MKIVCT(169); MKIVCT(170); MKIVCT(171); 189 MKIVCT(172); MKIVCT(173); MKIVCT(174); MKIVCT(175); 190 MKIVCT(176); MKIVCT(177); MKIVCT(178); MKIVCT(179); 191 MKIVCT(180); MKIVCT(181); MKIVCT(182); MKIVCT(183); 192 MKIVCT(184); MKIVCT(185); MKIVCT(186); MKIVCT(187); 193 MKIVCT(188); MKIVCT(189); MKIVCT(190); MKIVCT(191); 194 MKIVCT(192); MKIVCT(193); MKIVCT(194); MKIVCT(195); 195 MKIVCT(196); MKIVCT(197); MKIVCT(198); MKIVCT(199); 196 MKIVCT(200); MKIVCT(201); MKIVCT(202); MKIVCT(203); 197 MKIVCT(204); MKIVCT(205); MKIVCT(206); MKIVCT(207); 198 MKIVCT(208); MKIVCT(209); MKIVCT(210); MKIVCT(211); 199 MKIVCT(212); MKIVCT(213); MKIVCT(214); MKIVCT(215); 200 MKIVCT(216); MKIVCT(217); MKIVCT(218); MKIVCT(219); 201 MKIVCT(220); MKIVCT(221); MKIVCT(222); MKIVCT(223); 202 MKIVCT(224); MKIVCT(225); MKIVCT(226); MKIVCT(227); 203 MKIVCT(228); MKIVCT(229); MKIVCT(230); MKIVCT(231); 204 MKIVCT(232); MKIVCT(233); MKIVCT(234); MKIVCT(235); 205 MKIVCT(236); MKIVCT(237); MKIVCT(238); MKIVCT(239); 206 MKIVCT(240); MKIVCT(241); MKIVCT(242); MKIVCT(243); 207 MKIVCT(244); MKIVCT(245); MKIVCT(246); MKIVCT(247); 208 MKIVCT(248); MKIVCT(249); MKIVCT(250); MKIVCT(251); 209 MKIVCT(252); MKIVCT(253); MKIVCT(254); MKIVCT(255); 210 211#endif 212