OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librdbg/] [src/] [i386/] [excep_f.c] - Blame information for rev 602

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 **************************************************************************
3
 *
4
 * Component =
5
 *
6
 * Synopsis  =   rdbg/i386/excep.c
7
 *
8
 * $Id: excep_f.c,v 1.2 2001-09-27 12:02:01 chris Exp $
9
 *
10
 **************************************************************************
11
 */
12
 
13
#include <rtems.h>
14
#include <rtems/error.h>
15
#include <assert.h>
16
#include <errno.h>
17
#include <rdbg/rdbg.h>
18
#include <rdbg/servrpc.h>
19
 
20
/* -----------------------------------------------------------------
21
   Maping of hardware exceptions into Unix-like signal numbers.
22
   It is identical to the one used by the PM and the AM.
23
   ----------------------------------------------------------------- */
24
 
25
    int
26
ExcepToSig (Exception_context *ctx)
27
{
28
    int excep = getExcNum (ctx);
29
 
30
 
31
    switch (excep) {
32
 
33
    case I386_EXCEPTION_MATH_COPROC_UNAVAIL:
34
    case I386_EXCEPTION_I386_COPROC_SEG_ERR:
35
    case I386_EXCEPTION_FLOAT_ERROR:
36
    case I386_EXCEPTION_BOUND:
37
        return SIGFPE;
38
 
39
    case I386_EXCEPTION_DEBUG:
40
    case I386_EXCEPTION_BREAKPOINT:
41
    case I386_EXCEPTION_ENTER_RDBG:
42
        return SIGTRAP;
43
 
44
    case I386_EXCEPTION_OVERFLOW:
45
    case I386_EXCEPTION_DIVIDE_BY_ZERO:
46
    case I386_EXCEPTION_ILLEGAL_INSTR:
47
        return SIGILL;
48
 
49
    case I386_EXCEPTION_SEGMENT_NOT_PRESENT:
50
    case I386_EXCEPTION_STACK_SEGMENT_FAULT:
51
    case I386_EXCEPTION_GENERAL_PROT_ERR:
52
    case I386_EXCEPTION_PAGE_FAULT:
53
        return SIGSEGV;
54
 
55
    default:
56
        break;
57
    }
58
    return SIGKILL;
59
}
60
 
61
 
62
/*----- Breakpoint Exception management -----*/
63
 
64
    /*
65
     *  Handler for Breakpoint Exceptions :
66
     *  software breakpoints.
67
     */
68
 
69
void
70
BreakPointExcHdl(CPU_Exception_frame *ctx)
71
{
72
  rtems_status_code status;
73
  rtems_id continueSemId;
74
 
75
  if ( (justSaveContext) && (ctx->idtIndex == I386_EXCEPTION_ENTER_RDBG) ) {
76
    PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
77
    justSaveContext = 0;
78
  }
79
  else {
80
    if (ctx->idtIndex != I386_EXCEPTION_DEBUG){
81
      NbSerializedCtx++;
82
      rtems_semaphore_obtain(serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
83
      NbSerializedCtx--;
84
    }
85
 
86
    currentTargetThread = _Thread_Executing->Object.id;
87
 
88
#ifdef DDEBUG
89
    printk("----------------------------------------------------------\n");
90
    printk("Exception %d caught at PC %x by thread %d\n",
91
           ctx->idtIndex,
92
           ctx->eip,
93
           _Thread_Executing->Object.id);
94
    printk("----------------------------------------------------------\n");
95
    printk("Processor execution context at time of the fault was  :\n");
96
    printk("----------------------------------------------------------\n");
97
    printk(" EAX = %x   EBX = %x        ECX = %x        EDX = %x\n",
98
           ctx->eax, ctx->ebx, ctx->ecx, ctx->edx);
99
    printk(" ESI = %x   EDI = %x        EBP = %x        ESP = %x\n",
100
           ctx->esi, ctx->edi, ctx->ebp, ctx->esp0);
101
    printk("----------------------------------------------------------\n");
102
    printk("Error code pushed by processor itself (if not 0) = %x\n",
103
           ctx->faultCode);
104
    printk("----------------------------------------------------------\n\n");
105
#endif
106
 
107
    status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
108
                                     0,
109
                                     RTEMS_FIFO |
110
                                     RTEMS_COUNTING_SEMAPHORE |
111
                                     RTEMS_NO_INHERIT_PRIORITY |
112
                                     RTEMS_NO_PRIORITY_CEILING |
113
                                     RTEMS_LOCAL,
114
                                     0,
115
                                     &continueSemId);
116
    if (status != RTEMS_SUCCESSFUL)
117
      rtems_panic ("Can't create continue semaphore: `%s'\n",rtems_status_text(status));
118
 
119
    PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
120
 
121
    switch (ctx->idtIndex){
122
    case I386_EXCEPTION_DEBUG:
123
      DPRINTF((" DEBUG EXCEPTION !!!\n"));
124
      ctx->eflags &= ~EFLAGS_TF;
125
      ExitForSingleStep-- ;
126
      rtems_semaphore_release( wakeupEventSemId );
127
    break;
128
 
129
    case I386_EXCEPTION_BREAKPOINT:
130
      DPRINTF((" BREAKPOINT EXCEPTION !!!\n"));
131
      rtems_semaphore_release( wakeupEventSemId );
132
    break;
133
 
134
    case I386_EXCEPTION_ENTER_RDBG:
135
      DPRINTF((" ENTER RDBG !!!\n"));
136
      rtems_semaphore_release( wakeupEventSemId );
137
      break;
138
 
139
    default:
140
      DPRINTF((" OTHER EXCEPTION !!!\n"));
141
      rtems_semaphore_release( wakeupEventSemId );
142
      break;
143
    }
144
 
145
    rtems_semaphore_obtain(continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
146
 
147
    PopExceptCtx (_Thread_Executing->Object.id);
148
    rtems_semaphore_delete(continueSemId);
149
  }
150
}
151
 
152
 
153
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.