smp.h revision 105311
1220497Smarkm/* 2220497Smarkm * ---------------------------------------------------------------------------- 3220497Smarkm * "THE BEER-WARE LICENSE" (Revision 42): 4220497Smarkm * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 5220497Smarkm * can do whatever you want with this stuff. If we meet some day, and you think 6220497Smarkm * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7220497Smarkm * ---------------------------------------------------------------------------- 8220497Smarkm * 9220497Smarkm * $FreeBSD: head/sys/amd64/include/smp.h 105311 2002-10-17 05:51:36Z pirzyk $ 10220497Smarkm * 11220497Smarkm */ 12220497Smarkm 13220497Smarkm#ifndef _MACHINE_SMP_H_ 14220497Smarkm#define _MACHINE_SMP_H_ 15220497Smarkm 16220497Smarkm#ifdef _KERNEL 17220497Smarkm 18220497Smarkm#if defined(SMP) && defined(I386_CPU) && !defined(COMPILING_LINT) 19220497Smarkm#error SMP not supported with I386_CPU 20220497Smarkm#endif 21220497Smarkm#if defined(SMP) && !defined(APIC_IO) 22220497Smarkm# error APIC_IO required for SMP, add "options APIC_IO" to your config file. 23220497Smarkm#endif /* SMP && !APIC_IO */ 24220497Smarkm#if defined(SMP) && defined(CPU_DISABLE_CMPXCHG) 25220497Smarkm#error SMP not supported with CPU_DISABLE_CMPXCHG 26220497Smarkm#endif 27220497Smarkm 28220497Smarkm#if defined(SMP) || defined(APIC_IO) 29220497Smarkm 30220497Smarkm#ifndef LOCORE 31220497Smarkm 32220497Smarkm/* 33220497Smarkm * For sending values to POST displays. 34220497Smarkm * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 35220497Smarkm */ 36220497Smarkmextern int current_postcode; /** XXX currently in mp_machdep.c */ 37220497Smarkm#define POSTCODE(X) current_postcode = (X), \ 38220497Smarkm outb(0x80, current_postcode) 39220497Smarkm#define POSTCODE_LO(X) current_postcode &= 0xf0, \ 40220497Smarkm current_postcode |= ((X) & 0x0f), \ 41220497Smarkm outb(0x80, current_postcode) 42220497Smarkm#define POSTCODE_HI(X) current_postcode &= 0x0f, \ 43220497Smarkm current_postcode |= (((X) << 4) & 0xf0), \ 44220497Smarkm outb(0x80, current_postcode) 45220497Smarkm 46220497Smarkm 47220497Smarkm#include <sys/bus.h> /* XXX */ 48220497Smarkm#include <machine/apic.h> 49220497Smarkm#include <machine/frame.h> 50220497Smarkm#include <i386/isa/icu.h> 51220497Smarkm#include <i386/isa/intr_machdep.h> 52220497Smarkm 53220497Smarkm/* 54220497Smarkm * Interprocessor interrupts for SMP. 55220497Smarkm */ 56220497Smarkm#define IPI_INVLTLB XINVLTLB_OFFSET 57220497Smarkm#define IPI_INVLPG XINVLPG_OFFSET 58220497Smarkm#define IPI_INVLRNG XINVLRNG_OFFSET 59220497Smarkm#define IPI_RENDEZVOUS XRENDEZVOUS_OFFSET 60220497Smarkm#define IPI_AST XCPUAST_OFFSET 61220497Smarkm#define IPI_STOP XCPUSTOP_OFFSET 62220497Smarkm#define IPI_HARDCLOCK XHARDCLOCK_OFFSET 63220497Smarkm#define IPI_STATCLOCK XSTATCLOCK_OFFSET 64220497Smarkm 65220497Smarkm/* global data in mpboot.s */ 66220497Smarkmextern int bootMP_size; 67220497Smarkm 68220497Smarkm/* functions in mpboot.s */ 69220497Smarkmvoid bootMP(void); 70220497Smarkm 71220497Smarkm/* global data in mp_machdep.c */ 72220497Smarkmextern int bsp_apic_ready; 73220497Smarkmextern int mp_naps; 74220497Smarkmextern int mp_nbusses; 75220497Smarkmextern int mp_napics; 76220497Smarkmextern int mp_picmode; 77220497Smarkmextern int boot_cpu_id; 78220497Smarkmextern vm_offset_t cpu_apic_address; 79220497Smarkmextern vm_offset_t io_apic_address[]; 80220497Smarkmextern u_int32_t cpu_apic_versions[]; 81220497Smarkmextern u_int32_t *io_apic_versions; 82220497Smarkmextern int cpu_num_to_apic_id[]; 83220497Smarkmextern int io_num_to_apic_id[]; 84220497Smarkmextern int apic_id_to_logical[]; 85220497Smarkm#define APIC_INTMAPSIZE 32 86220497Smarkmstruct apic_intmapinfo { 87220497Smarkm int ioapic; 88220497Smarkm int int_pin; 89220497Smarkm volatile void *apic_address; 90220497Smarkm int redirindex; 91220497Smarkm}; 92220497Smarkmextern struct apic_intmapinfo int_to_apicintpin[]; 93220497Smarkmextern struct pcb stoppcbs[]; 94220497Smarkm 95220497Smarkm/* functions in mp_machdep.c */ 96220497Smarkmvoid i386_mp_probe(void); 97220497Smarkmu_int mp_bootaddress(u_int); 98220497Smarkmu_int isa_apic_mask(u_int); 99220497Smarkmint isa_apic_irq(int); 100220497Smarkmint pci_apic_irq(int, int, int); 101220497Smarkmint apic_irq(int, int); 102220497Smarkmint next_apic_irq(int); 103220497Smarkmint undirect_isa_irq(int); 104220497Smarkmint undirect_pci_irq(int); 105220497Smarkmint apic_bus_type(int); 106220497Smarkmint apic_src_bus_id(int, int); 107220497Smarkmint apic_src_bus_irq(int, int); 108220497Smarkmint apic_int_type(int, int); 109220497Smarkmint apic_trigger(int, int); 110220497Smarkmint apic_polarity(int, int); 111220497Smarkmvoid assign_apic_irq(int apic, int intpin, int irq); 112220497Smarkmvoid revoke_apic_irq(int irq); 113220497Smarkmvoid bsp_apic_configure(void); 114220497Smarkmvoid init_secondary(void); 115220497Smarkmvoid forward_statclock(void); 116220497Smarkmvoid forwarded_statclock(struct trapframe frame); 117220497Smarkmvoid forward_hardclock(void); 118220497Smarkmvoid forwarded_hardclock(struct trapframe frame); 119220497Smarkmvoid ipi_selected(u_int cpus, u_int ipi); 120220497Smarkmvoid ipi_all(u_int ipi); 121220497Smarkmvoid ipi_all_but_self(u_int ipi); 122220497Smarkmvoid ipi_self(u_int ipi); 123220497Smarkm#ifdef APIC_INTR_REORDER 124220497Smarkmvoid set_lapic_isrloc(int, int); 125220497Smarkm#endif /* APIC_INTR_REORDER */ 126220497Smarkmvoid smp_invlpg(vm_offset_t addr); 127220497Smarkmvoid smp_masked_invlpg(u_int mask, vm_offset_t addr); 128220497Smarkmvoid smp_invlpg_range(vm_offset_t startva, vm_offset_t endva); 129220497Smarkmvoid smp_masked_invlpg_range(u_int mask, vm_offset_t startva, 130220497Smarkm vm_offset_t endva); 131220497Smarkmvoid smp_invltlb(void); 132220497Smarkmvoid smp_masked_invltlb(u_int mask); 133220497Smarkm 134220497Smarkm/* global data in mpapic.c */ 135220497Smarkmextern volatile lapic_t lapic; 136220497Smarkmextern volatile ioapic_t **ioapic; 137220497Smarkm 138220497Smarkm/* functions in mpapic.c */ 139220497Smarkmvoid apic_dump(char*); 140220497Smarkmvoid apic_initialize(void); 141220497Smarkmvoid imen_dump(void); 142220497Smarkmint apic_ipi(int, int, int); 143220497Smarkmint selected_apic_ipi(u_int, int, int); 144220497Smarkmint io_apic_setup(int); 145220497Smarkmvoid io_apic_setup_intpin(int, int); 146220497Smarkmvoid io_apic_set_id(int, int); 147220497Smarkmint io_apic_get_id(int); 148220497Smarkmint ext_int_setup(int, int); 149220497Smarkm 150220497Smarkmvoid set_apic_timer(int); 151220497Smarkmint read_apic_timer(void); 152220497Smarkmvoid u_sleep(int); 153220497Smarkmu_int io_apic_read(int, int); 154220497Smarkmvoid io_apic_write(int, int, u_int); 155220497Smarkm 156220497Smarkm#endif /* !LOCORE */ 157220497Smarkm#endif /* SMP && !APIC_IO */ 158220497Smarkm 159220497Smarkm#endif /* _KERNEL */ 160220497Smarkm#endif /* _MACHINE_SMP_H_ */ 161220497Smarkm