subr.S revision 1.20 1 1.20 matt /* $NetBSD: subr.S,v 1.20 2008/02/05 00:04:24 matt Exp $ */
2 1.1 matt
3 1.1 matt /*
4 1.1 matt * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
5 1.1 matt * All rights reserved.
6 1.1 matt *
7 1.1 matt * Redistribution and use in source and binary forms, with or without
8 1.1 matt * modification, are permitted provided that the following conditions
9 1.1 matt * are met:
10 1.1 matt * 1. Redistributions of source code must retain the above copyright
11 1.1 matt * notice, this list of conditions and the following disclaimer.
12 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 matt * notice, this list of conditions and the following disclaimer in the
14 1.1 matt * documentation and/or other materials provided with the distribution.
15 1.1 matt * 3. All advertising materials mentioning features or use of this software
16 1.1 matt * must display the following acknowledgement:
17 1.1 matt * This product includes software developed at Ludd, University of Lule}.
18 1.1 matt * 4. The name of the author may not be used to endorse or promote products
19 1.1 matt * derived from this software without specific prior written permission
20 1.1 matt *
21 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 matt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 matt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 matt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 matt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 matt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 matt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 matt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 matt */
32 1.1 matt
33 1.1 matt #include <machine/asm.h>
34 1.1 matt
35 1.1 matt #include "assym.h"
36 1.1 matt #include "opt_ddb.h"
37 1.1 matt #include "opt_multiprocessor.h"
38 1.1 matt #include "opt_lockdebug.h"
39 1.1 matt #include "opt_compat_netbsd.h"
40 1.1 matt #include "opt_compat_ibcs2.h"
41 1.1 matt #ifdef COMPAT_IBCS2
42 1.1 matt #include <compat/ibcs2/ibcs2_syscall.h>
43 1.1 matt #endif
44 1.1 matt #include "opt_compat_ultrix.h"
45 1.1 matt #ifdef COMPAT_ULTRIX
46 1.1 matt #include <compat/ultrix/ultrix_syscall.h>
47 1.1 matt #endif
48 1.1 matt
49 1.1 matt #define JSBENTRY(x) .globl x ; .align 2 ; x :
50 1.1 matt
51 1.1 matt .text
52 1.1 matt
53 1.1 matt #ifdef KERNEL_LOADABLE_BY_MOP
54 1.1 matt /*
55 1.1 matt * This is a little tricky. The kernel is not loaded at the correct
56 1.1 matt * address, so the kernel must first be relocated, then copied, then
57 1.1 matt * jump back to the correct address.
58 1.1 matt */
59 1.1 matt /* Copy routine */
60 1.1 matt cps:
61 1.2 matt 2: movb (%r0)+,(%r1)+
62 1.2 matt cmpl %r0,%r7
63 1.1 matt bneq 2b
64 1.1 matt
65 1.2 matt 3: clrb (%r1)+
66 1.2 matt incl %r0
67 1.2 matt cmpl %r0,%r6
68 1.1 matt bneq 3b
69 1.2 matt clrl -(%sp)
70 1.2 matt movl %sp,%ap
71 1.2 matt movl $_cca,%r7
72 1.2 matt movl %r8,(%r7)
73 1.2 matt movpsl -(%sp)
74 1.2 matt pushl %r2
75 1.1 matt rei
76 1.1 matt cpe:
77 1.1 matt
78 1.1 matt /* Copy the copy routine */
79 1.2 matt 1: movab cps,%r0
80 1.2 matt movab cpe,%r1
81 1.2 matt movl $0x300000,%sp
82 1.2 matt movl %sp,%r3
83 1.2 matt 4: movb (%r0)+,(%r3)+
84 1.2 matt cmpl %r0,%r1
85 1.1 matt bneq 4b
86 1.2 matt movl %r7,%r8
87 1.1 matt /* Ok, copy routine copied, set registers and rei */
88 1.2 matt movab _edata,%r7
89 1.2 matt movab _end,%r6
90 1.2 matt movl $0x80000000,%r1
91 1.2 matt movl $0x80000200,%r0
92 1.2 matt subl3 $0x200,%r6,%r9
93 1.2 matt movab 2f,%r2
94 1.2 matt subl2 $0x200,%r2
95 1.2 matt movpsl -(%sp)
96 1.2 matt pushab 4(%sp)
97 1.1 matt rei
98 1.1 matt
99 1.1 matt /*
100 1.1 matt * First entry routine from boot. This should be in a file called locore.
101 1.1 matt */
102 1.1 matt JSBENTRY(start)
103 1.1 matt brb 1b # Netbooted starts here
104 1.1 matt #else
105 1.1 matt ASENTRY(start, 0)
106 1.1 matt #endif
107 1.2 matt 2: bisl3 $0x80000000,%r9,_C_LABEL(esym) # End of loaded code
108 1.1 matt pushl $0x1f0000 # Push a nice PSL
109 1.1 matt pushl $to # Address to jump to
110 1.1 matt rei # change to kernel stack
111 1.1 matt to: movw $0xfff,_C_LABEL(panic) # Save all regs in panic
112 1.3 matt cmpb (%ap),$3 # symbols info present?
113 1.1 matt blssu 3f # nope, skip
114 1.2 matt bisl3 $0x80000000,8(%ap),_C_LABEL(symtab_start)
115 1.1 matt # save start of symtab
116 1.2 matt movl 12(%ap),_C_LABEL(symtab_nsyms) # save number of symtab
117 1.3 matt bisl3 $0x80000000,%r9,_C_LABEL(symtab_end)
118 1.2 matt # save end of symtab
119 1.2 matt 3: addl3 _C_LABEL(esym),$0x3ff,%r0 # Round symbol table end
120 1.2 matt bicl3 $0x3ff,%r0,_C_LABEL(proc0paddr) # save proc0 uarea pointer
121 1.2 matt bicl3 $0x80000000,_C_LABEL(proc0paddr),%r0 # get phys proc0 uarea addr
122 1.2 matt mtpr %r0,$PR_PCBB # Save in IPR PCBB
123 1.2 matt addl3 $USPACE,_C_LABEL(proc0paddr),%r0 # Get kernel stack top
124 1.2 matt mtpr %r0,$PR_KSP # put in IPR KSP
125 1.2 matt movl %r0,_C_LABEL(Sysmap) # SPT start addr after KSP
126 1.2 matt movl _C_LABEL(proc0paddr),%r0 # get PCB virtual address
127 1.2 matt movab IFTRAP(%r0),4(%r0) # Save trap address in ESP
128 1.2 matt mtpr 4(%r0),$PR_ESP # Put it in ESP also
129 1.1 matt
130 1.1 matt # Set some registers in known state
131 1.2 matt movl _C_LABEL(proc0paddr),%r0
132 1.2 matt clrl P0LR(%r0)
133 1.2 matt clrl P1LR(%r0)
134 1.1 matt mtpr $0,$PR_P0LR
135 1.1 matt mtpr $0,$PR_P1LR
136 1.2 matt movl $0x80000000,%r1
137 1.2 matt movl %r1,P0BR(%r0)
138 1.2 matt movl %r1,P1BR(%r0)
139 1.2 matt mtpr %r1,$PR_P0BR
140 1.2 matt mtpr %r1,$PR_P1BR
141 1.2 matt clrl IFTRAP(%r0)
142 1.1 matt mtpr $0,$PR_SCBB
143 1.1 matt
144 1.1 matt # Copy the RPB to its new position
145 1.1 matt #if defined(COMPAT_14)
146 1.2 matt tstl (%ap) # Any arguments?
147 1.1 matt bneq 1f # Yes, called from new boot
148 1.2 matt movl %r11,_C_LABEL(boothowto) # Howto boot (single etc...)
149 1.2 matt # movl %r10,_C_LABEL(bootdev) # uninteresting, will complain
150 1.2 matt movl %r8,_C_LABEL(avail_end) # Usable memory (from VMB)
151 1.2 matt clrl -(%sp) # Have no RPB
152 1.1 matt brb 2f
153 1.1 matt #endif
154 1.1 matt
155 1.2 matt 1: pushl 4(%ap) # Address of old rpb
156 1.1 matt 2: calls $1,_C_LABEL(_start) # Jump away.
157 1.1 matt /* NOTREACHED */
158 1.1 matt
159 1.1 matt
160 1.1 matt /*
161 1.1 matt * Signal handler code.
162 1.1 matt */
163 1.1 matt
164 1.1 matt .align 2
165 1.11 matt .globl _C_LABEL(sigcode),_C_LABEL(esigcode)
166 1.1 matt _C_LABEL(sigcode):
167 1.1 matt pushr $0x3f
168 1.2 matt subl2 $0xc,%sp
169 1.2 matt movl 0x24(%sp),%r0
170 1.2 matt calls $3,(%r0)
171 1.1 matt popr $0x3f
172 1.8 matt chmk $SYS_compat_16___sigreturn14
173 1.1 matt chmk $SYS_exit
174 1.1 matt halt
175 1.1 matt _C_LABEL(esigcode):
176 1.1 matt
177 1.1 matt #ifdef COMPAT_IBCS2
178 1.1 matt .align 2
179 1.1 matt .globl _C_LABEL(ibcs2_sigcode),_C_LABEL(ibcs2_esigcode)
180 1.1 matt _C_LABEL(ibcs2_sigcode):
181 1.1 matt pushr $0x3f
182 1.2 matt subl2 $0xc,%sp
183 1.2 matt movl 0x24(%sp),%r0
184 1.2 matt calls $3,(%r0)
185 1.1 matt popr $0x3f
186 1.8 matt chmk $SYS_compat_16___sigreturn14
187 1.1 matt chmk $SYS_exit
188 1.1 matt halt
189 1.1 matt _C_LABEL(ibcs2_esigcode):
190 1.1 matt #endif /* COMPAT_IBCS2 */
191 1.1 matt
192 1.1 matt #ifdef COMPAT_ULTRIX
193 1.1 matt .align 2
194 1.1 matt .globl _C_LABEL(ultrix_sigcode),_C_LABEL(ultrix_esigcode)
195 1.1 matt _C_LABEL(ultrix_sigcode):
196 1.1 matt pushr $0x3f
197 1.2 matt subl2 $0xc,%sp
198 1.2 matt movl 0x24(%sp),%r0
199 1.2 matt calls $3,(%r0)
200 1.1 matt popr $0x3f
201 1.1 matt chmk $ULTRIX_SYS_sigreturn
202 1.1 matt chmk $SYS_exit
203 1.1 matt halt
204 1.1 matt _C_LABEL(ultrix_esigcode):
205 1.1 matt #endif
206 1.1 matt
207 1.1 matt .align 2
208 1.1 matt .globl _C_LABEL(idsptch), _C_LABEL(eidsptch)
209 1.16 matt _C_LABEL(idsptch):
210 1.16 matt pushr $0x3f
211 1.1 matt .word 0x9f16 # jsb to absolute address
212 1.1 matt .long _C_LABEL(cmn_idsptch) # the absolute address
213 1.1 matt .long 0 # the callback interrupt routine
214 1.1 matt .long 0 # its argument
215 1.1 matt .long 0 # ptr to correspond evcnt struct
216 1.1 matt _C_LABEL(eidsptch):
217 1.1 matt
218 1.1 matt _C_LABEL(cmn_idsptch):
219 1.16 matt #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
220 1.16 matt calls $0,_C_LABEL(krnlock)
221 1.16 matt #endif
222 1.2 matt movl (%sp)+,%r0 # get pointer to idspvec
223 1.20 matt mtpr $IPL_VM,$PR_IPL # Make sure we are at IPL_VM
224 1.2 matt movl 8(%r0),%r1 # get evcnt pointer
225 1.1 matt beql 1f # no ptr, skip increment
226 1.2 matt incl EV_COUNT(%r1) # increment low longword
227 1.2 matt adwc $0,EV_COUNT+4(%r1) # add any carry to hi longword
228 1.6 ragge 1: incl _C_LABEL(uvmexp)+UVME_INTRS # increment uvmexp.intrs
229 1.16 matt #if 0
230 1.16 matt pushl %r0
231 1.16 matt movq (%r0),-(%sp)
232 1.16 matt pushab 2f
233 1.16 matt calls $3,_C_LABEL(printf)
234 1.16 matt movl (%sp)+,%r0
235 1.16 matt #endif
236 1.6 ragge pushl 4(%r0) # push argument
237 1.2 matt calls $1,*(%r0) # call interrupt routine
238 1.16 matt #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
239 1.16 matt calls $0,_C_LABEL(krnunlock)
240 1.16 matt #endif
241 1.1 matt popr $0x3f # pop registers
242 1.1 matt rei # return from interrut
243 1.16 matt #if 0
244 1.16 matt 2: .asciz "intr %p(%p)\n"
245 1.16 matt #endif
246 1.1 matt
247 1.1 matt ENTRY(badaddr,0) # Called with addr,b/w/l
248 1.2 matt mfpr $PR_IPL,%r0 # splhigh()
249 1.1 matt mtpr $IPL_HIGH,$PR_IPL
250 1.2 matt movl 4(%ap),%r2 # First argument, the address
251 1.2 matt movl 8(%ap),%r1 # Sec arg, b,w,l
252 1.2 matt pushl %r0 # Save old IPL
253 1.2 matt clrl %r3
254 1.1 matt movab 4f,_C_LABEL(memtest) # Set the return address
255 1.1 matt
256 1.2 matt caseb %r1,$1,$4 # What is the size
257 1.1 matt 1: .word 1f-1b
258 1.1 matt .word 2f-1b
259 1.1 matt .word 3f-1b # This is unused
260 1.1 matt .word 3f-1b
261 1.1 matt
262 1.2 matt 1: movb (%r2),%r1 # Test a byte
263 1.1 matt brb 5f
264 1.1 matt
265 1.2 matt 2: movw (%r2),%r1 # Test a word
266 1.1 matt brb 5f
267 1.1 matt
268 1.2 matt 3: movl (%r2),%r1 # Test a long
269 1.1 matt brb 5f
270 1.1 matt
271 1.2 matt 4: incl %r3 # Got machine chk => addr bad
272 1.2 matt 5: mtpr (%sp)+,$PR_IPL
273 1.2 matt movl %r3,%r0
274 1.1 matt ret
275 1.1 matt
276 1.1 matt #ifdef DDB
277 1.1 matt /*
278 1.1 matt * DDB is the only routine that uses setjmp/longjmp.
279 1.1 matt */
280 1.1 matt .globl _C_LABEL(setjmp), _C_LABEL(longjmp)
281 1.1 matt _C_LABEL(setjmp):.word 0
282 1.2 matt movl 4(%ap), %r0
283 1.2 matt movl 8(%fp), (%r0)
284 1.2 matt movl 12(%fp), 4(%r0)
285 1.2 matt movl 16(%fp), 8(%r0)
286 1.2 matt moval 28(%fp),12(%r0)
287 1.2 matt clrl %r0
288 1.1 matt ret
289 1.1 matt
290 1.1 matt _C_LABEL(longjmp):.word 0
291 1.2 matt movl 4(%ap), %r1
292 1.2 matt movl 8(%ap), %r0
293 1.2 matt movl (%r1), %ap
294 1.2 matt movl 4(%r1), %fp
295 1.2 matt movl 12(%r1), %sp
296 1.2 matt jmp *8(%r1)
297 1.1 matt #endif
298 1.1 matt
299 1.1 matt #if defined(MULTIPROCESSOR)
300 1.1 matt .align 2
301 1.12 he .globl _C_LABEL(vax_mp_tramp) # used to kick off multiprocessor systems.
302 1.12 he _C_LABEL(vax_mp_tramp):
303 1.1 matt ldpctx
304 1.1 matt rei
305 1.1 matt #endif
306 1.5 thorpej
307 1.17 yamt /*
308 1.17 yamt * Helper routine for cpu_lwp_fork. It get invoked by Swtchto.
309 1.17 yamt * It let's the kernel know the lwp is alive and then calls func(arg)
310 1.17 yamt * and possibly returns to sret.
311 1.17 yamt */
312 1.17 yamt ENTRY(cpu_lwp_bootstrap, 0)
313 1.17 yamt movq %r2,-(%sp) /* save func & arg */
314 1.17 yamt movq %r0,-(%sp) /* push oldl/newl */
315 1.17 yamt calls $2,_C_LABEL(lwp_startup) /* startup the lwp */
316 1.17 yamt movl (%sp)+,%r0 /* grab func */
317 1.17 yamt calls $1,(%r0) /* call it with arg */
318 1.17 yamt ret
319 1.17 yamt
320 1.17 yamt /*
321 1.17 yamt * r1 = newlwp
322 1.17 yamt * r0 = oldlwp
323 1.17 yamt */
324 1.5 thorpej JSBENTRY(Swtchto)
325 1.17 yamt /* this pops the pc and psw from the stack and puts them in the pcb. */
326 1.5 thorpej svpctx # Now on interrupt stack
327 1.5 thorpej
328 1.17 yamt /* We can know use any register because ldpctx will overwrite them */
329 1.17 yamt /* New LWP already in %r1 */
330 1.17 yamt mfpr $PR_SSP,%r4 # Get curcpu
331 1.17 yamt movl %r1,CI_CURLWP(%r4) # update ci_curlwp
332 1.17 yamt movl L_ADDR(%r1),%r3 # Get pointer to new pcb.
333 1.17 yamt movl %r0,PCB_R0(%r3) # move r0 into new pcb (return value)
334 1.17 yamt movl %r4,SSP(%r3) # Put curcpu into new PCB
335 1.17 yamt addl3 %r3,$IFTRAP,%r4 # Save for copy* functions.
336 1.17 yamt mtpr %r4,$PR_ESP # Use ESP as CPU-specific pointer
337 1.17 yamt movl %r4,ESP(%r3) # Must save in PCB also.
338 1.17 yamt
339 1.17 yamt extzv $9,$21,%r3,%r1 # extract offset of PCB
340 1.17 yamt ashl $9,*_C_LABEL(Sysmap)[%r1],%r4
341 1.17 yamt
342 1.17 yamt mtpr %r4,$PR_PCBB # set PA of new pcb
343 1.17 yamt ldpctx # load it
344 1.17 yamt /* r0 already has previous lwp */
345 1.17 yamt /* r1 already has this lwp */
346 1.17 yamt /* r2/r3 and r4/r5 restored */
347 1.17 yamt rei /* get off interrupt stack */
348 1.1 matt
349 1.1 matt #
350 1.1 matt # copy/fetch/store routines.
351 1.1 matt #
352 1.1 matt
353 1.1 matt ENTRY(copyout, 0)
354 1.2 matt movl 8(%ap),%r2
355 1.1 matt blss 3f # kernel space
356 1.2 matt movl 4(%ap),%r1
357 1.1 matt brb 2f
358 1.1 matt
359 1.1 matt ENTRY(copyin, 0)
360 1.2 matt movl 4(%ap),%r1
361 1.1 matt blss 3f # kernel space
362 1.2 matt movl 8(%ap),%r2
363 1.2 matt 2: mfpr $PR_ESP,%r3
364 1.2 matt movab 1f,(%r3)
365 1.2 matt movc3 12(%ap),(%r1),(%r2)
366 1.2 matt 1: mfpr $PR_ESP,%r3
367 1.2 matt clrl (%r3)
368 1.1 matt ret
369 1.1 matt
370 1.2 matt 3: mnegl $1,%r0
371 1.1 matt ret
372 1.1 matt
373 1.1 matt ENTRY(kcopy,0)
374 1.2 matt mfpr $PR_ESP,%r3
375 1.2 matt movl (%r3),-(%sp)
376 1.2 matt movab 1f,(%r3)
377 1.2 matt movl 4(%ap),%r1
378 1.2 matt movl 8(%ap),%r2
379 1.2 matt movc3 12(%ap),(%r1), (%r2)
380 1.2 matt clrl %r1
381 1.2 matt 1: mfpr $PR_ESP,%r3
382 1.2 matt movl (%sp)+,(%r3)
383 1.2 matt movl %r1,%r0
384 1.1 matt ret
385 1.1 matt
386 1.1 matt /*
387 1.1 matt * copy{in,out}str() copies data from/to user space to/from kernel space.
388 1.1 matt * Security checks:
389 1.1 matt * 1) user space address must be < KERNBASE
390 1.1 matt * 2) the VM system will do the checks while copying
391 1.1 matt */
392 1.1 matt ENTRY(copyinstr, 0)
393 1.2 matt tstl 4(%ap) # kernel address?
394 1.1 matt bgeq 8f # no, continue
395 1.2 matt 6: movl $EFAULT,%r0
396 1.2 matt movl 16(%ap),%r2
397 1.1 matt beql 7f
398 1.2 matt clrl (%r2)
399 1.1 matt 7: ret
400 1.1 matt
401 1.1 matt ENTRY(copyoutstr, 0)
402 1.2 matt tstl 8(%ap) # kernel address?
403 1.1 matt bgeq 8f # no, continue
404 1.1 matt brb 6b # yes, return EFAULT
405 1.1 matt
406 1.1 matt ENTRY(copystr,0)
407 1.2 matt 8: movl 4(%ap),%r5 # from
408 1.2 matt movl 8(%ap),%r4 # to
409 1.2 matt movl 12(%ap),%r3 # len
410 1.2 matt movl 16(%ap),%r2 # copied
411 1.2 matt clrl %r0
412 1.2 matt mfpr $PR_ESP,%r1
413 1.2 matt movab 3f,(%r1)
414 1.1 matt
415 1.2 matt tstl %r3 # any chars to copy?
416 1.1 matt bneq 1f # yes, jump for more
417 1.2 matt 0: tstl %r2 # save copied len?
418 1.1 matt beql 2f # no
419 1.2 matt subl3 4(%ap),%r5,(%r2) # save copied len
420 1.1 matt 2: ret
421 1.1 matt
422 1.2 matt 1: movb (%r5)+,(%r4)+ # copy one char
423 1.1 matt beql 0b # jmp if last char
424 1.2 matt sobgtr %r3,1b # copy one more
425 1.2 matt movl $ENAMETOOLONG,%r0 # inform about too long string
426 1.1 matt brb 0b # out of chars
427 1.1 matt
428 1.2 matt 3: mfpr $PR_ESP,%r1
429 1.2 matt clrl (%r1)
430 1.1 matt brb 0b
431 1.1 matt
432 1.1 matt ENTRY(subyte,0)
433 1.2 matt movl 4(%ap),%r0
434 1.1 matt blss 3f # illegal space
435 1.2 matt mfpr $PR_ESP,%r1
436 1.2 matt movab 1f,(%r1)
437 1.2 matt movb 8(%ap),(%r0)
438 1.2 matt clrl %r1
439 1.2 matt 1: mfpr $PR_ESP,%r2
440 1.2 matt clrl (%r2)
441 1.2 matt movl %r1,%r0
442 1.1 matt ret
443 1.1 matt
444 1.1 matt ENTRY(suword,0)
445 1.2 matt movl 4(%ap),%r0
446 1.1 matt blss 3f # illegal space
447 1.2 matt mfpr $PR_ESP,%r1
448 1.2 matt movab 1f,(%r1)
449 1.2 matt movl 8(%ap),(%r0)
450 1.2 matt clrl %r1
451 1.2 matt 1: mfpr $PR_ESP,%r2
452 1.2 matt clrl (%r2)
453 1.2 matt movl %r1,%r0
454 1.1 matt ret
455 1.1 matt
456 1.1 matt ENTRY(suswintr,0)
457 1.2 matt movl 4(%ap),%r0
458 1.1 matt blss 3f # illegal space
459 1.2 matt mfpr $PR_ESP,%r1
460 1.2 matt movab 1f,(%r1)
461 1.2 matt movw 8(%ap),(%r0)
462 1.2 matt clrl %r1
463 1.2 matt 1: mfpr $PR_ESP,%r2
464 1.2 matt clrl (%r2)
465 1.2 matt movl %r1,%r0
466 1.1 matt ret
467 1.1 matt
468 1.2 matt 3: mnegl $1,%r0
469 1.1 matt ret
470 1.1 matt
471 1.1 matt .align 2
472 1.1 matt ALTENTRY(fusword)
473 1.1 matt ENTRY(fuswintr,0)
474 1.2 matt movl 4(%ap),%r0
475 1.1 matt blss 3b
476 1.2 matt mfpr $PR_ESP,%r1
477 1.2 matt movab 1f,(%r1)
478 1.2 matt movzwl (%r0),%r1
479 1.2 matt 1: mfpr $PR_ESP,%r2
480 1.2 matt clrl (%r2)
481 1.2 matt movl %r1,%r0
482 1.1 matt ret
483 1.1 matt
484 1.1 matt JSBENTRY(Slock)
485 1.2 matt 1: bbssi $0,(%r1),1b
486 1.1 matt rsb
487 1.1 matt
488 1.1 matt JSBENTRY(Slocktry)
489 1.2 matt clrl %r0
490 1.2 matt bbssi $0,(%r1),1f
491 1.2 matt incl %r0
492 1.1 matt 1: rsb
493 1.1 matt
494 1.1 matt JSBENTRY(Sunlock)
495 1.2 matt bbcci $0,(%r1),1f
496 1.1 matt 1: rsb
497 1.1 matt
498 1.1 matt #
499 1.1 matt # data department
500 1.1 matt #
501 1.1 matt .data
502 1.1 matt
503 1.1 matt .globl _C_LABEL(memtest)
504 1.1 matt _C_LABEL(memtest): # memory test in progress
505 1.1 matt .long 0
506 1.1 matt
507 1.1 matt #ifdef __ELF__
508 1.1 matt .section .rodata
509 1.1 matt #endif
510 1.1 matt noque: .asciz "swtch"
511