locore.s revision 1.2 1 1.2 gwr /* $NetBSD: locore.s,v 1.2 1997/01/17 16:27:18 gwr Exp $ */
2 1.1 gwr
3 1.1 gwr /*
4 1.1 gwr * Copyright (c) 1988 University of Utah.
5 1.1 gwr * Copyright (c) 1980, 1990, 1993
6 1.1 gwr * The Regents of the University of California. All rights reserved.
7 1.1 gwr *
8 1.1 gwr * This code is derived from software contributed to Berkeley by
9 1.1 gwr * the Systems Programming Group of the University of Utah Computer
10 1.1 gwr * Science Department.
11 1.1 gwr *
12 1.1 gwr * Redistribution and use in source and binary forms, with or without
13 1.1 gwr * modification, are permitted provided that the following conditions
14 1.1 gwr * are met:
15 1.1 gwr * 1. Redistributions of source code must retain the above copyright
16 1.1 gwr * notice, this list of conditions and the following disclaimer.
17 1.1 gwr * 2. Redistributions in binary form must reproduce the above copyright
18 1.1 gwr * notice, this list of conditions and the following disclaimer in the
19 1.1 gwr * documentation and/or other materials provided with the distribution.
20 1.1 gwr * 3. All advertising materials mentioning features or use of this software
21 1.1 gwr * must display the following acknowledgement:
22 1.1 gwr * This product includes software developed by the University of
23 1.1 gwr * California, Berkeley and its contributors.
24 1.1 gwr * 4. Neither the name of the University nor the names of its contributors
25 1.1 gwr * may be used to endorse or promote products derived from this software
26 1.1 gwr * without specific prior written permission.
27 1.1 gwr *
28 1.1 gwr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 1.1 gwr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.1 gwr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.1 gwr * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 1.1 gwr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.1 gwr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.1 gwr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.1 gwr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 1.1 gwr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 1.1 gwr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 1.1 gwr * SUCH DAMAGE.
39 1.1 gwr *
40 1.1 gwr * from: Utah $Hdr: locore.s 1.66 92/12/22$
41 1.1 gwr * @(#)locore.s 8.6 (Berkeley) 5/27/94
42 1.1 gwr */
43 1.1 gwr
44 1.1 gwr #include "assym.h"
45 1.1 gwr #include <machine/trap.h>
46 1.1 gwr
47 1.1 gwr | Remember this is a fun project!
48 1.1 gwr
49 1.1 gwr .data
50 1.1 gwr .globl _mon_crp
51 1.1 gwr _mon_crp:
52 1.1 gwr .long 0,0
53 1.1 gwr
54 1.1 gwr | This is for kvm_mkdb, and should be the address of the beginning
55 1.1 gwr | of the kernel text segment (not necessarily the same as kernbase).
56 1.1 gwr .text
57 1.1 gwr .globl _kernel_text
58 1.1 gwr _kernel_text:
59 1.1 gwr
60 1.1 gwr | This is the entry point, as well as the end of the temporary stack
61 1.1 gwr | used during process switch (one 8K page ending at start)
62 1.1 gwr .globl tmpstk
63 1.1 gwr tmpstk:
64 1.1 gwr .globl start
65 1.1 gwr start:
66 1.1 gwr | The first step, after disabling interrupts, is to map enough of the kernel
67 1.1 gwr | into high virtual address space so that we can use position dependent code.
68 1.1 gwr | This is a tricky task on the sun3x because the MMU is already enabled and
69 1.1 gwr | the ROM monitor provides no indication of where the root MMU table is mapped.
70 1.1 gwr | Therefore we must use one of the 68030's 'transparent translation' registers
71 1.1 gwr | to define a range in the address space where the MMU translation is
72 1.1 gwr | turned off. Once this is complete we can modify the MMU table directly
73 1.1 gwr | without the need for it to be mapped into virtual memory.
74 1.1 gwr | All code must be position independent until otherwise noted, as the
75 1.1 gwr | boot loader has loaded us into low memory but all the symbols in this
76 1.1 gwr | code have been linked high.
77 1.1 gwr movw #PSL_HIGHIPL, sr | no interrupts
78 1.1 gwr movl #KERNBASE, a5 | for vtop conversion
79 1.1 gwr lea _mon_crp, a0 | where to store the CRP
80 1.1 gwr subl a5, a0
81 1.1 gwr | Note: borrowing mon_crp for tt0 setup...
82 1.1 gwr movl #0x3F8107, a0@ | map the low 1GB v=p with the
83 1.1 gwr pmove a0@, tt0 | transparent translation reg0
84 1.1 gwr
85 1.1 gwr | In order to map the kernel into high memory we will copy the root table
86 1.1 gwr | entry which maps the 16 megabytes of memory starting at 0x0 into the
87 1.1 gwr | entry which maps the 16 megabytes starting at KERNBASE.
88 1.1 gwr pmove crp, a0@ | Get monitor CPU root pointer
89 1.1 gwr movl a0@(4), a1 | 2nd word is PA of level A table
90 1.1 gwr
91 1.1 gwr movl a1, a0 | compute the descriptor address
92 1.1 gwr addl #0x3e0, a1 | for VA starting at KERNBASE
93 1.1 gwr movl a0@, a1@ | copy descriptor type
94 1.1 gwr movl a0@(4), a1@(4) | copy physical address
95 1.1 gwr
96 1.1 gwr | Kernel is now double mapped at zero and KERNBASE.
97 1.1 gwr | Force a long jump to the relocated code (high VA).
98 1.1 gwr movl #IC_CLEAR, d0 | Flush the I-cache
99 1.1 gwr movc d0, cacr
100 1.1 gwr jmp L_high_code:l | long jump
101 1.1 gwr
102 1.1 gwr L_high_code:
103 1.1 gwr | We are now running in the correctly relocated kernel, so
104 1.1 gwr | we are no longer restricted to position-independent code.
105 1.1 gwr | It is handy to leave transparent translation enabled while
106 1.1 gwr | for the low 1GB while __bootstrap() is doing its thing.
107 1.1 gwr
108 1.1 gwr | Do bootstrap stuff needed before main() gets called.
109 1.1 gwr | Our boot loader leaves a copy of the kernel's exec header
110 1.1 gwr | just before the start of the kernel text segment, so the
111 1.1 gwr | kernel can sanity-check the DDB symbols at [end...esym].
112 1.1 gwr | Pass the struct exec at tmpstk-32 to __bootstrap().
113 1.1 gwr lea tmpstk-32, sp
114 1.1 gwr jsr __bootstrap | See _startup.c
115 1.1 gwr
116 1.1 gwr | Now turn off the transparent translation of the low 1GB.
117 1.1 gwr | (this also flushes the ATC)
118 1.1 gwr clrl sp@-
119 1.1 gwr pmove sp@,tt0
120 1.1 gwr addql #4,sp
121 1.1 gwr
122 1.1 gwr | Now that __bootstrap() is done using the PROM functions,
123 1.1 gwr | we can safely set the sfc/dfc to something != FC_CONTROL
124 1.1 gwr moveq #FC_USERD, d0 | make movs access "user data"
125 1.1 gwr movc d0, sfc | space for copyin/copyout
126 1.1 gwr movc d0, dfc
127 1.1 gwr
128 1.1 gwr | Setup process zero user/kernel stacks.
129 1.1 gwr movl _proc0paddr,a1 | get proc0 pcb addr
130 1.1 gwr lea a1@(USPACE-4),sp | set SSP to last word
131 1.1 gwr movl #USRSTACK-4,a2
132 1.1 gwr movl a2,usp | init user SP
133 1.1 gwr
134 1.1 gwr | Note curpcb was already set in __bootstrap().
135 1.1 gwr | Will do fpu initialization during autoconfig (see fpu.c)
136 1.1 gwr | The interrupt vector table and stack are now ready.
137 1.1 gwr | Interrupts will be enabled later, AFTER autoconfiguration
138 1.1 gwr | is finished, to avoid spurrious interrupts.
139 1.1 gwr
140 1.1 gwr /*
141 1.1 gwr * Final preparation for calling main.
142 1.1 gwr *
143 1.1 gwr * Create a fake exception frame that returns to user mode,
144 1.1 gwr * and save its address in p->p_md.md_regs for cpu_fork().
145 1.1 gwr * The new frames for process 1 and 2 will be adjusted by
146 1.1 gwr * cpu_set_kpc() to arrange for a call to a kernel function
147 1.1 gwr * before the new process does its rte out to user mode.
148 1.1 gwr */
149 1.1 gwr clrw sp@- | vector offset/frame type
150 1.1 gwr clrl sp@- | PC - filled in by "execve"
151 1.1 gwr movw #PSL_USER,sp@- | in user mode
152 1.1 gwr clrl sp@- | stack adjust count and padding
153 1.1 gwr lea sp@(-64),sp | construct space for D0-D7/A0-A7
154 1.1 gwr lea _proc0,a0 | proc0 in a0
155 1.1 gwr movl sp,a0@(P_MDREGS) | save frame for proc0
156 1.1 gwr movl usp,a1
157 1.1 gwr movl a1,sp@(FR_SP) | save user stack pointer in frame
158 1.1 gwr jbsr _main | main()
159 1.1 gwr trap #15 | should not get here
160 1.1 gwr
161 1.1 gwr | This is used by cpu_fork() to return to user mode.
162 1.1 gwr | It is called with SP pointing to a struct trapframe.
163 1.1 gwr .globl _proc_do_uret
164 1.1 gwr _proc_do_uret:
165 1.1 gwr movl sp@(FR_SP),a0 | grab and load
166 1.1 gwr movl a0,usp | user SP
167 1.1 gwr moveml sp@+,#0x7FFF | load most registers (all but SSP)
168 1.1 gwr addql #8,sp | pop SSP and stack adjust count
169 1.1 gwr rte
170 1.1 gwr
171 1.1 gwr /*
172 1.1 gwr * proc_trampoline:
173 1.1 gwr * This is used by cpu_set_kpc() to "push" a function call onto the
174 1.1 gwr * kernel stack of some process, very much like a signal delivery.
175 1.1 gwr * When we get here, the stack has:
176 1.1 gwr *
177 1.1 gwr * SP+8: switchframe from before cpu_set_kpc
178 1.1 gwr * SP+4: void *proc;
179 1.1 gwr * SP: u_long func;
180 1.1 gwr *
181 1.1 gwr * On entry, the switchframe pushed by cpu_set_kpc has already been
182 1.1 gwr * popped off the stack, so all this needs to do is pop the function
183 1.1 gwr * pointer into a register, call it, then pop the arg, and finally
184 1.1 gwr * return using the switchframe that remains on the stack.
185 1.1 gwr */
186 1.1 gwr .globl _proc_trampoline
187 1.1 gwr _proc_trampoline:
188 1.1 gwr movl sp@+,a0 | function pointer
189 1.1 gwr jbsr a0@ | (*func)(procp)
190 1.1 gwr addql #4,sp | toss the arg
191 1.1 gwr rts | as cpu_switch would do
192 1.1 gwr
193 1.1 gwr | That is all the assembly startup code we need on the sun3x!
194 1.1 gwr | The rest of this is like the hp300/locore.s where possible.
195 1.1 gwr
196 1.1 gwr /*
197 1.1 gwr * Trap/interrupt vector routines
198 1.1 gwr */
199 1.1 gwr
200 1.1 gwr .globl _buserr, _addrerr, _illinst, _zerodiv, _chkinst
201 1.1 gwr .globl _trapvinst, _privinst, _trace, _badtrap, _fmterr
202 1.1 gwr .globl _trap0, _trap1, _trap2, _trap12, _trap15
203 1.1 gwr .globl _coperr, _fpfline, _fpunsupp
204 1.1 gwr
205 1.1 gwr .globl _trap, _nofault, _longjmp
206 1.1 gwr _buserr:
207 1.1 gwr tstl _nofault | device probe?
208 1.1 gwr jeq _addrerr | no, handle as usual
209 1.1 gwr movl _nofault,sp@- | yes,
210 1.1 gwr jbsr _longjmp | longjmp(nofault)
211 1.1 gwr _addrerr:
212 1.1 gwr clrl sp@- | stack adjust count
213 1.1 gwr moveml #0xFFFF,sp@- | save user registers
214 1.1 gwr movl usp,a0 | save the user SP
215 1.1 gwr movl a0,sp@(FR_SP) | in the savearea
216 1.1 gwr lea sp@(FR_HW),a1 | grab base of HW berr frame
217 1.1 gwr moveq #0,d0
218 1.1 gwr movw a1@(10),d0 | grab SSW for fault processing
219 1.1 gwr btst #12,d0 | RB set?
220 1.1 gwr jeq LbeX0 | no, test RC
221 1.1 gwr bset #14,d0 | yes, must set FB
222 1.1 gwr movw d0,a1@(10) | for hardware too
223 1.1 gwr LbeX0:
224 1.1 gwr btst #13,d0 | RC set?
225 1.1 gwr jeq LbeX1 | no, skip
226 1.1 gwr bset #15,d0 | yes, must set FC
227 1.1 gwr movw d0,a1@(10) | for hardware too
228 1.1 gwr LbeX1:
229 1.1 gwr btst #8,d0 | data fault?
230 1.1 gwr jeq Lbe0 | no, check for hard cases
231 1.1 gwr movl a1@(16),d1 | fault address is as given in frame
232 1.1 gwr jra Lbe10 | thats it
233 1.1 gwr Lbe0:
234 1.1 gwr btst #4,a1@(6) | long (type B) stack frame?
235 1.1 gwr jne Lbe4 | yes, go handle
236 1.1 gwr movl a1@(2),d1 | no, can use save PC
237 1.1 gwr btst #14,d0 | FB set?
238 1.1 gwr jeq Lbe3 | no, try FC
239 1.1 gwr addql #4,d1 | yes, adjust address
240 1.1 gwr jra Lbe10 | done
241 1.1 gwr Lbe3:
242 1.1 gwr btst #15,d0 | FC set?
243 1.1 gwr jeq Lbe10 | no, done
244 1.1 gwr addql #2,d1 | yes, adjust address
245 1.1 gwr jra Lbe10 | done
246 1.1 gwr Lbe4:
247 1.1 gwr movl a1@(36),d1 | long format, use stage B address
248 1.1 gwr btst #15,d0 | FC set?
249 1.1 gwr jeq Lbe10 | no, all done
250 1.1 gwr subql #2,d1 | yes, adjust address
251 1.1 gwr Lbe10:
252 1.1 gwr movl d1,sp@- | push fault VA
253 1.1 gwr movl d0,sp@- | and padded SSW
254 1.1 gwr movw a1@(6),d0 | get frame format/vector offset
255 1.1 gwr andw #0x0FFF,d0 | clear out frame format
256 1.1 gwr cmpw #12,d0 | address error vector?
257 1.1 gwr jeq Lisaerr | yes, go to it
258 1.1 gwr
259 1.1 gwr /* MMU-specific code to determine reason for bus error. */
260 1.1 gwr movl d1,a0 | fault address
261 1.1 gwr movl sp@,d0 | function code from ssw
262 1.1 gwr btst #8,d0 | data fault?
263 1.1 gwr jne Lbe10a
264 1.1 gwr movql #1,d0 | user program access FC
265 1.1 gwr | (we dont separate data/program)
266 1.1 gwr btst #5,a1@ | supervisor mode?
267 1.1 gwr jeq Lbe10a | if no, done
268 1.1 gwr movql #5,d0 | else supervisor program access
269 1.1 gwr Lbe10a:
270 1.1 gwr ptestr d0,a0@,#7 | do a table search
271 1.1 gwr pmove psr,sp@ | save result
272 1.1 gwr movb sp@,d1
273 1.1 gwr btst #2,d1 | invalid? (incl. limit viol and berr)
274 1.1 gwr jeq Lmightnotbemerr | no -> wp check
275 1.1 gwr btst #7,d1 | is it MMU table berr?
276 1.1 gwr jeq Lismerr | no, must be fast
277 1.1 gwr jra Lisberr1 | real bus err needs not be fast
278 1.1 gwr Lmightnotbemerr:
279 1.1 gwr btst #3,d1 | write protect bit set?
280 1.1 gwr jeq Lisberr1 | no, must be bus error
281 1.1 gwr movl sp@,d0 | ssw into low word of d0
282 1.1 gwr andw #0xc0,d0 | write protect is set on page:
283 1.1 gwr cmpw #0x40,d0 | was it read cycle?
284 1.1 gwr jeq Lisberr1 | yes, was not WPE, must be bus err
285 1.1 gwr /* End of MMU-specific bus error code. */
286 1.1 gwr
287 1.1 gwr Lismerr:
288 1.1 gwr movl #T_MMUFLT,sp@- | show that we are an MMU fault
289 1.1 gwr jra Ltrapnstkadj | and deal with it
290 1.1 gwr Lisaerr:
291 1.1 gwr movl #T_ADDRERR,sp@- | mark address error
292 1.1 gwr jra Ltrapnstkadj | and deal with it
293 1.1 gwr Lisberr1:
294 1.1 gwr clrw sp@ | re-clear pad word
295 1.1 gwr Lisberr:
296 1.1 gwr movl #T_BUSERR,sp@- | mark bus error
297 1.1 gwr Ltrapnstkadj:
298 1.1 gwr jbsr _trap | handle the error
299 1.1 gwr lea sp@(12),sp | pop value args
300 1.1 gwr movl sp@(FR_SP),a0 | restore user SP
301 1.1 gwr movl a0,usp | from save area
302 1.1 gwr movw sp@(FR_ADJ),d0 | need to adjust stack?
303 1.1 gwr jne Lstkadj | yes, go to it
304 1.1 gwr moveml sp@+,#0x7FFF | no, restore most user regs
305 1.1 gwr addql #8,sp | toss SSP and stkadj
306 1.1 gwr jra rei | all done
307 1.1 gwr Lstkadj:
308 1.1 gwr lea sp@(FR_HW),a1 | pointer to HW frame
309 1.1 gwr addql #8,a1 | source pointer
310 1.1 gwr movl a1,a0 | source
311 1.1 gwr addw d0,a0 | + hole size = dest pointer
312 1.1 gwr movl a1@-,a0@- | copy
313 1.1 gwr movl a1@-,a0@- | 8 bytes
314 1.1 gwr movl a0,sp@(FR_SP) | new SSP
315 1.1 gwr moveml sp@+,#0x7FFF | restore user registers
316 1.1 gwr movl sp@,sp | and our SP
317 1.1 gwr jra rei | all done
318 1.1 gwr
319 1.1 gwr /*
320 1.1 gwr * FP exceptions.
321 1.1 gwr */
322 1.1 gwr _fpfline:
323 1.1 gwr clrl sp@- | stack adjust count
324 1.1 gwr moveml #0xFFFF,sp@- | save registers
325 1.1 gwr moveq #T_FPEMULI,d0 | denote as FP emulation trap
326 1.1 gwr jra fault | do it
327 1.1 gwr
328 1.1 gwr _fpunsupp:
329 1.1 gwr clrl sp@- | stack adjust count
330 1.1 gwr moveml #0xFFFF,sp@- | save registers
331 1.1 gwr moveq #T_FPEMULD,d0 | denote as FP emulation trap
332 1.1 gwr jra fault | do it
333 1.1 gwr
334 1.1 gwr /*
335 1.1 gwr * Handles all other FP coprocessor exceptions.
336 1.1 gwr * Note that since some FP exceptions generate mid-instruction frames
337 1.1 gwr * and may cause signal delivery, we need to test for stack adjustment
338 1.1 gwr * after the trap call.
339 1.1 gwr */
340 1.1 gwr .globl _fpfault
341 1.1 gwr _fpfault:
342 1.1 gwr clrl sp@- | stack adjust count
343 1.1 gwr moveml #0xFFFF,sp@- | save user registers
344 1.1 gwr movl usp,a0 | and save
345 1.1 gwr movl a0,sp@(FR_SP) | the user stack pointer
346 1.1 gwr clrl sp@- | no VA arg
347 1.1 gwr movl _curpcb,a0 | current pcb
348 1.1 gwr lea a0@(PCB_FPCTX),a0 | address of FP savearea
349 1.1 gwr fsave a0@ | save state
350 1.1 gwr tstb a0@ | null state frame?
351 1.1 gwr jeq Lfptnull | yes, safe
352 1.1 gwr clrw d0 | no, need to tweak BIU
353 1.1 gwr movb a0@(1),d0 | get frame size
354 1.1 gwr bset #3,a0@(0,d0:w) | set exc_pend bit of BIU
355 1.1 gwr Lfptnull:
356 1.1 gwr fmovem fpsr,sp@- | push fpsr as code argument
357 1.1 gwr frestore a0@ | restore state
358 1.1 gwr movl #T_FPERR,sp@- | push type arg
359 1.1 gwr jra Ltrapnstkadj | call trap and deal with stack cleanup
360 1.1 gwr
361 1.1 gwr /*
362 1.1 gwr * Coprocessor and format errors can generate mid-instruction stack
363 1.1 gwr * frames and cause signal delivery hence we need to check for potential
364 1.1 gwr * stack adjustment.
365 1.1 gwr */
366 1.1 gwr _coperr:
367 1.1 gwr clrl sp@- | stack adjust count
368 1.1 gwr moveml #0xFFFF,sp@-
369 1.1 gwr movl usp,a0 | get and save
370 1.1 gwr movl a0,sp@(FR_SP) | the user stack pointer
371 1.1 gwr clrl sp@- | no VA arg
372 1.1 gwr clrl sp@- | or code arg
373 1.1 gwr movl #T_COPERR,sp@- | push trap type
374 1.1 gwr jra Ltrapnstkadj | call trap and deal with stack adjustments
375 1.1 gwr
376 1.1 gwr _fmterr:
377 1.1 gwr clrl sp@- | stack adjust count
378 1.1 gwr moveml #0xFFFF,sp@-
379 1.1 gwr movl usp,a0 | get and save
380 1.1 gwr movl a0,sp@(FR_SP) | the user stack pointer
381 1.1 gwr clrl sp@- | no VA arg
382 1.1 gwr clrl sp@- | or code arg
383 1.1 gwr movl #T_FMTERR,sp@- | push trap type
384 1.1 gwr jra Ltrapnstkadj | call trap and deal with stack adjustments
385 1.1 gwr
386 1.1 gwr /*
387 1.1 gwr * Other exceptions only cause four and six word stack frame and require
388 1.1 gwr * no post-trap stack adjustment.
389 1.1 gwr */
390 1.1 gwr _illinst:
391 1.1 gwr clrl sp@-
392 1.1 gwr moveml #0xFFFF,sp@-
393 1.1 gwr moveq #T_ILLINST,d0
394 1.1 gwr jra fault
395 1.1 gwr
396 1.1 gwr _zerodiv:
397 1.1 gwr clrl sp@-
398 1.1 gwr moveml #0xFFFF,sp@-
399 1.1 gwr moveq #T_ZERODIV,d0
400 1.1 gwr jra fault
401 1.1 gwr
402 1.1 gwr _chkinst:
403 1.1 gwr clrl sp@-
404 1.1 gwr moveml #0xFFFF,sp@-
405 1.1 gwr moveq #T_CHKINST,d0
406 1.1 gwr jra fault
407 1.1 gwr
408 1.1 gwr _trapvinst:
409 1.1 gwr clrl sp@-
410 1.1 gwr moveml #0xFFFF,sp@-
411 1.1 gwr moveq #T_TRAPVINST,d0
412 1.1 gwr jra fault
413 1.1 gwr
414 1.1 gwr _privinst:
415 1.1 gwr clrl sp@-
416 1.1 gwr moveml #0xFFFF,sp@-
417 1.1 gwr moveq #T_PRIVINST,d0
418 1.1 gwr jra fault
419 1.1 gwr
420 1.1 gwr .globl fault
421 1.1 gwr fault:
422 1.1 gwr movl usp,a0 | get and save
423 1.1 gwr movl a0,sp@(FR_SP) | the user stack pointer
424 1.1 gwr clrl sp@- | no VA arg
425 1.1 gwr clrl sp@- | or code arg
426 1.1 gwr movl d0,sp@- | push trap type
427 1.1 gwr jbsr _trap | handle trap
428 1.1 gwr lea sp@(12),sp | pop value args
429 1.1 gwr movl sp@(FR_SP),a0 | restore
430 1.1 gwr movl a0,usp | user SP
431 1.1 gwr moveml sp@+,#0x7FFF | restore most user regs
432 1.1 gwr addql #8,sp | pop SP and stack adjust
433 1.1 gwr jra rei | all done
434 1.1 gwr
435 1.1 gwr .globl _straytrap
436 1.1 gwr _badtrap:
437 1.1 gwr clrl sp@- | stack adjust count
438 1.1 gwr moveml #0xFFFF,sp@- | save std frame regs
439 1.1 gwr jbsr _straytrap | report
440 1.1 gwr moveml sp@+,#0xFFFF | restore regs
441 1.1 gwr addql #4, sp | stack adjust count
442 1.1 gwr jra rei | all done
443 1.1 gwr
444 1.1 gwr /*
445 1.1 gwr * Trap 0 is for system calls
446 1.1 gwr */
447 1.1 gwr .globl _syscall
448 1.1 gwr _trap0:
449 1.1 gwr clrl sp@- | stack adjust count
450 1.1 gwr moveml #0xFFFF,sp@- | save user registers
451 1.1 gwr movl usp,a0 | save the user SP
452 1.1 gwr movl a0,sp@(FR_SP) | in the savearea
453 1.1 gwr movl d0,sp@- | push syscall number
454 1.1 gwr jbsr _syscall | handle it
455 1.1 gwr addql #4,sp | pop syscall arg
456 1.1 gwr movl sp@(FR_SP),a0 | grab and restore
457 1.1 gwr movl a0,usp | user SP
458 1.1 gwr moveml sp@+,#0x7FFF | restore most registers
459 1.1 gwr addql #8,sp | pop SP and stack adjust
460 1.1 gwr jra rei | all done
461 1.1 gwr
462 1.1 gwr /*
463 1.1 gwr * Trap 1 is either:
464 1.1 gwr * sigreturn (native NetBSD executable)
465 1.1 gwr * breakpoint (HPUX executable)
466 1.1 gwr */
467 1.1 gwr _trap1:
468 1.1 gwr #if 0 /* COMPAT_HPUX */
469 1.1 gwr /* If process is HPUX, this is a user breakpoint. */
470 1.1 gwr jne trap15 | breakpoint
471 1.1 gwr #endif
472 1.1 gwr /* fall into sigreturn */
473 1.1 gwr
474 1.1 gwr /*
475 1.1 gwr * The sigreturn() syscall comes here. It requires special handling
476 1.1 gwr * because we must open a hole in the stack to fill in the (possibly much
477 1.1 gwr * larger) original stack frame.
478 1.1 gwr */
479 1.1 gwr sigreturn:
480 1.1 gwr lea sp@(-84),sp | leave enough space for largest frame
481 1.1 gwr movl sp@(84),sp@ | move up current 8 byte frame
482 1.1 gwr movl sp@(88),sp@(4)
483 1.1 gwr movl #84,sp@- | default: adjust by 84 bytes
484 1.1 gwr moveml #0xFFFF,sp@- | save user registers
485 1.1 gwr movl usp,a0 | save the user SP
486 1.1 gwr movl a0,sp@(FR_SP) | in the savearea
487 1.1 gwr movl #SYS_sigreturn,sp@- | push syscall number
488 1.1 gwr jbsr _syscall | handle it
489 1.1 gwr addql #4,sp | pop syscall#
490 1.1 gwr movl sp@(FR_SP),a0 | grab and restore
491 1.1 gwr movl a0,usp | user SP
492 1.1 gwr lea sp@(FR_HW),a1 | pointer to HW frame
493 1.1 gwr movw sp@(FR_ADJ),d0 | do we need to adjust the stack?
494 1.1 gwr jeq Lsigr1 | no, just continue
495 1.1 gwr moveq #92,d1 | total size
496 1.1 gwr subw d0,d1 | - hole size = frame size
497 1.1 gwr lea a1@(92),a0 | destination
498 1.1 gwr addw d1,a1 | source
499 1.1 gwr lsrw #1,d1 | convert to word count
500 1.1 gwr subqw #1,d1 | minus 1 for dbf
501 1.1 gwr Lsigrlp:
502 1.1 gwr movw a1@-,a0@- | copy a word
503 1.1 gwr dbf d1,Lsigrlp | continue
504 1.1 gwr movl a0,a1 | new HW frame base
505 1.1 gwr Lsigr1:
506 1.1 gwr movl a1,sp@(FR_SP) | new SP value
507 1.1 gwr moveml sp@+,#0x7FFF | restore user registers
508 1.1 gwr movl sp@,sp | and our SP
509 1.1 gwr jra rei | all done
510 1.1 gwr
511 1.1 gwr /*
512 1.1 gwr * Trap 2 is one of:
513 1.1 gwr * NetBSD: not used (ignore)
514 1.1 gwr * SunOS: Some obscure FPU operation
515 1.1 gwr * HPUX: sigreturn
516 1.1 gwr */
517 1.1 gwr _trap2:
518 1.1 gwr #if 0 /* COMPAT_HPUX */
519 1.1 gwr /* XXX: If HPUX, this is a user breakpoint. */
520 1.1 gwr jne sigreturn
521 1.1 gwr #endif
522 1.1 gwr /* fall into trace (NetBSD or SunOS) */
523 1.1 gwr
524 1.1 gwr /*
525 1.1 gwr * Trace (single-step) trap. Kernel-mode is special.
526 1.1 gwr * User mode traps are simply passed on to trap().
527 1.1 gwr */
528 1.1 gwr _trace:
529 1.1 gwr clrl sp@- | stack adjust count
530 1.1 gwr moveml #0xFFFF,sp@-
531 1.1 gwr moveq #T_TRACE,d0
532 1.1 gwr movw sp@(FR_HW),d1 | get PSW
533 1.1 gwr andw #PSL_S,d1 | from system mode?
534 1.1 gwr jne kbrkpt | yes, kernel breakpoint
535 1.1 gwr jra fault | no, user-mode fault
536 1.1 gwr
537 1.1 gwr /*
538 1.1 gwr * Trap 15 is used for:
539 1.1 gwr * - GDB breakpoints (in user programs)
540 1.1 gwr * - KGDB breakpoints (in the kernel)
541 1.1 gwr * - trace traps for SUN binaries (not fully supported yet)
542 1.1 gwr * User mode traps are passed simply passed to trap()
543 1.1 gwr */
544 1.1 gwr _trap15:
545 1.1 gwr clrl sp@- | stack adjust count
546 1.1 gwr moveml #0xFFFF,sp@-
547 1.1 gwr moveq #T_TRAP15,d0
548 1.1 gwr movw sp@(FR_HW),d1 | get PSW
549 1.1 gwr andw #PSL_S,d1 | from system mode?
550 1.1 gwr jne kbrkpt | yes, kernel breakpoint
551 1.1 gwr jra fault | no, user-mode fault
552 1.1 gwr
553 1.1 gwr kbrkpt: | Kernel-mode breakpoint or trace trap. (d0=trap_type)
554 1.1 gwr | Save the system sp rather than the user sp.
555 1.1 gwr movw #PSL_HIGHIPL,sr | lock out interrupts
556 1.1 gwr lea sp@(FR_SIZE),a6 | Save stack pointer
557 1.1 gwr movl a6,sp@(FR_SP) | from before trap
558 1.1 gwr
559 1.1 gwr | If we are not on tmpstk switch to it.
560 1.1 gwr | (so debugger can change the stack pointer)
561 1.1 gwr movl a6,d1
562 1.1 gwr cmpl #tmpstk,d1
563 1.1 gwr jls Lbrkpt2 | already on tmpstk
564 1.1 gwr | Copy frame to the temporary stack
565 1.1 gwr movl sp,a0 | a0=src
566 1.1 gwr lea tmpstk-96,a1 | a1=dst
567 1.1 gwr movl a1,sp | sp=new frame
568 1.1 gwr moveq #FR_SIZE,d1
569 1.1 gwr Lbrkpt1:
570 1.1 gwr movl a0@+,a1@+
571 1.1 gwr subql #4,d1
572 1.1 gwr bgt Lbrkpt1
573 1.1 gwr
574 1.1 gwr Lbrkpt2:
575 1.1 gwr | Call the trap handler for the kernel debugger.
576 1.1 gwr | Do not call trap() to do it, so that we can
577 1.1 gwr | set breakpoints in trap() if we want. We know
578 1.1 gwr | the trap type is either T_TRACE or T_BREAKPOINT.
579 1.1 gwr | If we have both DDB and KGDB, let KGDB see it first,
580 1.1 gwr | because KGDB will just return 0 if not connected.
581 1.1 gwr | Save args in d2, a2
582 1.1 gwr movl d0,d2 | trap type
583 1.1 gwr movl sp,a2 | frame ptr
584 1.1 gwr #ifdef KGDB
585 1.1 gwr | Let KGDB handle it (if connected)
586 1.1 gwr movl a2,sp@- | push frame ptr
587 1.1 gwr movl d2,sp@- | push trap type
588 1.1 gwr jbsr _kgdb_trap | handle the trap
589 1.1 gwr addql #8,sp | pop args
590 1.1 gwr cmpl #0,d0 | did kgdb handle it
591 1.1 gwr jne Lbrkpt3 | yes, done
592 1.1 gwr #endif
593 1.1 gwr #ifdef DDB
594 1.1 gwr | Let DDB handle it.
595 1.1 gwr movl a2,sp@- | push frame ptr
596 1.1 gwr movl d2,sp@- | push trap type
597 1.1 gwr jbsr _kdb_trap | handle the trap
598 1.1 gwr addql #8,sp | pop args
599 1.1 gwr cmpl #0,d0 | did ddb handle it
600 1.1 gwr jne Lbrkpt3 | yes, done
601 1.1 gwr #endif
602 1.1 gwr | Drop into the PROM temporarily...
603 1.1 gwr movl a2,sp@- | push frame ptr
604 1.1 gwr movl d2,sp@- | push trap type
605 1.1 gwr jbsr _nodb_trap | handle the trap
606 1.1 gwr addql #8,sp | pop args
607 1.1 gwr Lbrkpt3:
608 1.1 gwr | The stack pointer may have been modified, or
609 1.1 gwr | data below it modified (by kgdb push call),
610 1.1 gwr | so push the hardware frame at the current sp
611 1.1 gwr | before restoring registers and returning.
612 1.1 gwr
613 1.1 gwr movl sp@(FR_SP),a0 | modified sp
614 1.1 gwr lea sp@(FR_SIZE),a1 | end of our frame
615 1.1 gwr movl a1@-,a0@- | copy 2 longs with
616 1.1 gwr movl a1@-,a0@- | ... predecrement
617 1.1 gwr movl a0,sp@(FR_SP) | sp = h/w frame
618 1.1 gwr moveml sp@+,#0x7FFF | restore all but sp
619 1.1 gwr movl sp@,sp | ... and sp
620 1.1 gwr rte | all done
621 1.1 gwr
622 1.1 gwr /*
623 1.1 gwr * Trap 12 is the entry point for the cachectl "syscall"
624 1.1 gwr * cachectl(command, addr, length)
625 1.1 gwr * command in d0, addr in a1, length in d1
626 1.1 gwr */
627 1.1 gwr .globl _cachectl
628 1.1 gwr _trap12:
629 1.1 gwr movl d1,sp@- | push length
630 1.1 gwr movl a1,sp@- | push addr
631 1.1 gwr movl d0,sp@- | push command
632 1.1 gwr jbsr _cachectl | do it
633 1.1 gwr lea sp@(12),sp | pop args
634 1.1 gwr jra rei | all done
635 1.1 gwr
636 1.1 gwr /*
637 1.1 gwr * Interrupt handlers. Most are auto-vectored,
638 1.1 gwr * and hard-wired the same way on all sun3 models.
639 1.1 gwr * Format in the stack is:
640 1.1 gwr * d0,d1,a0,a1, sr, pc, vo
641 1.1 gwr */
642 1.1 gwr
643 1.1 gwr #define INTERRUPT_SAVEREG \
644 1.1 gwr moveml #0xC0C0,sp@-
645 1.1 gwr
646 1.1 gwr #define INTERRUPT_RESTORE \
647 1.1 gwr moveml sp@+,#0x0303
648 1.1 gwr
649 1.1 gwr /*
650 1.1 gwr * This is the common auto-vector interrupt handler,
651 1.1 gwr * for which the CPU provides the vector=0x18+level.
652 1.1 gwr * These are installed in the interrupt vector table.
653 1.1 gwr */
654 1.1 gwr .align 2
655 1.1 gwr .globl __isr_autovec, _isr_autovec
656 1.1 gwr __isr_autovec:
657 1.1 gwr INTERRUPT_SAVEREG
658 1.1 gwr jbsr _isr_autovec
659 1.1 gwr INTERRUPT_RESTORE
660 1.1 gwr jra rei
661 1.1 gwr
662 1.1 gwr /* clock: see clock.c */
663 1.1 gwr .align 2
664 1.1 gwr .globl __isr_clock, _clock_intr
665 1.1 gwr __isr_clock:
666 1.1 gwr INTERRUPT_SAVEREG
667 1.1 gwr jbsr _clock_intr
668 1.1 gwr INTERRUPT_RESTORE
669 1.1 gwr jra rei
670 1.1 gwr
671 1.1 gwr | Handler for all vectored interrupts (i.e. VME interrupts)
672 1.1 gwr .align 2
673 1.1 gwr .globl __isr_vectored, _isr_vectored
674 1.1 gwr __isr_vectored:
675 1.1 gwr INTERRUPT_SAVEREG
676 1.1 gwr jbsr _isr_vectored
677 1.1 gwr INTERRUPT_RESTORE
678 1.1 gwr jra rei
679 1.1 gwr
680 1.1 gwr #undef INTERRUPT_SAVEREG
681 1.1 gwr #undef INTERRUPT_RESTORE
682 1.1 gwr
683 1.1 gwr /* interrupt counters (needed by vmstat) */
684 1.1 gwr .globl _intrcnt,_eintrcnt,_intrnames,_eintrnames
685 1.1 gwr _intrnames:
686 1.1 gwr .asciz "spur" | 0
687 1.1 gwr .asciz "lev1" | 1
688 1.1 gwr .asciz "lev2" | 2
689 1.1 gwr .asciz "lev3" | 3
690 1.1 gwr .asciz "lev4" | 4
691 1.1 gwr .asciz "clock" | 5
692 1.1 gwr .asciz "lev6" | 6
693 1.1 gwr .asciz "nmi" | 7
694 1.1 gwr _eintrnames:
695 1.1 gwr
696 1.1 gwr .data
697 1.1 gwr .even
698 1.1 gwr _intrcnt:
699 1.1 gwr .long 0,0,0,0,0,0,0,0,0,0
700 1.1 gwr _eintrcnt:
701 1.1 gwr .text
702 1.1 gwr
703 1.1 gwr /*
704 1.1 gwr * Emulation of VAX REI instruction.
705 1.1 gwr *
706 1.1 gwr * This code is (mostly) un-altered from the hp300 code,
707 1.1 gwr * except that sun machines do not need a simulated SIR
708 1.1 gwr * because they have a real software interrupt register.
709 1.1 gwr *
710 1.1 gwr * This code deals with checking for and servicing ASTs
711 1.1 gwr * (profiling, scheduling) and software interrupts (network, softclock).
712 1.1 gwr * We check for ASTs first, just like the VAX. To avoid excess overhead
713 1.1 gwr * the T_ASTFLT handling code will also check for software interrupts so we
714 1.1 gwr * do not have to do it here. After identifying that we need an AST we
715 1.1 gwr * drop the IPL to allow device interrupts.
716 1.1 gwr *
717 1.1 gwr * This code is complicated by the fact that sendsig may have been called
718 1.1 gwr * necessitating a stack cleanup.
719 1.1 gwr */
720 1.1 gwr
721 1.1 gwr .globl _astpending
722 1.1 gwr .globl rei
723 1.1 gwr rei:
724 1.1 gwr #ifdef DIAGNOSTIC
725 1.1 gwr tstl _panicstr | have we paniced?
726 1.1 gwr jne Ldorte | yes, do not make matters worse
727 1.1 gwr #endif
728 1.1 gwr tstl _astpending | AST pending?
729 1.1 gwr jeq Ldorte | no, done
730 1.1 gwr Lrei1:
731 1.1 gwr btst #5,sp@ | yes, are we returning to user mode?
732 1.1 gwr jne Ldorte | no, done
733 1.1 gwr movw #PSL_LOWIPL,sr | lower SPL
734 1.1 gwr clrl sp@- | stack adjust
735 1.1 gwr moveml #0xFFFF,sp@- | save all registers
736 1.1 gwr movl usp,a1 | including
737 1.1 gwr movl a1,sp@(FR_SP) | the users SP
738 1.1 gwr clrl sp@- | VA == none
739 1.1 gwr clrl sp@- | code == none
740 1.1 gwr movl #T_ASTFLT,sp@- | type == async system trap
741 1.1 gwr jbsr _trap | go handle it
742 1.1 gwr lea sp@(12),sp | pop value args
743 1.1 gwr movl sp@(FR_SP),a0 | restore user SP
744 1.1 gwr movl a0,usp | from save area
745 1.1 gwr movw sp@(FR_ADJ),d0 | need to adjust stack?
746 1.1 gwr jne Laststkadj | yes, go to it
747 1.1 gwr moveml sp@+,#0x7FFF | no, restore most user regs
748 1.1 gwr addql #8,sp | toss SP and stack adjust
749 1.1 gwr rte | and do real RTE
750 1.1 gwr Laststkadj:
751 1.1 gwr lea sp@(FR_HW),a1 | pointer to HW frame
752 1.1 gwr addql #8,a1 | source pointer
753 1.1 gwr movl a1,a0 | source
754 1.1 gwr addw d0,a0 | + hole size = dest pointer
755 1.1 gwr movl a1@-,a0@- | copy
756 1.1 gwr movl a1@-,a0@- | 8 bytes
757 1.1 gwr movl a0,sp@(FR_SP) | new SSP
758 1.1 gwr moveml sp@+,#0x7FFF | restore user registers
759 1.1 gwr movl sp@,sp | and our SP
760 1.1 gwr Ldorte:
761 1.1 gwr rte | real return
762 1.1 gwr
763 1.1 gwr /*
764 1.1 gwr * Initialization is at the beginning of this file, because the
765 1.1 gwr * kernel entry point needs to be at zero for compatibility with
766 1.1 gwr * the Sun boot loader. This works on Sun machines because the
767 1.1 gwr * interrupt vector table for reset is NOT at address zero.
768 1.1 gwr * (The MMU has a "boot" bit that forces access to the PROM)
769 1.1 gwr */
770 1.1 gwr
771 1.1 gwr /*
772 1.1 gwr * Signal "trampoline" code (18 bytes). Invoked from RTE setup by sendsig().
773 1.1 gwr *
774 1.1 gwr * Stack looks like:
775 1.1 gwr *
776 1.1 gwr * sp+0 -> signal number
777 1.1 gwr * sp+4 signal specific code
778 1.1 gwr * sp+8 pointer to signal context frame (scp)
779 1.1 gwr * sp+12 address of handler
780 1.1 gwr * sp+16 saved hardware state
781 1.1 gwr * .
782 1.1 gwr * .
783 1.1 gwr * scp+0-> beginning of signal context frame
784 1.1 gwr */
785 1.1 gwr .globl _sigcode, _esigcode
786 1.1 gwr .data
787 1.1 gwr .align 2
788 1.1 gwr _sigcode: /* Found at address: 0x0DFFffdc */
789 1.1 gwr movl sp@(12),a0 | signal handler addr (4 bytes)
790 1.1 gwr jsr a0@ | call signal handler (2 bytes)
791 1.1 gwr addql #4,sp | pop signo (2 bytes)
792 1.1 gwr trap #1 | special syscall entry (2 bytes)
793 1.1 gwr movl d0,sp@(4) | save errno (4 bytes)
794 1.1 gwr moveq #1,d0 | syscall == exit (2 bytes)
795 1.1 gwr trap #0 | exit(errno) (2 bytes)
796 1.1 gwr .align 2
797 1.1 gwr _esigcode:
798 1.1 gwr .text
799 1.1 gwr
800 1.1 gwr /* XXX - hp300 still has icode here... */
801 1.1 gwr
802 1.1 gwr /*
803 1.1 gwr * Primitives
804 1.1 gwr */
805 1.1 gwr #include <machine/asm.h>
806 1.1 gwr
807 1.1 gwr /* XXX copypage(fromaddr, toaddr) */
808 1.1 gwr
809 1.1 gwr /*
810 1.1 gwr * non-local gotos
811 1.1 gwr */
812 1.1 gwr ENTRY(setjmp)
813 1.1 gwr movl sp@(4),a0 | savearea pointer
814 1.1 gwr moveml #0xFCFC,a0@ | save d2-d7/a2-a7
815 1.1 gwr movl sp@,a0@(48) | and return address
816 1.1 gwr moveq #0,d0 | return 0
817 1.1 gwr rts
818 1.1 gwr
819 1.1 gwr ENTRY(longjmp)
820 1.1 gwr movl sp@(4),a0
821 1.1 gwr moveml a0@+,#0xFCFC
822 1.1 gwr movl a0@,sp@
823 1.1 gwr moveq #1,d0
824 1.1 gwr rts
825 1.1 gwr
826 1.1 gwr /*
827 1.1 gwr * The following primitives manipulate the run queues.
828 1.1 gwr * _whichqs tells which of the 32 queues _qs have processes in them.
829 1.1 gwr * Setrunqueue puts processes into queues, Remrunqueue removes them
830 1.1 gwr * from queues. The running process is on no queue, other processes
831 1.1 gwr * are on a queue related to p->p_priority, divided by 4 actually to
832 1.1 gwr * shrink the 0-127 range of priorities into the 32 available queues.
833 1.1 gwr */
834 1.1 gwr
835 1.1 gwr .globl _whichqs,_qs,_cnt,_panic
836 1.1 gwr .globl _curproc
837 1.1 gwr .comm _want_resched,4
838 1.1 gwr
839 1.1 gwr /*
840 1.1 gwr * setrunqueue(p)
841 1.1 gwr *
842 1.1 gwr * Call should be made at splclock(), and p->p_stat should be SRUN
843 1.1 gwr */
844 1.1 gwr ENTRY(setrunqueue)
845 1.1 gwr movl sp@(4),a0
846 1.1 gwr #ifdef DIAGNOSTIC
847 1.1 gwr tstl a0@(P_BACK)
848 1.1 gwr jne Lset1
849 1.1 gwr tstl a0@(P_WCHAN)
850 1.1 gwr jne Lset1
851 1.1 gwr cmpb #SRUN,a0@(P_STAT)
852 1.1 gwr jne Lset1
853 1.1 gwr #endif
854 1.1 gwr clrl d0
855 1.1 gwr movb a0@(P_PRIORITY),d0
856 1.1 gwr lsrb #2,d0
857 1.1 gwr movl _whichqs,d1
858 1.1 gwr bset d0,d1
859 1.1 gwr movl d1,_whichqs
860 1.1 gwr lslb #3,d0
861 1.1 gwr addl #_qs,d0
862 1.1 gwr movl d0,a0@(P_FORW)
863 1.1 gwr movl d0,a1
864 1.1 gwr movl a1@(P_BACK),a0@(P_BACK)
865 1.1 gwr movl a0,a1@(P_BACK)
866 1.1 gwr movl a0@(P_BACK),a1
867 1.1 gwr movl a0,a1@(P_FORW)
868 1.1 gwr rts
869 1.1 gwr #ifdef DIAGNOSTIC
870 1.1 gwr Lset1:
871 1.1 gwr movl #Lset2,sp@-
872 1.1 gwr jbsr _panic
873 1.1 gwr Lset2:
874 1.1 gwr .asciz "setrunqueue"
875 1.1 gwr .even
876 1.1 gwr #endif
877 1.1 gwr
878 1.1 gwr /*
879 1.1 gwr * remrunqueue(p)
880 1.1 gwr *
881 1.1 gwr * Call should be made at splclock().
882 1.1 gwr */
883 1.1 gwr ENTRY(remrunqueue)
884 1.1 gwr movl sp@(4),a0 | proc *p
885 1.1 gwr clrl d0
886 1.1 gwr movb a0@(P_PRIORITY),d0
887 1.1 gwr lsrb #2,d0
888 1.1 gwr movl _whichqs,d1
889 1.1 gwr bclr d0,d1 | if ((d1 & (1 << d0)) == 0)
890 1.1 gwr jeq Lrem2 | panic (empty queue)
891 1.1 gwr movl d1,_whichqs
892 1.1 gwr movl a0@(P_FORW),a1
893 1.1 gwr movl a0@(P_BACK),a1@(P_BACK)
894 1.1 gwr movl a0@(P_BACK),a1
895 1.1 gwr movl a0@(P_FORW),a1@(P_FORW)
896 1.1 gwr movl #_qs,a1
897 1.1 gwr movl d0,d1
898 1.1 gwr lslb #3,d1
899 1.1 gwr addl d1,a1
900 1.1 gwr cmpl a1@(P_FORW),a1
901 1.1 gwr jeq Lrem1
902 1.1 gwr movl _whichqs,d1
903 1.1 gwr bset d0,d1
904 1.1 gwr movl d1,_whichqs
905 1.1 gwr Lrem1:
906 1.1 gwr clrl a0@(P_BACK)
907 1.1 gwr rts
908 1.1 gwr Lrem2:
909 1.1 gwr movl #Lrem3,sp@-
910 1.1 gwr jbsr _panic
911 1.1 gwr Lrem3:
912 1.1 gwr .asciz "remrunqueue"
913 1.1 gwr
914 1.1 gwr
915 1.1 gwr | Message for Lbadsw panic
916 1.1 gwr Lsw0:
917 1.1 gwr .asciz "cpu_switch"
918 1.1 gwr .even
919 1.1 gwr
920 1.1 gwr .globl _curpcb
921 1.1 gwr .globl _masterpaddr | XXX compatibility (debuggers)
922 1.1 gwr .data
923 1.1 gwr _masterpaddr: | XXX compatibility (debuggers)
924 1.1 gwr _curpcb:
925 1.1 gwr .long 0
926 1.1 gwr mdpflag:
927 1.1 gwr .byte 0 | copy of proc md_flags low byte
928 1.1 gwr .align 2
929 1.1 gwr .comm nullpcb,SIZEOF_PCB
930 1.1 gwr .text
931 1.1 gwr
932 1.1 gwr /*
933 1.1 gwr * At exit of a process, do a cpu_switch for the last time.
934 1.1 gwr * Switch to a safe stack and PCB, and deallocate the process's resources.
935 1.1 gwr * The ipl is high enough to prevent the memory from being reallocated.
936 1.1 gwr */
937 1.1 gwr ENTRY(switch_exit)
938 1.1 gwr movl sp@(4),a0 | struct proc *p
939 1.1 gwr movl #nullpcb,_curpcb | save state into garbage pcb
940 1.1 gwr lea tmpstk,sp | goto a tmp stack
941 1.1 gwr movl a0,sp@- | pass proc ptr down
942 1.1 gwr
943 1.1 gwr /* Free old process's u-area. */
944 1.1 gwr movl #USPACE,sp@- | size of u-area
945 1.1 gwr movl a0@(P_ADDR),sp@- | address of process's u-area
946 1.1 gwr movl _kernel_map,sp@- | map it was allocated in
947 1.1 gwr jbsr _kmem_free | deallocate it
948 1.1 gwr lea sp@(12),sp | pop args
949 1.1 gwr
950 1.1 gwr jra _cpu_switch
951 1.1 gwr
952 1.1 gwr /*
953 1.1 gwr * When no processes are on the runq, cpu_switch() branches to idle
954 1.1 gwr * to wait for something to come ready.
955 1.1 gwr */
956 1.1 gwr .data
957 1.1 gwr .globl _Idle_count
958 1.1 gwr _Idle_count:
959 1.1 gwr .long 0
960 1.1 gwr .text
961 1.1 gwr
962 1.1 gwr .globl Idle
963 1.1 gwr Lidle:
964 1.1 gwr stop #PSL_LOWIPL
965 1.1 gwr Idle:
966 1.1 gwr movw #PSL_HIGHIPL,sr
967 1.1 gwr addql #1, _Idle_count
968 1.1 gwr tstl _whichqs
969 1.1 gwr jeq Lidle
970 1.1 gwr movw #PSL_LOWIPL,sr
971 1.1 gwr jra Lsw1
972 1.1 gwr
973 1.1 gwr Lbadsw:
974 1.1 gwr movl #Lsw0,sp@-
975 1.1 gwr jbsr _panic
976 1.1 gwr /*NOTREACHED*/
977 1.1 gwr
978 1.1 gwr /*
979 1.1 gwr * cpu_switch()
980 1.1 gwr * Hacked for sun3
981 1.1 gwr * XXX - Arg 1 is a proc pointer (curproc) but this doesn't use it.
982 1.1 gwr * XXX - Sould we use p->p_addr instead of curpcb? -gwr
983 1.1 gwr */
984 1.1 gwr ENTRY(cpu_switch)
985 1.1 gwr movl _curpcb,a1 | current pcb
986 1.1 gwr movw sr,a1@(PCB_PS) | save sr before changing ipl
987 1.1 gwr #ifdef notyet
988 1.1 gwr movl _curproc,sp@- | remember last proc running
989 1.1 gwr #endif
990 1.1 gwr clrl _curproc
991 1.1 gwr
992 1.1 gwr Lsw1:
993 1.1 gwr /*
994 1.1 gwr * Find the highest-priority queue that isn't empty,
995 1.1 gwr * then take the first proc from that queue.
996 1.1 gwr */
997 1.1 gwr clrl d0
998 1.1 gwr lea _whichqs,a0
999 1.1 gwr movl a0@,d1
1000 1.1 gwr Lswchk:
1001 1.1 gwr btst d0,d1
1002 1.1 gwr jne Lswfnd
1003 1.1 gwr addqb #1,d0
1004 1.1 gwr cmpb #32,d0
1005 1.1 gwr jne Lswchk
1006 1.1 gwr jra Idle
1007 1.1 gwr Lswfnd:
1008 1.1 gwr movw #PSL_HIGHIPL,sr | lock out interrupts
1009 1.1 gwr movl a0@,d1 | and check again...
1010 1.1 gwr bclr d0,d1
1011 1.1 gwr jeq Lsw1 | proc moved, rescan
1012 1.1 gwr movl d1,a0@ | update whichqs
1013 1.1 gwr moveq #1,d1 | double check for higher priority
1014 1.1 gwr lsll d0,d1 | process (which may have snuck in
1015 1.1 gwr subql #1,d1 | while we were finding this one)
1016 1.1 gwr andl a0@,d1
1017 1.1 gwr jeq Lswok | no one got in, continue
1018 1.1 gwr movl a0@,d1
1019 1.1 gwr bset d0,d1 | otherwise put this one back
1020 1.1 gwr movl d1,a0@
1021 1.1 gwr jra Lsw1 | and rescan
1022 1.1 gwr Lswok:
1023 1.1 gwr movl d0,d1
1024 1.1 gwr lslb #3,d1 | convert queue number to index
1025 1.1 gwr addl #_qs,d1 | locate queue (q)
1026 1.1 gwr movl d1,a1
1027 1.1 gwr cmpl a1@(P_FORW),a1 | anyone on queue?
1028 1.1 gwr jeq Lbadsw | no, panic
1029 1.1 gwr movl a1@(P_FORW),a0 | p = q->p_forw
1030 1.1 gwr movl a0@(P_FORW),a1@(P_FORW) | q->p_forw = p->p_forw
1031 1.1 gwr movl a0@(P_FORW),a1 | q = p->p_forw
1032 1.1 gwr movl a0@(P_BACK),a1@(P_BACK) | q->p_back = p->p_back
1033 1.1 gwr cmpl a0@(P_FORW),d1 | anyone left on queue?
1034 1.1 gwr jeq Lsw2 | no, skip
1035 1.1 gwr movl _whichqs,d1
1036 1.1 gwr bset d0,d1 | yes, reset bit
1037 1.1 gwr movl d1,_whichqs
1038 1.1 gwr Lsw2:
1039 1.1 gwr movl a0,_curproc
1040 1.1 gwr clrl _want_resched
1041 1.1 gwr #ifdef notyet
1042 1.1 gwr movl sp@+,a1 | XXX - Make this work!
1043 1.1 gwr cmpl a0,a1 | switching to same proc?
1044 1.1 gwr jeq Lswdone | yes, skip save and restore
1045 1.1 gwr #endif
1046 1.1 gwr /*
1047 1.1 gwr * Save state of previous process in its pcb.
1048 1.1 gwr */
1049 1.1 gwr movl _curpcb,a1
1050 1.1 gwr moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers
1051 1.1 gwr movl usp,a2 | grab USP (a2 has been saved)
1052 1.1 gwr movl a2,a1@(PCB_USP) | and save it
1053 1.1 gwr
1054 1.1 gwr tstl _fpu_type | Do we have an fpu?
1055 1.1 gwr jeq Lswnofpsave | No? Then don't try save.
1056 1.1 gwr lea a1@(PCB_FPCTX),a2 | pointer to FP save area
1057 1.1 gwr fsave a2@ | save FP state
1058 1.1 gwr tstb a2@ | null state frame?
1059 1.1 gwr jeq Lswnofpsave | yes, all done
1060 1.1 gwr fmovem fp0-fp7,a2@(FPF_REGS) | save FP general regs
1061 1.1 gwr fmovem fpcr/fpsr/fpi,a2@(FPF_FPCR) | save FP control regs
1062 1.1 gwr Lswnofpsave:
1063 1.1 gwr
1064 1.1 gwr #ifdef DIAGNOSTIC
1065 1.1 gwr tstl a0@(P_WCHAN)
1066 1.1 gwr jne Lbadsw
1067 1.1 gwr cmpb #SRUN,a0@(P_STAT)
1068 1.1 gwr jne Lbadsw
1069 1.1 gwr #endif
1070 1.1 gwr clrl a0@(P_BACK) | clear back link
1071 1.1 gwr movl a0@(P_ADDR),a1 | get p_addr
1072 1.1 gwr movl a1,_curpcb
1073 1.1 gwr movb a0@(P_MDFLAG+3),mdpflag | low byte of p_md.md_flags
1074 1.1 gwr
1075 1.1 gwr /* Our pmap does not need pmap_activate() */
1076 1.1 gwr /* Just load the new CPU Root Pointer (MMU) */
1077 1.1 gwr
1078 1.1 gwr movl #CACHE_CLR,d0
1079 1.1 gwr movc d0,cacr | invalidate cache(s)
1080 1.1 gwr pflusha | flush entire TLB
1081 1.1 gwr
1082 1.2 gwr movl a1@(PCB_MMUCRP),a0 | get CRP phys. addr.
1083 1.1 gwr pmove a0@,crp | load new user root pointer
1084 1.1 gwr
1085 1.1 gwr | Reload registers of new process.
1086 1.1 gwr moveml a1@(PCB_REGS),#0xFCFC | kernel registers
1087 1.1 gwr movl a1@(PCB_USP),a0
1088 1.1 gwr movl a0,usp | and USP
1089 1.1 gwr
1090 1.1 gwr tstl _fpu_type | If we don't have an fpu,
1091 1.1 gwr jeq Lres_skip | don't try to restore it.
1092 1.1 gwr lea a1@(PCB_FPCTX),a0 | pointer to FP save area
1093 1.1 gwr tstb a0@ | null state frame?
1094 1.1 gwr jeq Lresfprest | yes, easy
1095 1.1 gwr fmovem a0@(FPF_FPCR),fpcr/fpsr/fpi | restore FP control regs
1096 1.1 gwr fmovem a0@(FPF_REGS),fp0-fp7 | restore FP general regs
1097 1.1 gwr Lresfprest:
1098 1.1 gwr frestore a0@ | restore state
1099 1.1 gwr Lres_skip:
1100 1.1 gwr movw a1@(PCB_PS),d0 | no, restore PS
1101 1.1 gwr #ifdef DIAGNOSTIC
1102 1.1 gwr btst #13,d0 | supervisor mode?
1103 1.1 gwr jeq Lbadsw | no? panic!
1104 1.1 gwr #endif
1105 1.1 gwr movw d0,sr | OK, restore PS
1106 1.1 gwr moveq #1,d0 | return 1 (for alternate returns)
1107 1.1 gwr rts
1108 1.1 gwr
1109 1.1 gwr /*
1110 1.1 gwr * savectx(pcb)
1111 1.1 gwr * Update pcb, saving current processor state.
1112 1.1 gwr */
1113 1.1 gwr ENTRY(savectx)
1114 1.1 gwr movl sp@(4),a1
1115 1.1 gwr movw sr,a1@(PCB_PS)
1116 1.1 gwr movl usp,a0 | grab USP
1117 1.1 gwr movl a0,a1@(PCB_USP) | and save it
1118 1.1 gwr moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers
1119 1.1 gwr
1120 1.1 gwr tstl _fpu_type | Do we have FPU?
1121 1.1 gwr jeq Lsavedone | No? Then don't save state.
1122 1.1 gwr lea a1@(PCB_FPCTX),a0 | pointer to FP save area
1123 1.1 gwr fsave a0@ | save FP state
1124 1.1 gwr tstb a0@ | null state frame?
1125 1.1 gwr jeq Lsavedone | yes, all done
1126 1.1 gwr fmovem fp0-fp7,a0@(FPF_REGS) | save FP general regs
1127 1.1 gwr fmovem fpcr/fpsr/fpi,a0@(FPF_FPCR) | save FP control regs
1128 1.1 gwr Lsavedone:
1129 1.1 gwr moveq #0,d0 | return 0
1130 1.1 gwr rts
1131 1.1 gwr
1132 1.1 gwr /* suline() `040 only */
1133 1.1 gwr
1134 1.1 gwr #ifdef DEBUG
1135 1.1 gwr .data
1136 1.1 gwr .globl fulltflush, fullcflush
1137 1.1 gwr fulltflush:
1138 1.1 gwr .long 0
1139 1.1 gwr fullcflush:
1140 1.1 gwr .long 0
1141 1.1 gwr .text
1142 1.1 gwr #endif
1143 1.1 gwr
1144 1.1 gwr /*
1145 1.1 gwr * Invalidate entire TLB.
1146 1.1 gwr */
1147 1.1 gwr ENTRY(TBIA)
1148 1.1 gwr __TBIA:
1149 1.1 gwr pflusha
1150 1.1 gwr movl #DC_CLEAR,d0
1151 1.1 gwr movc d0,cacr | invalidate on-chip d-cache
1152 1.1 gwr rts
1153 1.1 gwr
1154 1.1 gwr /*
1155 1.1 gwr * Invalidate any TLB entry for given VA (TB Invalidate Single)
1156 1.1 gwr */
1157 1.1 gwr ENTRY(TBIS)
1158 1.1 gwr #ifdef DEBUG
1159 1.1 gwr tstl fulltflush | being conservative?
1160 1.1 gwr jne __TBIA | yes, flush entire TLB
1161 1.1 gwr #endif
1162 1.1 gwr movl sp@(4),a0
1163 1.1 gwr pflush #0,#0,a0@ | flush address from both sides
1164 1.1 gwr movl #DC_CLEAR,d0
1165 1.1 gwr movc d0,cacr | invalidate on-chip data cache
1166 1.1 gwr rts
1167 1.1 gwr
1168 1.1 gwr /*
1169 1.1 gwr * Invalidate supervisor side of TLB
1170 1.1 gwr */
1171 1.1 gwr ENTRY(TBIAS)
1172 1.1 gwr #ifdef DEBUG
1173 1.1 gwr tstl fulltflush | being conservative?
1174 1.1 gwr jne __TBIA | yes, flush everything
1175 1.1 gwr #endif
1176 1.1 gwr pflush #4,#4 | flush supervisor TLB entries
1177 1.1 gwr movl #DC_CLEAR,d0
1178 1.1 gwr movc d0,cacr | invalidate on-chip d-cache
1179 1.1 gwr rts
1180 1.1 gwr
1181 1.1 gwr /*
1182 1.1 gwr * Invalidate user side of TLB
1183 1.1 gwr */
1184 1.1 gwr ENTRY(TBIAU)
1185 1.1 gwr #ifdef DEBUG
1186 1.1 gwr tstl fulltflush | being conservative?
1187 1.1 gwr jne __TBIA | yes, flush everything
1188 1.1 gwr #endif
1189 1.1 gwr pflush #0,#4 | flush user TLB entries
1190 1.1 gwr movl #DC_CLEAR,d0
1191 1.1 gwr movc d0,cacr | invalidate on-chip d-cache
1192 1.1 gwr rts
1193 1.1 gwr
1194 1.1 gwr /*
1195 1.1 gwr * Invalidate instruction cache
1196 1.1 gwr */
1197 1.1 gwr ENTRY(ICIA)
1198 1.1 gwr movl #IC_CLEAR,d0
1199 1.1 gwr movc d0,cacr | invalidate i-cache
1200 1.1 gwr rts
1201 1.1 gwr
1202 1.1 gwr /*
1203 1.1 gwr * Invalidate data cache.
1204 1.1 gwr * NOTE: we do not flush 68030 on-chip cache as there are no aliasing
1205 1.1 gwr * problems with DC_WA. The only cases we have to worry about are context
1206 1.1 gwr * switch and TLB changes, both of which are handled "in-line" in resume
1207 1.1 gwr * and TBI*.
1208 1.1 gwr */
1209 1.1 gwr ENTRY(DCIA)
1210 1.1 gwr __DCIA:
1211 1.1 gwr rts
1212 1.1 gwr
1213 1.1 gwr ENTRY(DCIS)
1214 1.1 gwr __DCIS:
1215 1.1 gwr rts
1216 1.1 gwr
1217 1.1 gwr /*
1218 1.1 gwr * Invalidate data cache.
1219 1.1 gwr */
1220 1.1 gwr ENTRY(DCIU)
1221 1.1 gwr rts
1222 1.1 gwr
1223 1.1 gwr /* ICPL, ICPP, DCPL, DCPP, DCPA, DCFL, DCFP */
1224 1.1 gwr
1225 1.1 gwr ENTRY(PCIA)
1226 1.1 gwr movl #DC_CLEAR,d0
1227 1.1 gwr movc d0,cacr | invalidate on-chip d-cache
1228 1.1 gwr rts
1229 1.1 gwr
1230 1.1 gwr ENTRY(ecacheon)
1231 1.1 gwr rts
1232 1.1 gwr
1233 1.1 gwr ENTRY(ecacheoff)
1234 1.1 gwr rts
1235 1.1 gwr
1236 1.1 gwr /*
1237 1.1 gwr * Get callers current SP value.
1238 1.1 gwr * Note that simply taking the address of a local variable in a C function
1239 1.1 gwr * doesn't work because callee saved registers may be outside the stack frame
1240 1.1 gwr * defined by A6 (e.g. GCC generated code).
1241 1.1 gwr *
1242 1.1 gwr * [I don't think the ENTRY() macro will do the right thing with this -- glass]
1243 1.1 gwr */
1244 1.1 gwr .globl _getsp
1245 1.1 gwr _getsp:
1246 1.1 gwr movl sp,d0 | get current SP
1247 1.1 gwr addql #4,d0 | compensate for return address
1248 1.1 gwr rts
1249 1.1 gwr
1250 1.1 gwr ENTRY(getsfc)
1251 1.1 gwr movc sfc,d0
1252 1.1 gwr rts
1253 1.1 gwr
1254 1.1 gwr ENTRY(getdfc)
1255 1.1 gwr movc dfc,d0
1256 1.1 gwr rts
1257 1.1 gwr
1258 1.1 gwr ENTRY(getvbr)
1259 1.1 gwr movc vbr, d0
1260 1.1 gwr rts
1261 1.1 gwr
1262 1.1 gwr ENTRY(setvbr)
1263 1.1 gwr movl sp@(4), d0
1264 1.1 gwr movc d0, vbr
1265 1.1 gwr rts
1266 1.1 gwr
1267 1.1 gwr /*
1268 1.1 gwr * Load a new CPU Root Pointer (CRP) into the MMU.
1269 1.2 gwr * void loadcrp(struct mmu_rootptr *);
1270 1.1 gwr */
1271 1.1 gwr ENTRY(loadcrp)
1272 1.1 gwr movl sp@(4),a0 | arg1: &CRP
1273 1.1 gwr movl #CACHE_CLR,d0
1274 1.1 gwr movc d0,cacr | invalidate cache(s)
1275 1.1 gwr pflusha | flush entire TLB
1276 1.1 gwr pmove a0@,crp | load new user root pointer
1277 1.1 gwr rts
1278 1.1 gwr
1279 1.1 gwr /*
1280 1.1 gwr * Set processor priority level calls. Most are implemented with
1281 1.1 gwr * inline asm expansions. However, we need one instantiation here
1282 1.1 gwr * in case some non-optimized code makes external references.
1283 1.1 gwr * Most places will use the inlined function param.h supplies.
1284 1.1 gwr */
1285 1.1 gwr
1286 1.1 gwr ENTRY(_spl)
1287 1.1 gwr movl sp@(4),d1
1288 1.1 gwr clrl d0
1289 1.1 gwr movw sr,d0
1290 1.1 gwr movw d1,sr
1291 1.1 gwr rts
1292 1.1 gwr
1293 1.1 gwr ENTRY(getsr)
1294 1.1 gwr moveq #0, d0
1295 1.1 gwr movw sr, d0
1296 1.1 gwr rts
1297 1.1 gwr
1298 1.1 gwr ENTRY(_insque)
1299 1.1 gwr movw sr,d0
1300 1.1 gwr movw #PSL_HIGHIPL,sr | atomic
1301 1.1 gwr movl sp@(8),a0 | where to insert (after)
1302 1.1 gwr movl sp@(4),a1 | element to insert (e)
1303 1.1 gwr movl a0@,a1@ | e->next = after->next
1304 1.1 gwr movl a0,a1@(4) | e->prev = after
1305 1.1 gwr movl a1,a0@ | after->next = e
1306 1.1 gwr movl a1@,a0
1307 1.1 gwr movl a1,a0@(4) | e->next->prev = e
1308 1.1 gwr movw d0,sr
1309 1.1 gwr rts
1310 1.1 gwr
1311 1.1 gwr ENTRY(_remque)
1312 1.1 gwr movw sr,d0
1313 1.1 gwr movw #PSL_HIGHIPL,sr | atomic
1314 1.1 gwr movl sp@(4),a0 | element to remove (e)
1315 1.1 gwr movl a0@,a1
1316 1.1 gwr movl a0@(4),a0
1317 1.1 gwr movl a0,a1@(4) | e->next->prev = e->prev
1318 1.1 gwr movl a1,a0@ | e->prev->next = e->next
1319 1.1 gwr movw d0,sr
1320 1.1 gwr rts
1321 1.1 gwr
1322 1.1 gwr /*
1323 1.1 gwr * Save and restore 68881 state.
1324 1.1 gwr */
1325 1.1 gwr ENTRY(m68881_save)
1326 1.1 gwr movl sp@(4),a0 | save area pointer
1327 1.1 gwr fsave a0@ | save state
1328 1.1 gwr tstb a0@ | null state frame?
1329 1.1 gwr jeq Lm68881sdone | yes, all done
1330 1.1 gwr fmovem fp0-fp7,a0@(FPF_REGS) | save FP general regs
1331 1.1 gwr fmovem fpcr/fpsr/fpi,a0@(FPF_FPCR) | save FP control regs
1332 1.1 gwr Lm68881sdone:
1333 1.1 gwr rts
1334 1.1 gwr
1335 1.1 gwr ENTRY(m68881_restore)
1336 1.1 gwr movl sp@(4),a0 | save area pointer
1337 1.1 gwr tstb a0@ | null state frame?
1338 1.1 gwr jeq Lm68881rdone | yes, easy
1339 1.1 gwr fmovem a0@(FPF_FPCR),fpcr/fpsr/fpi | restore FP control regs
1340 1.1 gwr fmovem a0@(FPF_REGS),fp0-fp7 | restore FP general regs
1341 1.1 gwr Lm68881rdone:
1342 1.1 gwr frestore a0@ | restore state
1343 1.1 gwr rts
1344 1.1 gwr
1345 1.1 gwr /*
1346 1.1 gwr * _delay(unsigned N)
1347 1.1 gwr * Delay for at least (N/256) microseconds.
1348 1.1 gwr * This routine depends on the variable: delay_divisor
1349 1.1 gwr * which should be set based on the CPU clock rate.
1350 1.1 gwr * XXX: Currently this is set in sun3_startup.c based on the
1351 1.1 gwr * XXX: CPU model but this should be determined at run time...
1352 1.1 gwr */
1353 1.1 gwr .globl __delay
1354 1.1 gwr __delay:
1355 1.1 gwr | d0 = arg = (usecs << 8)
1356 1.1 gwr movl sp@(4),d0
1357 1.1 gwr | d1 = delay_divisor;
1358 1.1 gwr movl _delay_divisor,d1
1359 1.1 gwr L_delay:
1360 1.1 gwr subl d1,d0
1361 1.1 gwr jgt L_delay
1362 1.1 gwr rts
1363 1.1 gwr
1364 1.1 gwr
1365 1.1 gwr | Define some addresses, mostly so DDB can print useful info.
1366 1.1 gwr .globl _kernbase
1367 1.1 gwr .set _kernbase,KERNBASE
1368 1.1 gwr .globl _dvma_base
1369 1.1 gwr .set _dvma_base,DVMA_SPACE_START
1370 1.1 gwr .globl _prom_start
1371 1.1 gwr .set _prom_start,MONSTART
1372 1.1 gwr .globl _prom_base
1373 1.1 gwr .set _prom_base,PROM_BASE
1374 1.1 gwr
1375 1.1 gwr |The end!
1376