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

4.104.114.95
Last change on this file since 3d28361d was 25a92bc1, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/11/08 at 10:02:12

adapted powerpc exception code

  • Property mode set to 100644
File size: 4.1 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 *    thread_dispatch - address of disptaching routine
44 */
45
46void _CPU_Initialize(
47  void      (*thread_dispatch)      /* ignored on this CPU */
48)
49{
50  /* Do nothing */
51}
52
53/*PAGE
54 *
55 *  _CPU_Context_Initialize
56 */
57
58void _CPU_Context_Initialize(
59  Context_Control  *the_context,
60  uint32_t         *stack_base,
61  uint32_t          size,
62  uint32_t          new_level,
63  void             *entry_point,
64  boolean           is_fp
65)
66{
67  uint32_t   msr_value;
68  uint32_t   sp;
69
70  sp = (uint32_t)stack_base + size - PPC_MINIMUM_STACK_FRAME_SIZE;
71
72  sp &= ~(CPU_STACK_ALIGNMENT-1);
73
74  *((uint32_t*)sp) = 0;
75  the_context->gpr1 = sp;
76
77  _CPU_MSR_GET( msr_value );
78
79  if (!(new_level & CPU_MODES_INTERRUPT_MASK)) {
80    msr_value |= MSR_EE;
81  }
82  else {
83    msr_value &= ~MSR_EE;
84  }
85
86  the_context->msr = msr_value;
87
88  /*
89   *  The FP bit of the MSR should only be enabled if this is a floating
90   *  point task.  Unfortunately, the vfprintf_r routine in newlib
91   *  ends up pushing a floating point register regardless of whether or
92   *  not a floating point number is being printed.  Serious restructuring
93   *  of vfprintf.c will be required to avoid this behavior.  At this
94   *  time (7 July 1997), this restructuring is not being done.
95   */
96
97  /* Make sure integer tasks have no FPU access in order to
98   * catch violations. Gcc may implicitely use the FPU and
99   * data corruption may happen.
100   * Since we set the_contex->msr using our current MSR,
101   * we must make sure MSR_FP is off if (!is_fp)...
102   * Unfortunately, this means that users of vfprintf_r have to use FP
103   * tasks or fix vfprintf. Furthermore, users of int-only tasks
104   * must prevent gcc from using the FPU (currently -msoft-float is the
105   * only way...)
106   */
107  if ( is_fp )
108    the_context->msr |= PPC_MSR_FP;
109  else
110    the_context->msr &= ~PPC_MSR_FP;
111
112  the_context->pc = (uint32_t)entry_point;
113
114#if (PPC_ABI == PPC_ABI_SVR4)
115  { unsigned    r13 = 0;
116    asm volatile ("mr %0, 13" : "=r" ((r13)));
117
118    the_context->gpr13 = r13;
119  }
120#elif (PPC_ABI == PPC_ABI_EABI)
121  { uint32_t    r2 = 0;
122    unsigned    r13 = 0;
123    asm volatile ("mr %0,2; mr %1,13" : "=r" ((r2)), "=r" ((r13)));
124
125    the_context->gpr2 = r2;
126    the_context->gpr13 = r13;
127  }
128#else
129#error unsupported PPC_ABI
130#endif
131}
132
133/*PAGE
134 *
135 *  _CPU_Install_interrupt_stack
136 */
137
138void _CPU_Install_interrupt_stack( void )
139{
140}
141
142/*  _CPU_ISR_install_vector
143 *
144 *  This kernel routine installs the RTEMS handler for the
145 *  specified vector.
146 *
147 *  Input parameters:
148 *    vector      - interrupt vector number
149 *    old_handler - former ISR for this vector number
150 *    new_handler - replacement ISR for this vector number
151 *
152 *  Output parameters:  NONE
153 */
154
155void _CPU_ISR_install_vector(
156  uint32_t    vector,
157  proc_ptr    new_handler,
158  proc_ptr   *old_handler
159)
160{
161  BSP_panic("_CPU_ISR_install_vector called\n");
162}
Note: See TracBrowser for help on using the repository browser.