a46df3a882ab5e03e76a51b3e1695d47a7d9642c
[dragonfly.git] / sys / platform / pc32 / include / smp.h
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  * $FreeBSD: src/sys/i386/include/smp.h,v 1.50.2.5 2001/02/13 22:32:45 tegge Exp $
10  * $DragonFly: src/sys/platform/pc32/include/smp.h,v 1.20 2006/11/07 06:43:24 dillon Exp $
11  *
12  */
13
14 #ifndef _MACHINE_SMP_H_
15 #define _MACHINE_SMP_H_
16
17 #ifdef _KERNEL
18
19 #if defined(SMP)
20
21 #ifndef LOCORE
22
23 /*
24  * For sending values to POST displays.
25  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
26  */
27 extern int current_postcode;  /** XXX currently in mp_machdep.c */
28 #define POSTCODE(X)     current_postcode = (X), \
29                         outb(0x80, current_postcode)
30 #define POSTCODE_LO(X)  current_postcode &= 0xf0, \
31                         current_postcode |= ((X) & 0x0f), \
32                         outb(0x80, current_postcode)
33 #define POSTCODE_HI(X)  current_postcode &= 0x0f, \
34                         current_postcode |= (((X) << 4) & 0xf0), \
35                         outb(0x80, current_postcode)
36
37
38 #include <machine_base/apic/apicreg.h>
39 #include <machine/pcb.h>
40
41 /* global data in mpboot.s */
42 extern int                      bootMP_size;
43
44 /* functions in mpboot.s */
45 void    bootMP                  (void);
46
47 /* global data in apic_vector.s */
48 extern volatile cpumask_t       stopped_cpus;
49 extern volatile cpumask_t       started_cpus;
50
51 extern volatile u_int           checkstate_probed_cpus;
52 extern void (*cpustop_restartfunc) (void);
53
54 extern struct pcb               stoppcbs[];
55
56 /* functions in mp_machdep.c */
57 u_int   mp_bootaddress          (u_int);
58 void    mp_start                (void);
59 void    mp_announce             (void);
60 void    init_secondary          (void);
61 int     stop_cpus               (cpumask_t);
62 void    ap_init                 (void);
63 int     restart_cpus            (cpumask_t);
64 void    forward_signal          (struct proc *);
65
66 #if defined(READY)
67 void    clr_io_apic_mask24      (int, u_int32_t);
68 void    set_io_apic_mask24      (int, u_int32_t);
69 #endif /* READY */
70
71 void    cpu_send_ipiq           (int);
72 int     cpu_send_ipiq_passive   (int);
73
74 /* global data in init_smp.c */
75 extern cpumask_t                smp_active_mask;
76
77 /* Detect CPU topology bits */
78 void detect_cpu_topology(void);
79
80 /* Interface functions for IDs calculation */
81 int get_chip_ID(int cpuid);
82 int get_core_number_within_chip(int cpuid);
83 int get_logical_CPU_number_within_core(int cpuid);
84
85 #include <machine_base/apic/lapic.h>
86 static __inline
87 int get_apicid_from_cpuid(int cpuid) {
88         return CPUID_TO_APICID(cpuid);
89 }
90 static __inline
91 int get_cpuid_from_apicid(int cpuid) {
92         return APICID_TO_CPUID(cpuid);
93 }
94
95 #endif /* !LOCORE */
96 #else   /* !SMP */
97
98 #define smp_active_mask 1       /* smp_active_mask always 1 on UP machines */
99
100 #endif
101
102 #endif /* _KERNEL */
103 #endif /* _MACHINE_SMP_H_ */