smp.h revision 51661
125164Speter/* 225164Speter * ---------------------------------------------------------------------------- 325164Speter * "THE BEER-WARE LICENSE" (Revision 42): 425164Speter * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 525164Speter * can do whatever you want with this stuff. If we meet some day, and you think 625164Speter * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 725164Speter * ---------------------------------------------------------------------------- 825164Speter * 950477Speter * $FreeBSD: head/sys/i386/include/smp.h 51661 1999-09-25 18:36:31Z mjacob $ 1025164Speter * 1125164Speter */ 1225164Speter 1325164Speter#ifndef _MACHINE_SMP_H_ 1425164Speter#define _MACHINE_SMP_H_ 1525164Speter 1625164Speter#ifdef KERNEL 1725164Speter 1825517Sfsmp#if defined(SMP) && !defined(APIC_IO) 1925517Sfsmp# error APIC_IO required for SMP, add "options APIC_IO" to your config file. 2027002Sfsmp#endif /* SMP && !APIC_IO */ 2125517Sfsmp 2227728Sfsmp/* Number of CPUs. */ 2325164Speter#if defined(SMP) && !defined(NCPU) 2425164Speter# define NCPU 2 2525164Speter#endif /* SMP && NCPU */ 2625164Speter 2727728Sfsmp/* Number of IO APICs. */ 2827728Sfsmp#if defined(APIC_IO) && !defined(NAPIC) 2927728Sfsmp# define NAPIC 1 3027728Sfsmp#endif /* SMP && NAPIC */ 3127728Sfsmp 3227728Sfsmp 3325164Speter#if defined(SMP) || defined(APIC_IO) 3425164Speter 3527728Sfsmp#ifndef LOCORE 3627728Sfsmp 3727002Sfsmp/* 3827002Sfsmp * For sending values to POST displays. 3927252Sfsmp * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 4027002Sfsmp */ 4127252Sfsmpextern int current_postcode; /** XXX currently in mp_machdep.c */ 4227252Sfsmp#define POSTCODE(X) current_postcode = (X), \ 4327252Sfsmp outb(0x80, current_postcode) 4427252Sfsmp#define POSTCODE_LO(X) current_postcode &= 0xf0, \ 4527252Sfsmp current_postcode |= ((X) & 0x0f), \ 4627252Sfsmp outb(0x80, current_postcode) 4727252Sfsmp#define POSTCODE_HI(X) current_postcode &= 0x0f, \ 4827252Sfsmp current_postcode |= (((X) << 4) & 0xf0), \ 4927252Sfsmp outb(0x80, current_postcode) 5027002Sfsmp 5127252Sfsmp 5226269Sfsmp#include <machine/apic.h> 5326269Sfsmp 5425164Speter/* global data in mpboot.s */ 5525164Speterextern int bootMP_size; 5625164Speter 5725164Speter/* functions in mpboot.s */ 5825164Spetervoid bootMP __P((void)); 5925164Speter 6025164Speter/* global data in mplock.s */ 6125164Speterextern u_int mp_lock; 6228441Sfsmpextern u_int isr_lock; 6328921Sfsmp#ifdef RECURSIVE_MPINTRLOCK 6428921Sfsmpextern u_int mpintr_lock; 6528921Sfsmp#endif /* RECURSIVE_MPINTRLOCK */ 6625164Speter 6725164Speter/* functions in mplock.s */ 6825164Spetervoid get_mplock __P((void)); 6925164Spetervoid rel_mplock __P((void)); 7034206Sdysonint try_mplock __P((void)); 7128921Sfsmp#ifdef RECURSIVE_MPINTRLOCK 7228921Sfsmpvoid get_mpintrlock __P((void)); 7328921Sfsmpvoid rel_mpintrlock __P((void)); 7434206Sdysonint try_mpintrlock __P((void)); 7528921Sfsmp#endif /* RECURSIVE_MPINTRLOCK */ 7625164Speter 7727002Sfsmp/* global data in apic_vector.s */ 7827002Sfsmpextern volatile u_int stopped_cpus; 7927002Sfsmpextern volatile u_int started_cpus; 8027002Sfsmp 8134989Steggeextern volatile u_int checkstate_probed_cpus; 8234989Steggeextern volatile u_int checkstate_need_ast; 8336135Steggeextern volatile u_int resched_cpus; 8436135Steggeextern void (*cpustop_restartfunc) __P((void)); 8531639Sfsmp 8627616Sfsmp/* functions in apic_ipl.s */ 8727616Sfsmpvoid apic_eoi __P((void)); 8827616Sfsmpu_int io_apic_read __P((int, int)); 8927616Sfsmpvoid io_apic_write __P((int, int, u_int)); 9027616Sfsmp 9125164Speter/* global data in mp_machdep.c */ 9228669Sfsmpextern int bsp_apic_ready; 9325164Speterextern int mp_ncpus; 9425164Speterextern int mp_naps; 9525164Speterextern int mp_nbusses; 9625164Speterextern int mp_napics; 9725164Speterextern int mp_picmode; 9825164Speterextern int boot_cpu_id; 9925164Speterextern vm_offset_t cpu_apic_address; 10025164Speterextern vm_offset_t io_apic_address[]; 10125164Speterextern u_int32_t cpu_apic_versions[]; 10225164Speterextern u_int32_t io_apic_versions[]; 10325164Speterextern int cpu_num_to_apic_id[]; 10425164Speterextern int io_num_to_apic_id[]; 10525164Speterextern int apic_id_to_logical[]; 10638888Stegge#define APIC_INTMAPSIZE 24 10738888Steggestruct apic_intmapinfo { 10838888Stegge int ioapic; 10938888Stegge int int_pin; 11038888Stegge volatile void *apic_address; 11138888Stegge int redirindex; 11238888Stegge}; 11338888Steggeextern struct apic_intmapinfo int_to_apicintpin[]; 11427002Sfsmpextern u_int all_cpus; 11536135Steggeextern struct pcb stoppcbs[]; 11625164Speter 11725164Speter/* functions in mp_machdep.c */ 11825164Speteru_int mp_bootaddress __P((u_int)); 11926252Sfsmpint mp_probe __P((void)); 12025164Spetervoid mp_start __P((void)); 12125164Spetervoid mp_announce __P((void)); 12226948Sfsmpu_int isa_apic_mask __P((u_int)); 12338888Steggeint isa_apic_irq __P((int)); 12438888Steggeint pci_apic_irq __P((int, int, int)); 12538888Steggeint apic_irq __P((int, int)); 12638888Steggeint next_apic_irq __P((int)); 12725499Sfsmpint undirect_isa_irq __P((int)); 12825164Speterint undirect_pci_irq __P((int)); 12925164Speterint apic_bus_type __P((int)); 13025164Speterint apic_src_bus_id __P((int, int)); 13125164Speterint apic_src_bus_irq __P((int, int)); 13225164Speterint apic_int_type __P((int, int)); 13325164Speterint apic_trigger __P((int, int)); 13425164Speterint apic_polarity __P((int, int)); 13527285Sfsmpvoid bsp_apic_configure __P((void)); 13625164Spetervoid init_secondary __P((void)); 13725164Spetervoid smp_invltlb __P((void)); 13827002Sfsmpint stop_cpus __P((u_int)); 13927002Sfsmpint restart_cpus __P((u_int)); 14034017Stegge#ifdef BETTER_CLOCK 14134017Steggevoid forward_statclock __P((int pscnt)); 14234017Steggevoid forward_hardclock __P((int pscnt)); 14334017Stegge#endif /* BETTER_CLOCK */ 14434020Steggevoid forward_signal __P((struct proc *)); 14536135Steggevoid forward_roundrobin __P((void)); 14634021Stegge#ifdef APIC_INTR_REORDER 14734021Steggevoid set_lapic_isrloc __P((int, int)); 14834021Stegge#endif /* APIC_INTR_REORDER */ 14948924Smsmithvoid smp_rendezvous_action __P((void)); 15048924Smsmithvoid smp_rendezvous __P((void (*)(void *), 15148924Smsmith void (*)(void *), 15248924Smsmith void (*)(void *), 15348924Smsmith void *arg)); 15425164Speter 15525164Speter/* global data in mpapic.c */ 15626812Speterextern volatile lapic_t lapic; 15726812Speterextern volatile ioapic_t *ioapic[]; 15825164Speter 15925164Speter/* functions in mpapic.c */ 16027559Sfsmpvoid apic_dump __P((char*)); 16127285Sfsmpvoid apic_initialize __P((void)); 16227616Sfsmpvoid imen_dump __P((void)); 16325362Sfsmpint apic_ipi __P((int, int, int)); 16425164Speterint selected_apic_ipi __P((u_int, int, int)); 16525164Speterint io_apic_setup __P((int)); 16625164Speterint ext_int_setup __P((int, int)); 16725164Speter 16825164Speter#if defined(READY) 16925164Spetervoid clr_io_apic_mask24 __P((int, u_int32_t)); 17025164Spetervoid set_io_apic_mask24 __P((int, u_int32_t)); 17125164Speter#endif /* READY */ 17225164Speter 17325164Spetervoid set_apic_timer __P((int)); 17425164Speterint read_apic_timer __P((void)); 17525164Spetervoid u_sleep __P((int)); 17625164Speter 17725164Speter/* global data in init_smp.c */ 17828231Sfsmpextern int invltlb_ok; 17925164Speterextern int smp_active; 18051661Smjacobextern int smp_started; 18128231Sfsmpextern volatile int smp_idle_loops; 18225164Speter 18327728Sfsmp#endif /* !LOCORE */ 18425164Speter#endif /* SMP || APIC_IO */ 18525164Speter#endif /* KERNEL */ 18625164Speter#endif /* _MACHINE_SMP_H_ */ 187