1 /* $OpenBSD: i82489var.h,v 1.6 2007/05/26 22:09:17 weingart Exp $ */ 2 /* $NetBSD: i82489var.h,v 1.1.2.2 2000/02/21 18:46:14 sommerfeld Exp $ */ 3 4 /*- 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Frank van der Linden. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 #ifndef _I386_I82489VAR_H_ 41 #define _I386_I82489VAR_H_ 42 43 static __inline__ u_int32_t i82489_readreg(int); 44 static __inline__ void i82489_writereg(int, u_int32_t); 45 46 #ifdef _KERNEL 47 extern volatile u_int32_t local_apic[]; 48 #endif 49 50 static __inline__ u_int32_t 51 i82489_readreg(reg) 52 int reg; 53 { 54 return *((volatile u_int32_t *)(((volatile u_int8_t *)local_apic) 55 + reg)); 56 } 57 58 static __inline__ void 59 i82489_writereg(reg, val) 60 int reg; 61 u_int32_t val; 62 { 63 *((volatile u_int32_t *)(((volatile u_int8_t *)local_apic) + reg)) = 64 val; 65 /* 66 * intel xeon errata p53: 67 * write to a lapic register sometimes may appear to have not occured 68 * workaround: 69 * follow write with a read [from id register] 70 */ 71 val = *((volatile u_int32_t *)(((volatile u_int8_t *)local_apic) + 72 LAPIC_ID)); 73 } 74 75 /* 76 * "spurious interrupt vector"; vector used by interrupt which was 77 * aborted because the CPU masked it after it happened but before it 78 * was delivered.. "Oh, sorry, i caught you at a bad time". 79 * Low-order 4 bits must be all ones. 80 */ 81 extern void i386_spurious(void); 82 extern void Xintrspurious(void); 83 #define LAPIC_SPURIOUS_VECTOR 0xef 84 85 /* 86 * Vector used for inter-processor interrupts. 87 */ 88 extern void Xintripi(void); 89 #define LAPIC_IPI_VECTOR IPL_IPI 90 91 /* 92 * Vector used for local apic timer interrupts. 93 */ 94 95 extern void Xintrltimer(void); 96 #define LAPIC_TIMER_VECTOR IPL_CLOCK 97 98 /* 99 * Vectors to be used for self-soft-interrupts. 100 */ 101 102 #define LAPIC_SOFTCLOCK_VECTOR IPL_SOFTCLOCK 103 #define LAPIC_SOFTNET_VECTOR IPL_SOFTNET 104 #define LAPIC_SOFTTTY_VECTOR IPL_SOFTTTY 105 #define LAPIC_SOFTAST_VECTOR IPL_SOFTAST 106 107 /* 108 * Special IPI vectors. We can use IDT 0xf0 - 0xff for this. 109 */ 110 #define LAPIC_IPI_OFFSET 0xf0 111 #define LAPIC_IPI_AST (LAPIC_IPI_OFFSET + 0) 112 #define LAPIC_IPI_INVLTLB (LAPIC_IPI_OFFSET + 1) 113 #define LAPIC_IPI_INVLPG (LAPIC_IPI_OFFSET + 2) 114 #define LAPIC_IPI_INVLRANGE (LAPIC_IPI_OFFSET + 3) 115 116 extern void Xintripi_ast(void); 117 extern void Xintripi_invltlb(void); 118 extern void Xintripi_invlpg(void); 119 extern void Xintripi_invlrange(void); 120 121 extern void Xintrsoftclock(void); 122 extern void Xintrsoftnet(void); 123 extern void Xintrsofttty(void); 124 extern void Xintrsoftast(void); 125 126 extern void (*apichandler[])(void); 127 128 struct cpu_info; 129 130 extern void lapic_boot_init(paddr_t); 131 extern void lapic_initclocks(void); 132 extern void lapic_set_lvt(void); 133 extern void lapic_set_softvectors(void); 134 extern void lapic_enable(void); 135 extern void lapic_calibrate_timer(struct cpu_info *); 136 137 #define lapic_cpu_number() (i82489_readreg(LAPIC_ID)>>LAPIC_ID_SHIFT) 138 139 #endif