smp.h revision 28231
1/* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 * 9 * $Id: smp.h,v 1.20 1997/08/15 02:14:45 smp Exp smp $ 10 * 11 */ 12 13#ifndef _MACHINE_SMP_H_ 14#define _MACHINE_SMP_H_ 15 16#ifdef KERNEL 17 18#if defined(SMP) && !defined(APIC_IO) 19# error APIC_IO required for SMP, add "options APIC_IO" to your config file. 20#endif /* SMP && !APIC_IO */ 21 22/* Number of CPUs. */ 23#if defined(SMP) && !defined(NCPU) 24# define NCPU 2 25#endif /* SMP && NCPU */ 26 27/* Number of IO APICs. */ 28#if defined(APIC_IO) && !defined(NAPIC) 29# define NAPIC 1 30#endif /* SMP && NAPIC */ 31 32 33#if defined(SMP) || defined(APIC_IO) 34 35#ifndef LOCORE 36 37/* 38 * For sending values to POST displays. 39 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 40 */ 41extern int current_postcode; /** XXX currently in mp_machdep.c */ 42#define POSTCODE(X) current_postcode = (X), \ 43 outb(0x80, current_postcode) 44#define POSTCODE_LO(X) current_postcode &= 0xf0, \ 45 current_postcode |= ((X) & 0x0f), \ 46 outb(0x80, current_postcode) 47#define POSTCODE_HI(X) current_postcode &= 0x0f, \ 48 current_postcode |= (((X) << 4) & 0xf0), \ 49 outb(0x80, current_postcode) 50 51 52#include <machine/apic.h> 53 54/* global data in mpboot.s */ 55extern int bootMP_size; 56 57/* functions in mpboot.s */ 58void bootMP __P((void)); 59 60/* global data in mplock.s */ 61extern u_int mp_lock; 62 63/* functions in mplock.s */ 64void get_mplock __P((void)); 65void rel_mplock __P((void)); 66void try_mplock __P((void)); 67 68/* global data in apic_vector.s */ 69extern u_int ivectors[]; 70extern volatile u_int stopped_cpus; 71extern volatile u_int started_cpus; 72 73/* global data in apic_ipl.s */ 74extern u_int vec[]; 75extern u_int Xintr8254; 76extern u_int mask8254; 77extern volatile struct simplelock imen_lock; 78 79/* functions in apic_ipl.s */ 80void vec8254 __P((void)); 81void INTREN __P((u_int)); 82void INTRDIS __P((u_int)); 83void apic_eoi __P((void)); 84u_int io_apic_read __P((int, int)); 85void io_apic_write __P((int, int, u_int)); 86 87/* functions in simplelock.s */ 88#include <machine/param.h> 89void s_lock_init __P((struct simplelock *)); 90void s_lock __P((__volatile struct simplelock *)); 91int s_lock_try __P((__volatile struct simplelock *)); 92void s_unlock __P((__volatile struct simplelock *)); 93 94/* global data in mp_machdep.c */ 95extern int mp_ncpus; 96extern int mp_naps; 97extern int mp_nbusses; 98extern int mp_napics; 99extern int mp_picmode; 100extern int boot_cpu_id; 101extern vm_offset_t cpu_apic_address; 102extern vm_offset_t io_apic_address[]; 103extern u_int32_t cpu_apic_versions[]; 104extern u_int32_t io_apic_versions[]; 105extern int cpu_num_to_apic_id[]; 106extern int io_num_to_apic_id[]; 107extern int apic_id_to_logical[]; 108extern u_int all_cpus; 109extern u_int SMP_prvpt[]; 110extern u_char SMP_ioapic[]; 111 112/* functions in mp_machdep.c */ 113u_int mp_bootaddress __P((u_int)); 114int mp_probe __P((void)); 115void mp_start __P((void)); 116void mp_announce __P((void)); 117u_int isa_apic_mask __P((u_int)); 118int isa_apic_pin __P((int)); 119int pci_apic_pin __P((int, int, int)); 120int undirect_isa_irq __P((int)); 121int undirect_pci_irq __P((int)); 122int apic_bus_type __P((int)); 123int apic_src_bus_id __P((int, int)); 124int apic_src_bus_irq __P((int, int)); 125int apic_int_type __P((int, int)); 126int apic_trigger __P((int, int)); 127int apic_polarity __P((int, int)); 128void bsp_apic_configure __P((void)); 129void init_secondary __P((void)); 130void smp_invltlb __P((void)); 131int stop_cpus __P((u_int)); 132int restart_cpus __P((u_int)); 133 134/* global data in mpapic.c */ 135extern volatile lapic_t lapic; 136 137#if defined(MULTIPLE_IOAPICS) 138#error MULTIPLE_IOAPICSXXX 139#else 140extern volatile ioapic_t *ioapic[]; 141#endif /* MULTIPLE_IOAPICS */ 142 143/* functions in mpapic.c */ 144void apic_dump __P((char*)); 145void apic_initialize __P((void)); 146void imen_dump __P((void)); 147int apic_ipi __P((int, int, int)); 148int selected_apic_ipi __P((u_int, int, int)); 149int io_apic_setup __P((int)); 150int ext_int_setup __P((int, int)); 151 152#if defined(READY) 153void clr_io_apic_mask24 __P((int, u_int32_t)); 154void set_io_apic_mask24 __P((int, u_int32_t)); 155#endif /* READY */ 156 157void set_apic_timer __P((int)); 158int read_apic_timer __P((void)); 159void u_sleep __P((int)); 160 161/* global data in init_smp.c */ 162extern int invltlb_ok; 163extern int smp_active; 164extern volatile int smp_idle_loops; 165 166/* 'private' global data in locore.s */ 167extern volatile u_int cpuid; 168extern volatile u_int cpu_lockid; 169extern volatile u_int other_cpus; 170 171#endif /* !LOCORE */ 172#endif /* SMP || APIC_IO */ 173#endif /* KERNEL */ 174#endif /* _MACHINE_SMP_H_ */ 175