source: rtems/cpukit/score/cpu/avr/cpu_asm.c @ aaa5c0d

4.104.115
Last change on this file since aaa5c0d was aaa5c0d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/04/09 at 20:34:42

2009-05-04 Joel Sherrill <joel.sherrill@…>

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