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 25 #if defined(SMP) || defined(APIC_IO) 26 27 #ifndef LOCORE 28 29 /* 30 * For sending values to POST displays. 31 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 32 */ 33 extern int current_postcode; /** XXX currently in mp_machdep.c */ 34 #define POSTCODE(X) current_postcode = (X), \ 35 outb(0x80, current_postcode) 36 #define POSTCODE_LO(X) current_postcode &= 0xf0, \ 37 current_postcode |= ((X) & 0x0f), \ 38 outb(0x80, current_postcode) 39 #define POSTCODE_HI(X) current_postcode &= 0x0f, \ 40 current_postcode |= (((X) << 4) & 0xf0), \ 41 outb(0x80, current_postcode) 42 43 44 #include <sys/bus.h> /* XXX */ 45 #include <machine/apic.h> 46 #include <machine/frame.h> 47 #include <i386/isa/icu.h> 48 #include <i386/isa/intr_machdep.h> 49 50 /* 51 * Interprocessor interrupts for SMP. 52 */ 53 #define IPI_INVLTLB XINVLTLB_OFFSET 54 #define IPI_RENDEZVOUS XRENDEZVOUS_OFFSET 55 #define IPI_AST XCPUAST_OFFSET 56 #define IPI_STOP XCPUSTOP_OFFSET 57 #define IPI_HARDCLOCK XHARDCLOCK_OFFSET 58 #define IPI_STATCLOCK XSTATCLOCK_OFFSET 59 60 /* global data in mpboot.s */ 61 extern int bootMP_size; 62 63 /* functions in mpboot.s */ 64 void bootMP __P((void)); 65 66 /* global data in mp_machdep.c */ 67 extern int bsp_apic_ready; 68 extern int mp_naps; 69 extern int mp_nbusses; 70 extern int mp_napics; 71 extern int mp_picmode; 72 extern int boot_cpu_id; 73 extern vm_offset_t cpu_apic_address; 74 extern vm_offset_t io_apic_address[]; 75 extern u_int32_t cpu_apic_versions[]; 76 extern u_int32_t *io_apic_versions; 77 extern int cpu_num_to_apic_id[]; 78 extern int io_num_to_apic_id[]; 79 extern int apic_id_to_logical[]; 80 #define APIC_INTMAPSIZE 32 81 struct apic_intmapinfo { 82 int ioapic; 83 int int_pin; 84 volatile void *apic_address; 85 int redirindex; 86 }; 87 extern struct apic_intmapinfo int_to_apicintpin[]; 88 extern struct pcb stoppcbs[]; 89 90 /* functions in mp_machdep.c */ 91 void i386_mp_probe __P((void)); 92 u_int mp_bootaddress __P((u_int)); 93 u_int isa_apic_mask __P((u_int)); 94 int isa_apic_irq __P((int)); 95 int pci_apic_irq __P((int, int, int)); 96 int apic_irq __P((int, int)); 97 int next_apic_irq __P((int)); 98 int undirect_isa_irq __P((int)); 99 int undirect_pci_irq __P((int)); 100 int apic_bus_type __P((int)); 101 int apic_src_bus_id __P((int, int)); 102 int apic_src_bus_irq __P((int, int)); 103 int apic_int_type __P((int, int)); 104 int apic_trigger __P((int, int)); 105 int apic_polarity __P((int, int)); 106 void assign_apic_irq __P((int apic, int intpin, int irq)); 107 void revoke_apic_irq __P((int irq)); 108 void bsp_apic_configure __P((void)); 109 void init_secondary __P((void)); 110 void smp_invltlb __P((void)); 111 void forward_statclock __P((void)); 112 void forwarded_statclock __P((struct trapframe frame)); 113 void forward_hardclock __P((void)); 114 void forwarded_hardclock __P((struct trapframe frame)); 115 void ipi_selected __P((u_int cpus, u_int ipi)); 116 void ipi_all __P((u_int ipi)); 117 void ipi_all_but_self __P((u_int ipi)); 118 void ipi_self __P((u_int ipi)); 119 #ifdef APIC_INTR_REORDER 120 void set_lapic_isrloc __P((int, int)); 121 #endif /* APIC_INTR_REORDER */ 122 123 /* global data in mpapic.c */ 124 extern volatile lapic_t lapic; 125 extern volatile ioapic_t **ioapic; 126 127 /* functions in mpapic.c */ 128 void apic_dump __P((char*)); 129 void apic_initialize __P((void)); 130 void imen_dump __P((void)); 131 int apic_ipi __P((int, int, int)); 132 int selected_apic_ipi __P((u_int, int, int)); 133 int io_apic_setup __P((int)); 134 void io_apic_setup_intpin __P((int, int)); 135 void io_apic_set_id __P((int, int)); 136 int io_apic_get_id __P((int)); 137 int ext_int_setup __P((int, int)); 138 139 void set_apic_timer __P((int)); 140 int read_apic_timer __P((void)); 141 void u_sleep __P((int)); 142 u_int io_apic_read __P((int, int)); 143 void io_apic_write __P((int, int, u_int)); 144 145 146 /* global data in init_smp.c */ 147 extern int invltlb_ok; 148 extern volatile int smp_idle_loops; 149 150 #endif /* !LOCORE */ 151 #endif /* SMP && !APIC_IO */ 152 153 #endif /* _KERNEL */ 154 #endif /* _MACHINE_SMP_H_ */ 155