smp.h revision 25499
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 * 925499Sfsmp * $Id: smp.h,v 1.5 1997/05/03 18:05:31 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)); 6425499Sfsmpu_int get_isa_apic_mask __P((u_int)); 6525499Sfsmpint undirect_isa_irq __P((int)); 6625164Speterint get_eisa_apic_irq __P((int)); 6725164Speterint get_pci_apic_irq __P((int, int, int)); 6825164Speterint undirect_pci_irq __P((int)); 6925164Speterint apic_bus_type __P((int)); 7025164Speterint apic_src_bus_id __P((int, int)); 7125164Speterint apic_src_bus_irq __P((int, int)); 7225164Speterint apic_int_type __P((int, int)); 7325164Speterint apic_trigger __P((int, int)); 7425164Speterint apic_polarity __P((int, int)); 7525164Spetervoid configure_local_apic __P((void)); 7625164Spetervoid init_secondary __P((void)); 7725164Spetervoid smp_invltlb __P((void)); 7825164Speter 7925164Speter/* global data in mpapic.c */ 8025164Speterextern volatile u_int* apic_base; 8125164Speter 8225164Speter#if defined(MULTIPLE_IOAPICS) 8325164Speter#error MULTIPLE_IOAPICSXXX 8425164Speter#else 8525164Speterextern volatile u_int* io_apic_base; 8625164Speter#endif /* MULTIPLE_IOAPICS */ 8725164Speter 8825164Speter/* functions in mpapic.c */ 8925164Spetervoid apic_initialize __P((int)); 9025362Sfsmpint apic_ipi __P((int, int, int)); 9125164Speterint selected_apic_ipi __P((u_int, int, int)); 9225164Speterint io_apic_setup __P((int)); 9325164Speterint ext_int_setup __P((int, int)); 9425164Spetervoid write_io_apic_mask24 __P((int, u_int32_t)); 9525164Speter 9625164Speter#if defined(READY) 9725164Spetervoid clr_io_apic_mask24 __P((int, u_int32_t)); 9825164Spetervoid set_io_apic_mask24 __P((int, u_int32_t)); 9925164Speter#endif /* READY */ 10025164Speter 10125164Spetervoid set_apic_timer __P((int)); 10225164Speterint read_apic_timer __P((void)); 10325164Spetervoid u_sleep __P((int)); 10425164Speter 10525164Speter/* global data in init_smp.c */ 10625164Speterextern int smp_active; 10725215Sfsmpextern int invltlb_ok; 10825164Speter 10925164Speter/* in pmap.c FIXME: belongs in pmap.h??? */ 11025164Spetervoid pmap_bootstrap_apics __P((void)); 11125164Spetervoid pmap_bootstrap2 __P((void)); 11225164Speter 11325164Speter#if 0 11425164Speter/* chicken and egg problem... */ 11525164Speterstatic __inline unsigned 11625164Spetercpunumber(void) 11725164Speter{ 11825164Speter return (unsigned)ID_TO_CPU((apic_base[APIC_ID] & APIC_ID_MASK) >> 24); 11925164Speter} 12025164Speter#else 12125164Speter/* 12225164Speter * we 'borrow' this info from apic.h 12325164Speter * this will go away soon... 12425164Speter */ 12525164Speterstatic __inline unsigned 12625164Spetercpunumber(void) 12725164Speter{ 12825164Speter return (unsigned)(apic_id_to_logical[(apic_base[8] & 0x0f000000) >> 24]); 12925164Speter} 13025164Speter#endif /* 0 */ 13125164Speter 13225164Speter#endif /* SMP || APIC_IO */ 13325164Speter#endif /* KERNEL */ 13425164Speter#endif /* _MACHINE_SMP_H_ */ 135