source: rtems/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c @ d3d9ef37

4.104.114.84.95
Last change on this file since d3d9ef37 was cc043dc, checked in by Ralf Corsepius <ralf.corsepius@…>, on Feb 17, 2005 at 4:23:18 AM

2005-02-17 Ralf Corsepius <ralf.corsepius@…>

  • new-exceptions/cpu.c, rtems/powerpc/powerpc.h: Remove CPU_MINIMUM_STACK_FRAME_SIZE. Use PPC_MINIMUM_STACK_FRAME_SIZE instead.
  • rtems/powerpc/powerpc.h: Add PPC_MINIMUM_STACK_FRAME_SIZE.
  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 *  PowerPC CPU Dependent Source
3 *
4 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
5 *
6 *  COPYRIGHT (c) 1995 by i-cubed ltd.
7 *
8 *  To anyone who acknowledges that this file is provided "AS IS"
9 *  without any express or implied warranty:
10 *      permission to use, copy, modify, and distribute this file
11 *      for any purpose is hereby granted without fee, provided that
12 *      the above copyright notice and this notice appears in all
13 *      copies, and that the name of i-cubed limited not be used in
14 *      advertising or publicity pertaining to distribution of the
15 *      software without specific, written prior permission.
16 *      i-cubed limited makes no representations about the suitability
17 *      of this software for any purpose.
18 *
19 *  Derived from c/src/exec/cpu/no_cpu/cpu.c:
20 *
21 *  COPYRIGHT (c) 1989-1997.
22 *  On-Line Applications Research Corporation (OAR).
23 *
24 *  The license and distribution terms for this file may be found in
25 *  the file LICENSE in this distribution or at
26 *  http://www.rtems.com/license/LICENSE.
27 *
28 *  $Id$
29 */
30
31#include <rtems/system.h>
32#include <rtems/score/isr.h>
33#include <rtems/score/context.h>
34#include <rtems/score/thread.h>
35#include <rtems/score/interr.h>
36#include <rtems/powerpc/powerpc.h>
37
38/*  _CPU_Initialize
39 *
40 *  This routine performs processor dependent initialization.
41 *
42 *  INPUT PARAMETERS:
43 *    cpu_table       - CPU table to initialize
44 *    thread_dispatch - address of disptaching routine
45 */
46
47void _CPU_Initialize(
48  rtems_cpu_table  *cpu_table,
49  void      (*thread_dispatch)      /* ignored on this CPU */
50)
51{
52  _CPU_Table = *cpu_table;
53
54  { unsigned hasFixed = 0;
55  /* assert that our BSP has fixed PR288 */
56  __asm__ __volatile__ ("mfspr %0, %2":"=r"(hasFixed):"0"(hasFixed),"i"(SPRG0));
57  if ( PPC_BSP_HAS_FIXED_PR288 != hasFixed ) {
58    BSP_panic("This BSP needs to fix PR#288");
59  }
60  }
61}
62
63/*PAGE
64 *
65 *  _CPU_Context_Initialize
66 */
67
68void _CPU_Context_Initialize(
69  Context_Control  *the_context,
70  uint32_t         *stack_base,
71  uint32_t          size,
72  uint32_t          new_level,
73  void             *entry_point,
74  boolean           is_fp
75)
76{
77  uint32_t   msr_value;
78  uint32_t   sp;
79
80  sp = (uint32_t)stack_base + size - PPC_MINIMUM_STACK_FRAME_SIZE;
81
82  sp &= ~(CPU_STACK_ALIGNMENT-1);
83
84  *((uint32_t*)sp) = 0;
85  the_context->gpr1 = sp;
86
87  _CPU_MSR_GET( msr_value );
88
89  if (!(new_level & CPU_MODES_INTERRUPT_MASK)) {
90    msr_value |= MSR_EE;
91  }
92  else {
93    msr_value &= ~MSR_EE;
94  }
95
96  the_context->msr = msr_value;
97
98  /*
99   *  The FP bit of the MSR should only be enabled if this is a floating
100   *  point task.  Unfortunately, the vfprintf_r routine in newlib
101   *  ends up pushing a floating point register regardless of whether or
102   *  not a floating point number is being printed.  Serious restructuring
103   *  of vfprintf.c will be required to avoid this behavior.  At this
104   *  time (7 July 1997), this restructuring is not being done.
105   */
106
107  /* Till Straumann: For deferred FPContext save/restore, make sure integer
108   *                 tasks have no FPU access in order to catch violations.
109   *                 Otherwise, the FP registers may be corrupted.
110   *                             Since we set the_contex->msr using our current MSR,
111   *                             we must make sure MSR_FP is off if (!is_fp)...
112   */
113#if defined(CPU_USE_DEFERRED_FP_SWITCH) && (CPU_USE_DEFERRED_FP_SWITCH==TRUE)
114  if ( is_fp )
115#endif
116    the_context->msr |= PPC_MSR_FP;
117#if defined(CPU_USE_DEFERRED_FP_SWITCH) && (CPU_USE_DEFERRED_FP_SWITCH==TRUE)
118  else
119        the_context->msr &= ~PPC_MSR_FP;
120#endif
121
122  the_context->pc = (uint32_t)entry_point;
123
124#if (PPC_ABI == PPC_ABI_SVR4)
125  { unsigned    r13 = 0;
126    asm volatile ("mr %0, 13" : "=r" ((r13)));
127
128    the_context->gpr13 = r13;
129  }
130#elif (PPC_ABI == PPC_ABI_EABI)
131  { uint32_t    r2 = 0;
132    unsigned    r13 = 0;
133    asm volatile ("mr %0,2; mr %1,13" : "=r" ((r2)), "=r" ((r13)));
134
135    the_context->gpr2 = r2;
136    the_context->gpr13 = r13;
137  }
138#else
139#error unsupported PPC_ABI
140#endif
141}
142
143/*PAGE
144 *
145 *  _CPU_Install_interrupt_stack
146 */
147
148void _CPU_Install_interrupt_stack( void )
149{
150}
151
152/*  _CPU_ISR_install_vector
153 *
154 *  This kernel routine installs the RTEMS handler for the
155 *  specified vector.
156 *
157 *  Input parameters:
158 *    vector      - interrupt vector number
159 *    old_handler - former ISR for this vector number
160 *    new_handler - replacement ISR for this vector number
161 *
162 *  Output parameters:  NONE
163 */
164
165void _CPU_ISR_install_vector(
166  uint32_t    vector,
167  proc_ptr    new_handler,
168  proc_ptr   *old_handler
169) 
170{
171  BSP_panic("_CPU_ISR_install_vector called\n");
172}
Note: See TracBrowser for help on using the repository browser.