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