1 /* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 * 9 * $FreeBSD$ 10 * 11 */ 12 13 #ifndef _MACHINE_SMP_H_ 14 #define _MACHINE_SMP_H_ 15 16 #ifdef _KERNEL 17 18 #if defined(SMP) && defined(I386_CPU) && !defined(COMPILING_LINT) 19 #error SMP not supported with I386_CPU 20 #endif 21 #if defined(SMP) && !defined(APIC_IO) 22 # error APIC_IO required for SMP, add "options APIC_IO" to your config file. 23 #endif /* SMP && !APIC_IO */ 24 #if defined(SMP) && defined(CPU_DISABLE_CMPXCHG) && !defined(COMPILING_LINT) 25 #error SMP not supported with CPU_DISABLE_CMPXCHG 26 #endif 27 28 #if defined(SMP) || defined(APIC_IO) 29 30 #ifndef LOCORE 31 32 /* 33 * For sending values to POST displays. 34 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 35 */ 36 extern int current_postcode; /** XXX currently in mp_machdep.c */ 37 #define POSTCODE(X) current_postcode = (X), \ 38 outb(0x80, current_postcode) 39 #define POSTCODE_LO(X) current_postcode &= 0xf0, \ 40 current_postcode |= ((X) & 0x0f), \ 41 outb(0x80, current_postcode) 42 #define POSTCODE_HI(X) current_postcode &= 0x0f, \ 43 current_postcode |= (((X) << 4) & 0xf0), \ 44 outb(0x80, current_postcode) 45 46 47 #include <sys/bus.h> /* XXX */ 48 #include <machine/apic.h> 49 #include <machine/frame.h> 50 #include <i386/isa/icu.h> 51 #include <i386/isa/intr_machdep.h> 52 53 /* 54 * Interprocessor interrupts for SMP. 55 */ 56 #define IPI_INVLTLB XINVLTLB_OFFSET 57 #define IPI_INVLPG XINVLPG_OFFSET 58 #define IPI_INVLRNG XINVLRNG_OFFSET 59 #define IPI_RENDEZVOUS XRENDEZVOUS_OFFSET 60 #define IPI_AST XCPUAST_OFFSET 61 #define IPI_STOP XCPUSTOP_OFFSET 62 #define IPI_HARDCLOCK XHARDCLOCK_OFFSET 63 #define IPI_STATCLOCK XSTATCLOCK_OFFSET 64 65 /* global data in mpboot.s */ 66 extern int bootMP_size; 67 68 /* functions in mpboot.s */ 69 void bootMP(void); 70 71 /* global data in mp_machdep.c */ 72 extern int bsp_apic_ready; 73 extern int mp_naps; 74 extern int mp_nbusses; 75 extern int mp_napics; 76 extern int mp_picmode; 77 extern int boot_cpu_id; 78 extern vm_offset_t cpu_apic_address; 79 extern vm_offset_t io_apic_address[]; 80 extern u_int32_t cpu_apic_versions[]; 81 extern u_int32_t *io_apic_versions; 82 extern int cpu_num_to_apic_id[]; 83 extern int io_num_to_apic_id[]; 84 extern int apic_id_to_logical[]; 85 #define APIC_INTMAPSIZE 32 86 struct apic_intmapinfo { 87 int ioapic; 88 int int_pin; 89 volatile void *apic_address; 90 int redirindex; 91 }; 92 extern struct apic_intmapinfo int_to_apicintpin[]; 93 extern struct pcb stoppcbs[]; 94 95 /* functions in mp_machdep.c */ 96 void i386_mp_probe(void); 97 u_int mp_bootaddress(u_int); 98 u_int isa_apic_mask(u_int); 99 int isa_apic_irq(int); 100 int pci_apic_irq(int, int, int); 101 int apic_irq(int, int); 102 int next_apic_irq(int); 103 int undirect_isa_irq(int); 104 int undirect_pci_irq(int); 105 int apic_bus_type(int); 106 int apic_src_bus_id(int, int); 107 int apic_src_bus_irq(int, int); 108 int apic_int_type(int, int); 109 int apic_trigger(int, int); 110 int apic_polarity(int, int); 111 int mp_grab_cpu_hlt(void); 112 void assign_apic_irq(int apic, int intpin, int irq); 113 void revoke_apic_irq(int irq); 114 void bsp_apic_configure(void); 115 void init_secondary(void); 116 void forward_statclock(void); 117 void forwarded_statclock(struct clockframe frame); 118 void forward_hardclock(void); 119 void forwarded_hardclock(struct clockframe frame); 120 void ipi_selected(u_int cpus, u_int ipi); 121 void ipi_all(u_int ipi); 122 void ipi_all_but_self(u_int ipi); 123 void ipi_self(u_int ipi); 124 #ifdef APIC_INTR_REORDER 125 void set_lapic_isrloc(int, int); 126 #endif /* APIC_INTR_REORDER */ 127 void smp_invlpg(vm_offset_t addr); 128 void smp_masked_invlpg(u_int mask, vm_offset_t addr); 129 void smp_invlpg_range(vm_offset_t startva, vm_offset_t endva); 130 void smp_masked_invlpg_range(u_int mask, vm_offset_t startva, 131 vm_offset_t endva); 132 void smp_invltlb(void); 133 void smp_masked_invltlb(u_int mask); 134 135 /* global data in mpapic.c */ 136 extern volatile lapic_t lapic; 137 extern volatile ioapic_t **ioapic; 138 139 /* functions in mpapic.c */ 140 void apic_dump(char*); 141 void apic_initialize(void); 142 void imen_dump(void); 143 int apic_ipi(int, int, int); 144 int selected_apic_ipi(u_int, int, int); 145 int io_apic_setup(int); 146 void io_apic_setup_intpin(int, int); 147 void io_apic_set_id(int, int); 148 int io_apic_get_id(int); 149 int ext_int_setup(int, int); 150 151 void set_apic_timer(int); 152 int read_apic_timer(void); 153 void u_sleep(int); 154 u_int io_apic_read(int, int); 155 void io_apic_write(int, int, u_int); 156 157 #endif /* !LOCORE */ 158 #endif /* SMP && !APIC_IO */ 159 160 #endif /* _KERNEL */ 161 #endif /* _MACHINE_SMP_H_ */ 162