77acde88acbafc0cac40c1dca77d27cf09586f2d
[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 /*
20  * Size of APIC ID list.
21  * Also used a MAX size of various other arrays.
22  */
23 #define NAPICID         256
24
25 #if defined(SMP)
26
27 #ifndef LOCORE
28
29 /*
30  * For sending values to POST displays.
31  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
32  */
33 extern int current_postcode;  /** XXX currently in mp_machdep.c */
34 #define POSTCODE(X)     current_postcode = (X), \
35                         outb(0x80, current_postcode)
36 #define POSTCODE_LO(X)  current_postcode &= 0xf0, \
37                         current_postcode |= ((X) & 0x0f), \
38                         outb(0x80, current_postcode)
39 #define POSTCODE_HI(X)  current_postcode &= 0x0f, \
40                         current_postcode |= (((X) << 4) & 0xf0), \
41                         outb(0x80, current_postcode)
42
43
44 #include <machine_base/apic/apicreg.h>
45 #include <machine/pcb.h>
46
47 /* global data in mpboot.s */
48 extern int                      bootMP_size;
49
50 /* functions in mpboot.s */
51 void    bootMP                  (void);
52
53 /* global data in apic_vector.s */
54 extern volatile cpumask_t       stopped_cpus;
55 extern volatile cpumask_t       started_cpus;
56
57 extern volatile u_int           checkstate_probed_cpus;
58 extern void (*cpustop_restartfunc) (void);
59
60 /* global data in mp_machdep.c */
61 extern int                      imcr_present;
62 extern int                      mp_naps;
63 extern int                      cpu_num_to_apic_id[];
64 extern int                      apic_id_to_logical[];
65
66 #define APIC_INTMAPSIZE 192
67 /*
68  * NOTE:
69  * - Keep size of apic_intmapinfo power of 2
70  * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
71  */
72 struct apic_intmapinfo {
73         int ioapic;
74         int int_pin;
75         volatile void *apic_address;
76         int redirindex;
77         uint32_t flags;         /* IOAPIC_IM_FLAG_ */
78         uint32_t pad[3];
79 };
80 #define IOAPIC_IM_SZSHIFT       5
81
82 #define IOAPIC_IM_FLAG_LEVEL    0x1     /* default to edge trigger */
83 #define IOAPIC_IM_FLAG_MASKED   0x2
84
85 extern struct apic_intmapinfo   int_to_apicintpin[];
86 extern struct pcb               stoppcbs[];
87
88 /* functions in mp_machdep.c */
89 u_int   mp_bootaddress          (u_int);
90 void    mp_start                (void);
91 void    mp_announce             (void);
92 void    mp_set_cpuids           (int, int);
93 void    init_secondary          (void);
94 int     stop_cpus               (cpumask_t);
95 void    ap_init                 (void);
96 int     restart_cpus            (cpumask_t);
97 void    forward_signal          (struct proc *);
98 int     mptable_pci_int_route(int, int, int, int);
99 void    mptable_pci_int_dump(void);
100
101 extern int apic_io_enable;
102
103 #if defined(READY)
104 void    clr_io_apic_mask24      (int, u_int32_t);
105 void    set_io_apic_mask24      (int, u_int32_t);
106 #endif /* READY */
107
108 void    cpu_send_ipiq           (int);
109 int     cpu_send_ipiq_passive   (int);
110
111 /* global data in init_smp.c */
112 extern cpumask_t                smp_active_mask;
113
114 #endif /* !LOCORE */
115 #else   /* !SMP */
116
117 #define smp_active_mask 1       /* smp_active_mask always 1 on UP machines */
118
119 #endif
120
121 #endif /* _KERNEL */
122 #endif /* _MACHINE_SMP_H_ */