source: rtems/bsps/powerpc/shared/cpu.c @ a72419b

Last change on this file since a72419b was 3fe2155, checked in by Sebastian Huber <sebastian.huber@…>, on 02/01/19 at 09:00:36

Remove superfluous <rtems/system.h> includes

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  PowerPC CPU Dependent Source
3 */
4
5/*
6 *  Author:  Andrew Bray <andy@i-cubed.co.uk>
7 *
8 *  COPYRIGHT (c) 1995 by i-cubed ltd.
9 *
10 *  To anyone who acknowledges that this file is provided "AS IS"
11 *  without any express or implied warranty:
12 *      permission to use, copy, modify, and distribute this file
13 *      for any purpose is hereby granted without fee, provided that
14 *      the above copyright notice and this notice appears in all
15 *      copies, and that the name of i-cubed limited not be used in
16 *      advertising or publicity pertaining to distribution of the
17 *      software without specific, written prior permission.
18 *      i-cubed limited makes no representations about the suitability
19 *      of this software for any purpose.
20 *
21 *  Derived from c/src/exec/cpu/no_cpu/cpu.c:
22 *
23 *  COPYRIGHT (c) 1989-1997.
24 *  On-Line Applications Research Corporation (OAR).
25 *
26 *  The license and distribution terms for this file may be found in
27 *  the file LICENSE in this distribution or at
28 *  http://www.rtems.org/license/LICENSE.
29 */
30
31#include <string.h>
32
33#include <rtems/score/isr.h>
34#include <rtems/score/context.h>
35#include <rtems/score/thread.h>
36#include <rtems/score/interr.h>
37#include <rtems/score/cpu.h>
38#include <rtems/score/tls.h>
39#include <rtems/powerpc/powerpc.h>
40
41/*  _CPU_Initialize
42 *
43 *  This routine performs processor dependent initialization.
44 */
45void _CPU_Initialize(void)
46{
47#if defined(__ALTIVEC__) && !defined(PPC_MULTILIB_ALTIVEC)
48  _CPU_Initialize_altivec();
49#endif
50}
51
52/*
53 *  _CPU_Context_Initialize
54 */
55void _CPU_Context_Initialize(
56  Context_Control  *the_context,
57  void             *stack_base,
58  size_t            size,
59  uint32_t          new_level,
60  void             *entry_point,
61  bool              is_fp,
62  void             *tls_area
63)
64{
65  ppc_context *the_ppc_context;
66  uint32_t   msr_value = 0;
67  uintptr_t  sp;
68  uintptr_t  stack_alignment;
69
70  sp = (uintptr_t) stack_base + size - PPC_MINIMUM_STACK_FRAME_SIZE;
71
72  stack_alignment = CPU_STACK_ALIGNMENT;
73  sp &= ~(stack_alignment - 1);
74
75  sp = (uintptr_t) memset((void *) sp, 0, PPC_MINIMUM_STACK_FRAME_SIZE);
76
77  the_ppc_context = ppc_get_context( the_context );
78
79#if !defined(PPC_DISABLE_MSR_ACCESS)
80  _CPU_MSR_GET( msr_value );
81
82  /*
83   * Setting the interrupt mask here is not strictly necessary
84   * since the IRQ level will be established from _Thread_Handler()
85   * again, as soon as the task starts execution.
86   * Because we have to establish a defined state anyways we
87   * can as well leave this code here.
88   * I.e., simply (and unconditionally) saying
89   *
90   *   msr_value &= ~ppc_interrupt_get_disable_mask();
91   *
92   * would be an alternative.
93   */
94
95  if (!(new_level & CPU_MODES_INTERRUPT_MASK)) {
96    msr_value |= ppc_interrupt_get_disable_mask();
97  }
98  else {
99    msr_value &= ~ppc_interrupt_get_disable_mask();
100  }
101
102#ifdef PPC_MULTILIB_FPU
103  /*
104   *  The FP bit of the MSR should only be enabled if this is a floating
105   *  point task.  Unfortunately, the vfprintf_r routine in newlib
106   *  ends up pushing a floating point register regardless of whether or
107   *  not a floating point number is being printed.  Serious restructuring
108   *  of vfprintf.c will be required to avoid this behavior.  At this
109   *  time (7 July 1997), this restructuring is not being done.
110   */
111  msr_value |= MSR_FP;
112#endif
113
114#ifdef PPC_MULTILIB_ALTIVEC
115  msr_value |= MSR_VE;
116#endif
117#endif  /* END PPC_DISABLE_MSR_ACCESS */
118
119#ifdef PPC_MULTILIB_ALTIVEC
120  the_ppc_context->vrsave = 0;
121#endif
122
123  the_ppc_context->gpr1 = sp;
124  the_ppc_context->msr = msr_value;
125  the_ppc_context->lr = (uintptr_t) entry_point;
126  the_ppc_context->isr_dispatch_disable = 0;
127
128#if defined(__ALTIVEC__) && !defined(PPC_MULTILIB_ALTIVEC)
129  _CPU_Context_initialize_altivec( the_ppc_context );
130#endif
131
132  if ( tls_area != NULL ) {
133    void *tls_block = _TLS_TCB_before_TLS_block_initialize( tls_area );
134
135    the_ppc_context->tp = (uintptr_t) tls_block + 0x7000;
136  }
137}
Note: See TracBrowser for help on using the repository browser.