source: rtems/c/src/exec/score/cpu/i386/cpu.c @ b285860

4.104.114.84.95
Last change on this file since b285860 was b285860, checked in by Joel Sherrill <joel.sherrill@…>, on 08/31/98 at 23:03:45

Patch from Eric Valette <valette@…>:

Eric> NB : there is still a bug on PC386 serial line : exit does not
Eric> flush the remaining output queue. As this is not a bug in the
Eric> driver itself but somewhere in PC386 initialization/termios
Eric> relationship it will be part of another patch.

Eric> NB2 : As Emmanuel excerced the exception hanlder code, while
Eric> porting the SMC driver to the new BSD stack, we found a bug
Eric> in the exception handler : it shall not delete the current
Eric> thread in case we are running at interrupt level. This will
Eric> be part of another patch...

So here is the patch. This patch fixes the two problems mentionned above

+ it use vpath mechanism intead of copying the irq related files in

the right directory. This avoid to compile them each time and is
more homogenous with other Makefiles.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 *  Intel i386 Dependent Source
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/score/isr.h>
18#include <bspIo.h>
19#include <rtems/score/thread.h>
20
21
22/*  _CPU_Initialize
23 *
24 *  This routine performs processor dependent initialization.
25 *
26 *  INPUT PARAMETERS:
27 *    cpu_table       - CPU table to initialize
28 *    thread_dispatch - address of disptaching routine
29 */
30
31
32void _CPU_Initialize(
33  rtems_cpu_table  *cpu_table,
34  void      (*thread_dispatch)      /* ignored on this CPU */
35)
36{
37  register unsigned16  fp_status asm ("ax");
38  register void       *fp_context;
39
40  _CPU_Table = *cpu_table;
41
42  /*
43   *  The following code saves a NULL i387 context which is given
44   *  to each task at start and restart time.  The following code
45   *  is based upon that provided in the i386 Programmer's
46   *  Manual and should work on any coprocessor greater than
47   *  the i80287.
48   *
49   *  NOTE: The NO RTEMS_WAIT form of the coprocessor instructions
50   *        MUST be used in case there is not a coprocessor
51   *        to wait for.
52   */
53
54  fp_status = 0xa5a5;
55  asm volatile( "fninit" );
56  asm volatile( "fnstsw %0" : "=a" (fp_status) : "0" (fp_status) );
57
58  if ( fp_status ==  0 ) {
59
60    fp_context = &_CPU_Null_fp_context;
61
62    asm volatile( "fsave (%0)" : "=r" (fp_context)
63                               : "0"  (fp_context)
64                );
65  }
66}
67
68/*PAGE
69 *
70 *  _CPU_ISR_Get_level
71 */
72 
73unsigned32 _CPU_ISR_Get_level( void )
74{
75  unsigned32 level;
76 
77  i386_get_interrupt_level( level );
78 
79  return level;
80}
81
82void _CPU_Thread_Idle_body ()
83{
84  while(1){
85    asm volatile ("hlt");
86  }
87}
88
89void _defaultExcHandler (CPU_Exception_frame *ctx)
90{
91  printk("----------------------------------------------------------\n");
92  printk("Exception %d caught at PC %x by thread %d\n",
93         ctx->idtIndex,
94         ctx->eip,
95         _Thread_Executing->Object.id);
96  printk("----------------------------------------------------------\n");
97  printk("Processor execution context at time of the fault was  :\n");
98  printk("----------------------------------------------------------\n");
99  printk(" EAX = %x     EBX = %x        ECX = %x        EDX = %x\n",
100         ctx->eax, ctx->ebx, ctx->ecx, ctx->edx);
101  printk(" ESI = %x     EDI = %x        EBP = %x        ESP = %x\n",
102         ctx->esi, ctx->edi, ctx->ebp, ctx->esp0);
103  printk("----------------------------------------------------------\n");
104  printk("Error code pushed by processor itself (if not 0) = %x\n",
105         ctx->faultCode);
106  printk("----------------------------------------------------------\n\n");
107  if (_ISR_Nest_level > 0) {
108    /*
109     * In this case we shall not delete the task interrupted as
110     * it has nothing to do with the fault. We cannot return either
111     * because the eip points to the faulty instruction so...
112     */
113    printk("Exception while executing ISR!!!. System locked\n");
114    while(1);
115  }
116  else {
117    /*
118     * OK I could probably use a simplified version but at least this
119     * should work.
120     */
121    printk(" ************ FAULTY THREAD WILL BE DELETED **************\n");
122    rtems_task_delete(_Thread_Executing->Object.id);
123  }
124}
125
126cpuExcHandlerType _currentExcHandler = _defaultExcHandler;
127
128extern void rtems_exception_prologue_0();
129extern void rtems_exception_prologue_1();
130extern void rtems_exception_prologue_2();
131extern void rtems_exception_prologue_3();
132extern void rtems_exception_prologue_4();
133extern void rtems_exception_prologue_5();
134extern void rtems_exception_prologue_6();
135extern void rtems_exception_prologue_7();
136extern void rtems_exception_prologue_8();
137extern void rtems_exception_prologue_9();
138extern void rtems_exception_prologue_10();
139extern void rtems_exception_prologue_11();
140extern void rtems_exception_prologue_12();
141extern void rtems_exception_prologue_13();
142extern void rtems_exception_prologue_14();
143extern void rtems_exception_prologue_16();
144extern void rtems_exception_prologue_17();
145extern void rtems_exception_prologue_18();
146
147static rtems_raw_irq_hdl tbl[] = {
148         rtems_exception_prologue_0,
149         rtems_exception_prologue_1,
150         rtems_exception_prologue_2,
151         rtems_exception_prologue_3,
152         rtems_exception_prologue_4,
153         rtems_exception_prologue_5,
154         rtems_exception_prologue_6,
155         rtems_exception_prologue_7,
156         rtems_exception_prologue_8,
157         rtems_exception_prologue_9,
158         rtems_exception_prologue_10,
159         rtems_exception_prologue_11,
160         rtems_exception_prologue_12,
161         rtems_exception_prologue_13,
162         rtems_exception_prologue_14,
163         rtems_exception_prologue_16,
164         rtems_exception_prologue_17,
165         rtems_exception_prologue_18,
166};
167
168void rtems_exception_init_mngt()
169{
170      unsigned int               i,j;
171      interrupt_gate_descriptor  *currentIdtEntry;
172      unsigned                   limit;
173      unsigned                   level;
174     
175      i = sizeof(tbl) / sizeof (rtems_raw_irq_hdl);
176
177      i386_get_info_from_IDTR (&currentIdtEntry, &limit);
178
179      _CPU_ISR_Disable(level);
180      for (j = 0; j < i; j++) {
181        create_interrupt_gate_descriptor (&currentIdtEntry[j], tbl[j]);
182      }
183      _CPU_ISR_Enable(level);
184}
185     
Note: See TracBrowser for help on using the repository browser.