source: rtems/cpukit/score/cpu/i386/cpu.c @ 9e738b65

4.104.114.84.95
Last change on this file since 9e738b65 was 8044533, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/95 at 19:27:50

merged Linux UNIX simulator support (C)

  • 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 <go32.h>
77#include <dpmi.h>
78#endif /* __GO32__ */
79
80void _CPU_ISR_install_raw_handler(
81  unsigned32  vector,
82  proc_ptr    new_handler,
83  proc_ptr   *old_handler
84)
85{
86#if __GO32__
87    _go32_dpmi_seginfo handler_info;
88 
89    *old_handler =  0;    /* XXX not supported */
90
91    handler_info.pm_offset = (u_long) new_handler;
92    handler_info.pm_selector = _go32_my_cs();
93
94    /* install the IDT entry */
95    _go32_dpmi_set_protected_mode_interrupt_vector( vector, &handler_info );
96#else
97  i386_IDT_slot idt;
98  unsigned32    handler;
99
100  *old_handler =  0;    /* XXX not supported */
101
102  handler = (unsigned32) new_handler;
103
104  /* build the IDT entry */
105  idt.offset_0_15      = handler & 0xffff;
106  idt.segment_selector = i386_get_cs();
107  idt.reserved         = 0x00;
108  idt.p_dpl            = 0x8e;         /* present, ISR */
109  idt.offset_16_31     = handler >> 16;
110
111  /* install the IDT entry */
112  i386_Install_idt(
113    (unsigned32) &idt,
114    _CPU_Table.interrupt_table_segment,
115    (unsigned32) _CPU_Table.interrupt_table_offset + (8 * vector)
116  );
117#endif
118}
119
120/*PAGE
121 *
122 *  _CPU_ISR_install_vector
123 *
124 *  This kernel routine installs the RTEMS handler for the
125 *  specified vector.
126 *
127 *  Input parameters:
128 *    vector      - interrupt vector number
129 *    old_handler - former ISR for this vector number
130 *    new_handler - replacement ISR for this vector number
131 *
132 *  Output parameters:  NONE
133 *
134 */
135
136void _ISR_Handler_0(), _ISR_Handler_1();
137
138#define PER_ISR_ENTRY \
139    (((unsigned32) _ISR_Handler_1 - (unsigned32) _ISR_Handler_0))
140
141#define _Interrupt_Handler_entry( _vector ) \
142   (((unsigned32)_ISR_Handler_0) + ((_vector) * PER_ISR_ENTRY))
143
144void _CPU_ISR_install_vector(
145  unsigned32  vector,
146  proc_ptr    new_handler,
147  proc_ptr   *old_handler
148)
149{
150  proc_ptr      ignored;
151  unsigned32    unique_handler;
152
153  *old_handler = _ISR_Vector_table[ vector ];
154
155  /* calculate the unique entry point for this vector */
156  unique_handler = _Interrupt_Handler_entry( vector );
157
158  _CPU_ISR_install_raw_handler( vector, (void *)unique_handler, &ignored );
159
160  _ISR_Vector_table[ vector ] = new_handler;
161}
Note: See TracBrowser for help on using the repository browser.