1 /* $NetBSD: apic.c,v 1.10 2019/06/14 09:23:42 msaitoh Exp $ */ 2 3 /*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by RedBack Networks Inc. 9 * 10 * Author: Bill Sommerfeld 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <sys/cdefs.h> 35 __KERNEL_RCSID(0, "$NetBSD: apic.c,v 1.10 2019/06/14 09:23:42 msaitoh Exp $"); 36 37 #include <sys/types.h> 38 #include <sys/param.h> 39 #include <sys/systm.h> 40 41 #include <machine/i82489reg.h> 42 #include <machine/i82489var.h> 43 #include <machine/apicvar.h> 44 45 #define APICVTFMT "\177\20" \ 46 "f\0\10vector\0" \ 47 "f\10\3delmode\0" "=\0fixed\0" "=\1low\0" "=\2SMI\0" "=\4NMI\0" \ 48 "=\5INIT\0" "=\6startup\0" "=\7ExtINT\0" \ 49 "F\13\1\0" ":\0physical\0" ":\1logical\0" \ 50 "b\14pending\0" \ 51 "F\15\1\0" ":\0acthi\0" ":\1actlo\0" \ 52 "b\16irrpending\0" \ 53 "F\17\1\0" ":\0edge\0" ":\1level\0" \ 54 "b\20masked\0" 55 56 static const char ioapicfmt[] = APICVTFMT 57 "f\22\2dest\0" "=\1self\0" "=\2all\0" "=\3all-others\0"; 58 59 static const char lapicfmt[] = APICVTFMT 60 "f\21\2timer\0" "=\0oneshot\0" "=\1periodic\0" "=\2TSC-deadine\0"; 61 62 static const char redirhifmt[] = "\177\20" 63 "f\30\10target\0"; 64 65 void 66 apic_format_redir(const char *where1, const char *where2, int idx, int type, 67 uint32_t redirhi, uint32_t redirlo) 68 { 69 char buf[256]; 70 71 snprintb(buf, sizeof(buf), 72 type == APIC_VECTYPE_IOAPIC ? ioapicfmt : lapicfmt, redirlo); 73 printf("%s: %s%d %s", where1, where2, idx, buf); 74 75 if ((type == APIC_VECTYPE_IOAPIC) 76 && ((redirlo & LAPIC_DEST_MASK) == 0)) { 77 snprintb(buf, sizeof(buf), redirhifmt, redirhi); 78 printf(" %s", buf); 79 } 80 81 printf("\n"); 82 } 83