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