x86_smp.h revision 34020
1195534Sscottl/* 2195534Sscottl * ---------------------------------------------------------------------------- 3195534Sscottl * "THE BEER-WARE LICENSE" (Revision 42): 4195534Sscottl * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 5195534Sscottl * can do whatever you want with this stuff. If we meet some day, and you think 6195534Sscottl * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7195534Sscottl * ---------------------------------------------------------------------------- 8195534Sscottl * 9195534Sscottl * $Id: smp.h,v 1.36 1998/03/03 19:44:34 tegge Exp $ 10195534Sscottl * 11195534Sscottl */ 12195534Sscottl 13195534Sscottl#ifndef _MACHINE_SMP_H_ 14195534Sscottl#define _MACHINE_SMP_H_ 15195534Sscottl 16195534Sscottl#ifdef KERNEL 17195534Sscottl 18195534Sscottl#if defined(SMP) && !defined(APIC_IO) 19195534Sscottl# error APIC_IO required for SMP, add "options APIC_IO" to your config file. 20195534Sscottl#endif /* SMP && !APIC_IO */ 21195534Sscottl 22195534Sscottl/* Number of CPUs. */ 23195534Sscottl#if defined(SMP) && !defined(NCPU) 24195534Sscottl# define NCPU 2 25195534Sscottl#endif /* SMP && NCPU */ 26195534Sscottl 27195534Sscottl/* Number of IO APICs. */ 28195534Sscottl#if defined(APIC_IO) && !defined(NAPIC) 29195534Sscottl# define NAPIC 1 30195534Sscottl#endif /* SMP && NAPIC */ 31195534Sscottl 32195534Sscottl 33195534Sscottl#if defined(SMP) || defined(APIC_IO) 34195534Sscottl 35195534Sscottl#ifndef LOCORE 36195534Sscottl 37195534Sscottl/* 38195534Sscottl * For sending values to POST displays. 39195534Sscottl * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 40195534Sscottl */ 41195534Sscottlextern int current_postcode; /** XXX currently in mp_machdep.c */ 42195534Sscottl#define POSTCODE(X) current_postcode = (X), \ 43195534Sscottl outb(0x80, current_postcode) 44195534Sscottl#define POSTCODE_LO(X) current_postcode &= 0xf0, \ 45195534Sscottl current_postcode |= ((X) & 0x0f), \ 46195534Sscottl outb(0x80, current_postcode) 47195534Sscottl#define POSTCODE_HI(X) current_postcode &= 0x0f, \ 48195534Sscottl current_postcode |= (((X) << 4) & 0xf0), \ 49195534Sscottl outb(0x80, current_postcode) 50195534Sscottl 51195534Sscottl 52195534Sscottl#include <machine/apic.h> 53195534Sscottl 54195534Sscottl/* global data in mpboot.s */ 55195534Sscottlextern int bootMP_size; 56195534Sscottl 57195534Sscottl/* functions in mpboot.s */ 58195534Sscottlvoid bootMP __P((void)); 59195534Sscottl 60195534Sscottl/* global data in mplock.s */ 61195534Sscottlextern u_int mp_lock; 62195534Sscottlextern u_int isr_lock; 63195534Sscottl#ifdef RECURSIVE_MPINTRLOCK 64199178Smavextern u_int mpintr_lock; 65195534Sscottl#endif /* RECURSIVE_MPINTRLOCK */ 66195534Sscottl 67199178Smav/* functions in mplock.s */ 68195534Sscottlvoid get_mplock __P((void)); 69195534Sscottlvoid rel_mplock __P((void)); 70195534Sscottlint try_mplock __P((void)); 71195534Sscottl#ifdef RECURSIVE_MPINTRLOCK 72195534Sscottlvoid get_mpintrlock __P((void)); 73195534Sscottlvoid rel_mpintrlock __P((void)); 74195534Sscottlint try_mpintrlock __P((void)); 75195653Smav#endif /* RECURSIVE_MPINTRLOCK */ 76198708Smav 77198708Smav/* global data in apic_vector.s */ 78195534Sscottlextern u_int ivectors[]; 79195534Sscottlextern volatile u_int stopped_cpus; 80195653Smavextern volatile u_int started_cpus; 81195534Sscottl 82195534Sscottlextern unsigned int checkstate_probed_cpus; 83195534Sscottlextern unsigned int checkstate_need_ast; 84195534Sscottl 85203421Smav/* global data in apic_ipl.s */ 86195534Sscottlextern u_int vec[]; 87207499Smavextern u_int Xintr8254; 88207499Smavextern u_int mask8254; 89207499Smav 90198708Smav/* functions in apic_ipl.s */ 91195534Sscottlvoid vec8254 __P((void)); 92195534Sscottlvoid apic_eoi __P((void)); 93195534Sscottlu_int io_apic_read __P((int, int)); 94195534Sscottlvoid io_apic_write __P((int, int, u_int)); 95195534Sscottl 96195534Sscottl/* global data in mp_machdep.c */ 97195534Sscottlextern int bsp_apic_ready; 98195534Sscottlextern int mp_ncpus; 99195534Sscottlextern int mp_naps; 100195534Sscottlextern int mp_nbusses; 101203421Smavextern int mp_napics; 102195534Sscottlextern int mp_picmode; 103207499Smavextern int boot_cpu_id; 104207499Smavextern vm_offset_t cpu_apic_address; 105207499Smavextern vm_offset_t io_apic_address[]; 106198708Smavextern u_int32_t cpu_apic_versions[]; 107195534Sscottlextern u_int32_t io_apic_versions[]; 108195534Sscottlextern int cpu_num_to_apic_id[]; 109195534Sscottlextern int io_num_to_apic_id[]; 110195534Sscottlextern int apic_id_to_logical[]; 111195534Sscottlextern u_int all_cpus; 112195534Sscottlextern u_char SMP_ioapic[]; 113195534Sscottl 114195534Sscottl/* functions in mp_machdep.c */ 115195534Sscottlu_int mp_bootaddress __P((u_int)); 116195534Sscottlint mp_probe __P((void)); 117195534Sscottlvoid mp_start __P((void)); 118195534Sscottlvoid mp_announce __P((void)); 119195534Sscottlu_int isa_apic_mask __P((u_int)); 120195534Sscottlint isa_apic_pin __P((int)); 121195534Sscottlint pci_apic_pin __P((int, int, int)); 122195534Sscottlint undirect_isa_irq __P((int)); 123195534Sscottlint undirect_pci_irq __P((int)); 124195534Sscottlint apic_bus_type __P((int)); 125195534Sscottlint apic_src_bus_id __P((int, int)); 126195534Sscottlint apic_src_bus_irq __P((int, int)); 127195534Sscottlint apic_int_type __P((int, int)); 128195534Sscottlint apic_trigger __P((int, int)); 129195534Sscottlint apic_polarity __P((int, int)); 130203385Smavvoid bsp_apic_configure __P((void)); 131195534Sscottlvoid init_secondary __P((void)); 132195534Sscottlvoid smp_invltlb __P((void)); 133195534Sscottlint stop_cpus __P((u_int)); 134195534Sscottlint restart_cpus __P((u_int)); 135203108Smav#ifdef BETTER_CLOCK 136203421Smavvoid forward_statclock __P((int pscnt)); 137209744Smavvoid forward_hardclock __P((int pscnt)); 138207499Smav#endif /* BETTER_CLOCK */ 139195534Sscottlvoid forward_signal __P((struct proc *)); 140195534Sscottl 141195534Sscottl/* global data in mpapic.c */ 142199178Smavextern volatile lapic_t lapic; 143195534Sscottl 144195534Sscottl#if defined(MULTIPLE_IOAPICS) 145195534Sscottl#error MULTIPLE_IOAPICSXXX 146195534Sscottl#else 147195534Sscottlextern volatile ioapic_t *ioapic[]; 148195534Sscottl#endif /* MULTIPLE_IOAPICS */ 149195534Sscottl 150199178Smav/* functions in mpapic.c */ 151195534Sscottlvoid apic_dump __P((char*)); 152195534Sscottlvoid apic_initialize __P((void)); 153195534Sscottlvoid imen_dump __P((void)); 154199178Smavint apic_ipi __P((int, int, int)); 155199178Smavint selected_apic_ipi __P((u_int, int, int)); 156195534Sscottlint io_apic_setup __P((int)); 157195534Sscottlint ext_int_setup __P((int, int)); 158195534Sscottl 159195534Sscottl#if defined(READY) 160195534Sscottlvoid clr_io_apic_mask24 __P((int, u_int32_t)); 161195534Sscottlvoid set_io_apic_mask24 __P((int, u_int32_t)); 162195534Sscottl#endif /* READY */ 163195534Sscottl 164195534Sscottlvoid set_apic_timer __P((int)); 165195534Sscottlint read_apic_timer __P((void)); 166199178Smavvoid u_sleep __P((int)); 167195534Sscottl 168195534Sscottl/* global data in init_smp.c */ 169195534Sscottlextern int invltlb_ok; 170195534Sscottlextern int smp_active; 171195534Sscottlextern volatile int smp_idle_loops; 172195534Sscottl 173195534Sscottl/* 'private' global data in locore.s */ 174195534Sscottlextern volatile u_int cpuid; 175195534Sscottlextern volatile u_int cpu_lockid; 176199178Smavextern int inside_intr; 177195534Sscottlextern volatile u_int other_cpus; 178195534Sscottl 179195534Sscottl#endif /* !LOCORE */ 180195534Sscottl#endif /* SMP || APIC_IO */ 181195534Sscottl#endif /* KERNEL */ 182195534Sscottl#endif /* _MACHINE_SMP_H_ */ 183195534Sscottl