Merge from vendor branch NTPD:
[dragonfly.git] / sys / i386 / include / smptests.h
1 /*
2  * Copyright (c) 1996, by Steve Passe
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. The name of the developer may NOT be used to endorse or promote products
11  *    derived from this software without specific prior written permission.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD: src/sys/i386/include/smptests.h,v 1.33.2.1 2000/05/16 06:58:10 dillon Exp $
26  * $DragonFly: src/sys/i386/include/Attic/smptests.h,v 1.5 2004/02/21 06:37:07 dillon Exp $
27  */
28
29 #ifndef _MACHINE_SMPTESTS_H_
30 #define _MACHINE_SMPTESTS_H_
31
32 /*
33  * Various 'tests in progress' and configuration parameters.
34  */
35
36 #ifdef SMP
37
38 /*
39  * Control the "giant lock" pushdown by logical steps.
40  */
41 #define PUSHDOWN_LEVEL_1
42 #define PUSHDOWN_LEVEL_2
43 #define PUSHDOWN_LEVEL_3_NOT
44 #define PUSHDOWN_LEVEL_4_NOT
45
46 /*
47  * Put FAST_INTR() ISRs at an APIC priority above the regular INTs.
48  * Allow the mp_lock() routines to handle FAST interrupts while spinning.
49  */
50 #ifdef PUSHDOWN_LEVEL_1
51 #define FAST_HI
52 #endif
53
54
55 /*
56  * These defines enable critical region locking of areas that were
57  * protected via cli/sti in the UP kernel.
58  *
59  * MPINTRLOCK protects all the generic areas.
60  * COMLOCK protects the sio/cy drivers.
61  * CLOCKLOCK protects clock hardware and data
62  * known to be incomplete:
63  *      joystick lkm
64  *      ?
65  */
66 #ifdef PUSHDOWN_LEVEL_1
67 #define USE_MPINTRLOCK
68 #define USE_COMLOCK
69 #define USE_CLOCKLOCK
70 #endif
71
72
73 /*
74  * INTR_SIMPLELOCK has been removed, as the interrupt mechanism will likely
75  * not use this sort of optimization if we move to interrupt threads.
76  */
77 #ifdef PUSHDOWN_LEVEL_4
78 #endif
79
80
81 /*
82  * CPL_AND_CML has been removed.  Interrupt threads will eventually not
83  * use either mechanism so there is no point trying to optimize it.
84  */
85 #ifdef PUSHDOWN_LEVEL_3
86 #endif
87
88 /*
89  * Send CPUSTOP IPI for stop/restart of other CPUs on DDB break.
90  *
91 #define VERBOSE_CPUSTOP_ON_DDBBREAK
92  */
93 #define CPUSTOP_ON_DDBBREAK
94
95 /*
96  * Misc. counters.
97  *
98 #define COUNT_XINVLTLB_HITS
99  */
100
101 /**
102  * Hack to "fake-out" kernel into thinking it is running on a 'default config'.
103  *
104  * value == default type
105 #define TEST_DEFAULT_CONFIG     6
106  */
107
108 /*
109  * Simple test code for IPI interaction, save for future...
110  *
111 #define TEST_TEST1
112 #define IPI_TARGET_TEST1        1
113  */
114
115 #endif  /* SMP */
116
117 #ifdef APIC_IO
118
119 /*
120  * Portions of the old TEST_LOPRIO code, back from the grave!
121  */
122 #define GRAB_LOPRIO
123
124 /*
125  * Don't assume that slow interrupt handler X is called from vector
126  * X + ICU_OFFSET.
127  */
128 #define APIC_INTR_REORDER
129
130 /*
131  * Redirect clock interrupts to a higher priority (fast intr) vector,
132  * while still using the slow interrupt handler. Only effective when 
133  * APIC_INTR_REORDER is defined.
134  */
135 #define APIC_INTR_HIGHPRI_CLOCK
136
137 #endif /* APIC_IO */
138
139 #if 0   /* DEPRECATED */
140
141 /*
142  * Address of POST hardware port.
143  * Defining this enables POSTCODE macros.
144  *
145 #define POST_ADDR               0x80
146  */
147
148
149 /*
150  * POST hardware macros.
151  */
152 #ifdef POST_ADDR
153 #define ASMPOSTCODE_INC                         \
154         pushl   %eax ;                          \
155         movl    _current_postcode, %eax ;       \
156         incl    %eax ;                          \
157         andl    $0xff, %eax ;                   \
158         movl    %eax, _current_postcode ;       \
159         outb    %al, $POST_ADDR ;               \
160         popl    %eax
161
162 /*
163  * Overwrite the current_postcode value.
164  */
165 #define ASMPOSTCODE(X)                          \
166         pushl   %eax ;                          \
167         movl    $X, %eax ;                      \
168         movl    %eax, _current_postcode ;       \
169         outb    %al, $POST_ADDR ;               \
170         popl    %eax
171
172 /*
173  * Overwrite the current_postcode low nibble.
174  */
175 #define ASMPOSTCODE_LO(X)                       \
176         pushl   %eax ;                          \
177         movl    _current_postcode, %eax ;       \
178         andl    $0xf0, %eax ;                   \
179         orl     $X, %eax ;                      \
180         movl    %eax, _current_postcode ;       \
181         outb    %al, $POST_ADDR ;               \
182         popl    %eax
183
184 /*
185  * Overwrite the current_postcode high nibble.
186  */
187 #define ASMPOSTCODE_HI(X)                       \
188         pushl   %eax ;                          \
189         movl    _current_postcode, %eax ;       \
190         andl    $0x0f, %eax ;                   \
191         orl     $(X<<4), %eax ;                 \
192         movl    %eax, _current_postcode ;       \
193         outb    %al, $POST_ADDR ;               \
194         popl    %eax
195 #else
196 #define ASMPOSTCODE_INC
197 #define ASMPOSTCODE(X)
198 #define ASMPOSTCODE_LO(X)
199 #define ASMPOSTCODE_HI(X)
200 #endif /* POST_ADDR */
201
202 #endif  /* DEPRECATED */
203
204 #if 0   /* DEPRECATED */
205 /*
206  * These are all temps for debugging...
207  *
208 #define GUARD_INTS
209  */
210
211 /*
212  * This macro traps unexpected INTs to a specific CPU, eg. GUARD_CPU.
213  */
214 #ifdef GUARD_INTS
215 #define GUARD_CPU       1
216 #define MAYBE_PANIC(irq_num)            \
217         cmpl    $GUARD_CPU, _cpuid ;    \
218         jne     9f ;                    \
219         cmpl    $1, _ok_test1 ;         \
220         jne     9f ;                    \
221         pushl   lapic_isr3 ;            \
222         pushl   lapic_isr2 ;            \
223         pushl   lapic_isr1 ;            \
224         pushl   lapic_isr0 ;            \
225         pushl   lapic_irr3 ;            \
226         pushl   lapic_irr2 ;            \
227         pushl   lapic_irr1 ;            \
228         pushl   lapic_irr0 ;            \
229         pushl   $irq_num ;              \
230         pushl   _cpuid ;                \
231         pushl   $panic_msg ;            \
232         call    _printf ;               \
233         addl    $44, %esp ;             \
234 9:
235 #else
236 #define MAYBE_PANIC(irq_num)
237 #endif /* GUARD_INTS */
238
239 #endif /* DEPRECATED */
240
241 #endif /* _MACHINE_SMPTESTS_H_ */