Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: badtrap.c | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | #pragma ident "@(#)badtrap.c 1.9 07/06/07 SMI" | |
50 | ||
51 | #include <stdio.h> | |
52 | #include <sys/types.h> | |
53 | ||
54 | #include <sample/sample.h> | |
55 | ||
56 | struct trapinfo { | |
57 | uint64_t g[3][8]; | |
58 | uint64_t tpc; | |
59 | uint64_t tnpc; | |
60 | uint64_t tstate; | |
61 | ||
62 | uint8_t tl; | |
63 | uint8_t tt; | |
64 | uint8_t pil; | |
65 | uint8_t gl; | |
66 | uint8_t align1[4]; | |
67 | }; | |
68 | ||
69 | ||
70 | void | |
71 | stacktrace(uint64_t fp, uint64_t sp) | |
72 | { | |
73 | uint64_t *ip, *lp, *op; | |
74 | int i; | |
75 | ||
76 | while (fp & 1) { | |
77 | lp = (uint64_t *)((uint64_t)(fp+(2048-1))); | |
78 | ip = lp + 8; | |
79 | op = ((uint64_t *)(sp+2048-1))+8; | |
80 | for (i = 0; i < 8; i++) { | |
81 | (void) printf("%%o%d=%016lx ", i, op[i]); | |
82 | (void) printf("%%l%d=%016lx ", i, lp[i]); | |
83 | (void) printf("%%i%d=%016lx ", i, ip[i]); | |
84 | (void) printf("\n"); | |
85 | } | |
86 | (void) printf("\n"); | |
87 | sp = fp; | |
88 | fp = ip[6]; | |
89 | ||
90 | } | |
91 | } | |
92 | ||
93 | void | |
94 | badtrap(struct trapinfo *ti) | |
95 | { | |
96 | uint64_t fp, sp; | |
97 | int i, j; | |
98 | (void) printf("TT=%02x\n", ti->tt); | |
99 | (void) printf("TL=%02x\n", ti->tl); | |
100 | (void) printf("TPC=%016lx\n", ti->tpc); | |
101 | (void) printf("TnPC=%016lx\n", ti->tnpc); | |
102 | (void) printf("TSTATE=%010lx\n", ti->tstate); | |
103 | (void) printf("PIL=%x\n", ti->pil); | |
104 | (void) printf("\n"); | |
105 | ||
106 | flushw(); | |
107 | ||
108 | printf("GL=0\t\t\tGL=1\t\t\tGL=2\n"); | |
109 | for (j = 0; j < 7; j++) { | |
110 | for (i = 0; i < 3; i++) { | |
111 | printf("%%g%d=%016x ", j, ti->g[i][j]); | |
112 | } | |
113 | printf("\n"); | |
114 | } | |
115 | ||
116 | printf("\n"); | |
117 | ||
118 | fp = (uint64_t)getfp(); | |
119 | sp = (uint64_t)getsp(); | |
120 | ||
121 | stacktrace(fp, sp); | |
122 | ||
123 | #if 0 | |
124 | if (ti->tt == 0x68) { | |
125 | ti->tpc = ti->tnpc; | |
126 | ti->tnpc += 4; | |
127 | rtt(ti); | |
128 | printf("XXX SHOULD NOT GET HERE!!!\n"); | |
129 | } | |
130 | #endif | |
131 | ||
132 | while (1) { | |
133 | /* LINTED */ | |
134 | } | |
135 | } |