source: rtems/cpukit/score/cpu/i386/cpu.c @ 637df35

4.104.114.84.95
Last change on this file since 637df35 was 637df35, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 12, 1995 at 7:47:25 PM

Ada95, gnat, go32

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  Intel i386 Dependent Source
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/fatal.h>
18#include <rtems/isr.h>
19#include <rtems/wkspace.h>
20
21/*  _CPU_Initialize
22 *
23 *  This routine performs processor dependent initialization.
24 *
25 *  INPUT PARAMETERS:
26 *    cpu_table       - CPU table to initialize
27 *    thread_dispatch - address of disptaching routine
28 */
29
30
31void _CPU_Initialize(
32  rtems_cpu_table  *cpu_table,
33  void      (*thread_dispatch)      /* ignored on this CPU */
34)
35{
36  register unsigned16  fp_status asm ("ax");
37  register unsigned8  *fp_context;
38
39  if ( cpu_table == NULL )
40    rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED );
41
42  _CPU_Table = *cpu_table;
43
44  /*
45   *  The following code saves a NULL i387 context which is given
46   *  to each task at start and restart time.  The following code
47   *  is based upon that provided in the i386 Programmer's
48   *  Manual and should work on any coprocessor greater than
49   *  the i80287.
50   *
51   *  NOTE: The NO RTEMS_WAIT form of the coprocessor instructions
52   *        MUST be used in case there is not a coprocessor
53   *        to wait for.
54   */
55
56  fp_status = 0xa5a5;
57  asm volatile( "fninit" );
58  asm volatile( "fnstsw %0" : "=a" (fp_status) : "0" (fp_status) );
59
60  if ( fp_status ==  0 ) {
61
62    fp_context = _CPU_Null_fp_context;
63
64    asm volatile( "fsave (%0)" : "=r" (fp_context)
65                               : "0"  (fp_context)
66                );
67  }
68}
69
70/*PAGE
71 *
72 *  _CPU_ISR_install_raw_handler
73 */
74 
75#if __GO32__
76#include <cpu.h>
77#include <go32.h>
78#include <dpmi.h>
79#endif /* __GO32__ */
80
81void _CPU_ISR_install_raw_handler(
82  unsigned32  vector,
83  proc_ptr    new_handler,
84  proc_ptr   *old_handler
85)
86{
87#if __GO32__
88    _go32_dpmi_seginfo handler_info;
89 
90    *old_handler =  0;    /* XXX not supported */
91
92    handler_info.pm_offset = new_handler;
93    handler_info.pm_selector = _go32_my_cs();
94
95    /* install the IDT entry */
96    _go32_dpmi_set_protected_mode_interrupt_vector( vector, &handler_info );
97#else
98  i386_IDT_slot idt;
99  unsigned32    handler;
100
101  *old_handler =  0;    /* XXX not supported */
102
103  handler = (unsigned32) new_handler;
104
105  /* build the IDT entry */
106  idt.offset_0_15      = handler & 0xffff;
107  idt.segment_selector = i386_get_cs();
108  idt.reserved         = 0x00;
109  idt.p_dpl            = 0x8e;         /* present, ISR */
110  idt.offset_16_31     = handler >> 16;
111
112  /* install the IDT entry */
113  i386_Install_idt(
114    (unsigned32) &idt,
115    _CPU_Table.interrupt_table_segment,
116    (unsigned32) _CPU_Table.interrupt_table_offset + (8 * vector)
117  );
118#endif
119}
120
121/*PAGE
122 *
123 *  _CPU_ISR_install_vector
124 *
125 *  This kernel routine installs the RTEMS handler for the
126 *  specified vector.
127 *
128 *  Input parameters:
129 *    vector      - interrupt vector number
130 *    old_handler - former ISR for this vector number
131 *    new_handler - replacement ISR for this vector number
132 *
133 *  Output parameters:  NONE
134 *
135 */
136
137void _ISR_Handler_0(), _ISR_Handler_1();
138
139#define PER_ISR_ENTRY \
140    (((unsigned32) _ISR_Handler_1 - (unsigned32) _ISR_Handler_0))
141
142#define _Interrupt_Handler_entry( _vector ) \
143   (((unsigned32)_ISR_Handler_0) + ((_vector) * PER_ISR_ENTRY))
144
145void _CPU_ISR_install_vector(
146  unsigned32  vector,
147  proc_ptr    new_handler,
148  proc_ptr   *old_handler
149)
150{
151  proc_ptr      ignored;
152  unsigned32    unique_handler;
153
154  *old_handler = _ISR_Vector_table[ vector ];
155
156  /* calculate the unique entry point for this vector */
157  unique_handler = _Interrupt_Handler_entry( vector );
158
159  _CPU_ISR_install_raw_handler( vector, (void *)unique_handler, &ignored );
160
161  _ISR_Vector_table[ vector ] = new_handler;
162}
Note: See TracBrowser for help on using the repository browser.