source: rtems/tools/schedsim/rtems/sched_cpu/cpu_asm.c @ 4bc2c988

4.115
Last change on this file since 4bc2c988 was 4bc2c988, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/10 at 14:51:56

2010-12-17 Joel Sherrill <joel.sherrill@…>

Jennifer Averett <jennifer.averett@…>

Add RTEMS Scheduler Simulator. This is the RTEMS "port" to and
adapter code to run on GNU/Linux with a fake context switch.

  • ChangeLog?, Makefile.am, interr.c, rtems_init.c, rtems_sched.h, wkspace.c, sched_cpu/cpu.c, sched_cpu/cpu_asm.c, sched_cpu/rtems/asm.h, sched_cpu/rtems/stringto.h, sched_cpu/rtems/score/cpu.h, sched_cpu/rtems/score/cpu_asm.h, sched_cpu/rtems/score/cpuopts.h, sched_cpu/rtems/score/no_cpu.h, sched_cpu/rtems/score/types.h: New files.
  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*  cpu_asm.c  ===> cpu_asm.S or cpu_asm.s
2 *  BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR
3 *
4 *
5 *  This file contains the basic algorithms for all assembly code used
6 *  in an specific CPU port of RTEMS.  These algorithms must be implemented
7 *  in assembly language
8 *
9 *  NOTE:  This is supposed to be a .S or .s file NOT a C file.
10 *
11 *  COPYRIGHT (c) 1989-2010.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21/*
22 *  This is supposed to be an assembly file.  This means that system.h
23 *  and cpu.h should not be included in a "real" cpu_asm file.  An
24 *  implementation in assembly should include "cpu_asm.h>
25 */
26
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
31#include <rtems/system.h>
32#include <rtems/score/cpu.h>
33/* #include "cpu_asm.h> */
34
35/*
36 *  _CPU_Context_save_fp_context
37 *
38 *  This routine is responsible for saving the FP context
39 *  at *fp_context_ptr.  If the point to load the FP context
40 *  from is changed then the pointer is modified by this routine.
41 *
42 *  Sometimes a macro implementation of this is in cpu.h which dereferences
43 *  the ** and a similarly named routine in this file is passed something
44 *  like a (Context_Control_fp *).  The general rule on making this decision
45 *  is to avoid writing assembly language.
46 *
47 *  NO_CPU Specific Information:
48 *
49 *  XXX document implementation including references if appropriate
50 */
51
52void _CPU_Context_save_fp(
53  Context_Control_fp **fp_context_ptr
54)
55{
56}
57
58/*
59 *  _CPU_Context_restore_fp_context
60 *
61 *  This routine is responsible for restoring the FP context
62 *  at *fp_context_ptr.  If the point to load the FP context
63 *  from is changed then the pointer is modified by this routine.
64 *
65 *  Sometimes a macro implementation of this is in cpu.h which dereferences
66 *  the ** and a similarly named routine in this file is passed something
67 *  like a (Context_Control_fp *).  The general rule on making this decision
68 *  is to avoid writing assembly language.
69 *
70 *  NO_CPU Specific Information:
71 *
72 *  XXX document implementation including references if appropriate
73 */
74
75void _CPU_Context_restore_fp(
76  Context_Control_fp **fp_context_ptr
77)
78{
79}
80
81/*  _CPU_Context_switch
82 *
83 *  This routine performs a normal non-FP context switch.
84 *
85 *  NO_CPU Specific Information:
86 *
87 *  XXX document implementation including references if appropriate
88 */
89
90void _CPU_Context_switch(
91  Context_Control  *run,
92  Context_Control  *heir
93)
94{
95}
96
97/*
98 *  _CPU_Context_restore
99 *
100 *  This routine is generally used only to restart self in an
101 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
102 *
103 *  NOTE: May be unnecessary to reload some registers.
104 *
105 *  NO_CPU Specific Information:
106 *
107 *  XXX document implementation including references if appropriate
108 */
109
110void _CPU_Context_restore(
111  Context_Control *new_context
112)
113{
114}
115
116/*  void __ISR_Handler()
117 *
118 *  This routine provides the RTEMS interrupt management.
119 *
120 *  NO_CPU Specific Information:
121 *
122 *  XXX document implementation including references if appropriate
123 */
124
125void _ISR_Handler(void)
126{
127   /*
128    *  This discussion ignores a lot of the ugly details in a real
129    *  implementation such as saving enough registers/state to be
130    *  able to do something real.  Keep in mind that the goal is
131    *  to invoke a user's ISR handler which is written in C and
132    *  uses a certain set of registers.
133    *
134    *  Also note that the exact order is to a large extent flexible.
135    *  Hardware will dictate a sequence for a certain subset of
136    *  _ISR_Handler while requirements for setting
137    */
138
139  /*
140   *  At entry to "common" _ISR_Handler, the vector number must be
141   *  available.  On some CPUs the hardware puts either the vector
142   *  number or the offset into the vector table for this ISR in a
143   *  known place.  If the hardware does not give us this information,
144   *  then the assembly portion of RTEMS for this port will contain
145   *  a set of distinct interrupt entry points which somehow place
146   *  the vector number in a known place (which is safe if another
147   *  interrupt nests this one) and branches to _ISR_Handler.
148   *
149   *  save some or all context on stack
150   *  may need to save some special interrupt information for exit
151   *
152   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
153   *    if ( _ISR_Nest_level == 0 )
154   *      switch to software interrupt stack
155   *  #endif
156   *
157   *  _ISR_Nest_level++;
158   *
159   *  _Thread_Dispatch_disable_level++;
160   *
161   *  (*_ISR_Vector_table[ vector ])( vector );
162   *
163   *  _Thread_Dispatch_disable_level--;
164   *
165   *  --_ISR_Nest_level;
166   *
167   *  if ( _ISR_Nest_level )
168   *    goto the label "exit interrupt (simple case)"
169   *
170   *  if ( _Thread_Dispatch_disable_level )
171   *    _ISR_Signals_to_thread_executing = FALSE;
172   *    goto the label "exit interrupt (simple case)"
173   *
174   *  if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) {
175   *    _ISR_Signals_to_thread_executing = FALSE;
176   *    call _Thread_Dispatch() or prepare to return to _ISR_Dispatch
177   *    prepare to get out of interrupt
178   *    return from interrupt  (maybe to _ISR_Dispatch)
179   *
180   *  LABEL "exit interrupt (simple case):
181   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
182   *    if outermost interrupt
183   *      restore stack
184   *  #endif
185   *  prepare to get out of interrupt
186   *  return from interrupt
187   */
188}
Note: See TracBrowser for help on using the repository browser.