~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to extras/mini-os/arch/ia64/debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 ****************************************************************************
 
3
 * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com
 
4
 *
 
5
 * Description: ia64 specific part of the mini-os
 
6
 *              Prints debug information on a crash of mini-os
 
7
 *
 
8
 * Parts are taken from FreeBSD.
 
9
 *
 
10
 ****************************************************************************
 
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 
12
 * of this software and associated documentation files (the "Software"), to
 
13
 * deal in the Software without restriction, including without limitation the
 
14
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 
15
 * sell copies of the Software, and to permit persons to whom the Software is
 
16
 * furnished to do so, subject to the following conditions:
 
17
 * 
 
18
 * The above copyright notice and this permission notice shall be included in
 
19
 * all copies or substantial portions of the Software.
 
20
 * 
 
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 
22
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 
24
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 
26
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 
27
 * DEALINGS IN THE SOFTWARE.
 
28
 */
 
29
 
 
30
#include <mini-os/os.h>
 
31
 
 
32
static const char *ia64_vector_names[] = {
 
33
        "VHPT Translation",                     /* 0 */
 
34
        "Instruction TLB",                      /* 1 */
 
35
        "Data TLB",                             /* 2 */
 
36
        "Alternate Instruction TLB",            /* 3 */
 
37
        "Alternate Data TLB",                   /* 4 */
 
38
        "Data Nested TLB",                      /* 5 */
 
39
        "Instruction Key Miss",                 /* 6 */
 
40
        "Data Key Miss",                        /* 7 */
 
41
        "Dirty-Bit",                            /* 8 */
 
42
        "Instruction Access-Bit",               /* 9 */
 
43
        "Data Access-Bit",                      /* 10 */
 
44
        "Break Instruction",                    /* 11 */
 
45
        "External Interrupt",                   /* 12 */
 
46
        "Reserved 13",                          /* 13 */
 
47
        "Reserved 14",                          /* 14 */
 
48
        "Reserved 15",                          /* 15 */
 
49
        "Reserved 16",                          /* 16 */
 
50
        "Reserved 17",                          /* 17 */
 
51
        "Reserved 18",                          /* 18 */
 
52
        "Reserved 19",                          /* 19 */
 
53
        "Page Not Present",                     /* 20 */
 
54
        "Key Permission",                       /* 21 */
 
55
        "Instruction Access Rights",            /* 22 */
 
56
        "Data Access Rights",                   /* 23 */
 
57
        "General Exception",                    /* 24 */
 
58
        "Disabled FP-Register",                 /* 25 */
 
59
        "NaT Consumption",                      /* 26 */
 
60
        "Speculation",                          /* 27 */
 
61
        "Reserved 28",                          /* 28 */
 
62
        "Debug",                                /* 29 */
 
63
        "Unaligned Reference",                  /* 30 */
 
64
        "Unsupported Data Reference",           /* 31 */
 
65
        "Floating-point Fault",                 /* 32 */
 
66
        "Floating-point Trap",                  /* 33 */
 
67
        "Lower-Privilege Transfer Trap",        /* 34 */
 
68
        "Taken Branch Trap",                    /* 35 */
 
69
        "Single Step Trap",                     /* 36 */
 
70
        "Reserved 37",                          /* 37 */
 
71
        "Reserved 38",                          /* 38 */
 
72
        "Reserved 39",                          /* 39 */
 
73
        "Reserved 40",                          /* 40 */
 
74
        "Reserved 41",                          /* 41 */
 
75
        "Reserved 42",                          /* 42 */
 
76
        "Reserved 43",                          /* 43 */
 
77
        "Reserved 44",                          /* 44 */
 
78
        "IA-32 Exception",                      /* 45 */
 
79
        "IA-32 Intercept",                      /* 46 */
 
80
        "IA-32 Interrupt",                      /* 47 */
 
81
        "Reserved 48",                          /* 48 */
 
82
        "Reserved 49",                          /* 49 */
 
83
        "Reserved 50",                          /* 50 */
 
84
        "Reserved 51",                          /* 51 */
 
85
        "Reserved 52",                          /* 52 */
 
86
        "Reserved 53",                          /* 53 */
 
87
        "Reserved 54",                          /* 54 */
 
88
        "Reserved 55",                          /* 55 */
 
89
        "Reserved 56",                          /* 56 */
 
90
        "Reserved 57",                          /* 57 */
 
91
        "Reserved 58",                          /* 58 */
 
92
        "Reserved 59",                          /* 59 */
 
93
        "Reserved 60",                          /* 60 */
 
94
        "Reserved 61",                          /* 61 */
 
95
        "Reserved 62",                          /* 62 */
 
96
        "Reserved 63",                          /* 63 */
 
97
        "Reserved 64",                          /* 64 */
 
98
        "Reserved 65",                          /* 65 */
 
99
        "Reserved 66",                          /* 66 */
 
100
        "Reserved 67",                          /* 67 */
 
101
};
 
102
 
 
103
typedef struct
 
104
{
 
105
        uint64_t sof    :7;     /* 0-6 size of frame */
 
106
        uint64_t sol    :7;     /* 7-13 size of locals (in + loc) */
 
107
        uint64_t sor    :4;
 
108
        uint64_t rrb_gr :7;
 
109
        uint64_t rrb_fr :7;
 
110
        uint64_t rrb_pr :6;
 
111
        uint64_t res    :25;    /* reserved */
 
112
        uint64_t v      :1;     /* The v bit */
 
113
} ifs_t;
 
114
 
 
115
void
 
116
do_trap_error(trap_frame_t* tf)
 
117
{
 
118
        ifs_t curIfs;
 
119
 
 
120
        printk("TRAP in mini-os:\n");
 
121
        printk("  trap: %d (%s)\n", tf->trap_num,
 
122
               ia64_vector_names[tf->trap_num]);
 
123
        printk("  iip : 0x%.16lx  ifa: 0x%.16lx\n", tf->iip, tf->ifa);
 
124
        printk("  ipsr: 0x%.16lx  ifs: 0x%.16lx\n", tf->ipsr, tf->ifs);
 
125
        printk("  isr : 0x%.16lx\n", tf->isr);
 
126
        printk("  gp  : 0x%.16lx  sp : 0x%.16lx\n", tf->gp, tf->sp);
 
127
        printk("  rp  : 0x%.16lx  tp : 0x%.16lx\n", tf->b0, tf->tp);
 
128
        printk("  b6  : 0x%.16lx  b7 : 0x%.16lx\n", tf->b6, tf->b7);
 
129
        printk("  r8  : 0x%.16lx\n", tf->r8);
 
130
        printk("  bsp : 0x%.16lx  rsc: 0x%.16lx\n", tf->bsp, tf->rsc);
 
131
        printk("  r14 : 0x%.16lx  r15: 0x%.16lx\n", tf->r14, tf->r15);
 
132
        printk("  r16 : 0x%.16lx  r17: 0x%.16lx\n", tf->r16, tf->r17);
 
133
        printk("  r18 : 0x%.16lx  r19: 0x%.16lx\n", tf->r18, tf->r19);
 
134
        printk("  r20 : 0x%.16lx  r21: 0x%.16lx\n", tf->r20, tf->r21);
 
135
        printk("  r22 : 0x%.16lx  r23: 0x%.16lx\n", tf->r22, tf->r23);
 
136
        printk("  r24 : 0x%.16lx  r25: 0x%.16lx\n", tf->r24, tf->r25);
 
137
        printk("  r26 : 0x%.16lx  r27: 0x%.16lx\n", tf->r26, tf->r27);
 
138
        printk("  r28 : 0x%.16lx  r29: 0x%.16lx\n", tf->r28, tf->r29);
 
139
        printk("  r30 : 0x%.16lx  r31: 0x%.16lx\n", tf->r30, tf->r31);
 
140
 
 
141
        __asm __volatile("flushrs;;");
 
142
        curIfs = *((ifs_t*)((void*)(&tf->ifs)));
 
143
        if (!curIfs.v)
 
144
                printk(" ifs.v = 0");
 
145
        else {
 
146
                uint64_t* regP;
 
147
                uint32_t  i;
 
148
 
 
149
                printk("  cfm.sof: %d  cfm.sol: %d\n", curIfs.sof, curIfs.sol);
 
150
                regP = (uint64_t *)(tf->bsp + tf->ndirty);
 
151
                for (i = curIfs.sof; i != 0; ) {
 
152
                        if (i <= (((uint64_t)regP & 0x000001f8) >> 3)) {
 
153
                                regP -= i;
 
154
                                i = 0;
 
155
                                break;
 
156
                        }
 
157
                        i -= ((uint64_t)regP & 0x000001f8) >> 3;
 
158
                        regP = (uint64_t *)((uint64_t)regP & ~0x000001ff) - 1;
 
159
                }
 
160
                for (i = 0; i < curIfs.sof; i++) {
 
161
                        if (((uint64_t)regP & 0x000001f8) == 0x000001f8)
 
162
                                regP++;
 
163
                        printk("  r%d: 0x%lx\n",  i+32, *regP);
 
164
                        regP++;
 
165
                }
 
166
        }
 
167
        HYPERVISOR_shutdown(SHUTDOWN_poweroff);
 
168
}