smp.h revision 25362
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 * 925362Sfsmp * $Id: smp.h,v 1.3 1997/04/30 19:04:26 fsmp Exp $ 1025164Speter * 1125164Speter */ 1225164Speter 1325164Speter#ifndef _MACHINE_SMP_H_ 1425164Speter#define _MACHINE_SMP_H_ 1525164Speter 1625164Speter#ifdef KERNEL 1725164Speter 1825164Speter#include "opt_smp.h" 1925164Speter 2025164Speter#if defined(SMP) && !defined(NCPU) 2125164Speter# define NCPU 2 2225164Speter#endif /* SMP && NCPU */ 2325164Speter 2425164Speter#if defined(SMP) || defined(APIC_IO) 2525164Speter 2625164Speter/* global data in mpboot.s */ 2725164Speterextern int bootMP_size; 2825164Speter 2925164Speter/* functions in mpboot.s */ 3025164Spetervoid bootMP __P((void)); 3125164Speter 3225164Speter/* global data in mplock.s */ 3325164Speterextern u_int mp_lock; 3425164Speter 3525164Speter/* functions in mplock.s */ 3625164Spetervoid get_mplock __P((void)); 3725164Spetervoid rel_mplock __P((void)); 3825320Sfsmpvoid try_mplock __P((void)); 3925164Speter 4025164Speter/* global data in mp_machdep.c */ 4125164Speterextern struct proc* SMPcurproc[NCPU]; 4225164Speterextern struct pcb* SMPcurpcb[NCPU]; 4325164Speterextern struct timeval SMPruntime[NCPU]; 4425164Speterextern int mp_ncpus; 4525164Speterextern int mp_naps; 4625164Speterextern int mp_nbusses; 4725164Speterextern int mp_napics; 4825164Speterextern int mp_picmode; 4925164Speterextern int mpenabled; 5025164Speterextern int boot_cpu_id; 5125164Speterextern vm_offset_t cpu_apic_address; 5225164Speterextern vm_offset_t io_apic_address[]; 5325164Speterextern u_int32_t cpu_apic_versions[]; 5425164Speterextern u_int32_t io_apic_versions[]; 5525164Speterextern int cpu_num_to_apic_id[]; 5625164Speterextern int io_num_to_apic_id[]; 5725164Speterextern int apic_id_to_logical[]; 5825164Speter 5925164Speter/* functions in mp_machdep.c */ 6025164Speteru_int mp_bootaddress __P((u_int)); 6125164Spetervoid mp_start __P((void)); 6225164Spetervoid mp_announce __P((void)); 6325164Speterint get_isa_apic_irq __P((int)); 6425164Speterint get_eisa_apic_irq __P((int)); 6525164Speterint get_pci_apic_irq __P((int, int, int)); 6625164Speterint undirect_pci_irq __P((int)); 6725164Speterint apic_bus_type __P((int)); 6825164Speterint apic_src_bus_id __P((int, int)); 6925164Speterint apic_src_bus_irq __P((int, int)); 7025164Speterint apic_int_type __P((int, int)); 7125164Speterint apic_trigger __P((int, int)); 7225164Speterint apic_polarity __P((int, int)); 7325164Spetervoid configure_local_apic __P((void)); 7425164Spetervoid init_secondary __P((void)); 7525164Spetervoid smp_invltlb __P((void)); 7625164Speter 7725164Speter/* global data in mpapic.c */ 7825164Speterextern volatile u_int* apic_base; 7925164Speter 8025164Speter#if defined(MULTIPLE_IOAPICS) 8125164Speter#error MULTIPLE_IOAPICSXXX 8225164Speter#else 8325164Speterextern volatile u_int* io_apic_base; 8425164Speter#endif /* MULTIPLE_IOAPICS */ 8525164Speter 8625164Speter/* functions in mpapic.c */ 8725164Spetervoid apic_initialize __P((int)); 8825362Sfsmpint apic_ipi __P((int, int, int)); 8925164Speterint selected_apic_ipi __P((u_int, int, int)); 9025164Speterint io_apic_setup __P((int)); 9125164Speterint ext_int_setup __P((int, int)); 9225164Spetervoid write_io_apic_mask24 __P((int, u_int32_t)); 9325164Speter 9425164Speter#if defined(READY) 9525164Spetervoid clr_io_apic_mask24 __P((int, u_int32_t)); 9625164Spetervoid set_io_apic_mask24 __P((int, u_int32_t)); 9725164Speter#endif /* READY */ 9825164Speter 9925164Spetervoid set_apic_timer __P((int)); 10025164Speterint read_apic_timer __P((void)); 10125164Spetervoid u_sleep __P((int)); 10225164Speter 10325164Speter/* global data in init_smp.c */ 10425164Speterextern int smp_active; 10525215Sfsmpextern int invltlb_ok; 10625164Speter 10725164Speter/* in pmap.c FIXME: belongs in pmap.h??? */ 10825164Spetervoid pmap_bootstrap_apics __P((void)); 10925164Spetervoid pmap_bootstrap2 __P((void)); 11025164Speter 11125164Speter#if 0 11225164Speter/* chicken and egg problem... */ 11325164Speterstatic __inline unsigned 11425164Spetercpunumber(void) 11525164Speter{ 11625164Speter return (unsigned)ID_TO_CPU((apic_base[APIC_ID] & APIC_ID_MASK) >> 24); 11725164Speter} 11825164Speter#else 11925164Speter/* 12025164Speter * we 'borrow' this info from apic.h 12125164Speter * this will go away soon... 12225164Speter */ 12325164Speterstatic __inline unsigned 12425164Spetercpunumber(void) 12525164Speter{ 12625164Speter return (unsigned)(apic_id_to_logical[(apic_base[8] & 0x0f000000) >> 24]); 12725164Speter} 12825164Speter#endif /* 0 */ 12925164Speter 13025164Speter#endif /* SMP || APIC_IO */ 13125164Speter#endif /* KERNEL */ 13225164Speter#endif /* _MACHINE_SMP_H_ */ 133