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

4.11
Last change on this file since b31a960 was b31a960, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 13, 2012 at 4:53:43 PM

score: Add INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR

Use INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR on PowerPC for
_CPU_ISR_install_vector().

  • Property mode set to 100644
File size: 3.8 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
29#include <string.h>
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/score/cpu.h>
37#include <rtems/powerpc/powerpc.h>
38
39/*  _CPU_Initialize
40 *
41 *  This routine performs processor dependent initialization.
42 *
43 *  INPUT PARAMETERS: NONE
44 */
45
46void _CPU_Initialize(void)
47{
48  /* Do nothing */
49#ifdef __ALTIVEC__
50  _CPU_Initialize_altivec();
51#endif
52}
53
54/*PAGE
55 *
56 *  _CPU_Context_Initialize
57 */
58
59void _CPU_Context_Initialize(
60  Context_Control  *the_context,
61  uint32_t         *stack_base,
62  uint32_t          size,
63  uint32_t          new_level,
64  void             *entry_point,
65  bool              is_fp
66)
67{
68  ppc_context *the_ppc_context;
69  uint32_t   msr_value;
70  uint32_t   sp;
71
72  sp = (uint32_t)stack_base + size - PPC_MINIMUM_STACK_FRAME_SIZE;
73
74  sp &= ~(CPU_STACK_ALIGNMENT-1);
75
76  *((uint32_t*)sp) = 0;
77
78  _CPU_MSR_GET( msr_value );
79
80  /*
81   * Setting the interrupt mask here is not strictly necessary
82   * since the IRQ level will be established from _Thread_Handler()
83   * again, as soon as the task starts execution.
84   * Because we have to establish a defined state anyways we
85   * can as well leave this code here.
86   * I.e., simply (and unconditionally) saying
87   *
88   *   msr_value &= ~ppc_interrupt_get_disable_mask();
89   *
90   * would be an alternative.
91   */
92
93  if (!(new_level & CPU_MODES_INTERRUPT_MASK)) {
94    msr_value |= ppc_interrupt_get_disable_mask();
95  }
96  else {
97    msr_value &= ~ppc_interrupt_get_disable_mask();
98  }
99
100  /*
101   *  The FP bit of the MSR should only be enabled if this is a floating
102   *  point task.  Unfortunately, the vfprintf_r routine in newlib
103   *  ends up pushing a floating point register regardless of whether or
104   *  not a floating point number is being printed.  Serious restructuring
105   *  of vfprintf.c will be required to avoid this behavior.  At this
106   *  time (7 July 1997), this restructuring is not being done.
107   */
108
109  /* Make sure integer tasks have no FPU access in order to
110   * catch violations. Gcc may implicitely use the FPU and
111   * data corruption may happen.
112   * Since we set the_contex->msr using our current MSR,
113   * we must make sure MSR_FP is off if (!is_fp)...
114   * Unfortunately, this means that users of vfprintf_r have to use FP
115   * tasks or fix vfprintf. Furthermore, users of int-only tasks
116   * must prevent gcc from using the FPU (currently -msoft-float is the
117   * only way...)
118   */
119  if ( is_fp )
120    msr_value |= PPC_MSR_FP;
121  else
122    msr_value &= ~PPC_MSR_FP;
123
124  memset( the_context, 0, sizeof( *the_context ) );
125
126  the_ppc_context = ppc_get_context( the_context );
127  the_ppc_context->gpr1 = sp;
128  the_ppc_context->msr = msr_value;
129  the_ppc_context->lr = (uint32_t) entry_point;
130
131#ifdef __ALTIVEC__
132  _CPU_Context_initialize_altivec(the_context);
133#endif
134}
Note: See TracBrowser for help on using the repository browser.