smp.h revision 28231
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 * 928231Sfsmp * $Id: smp.h,v 1.20 1997/08/15 02:14:45 smp Exp smp $ 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; 6225164Speter 6325164Speter/* functions in mplock.s */ 6425164Spetervoid get_mplock __P((void)); 6525164Spetervoid rel_mplock __P((void)); 6625320Sfsmpvoid try_mplock __P((void)); 6725164Speter 6827002Sfsmp/* global data in apic_vector.s */ 6927616Sfsmpextern u_int ivectors[]; 7027002Sfsmpextern volatile u_int stopped_cpus; 7127002Sfsmpextern volatile u_int started_cpus; 7227002Sfsmp 7327616Sfsmp/* global data in apic_ipl.s */ 7427616Sfsmpextern u_int vec[]; 7527616Sfsmpextern u_int Xintr8254; 7627616Sfsmpextern u_int mask8254; 7727808Sfsmpextern volatile struct simplelock imen_lock; 7827616Sfsmp 7927616Sfsmp/* functions in apic_ipl.s */ 8027616Sfsmpvoid vec8254 __P((void)); 8127616Sfsmpvoid INTREN __P((u_int)); 8227616Sfsmpvoid INTRDIS __P((u_int)); 8327616Sfsmpvoid apic_eoi __P((void)); 8427616Sfsmpu_int io_apic_read __P((int, int)); 8527616Sfsmpvoid io_apic_write __P((int, int, u_int)); 8627616Sfsmp 8727663Sfsmp/* functions in simplelock.s */ 8827619Sfsmp#include <machine/param.h> 8927619Sfsmpvoid s_lock_init __P((struct simplelock *)); 9027619Sfsmpvoid s_lock __P((__volatile struct simplelock *)); 9127619Sfsmpint s_lock_try __P((__volatile struct simplelock *)); 9227619Sfsmpvoid s_unlock __P((__volatile struct simplelock *)); 9327619Sfsmp 9425164Speter/* global data in mp_machdep.c */ 9525164Speterextern int mp_ncpus; 9625164Speterextern int mp_naps; 9725164Speterextern int mp_nbusses; 9825164Speterextern int mp_napics; 9925164Speterextern int mp_picmode; 10025164Speterextern int boot_cpu_id; 10125164Speterextern vm_offset_t cpu_apic_address; 10225164Speterextern vm_offset_t io_apic_address[]; 10325164Speterextern u_int32_t cpu_apic_versions[]; 10425164Speterextern u_int32_t io_apic_versions[]; 10525164Speterextern int cpu_num_to_apic_id[]; 10625164Speterextern int io_num_to_apic_id[]; 10725164Speterextern int apic_id_to_logical[]; 10827002Sfsmpextern u_int all_cpus; 10926812Speterextern u_int SMP_prvpt[]; 11026812Speterextern u_char SMP_ioapic[]; 11125164Speter 11225164Speter/* functions in mp_machdep.c */ 11325164Speteru_int mp_bootaddress __P((u_int)); 11426252Sfsmpint mp_probe __P((void)); 11525164Spetervoid mp_start __P((void)); 11625164Spetervoid mp_announce __P((void)); 11726948Sfsmpu_int isa_apic_mask __P((u_int)); 11826948Sfsmpint isa_apic_pin __P((int)); 11926948Sfsmpint pci_apic_pin __P((int, int, int)); 12025499Sfsmpint undirect_isa_irq __P((int)); 12125164Speterint undirect_pci_irq __P((int)); 12225164Speterint apic_bus_type __P((int)); 12325164Speterint apic_src_bus_id __P((int, int)); 12425164Speterint apic_src_bus_irq __P((int, int)); 12525164Speterint apic_int_type __P((int, int)); 12625164Speterint apic_trigger __P((int, int)); 12725164Speterint apic_polarity __P((int, int)); 12827285Sfsmpvoid bsp_apic_configure __P((void)); 12925164Spetervoid init_secondary __P((void)); 13025164Spetervoid smp_invltlb __P((void)); 13127002Sfsmpint stop_cpus __P((u_int)); 13227002Sfsmpint restart_cpus __P((u_int)); 13325164Speter 13425164Speter/* global data in mpapic.c */ 13526812Speterextern volatile lapic_t lapic; 13625164Speter 13725164Speter#if defined(MULTIPLE_IOAPICS) 13825164Speter#error MULTIPLE_IOAPICSXXX 13925164Speter#else 14026812Speterextern volatile ioapic_t *ioapic[]; 14125164Speter#endif /* MULTIPLE_IOAPICS */ 14225164Speter 14325164Speter/* functions in mpapic.c */ 14427559Sfsmpvoid apic_dump __P((char*)); 14527285Sfsmpvoid apic_initialize __P((void)); 14627616Sfsmpvoid imen_dump __P((void)); 14725362Sfsmpint apic_ipi __P((int, int, int)); 14825164Speterint selected_apic_ipi __P((u_int, int, int)); 14925164Speterint io_apic_setup __P((int)); 15025164Speterint ext_int_setup __P((int, int)); 15125164Speter 15225164Speter#if defined(READY) 15325164Spetervoid clr_io_apic_mask24 __P((int, u_int32_t)); 15425164Spetervoid set_io_apic_mask24 __P((int, u_int32_t)); 15525164Speter#endif /* READY */ 15625164Speter 15725164Spetervoid set_apic_timer __P((int)); 15825164Speterint read_apic_timer __P((void)); 15925164Spetervoid u_sleep __P((int)); 16025164Speter 16125164Speter/* global data in init_smp.c */ 16228231Sfsmpextern int invltlb_ok; 16325164Speterextern int smp_active; 16428231Sfsmpextern volatile int smp_idle_loops; 16525164Speter 16627002Sfsmp/* 'private' global data in locore.s */ 16726812Speterextern volatile u_int cpuid; 16826812Speterextern volatile u_int cpu_lockid; 16927002Sfsmpextern volatile u_int other_cpus; 17025164Speter 17127728Sfsmp#endif /* !LOCORE */ 17225164Speter#endif /* SMP || APIC_IO */ 17325164Speter#endif /* KERNEL */ 17425164Speter#endif /* _MACHINE_SMP_H_ */ 175