FreeBSD/Linux Kernel Cross Reference
sys/sqt/sqtasm.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991 Carnegie Mellon University
4 * Copyright (c) 1991 Sequent Computer Systems
5 * All Rights Reserved.
6 *
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation.
12 *
13 * CARNEGIE MELLON AND SEQUENT COMPUTER SYSTEMS ALLOW FREE USE OF
14 * THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON AND
15 * SEQUENT COMPUTER SYSTEMS DISCLAIM ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie Mellon
26 * the rights to redistribute these changes.
27 */
28
29 /*
30 * HISTORY
31 * $Log: sqtasm.h,v $
32 * Revision 2.3 91/07/31 18:04:22 dbg
33 * Changed copyright.
34 * [91/07/31 dbg]
35 *
36 * Revision 2.2 91/05/08 13:00:26 dbg
37 * Changes for pure kernel.
38 * [90/05/02 dbg]
39 *
40 */
41
42 #ifndef _SQT_SQTASM_H_
43 #define _SQT_SQTASM_H_
44
45 #if defined(KXX) || defined(SLIC_GATES)
46
47 /*
48 * In-line ASM macros for portable gate and lock implementations.
49 * Macros don't block interrupts; caller must do this.
50 *
51 * P_GATE_ASM grab a gate, used in ASM code.
52 * CP_GATE_ASM conditionally grab a gate, used in ASM code.
53 * V_GATE_ASM release a gate in ASM code.
54 *
55 * These macros touch only EAX.
56 */
57
58 /*
59 * P_SLIC_GATE and V_SLIC_GATE lock/unlock slic gate whose number is in %al.
60 * Since these may be called from (eg) p_gate() and cp_gate(), the must be
61 * sure to save/restore interrupt enable flag. This is ok in the prototype
62 * (K20), and a non-issue on the real HW.
63 */
64
65 #define P_SLIC_GATE(gateno) \
66 pushfl; cli; \
67 movb $GATE_GROUP, SL_DEST+VA_SLIC; \
68 movb gateno, SL_SMESSAGE+VA_SLIC; \
69 9: movb $SL_REQG, SL_CMD_STAT+VA_SLIC; \
70 8: testb $SL_BUSY, SL_CMD_STAT+VA_SLIC; \
71 jne 8b; \
72 testb $SL_OK, SL_CMD_STAT+VA_SLIC; \
73 je 9b
74
75 #define V_SLIC_GATE(gateno) \
76 movb $GATE_GROUP, SL_DEST+VA_SLIC; \
77 movb gateno, SL_SMESSAGE+VA_SLIC; \
78 movb $SL_RELG, SL_CMD_STAT+VA_SLIC; \
79 9: testb $SL_BUSY, SL_CMD_STAT+VA_SLIC; \
80 jne 9b; \
81 popfl
82
83 #define P_GATE_ASM(gaddr) \
84 leal gaddr, %eax; \
85 shrb $2, %al; \
86 andb $0x3f, %al; \
87 5: cmpb $G_UNLOCKED, gaddr; \
88 jne 5b; \
89 P_SLIC_GATE(%al); \
90 movb gaddr, %ah; \
91 cmpb $G_UNLOCKED, %ah; \
92 jne 6f; \
93 movb $G_LOCKED, gaddr; \
94 6: V_SLIC_GATE(%al); \
95 cmpb $G_UNLOCKED, %ah; \
96 jne 5b
97
98 #define CP_GATE_ASM(gaddr,fail) \
99 leal gaddr, %eax; \
100 shrb $2, %al; \
101 andb $0x3f, %al; \
102 P_SLIC_GATE(%al); \
103 movb gaddr, %ah; \
104 cmpb $G_UNLOCKED, %ah; \
105 jne 6f; \
106 movb $G_LOCKED, gaddr; \
107 6: V_SLIC_GATE(%al); \
108 cmpb $G_UNLOCKED, %ah; \
109 jne fail
110
111 #define V_GATE_ASM(gaddr) movb $G_UNLOCKED, gaddr
112
113 #else Real HW
114
115 /*
116 * Gate and lock accesses on real HW are in-line expanded.
117 * See machine/mutex.h
118 */
119
120 #define V_GATE_ASM(gaddr) \
121 movb $G_UNLOCKED, %al; \
122 xchgb %al, gaddr
123
124 #endif KXX
125
126 /*
127 * V_LOCK_ASM() assumes gate and lock data-structure and values are idential.
128 */
129
130 #define V_LOCK_ASM(lock) V_GATE_ASM(lock)
131
132 /*
133 * SPL_ASM(new,old) raise SPL to "new", put old value in "old" (mod's %ah).
134 * SPLX_ASM(old) lower SPL back to "old".
135 *
136 * See machine/intctl.h for detail on spl synch with SLIC.
137 * need 8 clocks at 16Mhz 10 at 20 Mhz 12 at 24 Mhz etc
138 * modelC requires an extra 50 ns
139 * all machines may run at 10% margins.
140 * Note: movb X,r will contribute 2 cycles
141 * nop is 3 cycles
142 * movl r,r is 2 cycles
143 */
144
145 #ifndef MHz
146 #define MHz 20
147 #endif MHz
148
149 /***************SLICSYNC 2 ***************************************/
150 #if MHz == 16
151 #define SPL_ASM(new,old) \
152 movb VA_SLIC+SL_LMASK, old; \
153 movb new, VA_SLIC+SL_LMASK; \
154 movb VA_SLIC+SL_LMASK, %ah; \
155 nop; nop;
156 #else
157 #if MHz == 20
158 #define SPL_ASM(new,old) \
159 movb VA_SLIC+SL_LMASK, old; \
160 movb new, VA_SLIC+SL_LMASK; \
161 movb VA_SLIC+SL_LMASK, %ah; \
162 movl %eax,%eax; \
163 movl %eax,%eax; \
164 nop; nop;
165 #else
166 ERROR not 16Mhz nor 20Hz
167 #endif
168 #endif
169
170 #define SPLX_ASM(old) movb old, VA_SLIC+SL_LMASK
171
172 /*
173 * Put cpu_number() is passed arg
174 */
175
176 #define CPU_NUMBER(arg) \
177 movzbl VA_SLIC+SL_PROCID, arg; \
178 movzbl _slic_to_cpu(arg), arg
179
180 /*
181 * Put current_thread pointer into passed arg
182 * See current_thread() defn in thread.h
183 */
184
185 #define CURRENT_THREAD(arg) \
186 CPU_NUMBER(arg); \
187 movl _active_threads(,arg,4), arg
188
189 /*
190 * Put pointer to current pcb in arg
191 */
192
193 #define CURRENT_PCB(arg) \
194 CURRENT_THREAD(arg); \
195 movl THREAD_PCB(arg), arg
196
197 /*
198 * Put pointer to engine[] structure in arg
199 */
200
201 #define ENGINE_POINTER(arg) \
202 CPU_NUMBER(arg); \
203 imull $ENGSIZE, arg; \
204 addl _engine, arg
205
206 /*
207 * Put pointer to plocal structure in arg
208 */
209
210 #define LOCAL_POINTER(arg) \
211 ENGINE_POINTER(arg); \
212 movl E_LOCAL(arg), arg
213
214 #endif /* _SQT_SQTASM_H_ */
Cache object: ce44d11110fcdfd834506dd6fcb29e78
|