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

4.104.115
Last change on this file since 9b974cf4 was 9b974cf4, checked in by Joel Sherrill <joel.sherrill@…>, on 02/13/09 at 14:20:58

2009-02-13 Joel Sherrill <joel.sherrill@…>

  • new-exceptions/cpu.c: Correct prototype of _CPU_Initialize.
  • Property mode set to 100644
File size: 4.7 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: NONE
43 */
44
45void _CPU_Initialize(void)
46{
47  /* Do nothing */
48}
49
50/*PAGE
51 *
52 *  _CPU_Context_Initialize
53 */
54
55void _CPU_Context_Initialize(
56  Context_Control  *the_context,
57  uint32_t         *stack_base,
58  uint32_t          size,
59  uint32_t          new_level,
60  void             *entry_point,
61  bool              is_fp
62)
63{
64  uint32_t   msr_value;
65  uint32_t   sp;
66
67  sp = (uint32_t)stack_base + size - PPC_MINIMUM_STACK_FRAME_SIZE;
68
69  sp &= ~(CPU_STACK_ALIGNMENT-1);
70
71  *((uint32_t*)sp) = 0;
72  the_context->gpr1 = sp;
73
74  _CPU_MSR_GET( msr_value );
75
76  /*
77   * Setting the interrupt mask here is not strictly necessary
78   * since the IRQ level will be established from _Thread_Handler()
79   * again, as soon as the task starts execution.
80   * Because we have to establish a defined state anyways we
81   * can as well leave this code here.
82   * I.e., simply (and unconditionally) saying
83   *
84   *   msr_value &= ~ppc_interrupt_get_disable_mask();
85   *
86   * would be an alternative.
87   */
88
89  if (!(new_level & CPU_MODES_INTERRUPT_MASK)) {
90    msr_value |= ppc_interrupt_get_disable_mask();
91  }
92  else {
93    msr_value &= ~ppc_interrupt_get_disable_mask();
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  /* Make sure integer tasks have no FPU access in order to
108   * catch violations. Gcc may implicitely use the FPU and
109   * data corruption may happen.
110   * Since we set the_contex->msr using our current MSR,
111   * we must make sure MSR_FP is off if (!is_fp)...
112   * Unfortunately, this means that users of vfprintf_r have to use FP
113   * tasks or fix vfprintf. Furthermore, users of int-only tasks
114   * must prevent gcc from using the FPU (currently -msoft-float is the
115   * only way...)
116   */
117  if ( is_fp )
118    the_context->msr |= PPC_MSR_FP;
119  else
120    the_context->msr &= ~PPC_MSR_FP;
121
122  the_context->pc = (uint32_t)entry_point;
123
124#if (PPC_ABI == PPC_ABI_SVR4)
125  /*
126   * SVR4 says R2 is for 'system-reserved' use; it cannot hurt to
127   * propagate R2 to all task contexts.
128   */
129  { uint32_t    r2 = 0;
130    unsigned    r13 = 0;
131    asm volatile ("mr %0,2; mr %1,13" : "=r" ((r2)), "=r" ((r13)));
132
133    the_context->gpr2 = r2;
134    the_context->gpr13 = r13;
135  }
136#elif (PPC_ABI == PPC_ABI_EABI)
137  { uint32_t    r2 = 0;
138    unsigned    r13 = 0;
139    asm volatile ("mr %0,2; mr %1,13" : "=r" ((r2)), "=r" ((r13)));
140
141    the_context->gpr2 = r2;
142    the_context->gpr13 = r13;
143  }
144#else
145#error unsupported PPC_ABI
146#endif
147}
148
149/*PAGE
150 *
151 *  _CPU_Install_interrupt_stack
152 */
153
154void _CPU_Install_interrupt_stack( void )
155{
156}
157
158/*  _CPU_ISR_install_vector
159 *
160 *  This kernel routine installs the RTEMS handler for the
161 *  specified vector.
162 *
163 *  Input parameters:
164 *    vector      - interrupt vector number
165 *    old_handler - former ISR for this vector number
166 *    new_handler - replacement ISR for this vector number
167 *
168 *  Output parameters:  NONE
169 */
170
171void _CPU_ISR_install_vector(
172  uint32_t    vector,
173  proc_ptr    new_handler,
174  proc_ptr   *old_handler
175)
176{
177  BSP_panic("_CPU_ISR_install_vector called\n");
178}
Note: See TracBrowser for help on using the repository browser.