~ari-tczew/ubuntu/lucid/skyeye/sru-lp-464175

« back to all changes in this revision

Viewing changes to arch/coldfire/common/exception.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2009-02-20 10:02:22 UTC
  • mfrom: (1.1.3 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090220100222-sw2erxpve46mtx7j
Tags: 1.2.5-2
* Fix get_sym implicit-pointer-conversion. (Closes:Bug#516248) 
* Modified configure.in to disable link with libbfd.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
/*                                */
7
7
/**********************************/
8
8
 
9
 
/*#define TRACER_OFF*/
 
9
/*#define SKYEYE_DBGR_OFF*/
10
10
 
11
11
#include "coldfire.h"
12
12
 
13
 
TRACER_DEFAULT_CHANNEL(exception);
 
13
SKYEYE_DBGR_DEFAULT_CHANNEL(exception);
14
14
 
15
15
static short exception_pending = 0;
16
16
static unsigned int (*iack_func[8])(unsigned int interrupt_level)
21
21
        int x;
22
22
        if(!exception_pending) return;
23
23
 
24
 
        TRACE("exception_pending = 0x%04x\n", exception_pending);
 
24
        SKYEYE_DBG("exception_pending = 0x%04x\n", exception_pending);
25
25
 
26
26
        /* if the mask is 7, do nothing, if the mask is 0, check 
27
27
         * all interrupts 7->1, interrupts level 0 doesn't make sense
28
28
         *  FIXME: can the coldfire fire an interrupt with priority 0 ? */
29
29
        
30
 
        TRACE("currint interrupt mask is %d, checking 7->%d\n", 
 
30
        SKYEYE_DBG("currint interrupt mask is %d, checking 7->%d\n", 
31
31
                SRBits->InterruptPriorityMask, SRBits->InterruptPriorityMask+1);
32
32
        
33
33
        for(x=7; x>=SRBits->InterruptPriorityMask+1; x--) {
34
34
                if(iack_func[x] != NULL) {
35
35
                        unsigned int vector;
36
 
                        TRACE("Found interrupt_level %d to do exception.\n",
 
36
                        SKYEYE_DBG("Found interrupt_level %d to do exception.\n",
37
37
                                        x);
38
38
                        vector = (iack_func[x])(x);
39
 
                        TRACE("iack_func returned vector %lu\n", vector);
 
39
                        SKYEYE_DBG("iack_func returned vector %lu\n", vector);
40
40
                        exception_push_stack_frame(vector);
41
41
                        /* Set the new interrupt priority */
42
42
                        SRBits->InterruptPriorityMask = x;
43
43
                        
44
44
                        /* Set the Master/Interrupt bit to 0 */
45
45
                        SRBits->M = 0;
46
 
                        TRACE("   Interrupt Priority mask is now %d\n",
 
46
                        SKYEYE_DBG("   Interrupt Priority mask is now %d\n",
47
47
                                                SRBits->InterruptPriorityMask);
48
48
                        /* Do the RAW exception */
49
49
                        exception_do_raw_exception(vector);
56
56
void exception_post(unsigned int interrupt_level, 
57
57
                unsigned int (*func)(unsigned int interrupt_level) )
58
58
{
59
 
        TRACE("Exception posted at interrupt level %d\n", interrupt_level);
 
59
        SKYEYE_DBG("Exception posted at interrupt level %d\n", interrupt_level);
60
60
        exception_pending |= (0x1 << interrupt_level);
61
61
        iack_func[interrupt_level] = func;
62
62
}
63
63
 
64
64
void exception_withdraw(unsigned int interrupt_level)
65
65
{
66
 
        TRACE("Exception withdrawn at interrupt level %d\n", interrupt_level);
 
66
        SKYEYE_DBG("Exception withdrawn at interrupt level %d\n", interrupt_level);
67
67
        if(iack_func[interrupt_level] == NULL) {
68
 
                ERR("Attempting to withdraw interrupt level %d which is not set.\n",
 
68
                SKYEYE_ERR("Attempting to withdraw interrupt level %d which is not set.\n",
69
69
                                interrupt_level);
70
70
        }
71
71
        exception_pending &= ~(0x1 << interrupt_level);
86
86
        unsigned int stack_frame;
87
87
 
88
88
        /* Restore the PC to the fault address */
89
 
        TRACE("pushing exception stack frame for exception vector=%d\n", vector);
 
89
        SKYEYE_DBG("pushing exception stack frame for exception vector=%d\n", vector);
90
90
        if(vector < 16) {
91
91
                if(exception_pc_location[vector] == 1)
92
92
                        PC_to_push = memory_core.pc_instruction_begin;
127
127
                        (0x0 << 16) |
128
128
                        (memory_core.sr & 0xFFFF);
129
129
 
130
 
        TRACE("Pushing PC [0x%x] and StackFrame [0x%x]\n", PC_to_push,
 
130
        SKYEYE_DBG("Pushing PC [0x%x] and StackFrame [0x%x]\n", PC_to_push,
131
131
                         *(int *)&stack_frame);
132
132
 
133
133
        /* Align the stack to the next longword offset */
152
152
/*      FIXME: I'm not convinced that this is correct 
153
153
        memory_core.a[7] += (frame & 0x30000000 >> 28);*/
154
154
 
155
 
        TRACE("Set SR=0x%08lx\n", memory_core.sr);
156
 
        TRACE("Set PC=0x%08lx\n", memory_core.pc);
 
155
        SKYEYE_DBG("Set SR=0x%08lx\n", memory_core.sr);
 
156
        SKYEYE_DBG("Set PC=0x%08lx\n", memory_core.pc);
157
157
}
158
158
 
159
159
 
162
162
        unsigned int offset=0;
163
163
        static struct _memory_segment *seg;
164
164
        /* Find the jump offset in the vbr */
165
 
        TRACE("Doing Exception Vector=%d, vbr=0x%08lx\n", vector, 
 
165
        SKYEYE_DBG("Doing Exception Vector=%d, vbr=0x%08lx\n", vector, 
166
166
                        memory_core.vbr);
167
167
        /* If this falis, we could go into an infinite loop, with an invalid
168
168
         * memory access exception */
169
169
        if(!Memory_Retr(&offset, 32, memory_core.vbr + (vector*4))) return 0;
170
170
        
171
 
        TRACE("ISR is at 0x%08lx\n", offset);
 
171
        SKYEYE_DBG("ISR is at 0x%08lx\n", offset);
172
172
 
173
173
        /* Assert the S bit, and clear the T bit */
174
174
        SRBits->S = 1;
191
191
        }
192
192
        memory_core.pc=offset;
193
193
 
194
 
        TRACE("Set PC to ISR offset [0x%x]\n", memory_core.pc);
195
 
        TRACE("Done\n");
 
194
        SKYEYE_DBG("Set PC to ISR offset [0x%x]\n", memory_core.pc);
 
195
        SKYEYE_DBG("Done\n");
196
196
        return 0;
197
197
}
198
198