1 /* $OpenBSD: i82489var.h,v 1.14 2014/01/24 21:20:23 kettenis 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 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _MACHINE_I82489VAR_H_ 34 #define _MACHINE_I82489VAR_H_ 35 36 static __inline__ u_int32_t i82489_readreg(int); 37 static __inline__ void i82489_writereg(int, u_int32_t); 38 39 #ifdef _KERNEL 40 extern volatile u_int32_t local_apic[]; 41 #endif 42 43 static __inline__ u_int32_t 44 i82489_readreg(int reg) 45 { 46 return *((volatile u_int32_t *)(((volatile u_int8_t *)local_apic) 47 + reg)); 48 } 49 50 static __inline__ void 51 i82489_writereg(int reg, u_int32_t val) 52 { 53 *((volatile u_int32_t *)(((volatile u_int8_t *)local_apic) + reg)) = 54 val; 55 /* 56 * intel xeon errata p53: 57 * write to a lapic register sometimes may appear to have not occured 58 * workaround: 59 * follow write with a read [from id register] 60 */ 61 val = *((volatile u_int32_t *)(((volatile u_int8_t *)local_apic) + 62 LAPIC_ID)); 63 } 64 65 /* 66 * "spurious interrupt vector"; vector used by interrupt which was 67 * aborted because the CPU masked it after it happened but before it 68 * was delivered.. "Oh, sorry, i caught you at a bad time". 69 * Low-order 4 bits must be all ones. 70 */ 71 extern void i386_spurious(void); 72 extern void Xintrspurious(void); 73 #define LAPIC_SPURIOUS_VECTOR 0xef 74 75 /* 76 * Vector used for inter-processor interrupts. 77 */ 78 extern void Xintripi(void); 79 #define LAPIC_IPI_VECTOR IPL_IPI 80 81 /* 82 * Vector used for local apic timer interrupts. 83 */ 84 85 extern void Xintrltimer(void); 86 #define LAPIC_TIMER_VECTOR IPL_CLOCK 87 88 /* 89 * Vectors to be used for self-soft-interrupts. 90 */ 91 92 #define LAPIC_SOFTCLOCK_VECTOR IPL_SOFTCLOCK 93 #define LAPIC_SOFTNET_VECTOR IPL_SOFTNET 94 #define LAPIC_SOFTTTY_VECTOR IPL_SOFTTTY 95 96 /* 97 * Special IPI vectors. We can use IDT 0xf0 - 0xff for this. 98 */ 99 #define LAPIC_IPI_OFFSET 0xf0 100 #define LAPIC_IPI_INVLTLB (LAPIC_IPI_OFFSET + 0) 101 #define LAPIC_IPI_INVLPG (LAPIC_IPI_OFFSET + 1) 102 #define LAPIC_IPI_INVLRANGE (LAPIC_IPI_OFFSET + 2) 103 #define LAPIC_IPI_RELOADCR3 (LAPIC_IPI_OFFSET + 3) 104 105 extern void Xintripi_invltlb(void); 106 extern void Xintripi_invlpg(void); 107 extern void Xintripi_invlrange(void); 108 extern void Xintripi_reloadcr3(void); 109 110 extern void Xintrsoftclock(void); 111 extern void Xintrsoftnet(void); 112 extern void Xintrsofttty(void); 113 114 extern void (*apichandler[])(void); 115 116 struct cpu_info; 117 118 extern void lapic_boot_init(paddr_t); 119 extern void lapic_startclock(void); 120 extern void lapic_initclocks(void); 121 extern void lapic_set_lvt(void); 122 extern void lapic_set_softvectors(void); 123 extern void lapic_enable(void); 124 extern void lapic_disable(void); 125 extern void lapic_calibrate_timer(struct cpu_info *); 126 127 #define lapic_cpu_number() (i82489_readreg(LAPIC_ID)>>LAPIC_ID_SHIFT) 128 129 #endif 130