~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/arch/powerpc/cpu/mpc824x/traps.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * linux/arch/powerpc/kernel/traps.c
 
3
 *
 
4
 * Copyright (C) 1995-1996  Gary Thomas (gdt@linuxppc.org)
 
5
 *
 
6
 * Modified by Cort Dougan (cort@cs.nmt.edu)
 
7
 * and Paul Mackerras (paulus@cs.anu.edu.au)
 
8
 *
 
9
 * (C) Copyright 2000
 
10
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
11
 *
 
12
 * SPDX-License-Identifier:     GPL-2.0+
 
13
 */
 
14
 
 
15
/*
 
16
 * This file handles the architecture-dependent parts of hardware exceptions
 
17
 */
 
18
 
 
19
#include <common.h>
 
20
#include <asm/processor.h>
 
21
 
 
22
/* Returns 0 if exception not found and fixup otherwise.  */
 
23
extern unsigned long search_exception_table(unsigned long);
 
24
 
 
25
/* THIS NEEDS CHANGING to use the board info structure.
 
26
*/
 
27
#define END_OF_MEM      0x00400000
 
28
 
 
29
/*
 
30
 * Trap & Exception support
 
31
 */
 
32
 
 
33
static void print_backtrace(unsigned long *sp)
 
34
{
 
35
        int cnt = 0;
 
36
        unsigned long i;
 
37
 
 
38
        printf("Call backtrace: ");
 
39
        while (sp) {
 
40
                if ((uint)sp > END_OF_MEM)
 
41
                        break;
 
42
 
 
43
                i = sp[1];
 
44
                if (cnt++ % 7 == 0)
 
45
                        printf("\n");
 
46
                printf("%08lX ", i);
 
47
                if (cnt > 32) break;
 
48
                sp = (unsigned long *)*sp;
 
49
        }
 
50
        printf("\n");
 
51
}
 
52
 
 
53
void show_regs(struct pt_regs *regs)
 
54
{
 
55
        int i;
 
56
 
 
57
        printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DAR: %08lX\n",
 
58
               regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar);
 
59
        printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
 
60
               regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
 
61
               regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
 
62
               regs->msr&MSR_IR ? 1 : 0,
 
63
               regs->msr&MSR_DR ? 1 : 0);
 
64
 
 
65
        printf("\n");
 
66
        for (i = 0;  i < 32;  i++) {
 
67
                if ((i % 8) == 0)
 
68
                {
 
69
                        printf("GPR%02d: ", i);
 
70
                }
 
71
 
 
72
                printf("%08lX ", regs->gpr[i]);
 
73
                if ((i % 8) == 7)
 
74
                {
 
75
                        printf("\n");
 
76
                }
 
77
        }
 
78
}
 
79
 
 
80
 
 
81
static void _exception(int signr, struct pt_regs *regs)
 
82
{
 
83
        show_regs(regs);
 
84
        print_backtrace((unsigned long *)regs->gpr[1]);
 
85
        panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
 
86
}
 
87
 
 
88
void MachineCheckException(struct pt_regs *regs)
 
89
{
 
90
        unsigned long fixup;
 
91
 
 
92
        /* Probing PCI using config cycles cause this exception
 
93
         * when a device is not present.  Catch it and return to
 
94
         * the PCI exception handler.
 
95
         */
 
96
        if ((fixup = search_exception_table(regs->nip)) != 0) {
 
97
                regs->nip = fixup;
 
98
                return;
 
99
        }
 
100
 
 
101
        printf("Machine check in kernel mode.\n");
 
102
        printf("Caused by (from msr): ");
 
103
        printf("regs %p ",regs);
 
104
        switch( regs->msr & 0x000F0000) {
 
105
        case (0x80000000>>12):
 
106
                printf("Machine check signal - probably due to mm fault\n"
 
107
                        "with mmu off\n");
 
108
                break;
 
109
        case (0x80000000>>13):
 
110
                printf("Transfer error ack signal\n");
 
111
                break;
 
112
        case (0x80000000>>14):
 
113
                printf("Data parity signal\n");
 
114
                break;
 
115
        case (0x80000000>>15):
 
116
                printf("Address parity signal\n");
 
117
                break;
 
118
        default:
 
119
                printf("Unknown values in msr\n");
 
120
        }
 
121
        show_regs(regs);
 
122
        print_backtrace((unsigned long *)regs->gpr[1]);
 
123
        panic("machine check");
 
124
}
 
125
 
 
126
void AlignmentException(struct pt_regs *regs)
 
127
{
 
128
        show_regs(regs);
 
129
        print_backtrace((unsigned long *)regs->gpr[1]);
 
130
        panic("Alignment Exception");
 
131
}
 
132
 
 
133
void ProgramCheckException(struct pt_regs *regs)
 
134
{
 
135
        show_regs(regs);
 
136
        print_backtrace((unsigned long *)regs->gpr[1]);
 
137
        panic("Program Check Exception");
 
138
}
 
139
 
 
140
void SoftEmuException(struct pt_regs *regs)
 
141
{
 
142
        show_regs(regs);
 
143
        print_backtrace((unsigned long *)regs->gpr[1]);
 
144
        panic("Software Emulation Exception");
 
145
}
 
146
 
 
147
 
 
148
void UnknownException(struct pt_regs *regs)
 
149
{
 
150
        printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
 
151
               regs->nip, regs->msr, regs->trap);
 
152
        _exception(0, regs);
 
153
}
 
154
 
 
155
#if defined(CONFIG_CMD_BEDBUG)
 
156
extern void do_bedbug_breakpoint(struct pt_regs *);
 
157
#endif
 
158
 
 
159
void DebugException(struct pt_regs *regs)
 
160
{
 
161
 
 
162
  printf("Debugger trap at @ %lx\n", regs->nip );
 
163
  show_regs(regs);
 
164
#if defined(CONFIG_CMD_BEDBUG)
 
165
  do_bedbug_breakpoint( regs );
 
166
#endif
 
167
}
 
168
 
 
169
/* Probe an address by reading.  If not present, return -1, otherwise
 
170
 * return 0.
 
171
 */
 
172
int addr_probe(uint *addr)
 
173
{
 
174
#if 0
 
175
        int     retval;
 
176
 
 
177
        __asm__ __volatile__(                   \
 
178
                "1:     lwz %0,0(%1)\n"         \
 
179
                "       eieio\n"                \
 
180
                "       li %0,0\n"              \
 
181
                "2:\n"                          \
 
182
                ".section .fixup,\"ax\"\n"      \
 
183
                "3:     li %0,-1\n"             \
 
184
                "       b 2b\n"                 \
 
185
                ".section __ex_table,\"a\"\n"   \
 
186
                "       .align 2\n"             \
 
187
                "       .long 1b,3b\n"          \
 
188
                ".text"                         \
 
189
                : "=r" (retval) : "r"(addr));
 
190
 
 
191
        return (retval);
 
192
#endif
 
193
        return 0;
 
194
}