| 192 | */ |
| 193 | |
| 194 | void |
| 195 | trap(struct trapframe *frame) |
| 196 | { |
| 197 | ksiginfo_t ksi; |
| 198 | struct thread *td; |
| 199 | struct proc *p; |
| 200 | int pf, signo, ucode; |
| 201 | u_int type; |
| 202 | register_t addr, dr6; |
| 203 | vm_offset_t eva; |
| 204 | #ifdef POWERFAIL_NMI |
| 205 | static int lastalert = 0; |
| 206 | #endif |
| 207 | |
| 208 | td = curthread; |
| 209 | p = td->td_proc; |
| 210 | dr6 = 0; |
| 211 | |
| 212 | VM_CNT_INC(v_trap); |
| 213 | type = frame->tf_trapno; |
| 214 | |
| 215 | KASSERT((read_eflags() & PSL_I) == 0, |
| 216 | ("trap: interrupts enabled, type %d frame %p", type, frame)); |
| 217 | |
| 218 | #ifdef SMP |
| 219 | /* Handler for NMI IPIs used for stopping CPUs. */ |
| 220 | if (type == T_NMI && ipi_nmi_handler() == 0) |
| 221 | return; |
| 222 | #endif /* SMP */ |
| 223 | |
| 224 | #ifdef KDB |
| 225 | if (kdb_active) { |
| 226 | kdb_reenter(); |
| 227 | return; |
| 228 | } |
| 229 | #endif |
| 230 | |
| 231 | if (type == T_RESERVED) { |
| 232 | trap_fatal(frame, 0); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | if (type == T_NMI) { |
| 237 | #ifdef HWPMC_HOOKS |
| 238 | /* |
| 239 | * CPU PMCs interrupt using an NMI so we check for that first. |
| 240 | * If the HWPMC module is active, 'pmc_hook' will point to |
| 241 | * the function to be called. A non-zero return value from the |
| 242 | * hook means that the NMI was consumed by it and that we can |
| 243 | * return immediately. |
| 244 | */ |
| 245 | if (pmc_intr != NULL && |
| 246 | (*pmc_intr)(frame) != 0) |
| 247 | return; |
| 248 | #endif |
| 249 | } |
| 250 | |
| 251 | if (type == T_MCHK) { |
nothing calls this directly
no test coverage detected