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 <machine/apic.h> 45 46 /* global data in mpboot.s */ 47 extern int bootMP_size; 48 49 /* functions in mpboot.s */ 50 void bootMP __P((void)); 51 52 /* global data in apic_vector.s */ 53 extern volatile u_int stopped_cpus; 54 extern volatile u_int started_cpus; 55 56 extern volatile u_int checkstate_probed_cpus; 57 extern volatile u_int checkstate_need_ast; 58 extern volatile u_int resched_cpus; 59 extern void (*cpustop_restartfunc) __P((void)); 60 61 /* functions in apic_ipl.s */ 62 void apic_eoi __P((void)); 63 u_int io_apic_read __P((int, int)); 64 void io_apic_write __P((int, int, u_int)); 65 66 /* global data in mp_machdep.c */ 67 extern int bsp_apic_ready; 68 extern int mp_ncpus; 69 extern int mp_naps; 70 extern int mp_nbusses; 71 extern int mp_napics; 72 extern int mp_picmode; 73 extern int boot_cpu_id; 74 extern vm_offset_t cpu_apic_address; 75 extern vm_offset_t io_apic_address[]; 76 extern u_int32_t cpu_apic_versions[]; 77 extern u_int32_t *io_apic_versions; 78 extern int cpu_num_to_apic_id[]; 79 extern int io_num_to_apic_id[]; 80 extern int apic_id_to_logical[]; 81 #define APIC_INTMAPSIZE 24 82 struct apic_intmapinfo { 83 int ioapic; 84 int int_pin; 85 volatile void *apic_address; 86 int redirindex; 87 }; 88 extern struct apic_intmapinfo int_to_apicintpin[]; 89 extern u_int all_cpus; 90 extern struct pcb stoppcbs[]; 91 92 /* functions in mp_machdep.c */ 93 u_int mp_bootaddress __P((u_int)); 94 int mp_probe __P((void)); 95 void mp_start __P((void)); 96 void mp_announce __P((void)); 97 u_int isa_apic_mask __P((u_int)); 98 int isa_apic_irq __P((int)); 99 int pci_apic_irq __P((int, int, int)); 100 int apic_irq __P((int, int)); 101 int next_apic_irq __P((int)); 102 int undirect_isa_irq __P((int)); 103 int undirect_pci_irq __P((int)); 104 int apic_bus_type __P((int)); 105 int apic_src_bus_id __P((int, int)); 106 int apic_src_bus_irq __P((int, int)); 107 int apic_int_type __P((int, int)); 108 int apic_trigger __P((int, int)); 109 int apic_polarity __P((int, int)); 110 void assign_apic_irq __P((int apic, int intpin, int irq)); 111 void revoke_apic_irq __P((int irq)); 112 void bsp_apic_configure __P((void)); 113 void init_secondary __P((void)); 114 void smp_invltlb __P((void)); 115 int stop_cpus __P((u_int)); 116 int restart_cpus __P((u_int)); 117 #ifdef BETTER_CLOCK 118 void forward_statclock __P((int pscnt)); 119 void forward_hardclock __P((int pscnt)); 120 #endif /* BETTER_CLOCK */ 121 void forward_signal __P((struct proc *)); 122 void forward_roundrobin __P((void)); 123 #ifdef APIC_INTR_REORDER 124 void set_lapic_isrloc __P((int, int)); 125 #endif /* APIC_INTR_REORDER */ 126 void smp_rendezvous_action __P((void)); 127 void smp_rendezvous __P((void (*)(void *), 128 void (*)(void *), 129 void (*)(void *), 130 void *arg)); 131 132 /* global data in mpapic.c */ 133 extern volatile lapic_t lapic; 134 extern volatile ioapic_t **ioapic; 135 136 /* functions in mpapic.c */ 137 void apic_dump __P((char*)); 138 void apic_initialize __P((void)); 139 void imen_dump __P((void)); 140 int apic_ipi __P((int, int, int)); 141 int selected_apic_ipi __P((u_int, int, int)); 142 int io_apic_setup __P((int)); 143 void io_apic_set_id __P((int, int)); 144 int io_apic_get_id __P((int)); 145 int ext_int_setup __P((int, int)); 146 147 #if defined(READY) 148 void clr_io_apic_mask24 __P((int, u_int32_t)); 149 void set_io_apic_mask24 __P((int, u_int32_t)); 150 #endif /* READY */ 151 152 void set_apic_timer __P((int)); 153 int read_apic_timer __P((void)); 154 void u_sleep __P((int)); 155 156 /* global data in init_smp.c */ 157 extern int invltlb_ok; 158 extern int smp_active; 159 extern int smp_started; 160 extern volatile int smp_idle_loops; 161 162 #endif /* !LOCORE */ 163 #endif /* SMP && !APIC_IO */ 164 165 #endif /* _KERNEL */ 166 #endif /* _MACHINE_SMP_H_ */ 167