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

4.104.115
Last change on this file since 274ee57 was 274ee57, checked in by Joel Sherrill <joel.sherrill@…>, on 11/26/08 at 14:29:56

2008-11-26 Joel Sherrill <joel.sherrill@…>

  • cpu.c, cpu_asm.c: Add debug printk() calls until the BSP/port can initialize and shutdown completely cleanly. When this works, implement context switch. Testing on avrtest and simulavr.
  • Property mode set to 100644
File size: 5.4 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-1999.
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/*
30 *  _CPU_Context_save_fp_context
31 *
32 *  This routine is responsible for saving the FP context
33 *  at *fp_context_ptr.  If the point to load the FP context
34 *  from is changed then the pointer is modified by this routine.
35 *
36 *  Sometimes a macro implementation of this is in cpu.h which dereferences
37 *  the ** and a similarly named routine in this file is passed something
38 *  like a (Context_Control_fp *).  The general rule on making this decision
39 *  is to avoid writing assembly language.
40 *
41 *  NO_CPU Specific Information:
42 *
43 *  XXX document implementation including references if appropriate
44 */
45
46void _CPU_Context_save_fp(
47  Context_Control_fp **fp_context_ptr
48)
49{
50}
51
52/*
53 *  _CPU_Context_restore_fp_context
54 *
55 *  This routine is responsible for restoring the FP context
56 *  at *fp_context_ptr.  If the point to load the FP context
57 *  from is changed then the pointer is modified by this routine.
58 *
59 *  Sometimes a macro implementation of this is in cpu.h which dereferences
60 *  the ** and a similarly named routine in this file is passed something
61 *  like a (Context_Control_fp *).  The general rule on making this decision
62 *  is to avoid writing assembly language.
63 *
64 *  NO_CPU Specific Information:
65 *
66 *  XXX document implementation including references if appropriate
67 */
68
69void _CPU_Context_restore_fp(
70  Context_Control_fp **fp_context_ptr
71)
72{
73}
74
75/*  _CPU_Context_switch
76 *
77 *  This routine performs a normal non-FP context switch.
78 *
79 *  NO_CPU Specific Information:
80 *
81 *  XXX document implementation including references if appropriate
82 */
83
84void _CPU_Context_switch(
85  Context_Control  *run,
86  Context_Control  *heir
87)
88{
89  printk( "AVR _CPU_Context_switch\n" );
90}
91
92/*
93 *  _CPU_Context_restore
94 *
95 *  This routine is generally used only to restart self in an
96 *  efficient manner.  It may simply be a label in _CPU_Context_switch.
97 *
98 *  NOTE: May be unnecessary to reload some registers.
99 *
100 *  NO_CPU Specific Information:
101 *
102 *  XXX document implementation including references if appropriate
103 */
104
105void _CPU_Context_restore(
106  Context_Control *new_context
107)
108{
109  printk( "AVR _CPU_Context_restore\n" );
110}
111
112/*  void __ISR_Handler()
113 *
114 *  This routine provides the RTEMS interrupt management.
115 *
116 *  NO_CPU Specific Information:
117 *
118 *  XXX document implementation including references if appropriate
119 */
120
121void _ISR_Handler()
122{
123   /*
124    *  This discussion ignores a lot of the ugly details in a real
125    *  implementation such as saving enough registers/state to be
126    *  able to do something real.  Keep in mind that the goal is
127    *  to invoke a user's ISR handler which is written in C and
128    *  uses a certain set of registers.
129    *
130    *  Also note that the exact order is to a large extent flexible.
131    *  Hardware will dictate a sequence for a certain subset of
132    *  _ISR_Handler while requirements for setting
133    */
134
135  /*
136   *  At entry to "common" _ISR_Handler, the vector number must be
137   *  available.  On some CPUs the hardware puts either the vector
138   *  number or the offset into the vector table for this ISR in a
139   *  known place.  If the hardware does not give us this information,
140   *  then the assembly portion of RTEMS for this port will contain
141   *  a set of distinct interrupt entry points which somehow place
142   *  the vector number in a known place (which is safe if another
143   *  interrupt nests this one) and branches to _ISR_Handler.
144   *
145   *  save some or all context on stack
146   *  may need to save some special interrupt information for exit
147   *
148   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
149   *    if ( _ISR_Nest_level == 0 )
150   *      switch to software interrupt stack
151   *  #endif
152   *
153   *  _ISR_Nest_level++;
154   *
155   *  _Thread_Dispatch_disable_level++;
156   *
157   *  (*_ISR_Vector_table[ vector ])( vector );
158   *
159   *  _Thread_Dispatch_disable_level--;
160   *
161   *  --_ISR_Nest_level;
162   *
163   *  if ( _ISR_Nest_level )
164   *    goto the label "exit interrupt (simple case)"
165   *
166   *  if ( _Thread_Dispatch_disable_level )
167   *    _ISR_Signals_to_thread_executing = FALSE;
168   *    goto the label "exit interrupt (simple case)"
169   *
170   *  if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) {
171   *    _ISR_Signals_to_thread_executing = FALSE;
172   *    call _Thread_Dispatch() or prepare to return to _ISR_Dispatch
173   *    prepare to get out of interrupt
174   *    return from interrupt  (maybe to _ISR_Dispatch)
175   *
176   *  LABEL "exit interrupt (simple case):
177   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
178   *    if outermost interrupt
179   *      restore stack
180   *  #endif
181   *  prepare to get out of interrupt
182   *  return from interrupt
183   */
184}
Note: See TracBrowser for help on using the repository browser.