source: rtems/cpukit/score/cpu/nios2/nios2-context-initialize.c @ 80cf60e

5
Last change on this file since 80cf60e was 80cf60e, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 15, 2020 at 7:48:32 AM

Canonicalize config.h include

Use the following variant which was already used by most source files:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 * Copyright (c) 2011 embedded brains GmbH
3 *
4 * Copyright (c) 2006 Kolja Waschk (rtemsdev/ixo.de)
5 *
6 * COPYRIGHT (c) 1989-2006
7 * On-Line Applications Research Corporation (OAR).
8 *
9 * The license and distribution terms for this file may be
10 * found in the file LICENSE in this distribution or at
11 * http://www.rtems.org/license/LICENSE.
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <string.h>
19
20#include <rtems/score/cpu.h>
21#include <rtems/score/nios2-utility.h>
22#include <rtems/score/interr.h>
23
24void _CPU_Context_Initialize(
25  Context_Control *context,
26  void *stack_area_begin,
27  size_t stack_area_size,
28  uint32_t new_level,
29  void (*entry_point)( void ),
30  bool is_fp,
31  void *tls_area
32)
33{
34  const Nios2_MPU_Configuration *mpu_config = _Nios2_MPU_Get_configuration();
35  uint32_t stack = (uint32_t) stack_area_begin + stack_area_size - 4;
36
37  memset(context, 0, sizeof(*context));
38
39  context->fp = stack;
40  context->status = _Nios2_ISR_Set_level( new_level, NIOS2_STATUS_PIE );
41  context->sp = stack;
42  context->ra = (uint32_t) entry_point;
43
44  if ( mpu_config != NULL ) {
45    Nios2_MPU_Region_descriptor desc = {
46      .index = mpu_config->data_index_for_stack_protection,
47      /* FIXME: Brocken stack allocator */
48      .base = (void *) ((int) stack_area_begin & ~((1 << mpu_config->data_region_size_log2) - 1)),
49      .end = (char *) stack_area_begin + stack_area_size,
50      .perm = NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE,
51      .data = true,
52      .cacheable = mpu_config->enable_data_cache_for_stack,
53      .read = false,
54      .write = true
55    };
56    bool ok = _Nios2_MPU_Setup_region_registers(
57      mpu_config,
58      &desc,
59      &context->stack_mpubase,
60      &context->stack_mpuacc
61    );
62
63    if ( !ok ) {
64      /* The task stack allocator must ensure that the stack area is valid */
65      _Terminate( INTERNAL_ERROR_CORE, 0xdeadbeef );
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.