smp.h revision 65557
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 * 950477Speter * $FreeBSD: head/sys/i386/include/smp.h 65557 2000-09-07 01:33:02Z jasone $ 1025164Speter * 1125164Speter */ 1225164Speter 1325164Speter#ifndef _MACHINE_SMP_H_ 1425164Speter#define _MACHINE_SMP_H_ 1525164Speter 1655205Speter#ifdef _KERNEL 1725164Speter 1865557Sjasone#ifdef I386_CPU 1965557Sjasone#error SMP not supported with I386_CPU 2065557Sjasone#endif 2125517Sfsmp#if defined(SMP) && !defined(APIC_IO) 2225517Sfsmp# error APIC_IO required for SMP, add "options APIC_IO" to your config file. 2327002Sfsmp#endif /* SMP && !APIC_IO */ 2425517Sfsmp 2527728Sfsmp/* Number of CPUs. */ 2625164Speter#if defined(SMP) && !defined(NCPU) 2725164Speter# define NCPU 2 2825164Speter#endif /* SMP && NCPU */ 2925164Speter 3027728Sfsmp/* Number of IO APICs. */ 3127728Sfsmp#if defined(APIC_IO) && !defined(NAPIC) 3264834Smsmith# define NAPIC 2 3327728Sfsmp#endif /* SMP && NAPIC */ 3427728Sfsmp 3527728Sfsmp 3625164Speter#if defined(SMP) || defined(APIC_IO) 3725164Speter 3827728Sfsmp#ifndef LOCORE 3927728Sfsmp 4027002Sfsmp/* 4127002Sfsmp * For sending values to POST displays. 4227252Sfsmp * XXX FIXME: where does this really belong, isa.h/isa.c perhaps? 4327002Sfsmp */ 4427252Sfsmpextern int current_postcode; /** XXX currently in mp_machdep.c */ 4527252Sfsmp#define POSTCODE(X) current_postcode = (X), \ 4627252Sfsmp outb(0x80, current_postcode) 4727252Sfsmp#define POSTCODE_LO(X) current_postcode &= 0xf0, \ 4827252Sfsmp current_postcode |= ((X) & 0x0f), \ 4927252Sfsmp outb(0x80, current_postcode) 5027252Sfsmp#define POSTCODE_HI(X) current_postcode &= 0x0f, \ 5127252Sfsmp current_postcode |= (((X) << 4) & 0xf0), \ 5227252Sfsmp outb(0x80, current_postcode) 5327002Sfsmp 5427252Sfsmp 5526269Sfsmp#include <machine/apic.h> 5626269Sfsmp 5725164Speter/* global data in mpboot.s */ 5825164Speterextern int bootMP_size; 5925164Speter 6025164Speter/* functions in mpboot.s */ 6125164Spetervoid bootMP __P((void)); 6225164Speter 6327002Sfsmp/* global data in apic_vector.s */ 6427002Sfsmpextern volatile u_int stopped_cpus; 6527002Sfsmpextern volatile u_int started_cpus; 6627002Sfsmp 6734989Steggeextern volatile u_int checkstate_probed_cpus; 6834989Steggeextern volatile u_int checkstate_need_ast; 6936135Steggeextern volatile u_int resched_cpus; 7036135Steggeextern void (*cpustop_restartfunc) __P((void)); 7131639Sfsmp 7227616Sfsmp/* functions in apic_ipl.s */ 7327616Sfsmpvoid apic_eoi __P((void)); 7427616Sfsmpu_int io_apic_read __P((int, int)); 7527616Sfsmpvoid io_apic_write __P((int, int, u_int)); 7627616Sfsmp 7725164Speter/* global data in mp_machdep.c */ 7828669Sfsmpextern int bsp_apic_ready; 7925164Speterextern int mp_ncpus; 8025164Speterextern int mp_naps; 8125164Speterextern int mp_nbusses; 8225164Speterextern int mp_napics; 8325164Speterextern int mp_picmode; 8425164Speterextern int boot_cpu_id; 8525164Speterextern vm_offset_t cpu_apic_address; 8625164Speterextern vm_offset_t io_apic_address[]; 8725164Speterextern u_int32_t cpu_apic_versions[]; 8825164Speterextern u_int32_t io_apic_versions[]; 8925164Speterextern int cpu_num_to_apic_id[]; 9025164Speterextern int io_num_to_apic_id[]; 9125164Speterextern int apic_id_to_logical[]; 9238888Stegge#define APIC_INTMAPSIZE 24 9338888Steggestruct apic_intmapinfo { 9438888Stegge int ioapic; 9538888Stegge int int_pin; 9638888Stegge volatile void *apic_address; 9738888Stegge int redirindex; 9838888Stegge}; 9938888Steggeextern struct apic_intmapinfo int_to_apicintpin[]; 10027002Sfsmpextern u_int all_cpus; 10136135Steggeextern struct pcb stoppcbs[]; 10225164Speter 10325164Speter/* functions in mp_machdep.c */ 10425164Speteru_int mp_bootaddress __P((u_int)); 10526252Sfsmpint mp_probe __P((void)); 10625164Spetervoid mp_start __P((void)); 10725164Spetervoid mp_announce __P((void)); 10826948Sfsmpu_int isa_apic_mask __P((u_int)); 10938888Steggeint isa_apic_irq __P((int)); 11038888Steggeint pci_apic_irq __P((int, int, int)); 11138888Steggeint apic_irq __P((int, int)); 11238888Steggeint next_apic_irq __P((int)); 11325499Sfsmpint undirect_isa_irq __P((int)); 11425164Speterint undirect_pci_irq __P((int)); 11525164Speterint apic_bus_type __P((int)); 11625164Speterint apic_src_bus_id __P((int, int)); 11725164Speterint apic_src_bus_irq __P((int, int)); 11825164Speterint apic_int_type __P((int, int)); 11925164Speterint apic_trigger __P((int, int)); 12025164Speterint apic_polarity __P((int, int)); 12155420Steggevoid assign_apic_irq __P((int apic, int intpin, int irq)); 12255420Steggevoid revoke_apic_irq __P((int irq)); 12327285Sfsmpvoid bsp_apic_configure __P((void)); 12425164Spetervoid init_secondary __P((void)); 12525164Spetervoid smp_invltlb __P((void)); 12627002Sfsmpint stop_cpus __P((u_int)); 12727002Sfsmpint restart_cpus __P((u_int)); 12834017Stegge#ifdef BETTER_CLOCK 12934017Steggevoid forward_statclock __P((int pscnt)); 13034017Steggevoid forward_hardclock __P((int pscnt)); 13134017Stegge#endif /* BETTER_CLOCK */ 13234020Steggevoid forward_signal __P((struct proc *)); 13336135Steggevoid forward_roundrobin __P((void)); 13434021Stegge#ifdef APIC_INTR_REORDER 13534021Steggevoid set_lapic_isrloc __P((int, int)); 13634021Stegge#endif /* APIC_INTR_REORDER */ 13748924Smsmithvoid smp_rendezvous_action __P((void)); 13848924Smsmithvoid smp_rendezvous __P((void (*)(void *), 13948924Smsmith void (*)(void *), 14048924Smsmith void (*)(void *), 14148924Smsmith void *arg)); 14225164Speter 14325164Speter/* global data in mpapic.c */ 14426812Speterextern volatile lapic_t lapic; 14526812Speterextern volatile ioapic_t *ioapic[]; 14625164Speter 14725164Speter/* functions in mpapic.c */ 14827559Sfsmpvoid apic_dump __P((char*)); 14927285Sfsmpvoid apic_initialize __P((void)); 15027616Sfsmpvoid imen_dump __P((void)); 15125362Sfsmpint apic_ipi __P((int, int, int)); 15225164Speterint selected_apic_ipi __P((u_int, int, int)); 15325164Speterint io_apic_setup __P((int)); 15461136Smsmithvoid io_apic_set_id __P((int, int)); 15564290Steggeint io_apic_get_id __P((int)); 15625164Speterint ext_int_setup __P((int, int)); 15725164Speter 15825164Speter#if defined(READY) 15925164Spetervoid clr_io_apic_mask24 __P((int, u_int32_t)); 16025164Spetervoid set_io_apic_mask24 __P((int, u_int32_t)); 16125164Speter#endif /* READY */ 16225164Speter 16325164Spetervoid set_apic_timer __P((int)); 16425164Speterint read_apic_timer __P((void)); 16525164Spetervoid u_sleep __P((int)); 16625164Speter 16725164Speter/* global data in init_smp.c */ 16828231Sfsmpextern int invltlb_ok; 16925164Speterextern int smp_active; 17051661Smjacobextern int smp_started; 17128231Sfsmpextern volatile int smp_idle_loops; 17225164Speter 17327728Sfsmp#endif /* !LOCORE */ 17465557Sjasone#endif /* SMP && !APIC_IO */ 17558755Sdillon 17655205Speter#endif /* _KERNEL */ 17725164Speter#endif /* _MACHINE_SMP_H_ */ 178