Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / i386 / 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/i386/include/Attic/smp.h,v 1.2 2003/06/17 04:28:36 dillon Exp $
11  *
12  */
13
14 #ifndef _MACHINE_SMP_H_
15 #define _MACHINE_SMP_H_
16
17 #ifdef _KERNEL
18
19 #if defined(SMP) && !defined(APIC_IO)
20 # error APIC_IO required for SMP, add "options APIC_IO" to your config file.
21 #endif /* SMP && !APIC_IO */
22
23 #if defined(SMP) || defined(APIC_IO)
24
25 #ifndef LOCORE
26
27 /*
28  * For sending values to POST displays.
29  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
30  */
31 extern int current_postcode;  /** XXX currently in mp_machdep.c */
32 #define POSTCODE(X)     current_postcode = (X), \
33                         outb(0x80, current_postcode)
34 #define POSTCODE_LO(X)  current_postcode &= 0xf0, \
35                         current_postcode |= ((X) & 0x0f), \
36                         outb(0x80, current_postcode)
37 #define POSTCODE_HI(X)  current_postcode &= 0x0f, \
38                         current_postcode |= (((X) << 4) & 0xf0), \
39                         outb(0x80, current_postcode)
40
41
42 #include <machine/apic.h>
43
44 /* global data in mpboot.s */
45 extern int                      bootMP_size;
46
47 /* functions in mpboot.s */
48 void    bootMP                  __P((void));
49
50 /* global data in mplock.s */
51 extern u_int                    mp_lock;
52 extern u_int                    isr_lock;
53 #ifdef RECURSIVE_MPINTRLOCK
54 extern u_int                    mpintr_lock;
55 #endif /*  RECURSIVE_MPINTRLOCK */
56
57 /* functions in mplock.s */
58 void    get_mplock              __P((void));
59 void    rel_mplock              __P((void));
60 int             try_mplock              __P((void));
61 #ifdef RECURSIVE_MPINTRLOCK
62 void    get_mpintrlock          __P((void));
63 void    rel_mpintrlock          __P((void));
64 int             try_mpintrlock          __P((void));
65 #endif /*  RECURSIVE_MPINTRLOCK */
66
67 /* global data in apic_vector.s */
68 extern volatile u_int           stopped_cpus;
69 extern volatile u_int           started_cpus;
70
71 extern volatile u_int           checkstate_probed_cpus;
72 extern volatile u_int           checkstate_need_ast;
73 extern volatile u_int           resched_cpus;
74 extern void (*cpustop_restartfunc) __P((void));
75
76 /* functions in apic_ipl.s */
77 void    apic_eoi                __P((void));
78 u_int   io_apic_read            __P((int, int));
79 void    io_apic_write           __P((int, int, u_int));
80
81 /* global data in mp_machdep.c */
82 extern int                      bsp_apic_ready;
83 extern int                      mp_ncpus;
84 extern int                      mp_naps;
85 extern int                      mp_nbusses;
86 extern int                      mp_napics;
87 extern int                      mp_picmode;
88 extern int                      boot_cpu_id;
89 extern vm_offset_t              cpu_apic_address;
90 extern vm_offset_t              io_apic_address[];
91 extern u_int32_t                cpu_apic_versions[];
92 extern u_int32_t                *io_apic_versions;
93 extern int                      cpu_num_to_apic_id[];
94 extern int                      io_num_to_apic_id[];
95 extern int                      apic_id_to_logical[];
96 #define APIC_INTMAPSIZE 24
97 struct apic_intmapinfo {
98         int ioapic;
99         int int_pin;
100         volatile void *apic_address;
101         int redirindex;
102 };
103 extern struct apic_intmapinfo   int_to_apicintpin[];
104 extern u_int                    all_cpus;
105 extern struct pcb               stoppcbs[];
106
107 /* functions in mp_machdep.c */
108 u_int   mp_bootaddress          __P((u_int));
109 int     mp_probe                __P((void));
110 void    mp_start                __P((void));
111 void    mp_announce             __P((void));
112 u_int   isa_apic_mask           __P((u_int));
113 int     isa_apic_irq            __P((int));
114 int     pci_apic_irq            __P((int, int, int));
115 int     apic_irq                __P((int, int));
116 int     next_apic_irq           __P((int));
117 int     undirect_isa_irq        __P((int));
118 int     undirect_pci_irq        __P((int));
119 int     apic_bus_type           __P((int));
120 int     apic_src_bus_id         __P((int, int));
121 int     apic_src_bus_irq        __P((int, int));
122 int     apic_int_type           __P((int, int));
123 int     apic_trigger            __P((int, int));
124 int     apic_polarity           __P((int, int));
125 void    assign_apic_irq         __P((int apic, int intpin, int irq));
126 void    revoke_apic_irq         __P((int irq));
127 void    bsp_apic_configure      __P((void));
128 void    init_secondary          __P((void));
129 void    smp_invltlb             __P((void));
130 int     stop_cpus               __P((u_int));
131 int     restart_cpus            __P((u_int));
132 #ifdef BETTER_CLOCK 
133 void    forward_statclock       __P((int pscnt));
134 void    forward_hardclock       __P((int pscnt));
135 #endif /* BETTER_CLOCK */
136 void    forward_signal          __P((struct proc *));
137 void    forward_roundrobin      __P((void));
138 #ifdef  APIC_INTR_REORDER
139 void    set_lapic_isrloc        __P((int, int));
140 #endif /* APIC_INTR_REORDER */
141 void    smp_rendezvous_action   __P((void));
142 void    smp_rendezvous          __P((void (*)(void *), 
143                                      void (*)(void *),
144                                      void (*)(void *),
145                                      void *arg));
146
147 /* global data in mpapic.c */
148 extern volatile lapic_t         lapic;
149 extern volatile ioapic_t        **ioapic;
150
151 /* functions in mpapic.c */
152 void    apic_dump               __P((char*));
153 void    apic_initialize         __P((void));
154 void    imen_dump               __P((void));
155 int     apic_ipi                __P((int, int, int));
156 int     selected_apic_ipi       __P((u_int, int, int));
157 int     io_apic_setup           __P((int));
158 void    io_apic_setup_intpin    __P((int, int));
159 void    io_apic_set_id          __P((int, int));
160 int     io_apic_get_id          __P((int));
161 int     ext_int_setup           __P((int, int));
162
163 #if defined(READY)
164 void    clr_io_apic_mask24      __P((int, u_int32_t));
165 void    set_io_apic_mask24      __P((int, u_int32_t));
166 #endif /* READY */
167
168 void    set_apic_timer          __P((int));
169 int     read_apic_timer         __P((void));
170 void    u_sleep                 __P((int));
171
172 /* global data in init_smp.c */
173 extern int                      invltlb_ok;
174 extern int                      smp_active;
175 extern int                      smp_started;
176 extern volatile int             smp_idle_loops;
177
178 #endif /* !LOCORE */
179 #else   /* !SMP && !APIC_IO */
180
181 /*
182  * Create dummy MP lock empties
183  */
184
185 static __inline void
186 get_mplock(void)
187 {
188 }
189
190 static __inline void
191 rel_mplock(void)
192 {
193 }
194
195 #endif
196
197 #endif /* _KERNEL */
198 #endif /* _MACHINE_SMP_H_ */