smp.h revision 34020
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.36 1998/03/03 19:44:34 tegge Exp $ 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; 62extern u_int isr_lock; 63#ifdef RECURSIVE_MPINTRLOCK 64extern u_int mpintr_lock; 65#endif /* RECURSIVE_MPINTRLOCK */ 66 67/* functions in mplock.s */ 68void get_mplock __P((void)); 69void rel_mplock __P((void)); 70int try_mplock __P((void)); 71#ifdef RECURSIVE_MPINTRLOCK 72void get_mpintrlock __P((void)); 73void rel_mpintrlock __P((void)); 74int try_mpintrlock __P((void)); 75#endif /* RECURSIVE_MPINTRLOCK */ 76 77/* global data in apic_vector.s */ 78extern u_int ivectors[]; 79extern volatile u_int stopped_cpus; 80extern volatile u_int started_cpus; 81 82extern unsigned int checkstate_probed_cpus; 83extern unsigned int checkstate_need_ast; 84 85/* global data in apic_ipl.s */ 86extern u_int vec[]; 87extern u_int Xintr8254; 88extern u_int mask8254; 89 90/* functions in apic_ipl.s */ 91void vec8254 __P((void)); 92void apic_eoi __P((void)); 93u_int io_apic_read __P((int, int)); 94void io_apic_write __P((int, int, u_int)); 95 96/* global data in mp_machdep.c */ 97extern int bsp_apic_ready; 98extern int mp_ncpus; 99extern int mp_naps; 100extern int mp_nbusses; 101extern int mp_napics; 102extern int mp_picmode; 103extern int boot_cpu_id; 104extern vm_offset_t cpu_apic_address; 105extern vm_offset_t io_apic_address[]; 106extern u_int32_t cpu_apic_versions[]; 107extern u_int32_t io_apic_versions[]; 108extern int cpu_num_to_apic_id[]; 109extern int io_num_to_apic_id[]; 110extern int apic_id_to_logical[]; 111extern u_int all_cpus; 112extern u_char SMP_ioapic[]; 113 114/* functions in mp_machdep.c */ 115u_int mp_bootaddress __P((u_int)); 116int mp_probe __P((void)); 117void mp_start __P((void)); 118void mp_announce __P((void)); 119u_int isa_apic_mask __P((u_int)); 120int isa_apic_pin __P((int)); 121int pci_apic_pin __P((int, int, int)); 122int undirect_isa_irq __P((int)); 123int undirect_pci_irq __P((int)); 124int apic_bus_type __P((int)); 125int apic_src_bus_id __P((int, int)); 126int apic_src_bus_irq __P((int, int)); 127int apic_int_type __P((int, int)); 128int apic_trigger __P((int, int)); 129int apic_polarity __P((int, int)); 130void bsp_apic_configure __P((void)); 131void init_secondary __P((void)); 132void smp_invltlb __P((void)); 133int stop_cpus __P((u_int)); 134int restart_cpus __P((u_int)); 135#ifdef BETTER_CLOCK 136void forward_statclock __P((int pscnt)); 137void forward_hardclock __P((int pscnt)); 138#endif /* BETTER_CLOCK */ 139void forward_signal __P((struct proc *)); 140 141/* global data in mpapic.c */ 142extern volatile lapic_t lapic; 143 144#if defined(MULTIPLE_IOAPICS) 145#error MULTIPLE_IOAPICSXXX 146#else 147extern volatile ioapic_t *ioapic[]; 148#endif /* MULTIPLE_IOAPICS */ 149 150/* functions in mpapic.c */ 151void apic_dump __P((char*)); 152void apic_initialize __P((void)); 153void imen_dump __P((void)); 154int apic_ipi __P((int, int, int)); 155int selected_apic_ipi __P((u_int, int, int)); 156int io_apic_setup __P((int)); 157int ext_int_setup __P((int, int)); 158 159#if defined(READY) 160void clr_io_apic_mask24 __P((int, u_int32_t)); 161void set_io_apic_mask24 __P((int, u_int32_t)); 162#endif /* READY */ 163 164void set_apic_timer __P((int)); 165int read_apic_timer __P((void)); 166void u_sleep __P((int)); 167 168/* global data in init_smp.c */ 169extern int invltlb_ok; 170extern int smp_active; 171extern volatile int smp_idle_loops; 172 173/* 'private' global data in locore.s */ 174extern volatile u_int cpuid; 175extern volatile u_int cpu_lockid; 176extern int inside_intr; 177extern volatile u_int other_cpus; 178 179#endif /* !LOCORE */ 180#endif /* SMP || APIC_IO */ 181#endif /* KERNEL */ 182#endif /* _MACHINE_SMP_H_ */ 183