]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/mips/mips/vm_machdep.c
Import 1.14.3
[FreeBSD/FreeBSD.git] / sys / mips / mips / vm_machdep.c
1 /*-
2  * Copyright (c) 1982, 1986 The Regents of the University of California.
3  * Copyright (c) 1989, 1990 William Jolitz
4  * Copyright (c) 1994 John Dyson
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * the Systems Programming Group of the University of Utah Computer
9  * Science Department, and William Jolitz.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *      from: @(#)vm_machdep.c  7.3 (Berkeley) 5/13/91
36  *      Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
37  *      from: src/sys/i386/i386/vm_machdep.c,v 1.132.2.2 2000/08/26 04:19:26 yokota
38  *      JNPR: vm_machdep.c,v 1.8.2.2 2007/08/16 15:59:17 girish
39  */
40
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD$");
43
44 #include "opt_compat.h"
45 #include "opt_ddb.h"
46
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/malloc.h>
50 #include <sys/proc.h>
51 #include <sys/syscall.h>
52 #include <sys/sysent.h>
53 #include <sys/buf.h>
54 #include <sys/vnode.h>
55 #include <sys/vmmeter.h>
56 #include <sys/kernel.h>
57 #include <sys/sysctl.h>
58 #include <sys/unistd.h>
59
60 #include <machine/cache.h>
61 #include <machine/clock.h>
62 #include <machine/cpu.h>
63 #include <machine/cpufunc.h>
64 #include <machine/cpuinfo.h>
65 #include <machine/md_var.h>
66 #include <machine/pcb.h>
67 #include <machine/tls.h>
68
69 #include <vm/vm.h>
70 #include <vm/vm_extern.h>
71 #include <vm/pmap.h>
72 #include <vm/vm_kern.h>
73 #include <vm/vm_map.h>
74 #include <vm/vm_page.h>
75 #include <vm/vm_pageout.h>
76 #include <vm/vm_param.h>
77 #include <vm/uma.h>
78 #include <vm/uma_int.h>
79
80 #include <sys/user.h>
81 #include <sys/mbuf.h>
82
83 /* Duplicated from asm.h */
84 #if defined(__mips_o32)
85 #define SZREG   4
86 #else
87 #define SZREG   8
88 #endif
89 #if defined(__mips_o32) || defined(__mips_o64)
90 #define CALLFRAME_SIZ   (SZREG * (4 + 2))
91 #elif defined(__mips_n32) || defined(__mips_n64)
92 #define CALLFRAME_SIZ   (SZREG * 4)
93 #endif
94
95 /*
96  * Finish a fork operation, with process p2 nearly set up.
97  * Copy and update the pcb, set up the stack so that the child
98  * ready to run and return to user mode.
99  */
100 void
101 cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2,int flags)
102 {
103         struct proc *p1;
104         struct pcb *pcb2;
105
106         p1 = td1->td_proc;
107         if ((flags & RFPROC) == 0)
108                 return;
109         /* It is assumed that the vm_thread_alloc called
110          * cpu_thread_alloc() before cpu_fork is called.
111          */
112
113         /* Point the pcb to the top of the stack */
114         pcb2 = td2->td_pcb;
115
116         /* Copy p1's pcb, note that in this case
117          * our pcb also includes the td_frame being copied
118          * too. The older mips2 code did an additional copy
119          * of the td_frame, for us that's not needed any
120          * longer (this copy does them both) 
121          */
122         bcopy(td1->td_pcb, pcb2, sizeof(*pcb2));
123
124         /* Point mdproc and then copy over td1's contents
125          * md_proc is empty for MIPS
126          */
127         td2->td_md.md_flags = td1->td_md.md_flags & MDTD_FPUSED;
128
129         /*
130          * Set up return-value registers as fork() libc stub expects.
131          */
132         td2->td_frame->v0 = 0;
133         td2->td_frame->v1 = 1;
134         td2->td_frame->a3 = 0;
135
136         if (td1 == PCPU_GET(fpcurthread))
137                 MipsSaveCurFPState(td1);
138
139         pcb2->pcb_context[PCB_REG_RA] = (register_t)(intptr_t)fork_trampoline;
140         /* Make sp 64-bit aligned */
141         pcb2->pcb_context[PCB_REG_SP] = (register_t)(((vm_offset_t)td2->td_pcb &
142             ~(sizeof(__int64_t) - 1)) - CALLFRAME_SIZ);
143         pcb2->pcb_context[PCB_REG_S0] = (register_t)(intptr_t)fork_return;
144         pcb2->pcb_context[PCB_REG_S1] = (register_t)(intptr_t)td2;
145         pcb2->pcb_context[PCB_REG_S2] = (register_t)(intptr_t)td2->td_frame;
146         pcb2->pcb_context[PCB_REG_SR] = mips_rd_status() &
147             (MIPS_SR_KX | MIPS_SR_UX | MIPS_SR_INT_MASK);
148         /*
149          * FREEBSD_DEVELOPERS_FIXME:
150          * Setup any other CPU-Specific registers (Not MIPS Standard)
151          * and/or bits in other standard MIPS registers (if CPU-Specific)
152          *  that are needed.
153          */
154
155         td2->td_md.md_tls = td1->td_md.md_tls;
156         td2->td_md.md_tls_tcb_offset = td1->td_md.md_tls_tcb_offset;
157         td2->td_md.md_saved_intr = MIPS_SR_INT_IE;
158         td2->td_md.md_spinlock_count = 1;
159 #ifdef CPU_CNMIPS
160         if (td1->td_md.md_flags & MDTD_COP2USED) {
161                 if (td1->td_md.md_cop2owner == COP2_OWNER_USERLAND) {
162                         if (td1->td_md.md_ucop2)
163                                 octeon_cop2_save(td1->td_md.md_ucop2);
164                         else
165                                 panic("cpu_fork: ucop2 is NULL but COP2 is enabled");
166                 }
167                 else {
168                         if (td1->td_md.md_cop2)
169                                 octeon_cop2_save(td1->td_md.md_cop2);
170                         else
171                                 panic("cpu_fork: cop2 is NULL but COP2 is enabled");
172                 }
173         }
174
175         if (td1->td_md.md_cop2) {
176                 td2->td_md.md_cop2 = octeon_cop2_alloc_ctx();
177                 memcpy(td2->td_md.md_cop2, td1->td_md.md_cop2, 
178                         sizeof(*td1->td_md.md_cop2));
179         }
180         if (td1->td_md.md_ucop2) {
181                 td2->td_md.md_ucop2 = octeon_cop2_alloc_ctx();
182                 memcpy(td2->td_md.md_ucop2, td1->td_md.md_ucop2, 
183                         sizeof(*td1->td_md.md_ucop2));
184         }
185         td2->td_md.md_cop2owner = td1->td_md.md_cop2owner;
186         pcb2->pcb_context[PCB_REG_SR] |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX | MIPS_SR_SX;
187         /* Clear COP2 bits for userland & kernel */
188         td2->td_frame->sr &= ~MIPS_SR_COP_2_BIT;
189         pcb2->pcb_context[PCB_REG_SR] &= ~MIPS_SR_COP_2_BIT;
190 #endif
191 }
192
193 /*
194  * Intercept the return address from a freshly forked process that has NOT
195  * been scheduled yet.
196  *
197  * This is needed to make kernel threads stay in kernel mode.
198  */
199 void
200 cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
201 {
202         /*
203          * Note that the trap frame follows the args, so the function
204          * is really called like this:  func(arg, frame);
205          */
206         td->td_pcb->pcb_context[PCB_REG_S0] = (register_t)(intptr_t)func;
207         td->td_pcb->pcb_context[PCB_REG_S1] = (register_t)(intptr_t)arg;
208 }
209
210 void
211 cpu_exit(struct thread *td)
212 {
213 }
214
215 void
216 cpu_thread_exit(struct thread *td)
217 {
218
219         if (PCPU_GET(fpcurthread) == td)
220                 PCPU_GET(fpcurthread) = (struct thread *)0;
221 #ifdef  CPU_CNMIPS
222         if (td->td_md.md_cop2)
223                 memset(td->td_md.md_cop2, 0,
224                         sizeof(*td->td_md.md_cop2));
225         if (td->td_md.md_ucop2)
226                 memset(td->td_md.md_ucop2, 0,
227                         sizeof(*td->td_md.md_ucop2));
228 #endif
229 }
230
231 void
232 cpu_thread_free(struct thread *td)
233 {
234 #ifdef  CPU_CNMIPS
235         if (td->td_md.md_cop2)
236                 octeon_cop2_free_ctx(td->td_md.md_cop2);
237         if (td->td_md.md_ucop2)
238                 octeon_cop2_free_ctx(td->td_md.md_ucop2);
239         td->td_md.md_cop2 = NULL;
240         td->td_md.md_ucop2 = NULL;
241 #endif
242 }
243
244 void
245 cpu_thread_clean(struct thread *td)
246 {
247 }
248
249 void
250 cpu_thread_swapin(struct thread *td)
251 {
252         pt_entry_t *pte;
253         int i;
254
255         /*
256          * The kstack may be at a different physical address now.
257          * Cache the PTEs for the Kernel stack in the machine dependent
258          * part of the thread struct so cpu_switch() can quickly map in
259          * the pcb struct and kernel stack.
260          */
261         for (i = 0; i < KSTACK_PAGES; i++) {
262                 pte = pmap_pte(kernel_pmap, td->td_kstack + i * PAGE_SIZE);
263                 td->td_md.md_upte[i] = *pte & ~TLBLO_SWBITS_MASK;
264         }
265 }
266
267 void
268 cpu_thread_swapout(struct thread *td)
269 {
270 }
271
272 void
273 cpu_thread_alloc(struct thread *td)
274 {
275         pt_entry_t *pte;
276         int i;
277
278         KASSERT((td->td_kstack & (1 << PAGE_SHIFT)) == 0, ("kernel stack must be aligned."));
279         td->td_pcb = (struct pcb *)(td->td_kstack +
280             td->td_kstack_pages * PAGE_SIZE) - 1;
281         td->td_frame = &td->td_pcb->pcb_regs;
282
283         for (i = 0; i < KSTACK_PAGES; i++) {
284                 pte = pmap_pte(kernel_pmap, td->td_kstack + i * PAGE_SIZE);
285                 td->td_md.md_upte[i] = *pte & ~TLBLO_SWBITS_MASK;
286         }
287 }
288
289 void
290 cpu_set_syscall_retval(struct thread *td, int error)
291 {
292         struct trapframe *locr0 = td->td_frame;
293         unsigned int code;
294         int quad_syscall;
295
296         code = locr0->v0;
297         quad_syscall = 0;
298 #if defined(__mips_n32) || defined(__mips_n64)
299 #ifdef COMPAT_FREEBSD32
300         if (code == SYS___syscall && SV_PROC_FLAG(td->td_proc, SV_ILP32))
301                 quad_syscall = 1;
302 #endif
303 #else
304         if (code == SYS___syscall)
305                 quad_syscall = 1;
306 #endif
307
308         if (code == SYS_syscall)
309                 code = locr0->a0;
310         else if (code == SYS___syscall) {
311                 if (quad_syscall)
312                         code = _QUAD_LOWWORD ? locr0->a1 : locr0->a0;
313                 else
314                         code = locr0->a0;
315         }
316
317         switch (error) {
318         case 0:
319                 if (quad_syscall && code != SYS_lseek) {
320                         /*
321                          * System call invoked through the
322                          * SYS___syscall interface but the
323                          * return value is really just 32
324                          * bits.
325                          */
326                         locr0->v0 = td->td_retval[0];
327                         if (_QUAD_LOWWORD)
328                                 locr0->v1 = td->td_retval[0];
329                         locr0->a3 = 0;
330                 } else {
331                         locr0->v0 = td->td_retval[0];
332                         locr0->v1 = td->td_retval[1];
333                         locr0->a3 = 0;
334                 }
335                 break;
336
337         case ERESTART:
338                 locr0->pc = td->td_pcb->pcb_tpc;
339                 break;
340
341         case EJUSTRETURN:
342                 break;  /* nothing to do */
343
344         default:
345                 if (quad_syscall && code != SYS_lseek) {
346                         locr0->v0 = error;
347                         if (_QUAD_LOWWORD)
348                                 locr0->v1 = error;
349                         locr0->a3 = 1;
350                 } else {
351                         locr0->v0 = error;
352                         locr0->a3 = 1;
353                 }
354         }
355 }
356
357 /*
358  * Initialize machine state, mostly pcb and trap frame for a new
359  * thread, about to return to userspace.  Put enough state in the new
360  * thread's PCB to get it to go back to the fork_return(), which
361  * finalizes the thread state and handles peculiarities of the first
362  * return to userspace for the new thread.
363  */
364 void
365 cpu_copy_thread(struct thread *td, struct thread *td0)
366 {
367         struct pcb *pcb2;
368
369         /* Point the pcb to the top of the stack. */
370         pcb2 = td->td_pcb;
371
372         /*
373          * Copy the upcall pcb.  This loads kernel regs.
374          * Those not loaded individually below get their default
375          * values here.
376          *
377          * XXXKSE It might be a good idea to simply skip this as
378          * the values of the other registers may be unimportant.
379          * This would remove any requirement for knowing the KSE
380          * at this time (see the matching comment below for
381          * more analysis) (need a good safe default).
382          * In MIPS, the trapframe is the first element of the PCB
383          * and gets copied when we copy the PCB. No separate copy
384          * is needed.
385          */
386         bcopy(td0->td_pcb, pcb2, sizeof(*pcb2));
387
388         /*
389          * Set registers for trampoline to user mode.
390          */
391
392         pcb2->pcb_context[PCB_REG_RA] = (register_t)(intptr_t)fork_trampoline;
393         /* Make sp 64-bit aligned */
394         pcb2->pcb_context[PCB_REG_SP] = (register_t)(((vm_offset_t)td->td_pcb &
395             ~(sizeof(__int64_t) - 1)) - CALLFRAME_SIZ);
396         pcb2->pcb_context[PCB_REG_S0] = (register_t)(intptr_t)fork_return;
397         pcb2->pcb_context[PCB_REG_S1] = (register_t)(intptr_t)td;
398         pcb2->pcb_context[PCB_REG_S2] = (register_t)(intptr_t)td->td_frame;
399         /* Dont set IE bit in SR. sched lock release will take care of it */
400         pcb2->pcb_context[PCB_REG_SR] = mips_rd_status() &
401             (MIPS_SR_PX | MIPS_SR_KX | MIPS_SR_UX | MIPS_SR_INT_MASK);
402
403         /*
404          * FREEBSD_DEVELOPERS_FIXME:
405          * Setup any other CPU-Specific registers (Not MIPS Standard)
406          * that are needed.
407          */
408
409         /* Setup to release spin count in in fork_exit(). */
410         td->td_md.md_spinlock_count = 1;
411         td->td_md.md_saved_intr = MIPS_SR_INT_IE;
412 #if 0
413             /* Maybe we need to fix this? */
414         td->td_md.md_saved_sr = ( (MIPS_SR_COP_2_BIT | MIPS_SR_COP_0_BIT) |
415                                   (MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX | MIPS_SR_SX) |
416                                   (MIPS_SR_INT_IE | MIPS_HARD_INT_MASK));
417 #endif
418 }
419
420 /*
421  * Set that machine state for performing an upcall that starts
422  * the entry function with the given argument.
423  */
424 void
425 cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
426     stack_t *stack)
427 {
428         struct trapframe *tf;
429         register_t sp;
430
431         /*
432          * At the point where a function is called, sp must be 8
433          * byte aligned[for compatibility with 64-bit CPUs]
434          * in ``See MIPS Run'' by D. Sweetman, p. 269
435          * align stack
436          */
437         sp = (((intptr_t)stack->ss_sp + stack->ss_size) & ~0x7) -
438             CALLFRAME_SIZ;
439
440         /*
441          * Set the trap frame to point at the beginning of the uts
442          * function.
443          */
444         tf = td->td_frame;
445         bzero(tf, sizeof(struct trapframe));
446         tf->sp = sp;
447         tf->pc = (register_t)(intptr_t)entry;
448         /* 
449          * MIPS ABI requires T9 to be the same as PC 
450          * in subroutine entry point
451          */
452         tf->t9 = (register_t)(intptr_t)entry; 
453         tf->a0 = (register_t)(intptr_t)arg;
454
455         /*
456          * Keep interrupt mask
457          */
458         td->td_frame->sr = MIPS_SR_KSU_USER | MIPS_SR_EXL | MIPS_SR_INT_IE |
459             (mips_rd_status() & MIPS_SR_INT_MASK);
460 #if defined(__mips_n32) 
461         td->td_frame->sr |= MIPS_SR_PX;
462 #elif  defined(__mips_n64)
463         td->td_frame->sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX;
464 #endif
465 /*      tf->sr |= (ALL_INT_MASK & idle_mask) | SR_INT_ENAB; */
466         /**XXX the above may now be wrong -- mips2 implements this as panic */
467         /*
468          * FREEBSD_DEVELOPERS_FIXME:
469          * Setup any other CPU-Specific registers (Not MIPS Standard)
470          * that are needed.
471          */
472 }
473
474 /*
475  * Implement the pre-zeroed page mechanism.
476  * This routine is called from the idle loop.
477  */
478
479 #define ZIDLE_LO(v)     ((v) * 2 / 3)
480 #define ZIDLE_HI(v)     ((v) * 4 / 5)
481
482 /*
483  * Software interrupt handler for queued VM system processing.
484  */
485 void
486 swi_vm(void *dummy)
487 {
488
489         if (busdma_swi_pending)
490                 busdma_swi();
491 }
492
493 int
494 cpu_set_user_tls(struct thread *td, void *tls_base)
495 {
496
497 #if defined(__mips_n64) && defined(COMPAT_FREEBSD32)
498         if (td->td_proc && SV_PROC_FLAG(td->td_proc, SV_ILP32))
499                 td->td_md.md_tls_tcb_offset = TLS_TP_OFFSET + TLS_TCB_SIZE32;
500         else
501 #endif
502         td->td_md.md_tls_tcb_offset = TLS_TP_OFFSET + TLS_TCB_SIZE;
503         td->td_md.md_tls = (char*)tls_base;
504         if (td == curthread && cpuinfo.userlocal_reg == true) {
505                 mips_wr_userlocal((unsigned long)tls_base +
506                     td->td_md.md_tls_tcb_offset);
507         }
508
509         return (0);
510 }
511
512 #ifdef DDB
513 #include <ddb/ddb.h>
514
515 #define DB_PRINT_REG(ptr, regname)                      \
516         db_printf("  %-12s %p\n", #regname, (void *)(intptr_t)((ptr)->regname))
517
518 #define DB_PRINT_REG_ARRAY(ptr, arrname, regname)       \
519         db_printf("  %-12s %p\n", #regname, (void *)(intptr_t)((ptr)->arrname[regname]))
520
521 static void
522 dump_trapframe(struct trapframe *trapframe)
523 {
524
525         db_printf("Trapframe at %p\n", trapframe);
526
527         DB_PRINT_REG(trapframe, zero);
528         DB_PRINT_REG(trapframe, ast);
529         DB_PRINT_REG(trapframe, v0);
530         DB_PRINT_REG(trapframe, v1);
531         DB_PRINT_REG(trapframe, a0);
532         DB_PRINT_REG(trapframe, a1);
533         DB_PRINT_REG(trapframe, a2);
534         DB_PRINT_REG(trapframe, a3);
535 #if defined(__mips_n32) || defined(__mips_n64)
536         DB_PRINT_REG(trapframe, a4);
537         DB_PRINT_REG(trapframe, a5);
538         DB_PRINT_REG(trapframe, a6);
539         DB_PRINT_REG(trapframe, a7);
540         DB_PRINT_REG(trapframe, t0);
541         DB_PRINT_REG(trapframe, t1);
542         DB_PRINT_REG(trapframe, t2);
543         DB_PRINT_REG(trapframe, t3);
544 #else
545         DB_PRINT_REG(trapframe, t0);
546         DB_PRINT_REG(trapframe, t1);
547         DB_PRINT_REG(trapframe, t2);
548         DB_PRINT_REG(trapframe, t3);
549         DB_PRINT_REG(trapframe, t4);
550         DB_PRINT_REG(trapframe, t5);
551         DB_PRINT_REG(trapframe, t6);
552         DB_PRINT_REG(trapframe, t7);
553 #endif
554         DB_PRINT_REG(trapframe, s0);
555         DB_PRINT_REG(trapframe, s1);
556         DB_PRINT_REG(trapframe, s2);
557         DB_PRINT_REG(trapframe, s3);
558         DB_PRINT_REG(trapframe, s4);
559         DB_PRINT_REG(trapframe, s5);
560         DB_PRINT_REG(trapframe, s6);
561         DB_PRINT_REG(trapframe, s7);
562         DB_PRINT_REG(trapframe, t8);
563         DB_PRINT_REG(trapframe, t9);
564         DB_PRINT_REG(trapframe, k0);
565         DB_PRINT_REG(trapframe, k1);
566         DB_PRINT_REG(trapframe, gp);
567         DB_PRINT_REG(trapframe, sp);
568         DB_PRINT_REG(trapframe, s8);
569         DB_PRINT_REG(trapframe, ra);
570         DB_PRINT_REG(trapframe, sr);
571         DB_PRINT_REG(trapframe, mullo);
572         DB_PRINT_REG(trapframe, mulhi);
573         DB_PRINT_REG(trapframe, badvaddr);
574         DB_PRINT_REG(trapframe, cause);
575         DB_PRINT_REG(trapframe, pc);
576 }
577
578 DB_SHOW_COMMAND(pcb, ddb_dump_pcb)
579 {
580         struct thread *td;
581         struct pcb *pcb;
582         struct trapframe *trapframe;
583
584         /* Determine which thread to examine. */
585         if (have_addr)
586                 td = db_lookup_thread(addr, true);
587         else
588                 td = curthread;
589         
590         pcb = td->td_pcb;
591
592         db_printf("Thread %d at %p\n", td->td_tid, td);
593
594         db_printf("PCB at %p\n", pcb);
595
596         trapframe = &pcb->pcb_regs;
597         dump_trapframe(trapframe);
598
599         db_printf("PCB Context:\n");
600         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S0);
601         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S1);
602         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S2);
603         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S3);
604         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S4);
605         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S5);
606         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S6);
607         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S7);
608         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_SP);
609         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S8);
610         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_RA);
611         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_SR);
612         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_GP);
613         DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_PC);
614
615         db_printf("PCB onfault = %p\n", pcb->pcb_onfault);
616         db_printf("md_saved_intr = 0x%0lx\n", (long)td->td_md.md_saved_intr);
617         db_printf("md_spinlock_count = %d\n", td->td_md.md_spinlock_count);
618
619         if (td->td_frame != trapframe) {
620                 db_printf("td->td_frame %p is not the same as pcb_regs %p\n",
621                           td->td_frame, trapframe);
622         }
623 }
624
625 /*
626  * Dump the trapframe beginning at address specified by first argument.
627  */
628 DB_SHOW_COMMAND(trapframe, ddb_dump_trapframe)
629 {
630         
631         if (!have_addr)
632                 return;
633
634         dump_trapframe((struct trapframe *)addr);
635 }
636
637 #endif  /* DDB */