Merge branch 'vendor/OPENSSH'
[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 void (*cpustop_restartfunc) (void);
48
49 extern struct pcb               stoppcbs[];
50
51 /* functions in mp_machdep.c */
52 u_int   mp_bootaddress          (u_int);
53 void    mp_start                (void);
54 void    mp_announce             (void);
55 void    init_secondary          (void);
56 int     stop_cpus               (cpumask_t);
57 void    ap_init                 (void);
58 int     restart_cpus            (cpumask_t);
59 void    forward_signal          (struct proc *);
60
61 #if defined(READY)
62 void    clr_io_apic_mask24      (int, u_int32_t);
63 void    set_io_apic_mask24      (int, u_int32_t);
64 #endif /* READY */
65
66 void    cpu_send_ipiq           (int);
67 int     cpu_send_ipiq_passive   (int);
68
69 /* global data in init_smp.c */
70 extern cpumask_t                smp_active_mask;
71
72 /* Detect CPU topology bits */
73 void detect_cpu_topology(void);
74
75 /* Interface functions for IDs calculation */
76 int get_chip_ID(int cpuid);
77 int get_core_number_within_chip(int cpuid);
78 int get_logical_CPU_number_within_core(int cpuid);
79
80 #include <machine_base/apic/lapic.h>
81 static __inline
82 int get_apicid_from_cpuid(int cpuid) {
83         return CPUID_TO_APICID(cpuid);
84 }
85 static __inline
86 int get_cpuid_from_apicid(int cpuid) {
87         return APICID_TO_CPUID(cpuid);
88 }
89
90 #endif /* !LOCORE */
91
92 #endif /* _KERNEL */
93 #endif /* _MACHINE_SMP_H_ */