source: rtems/cpukit/score/cpu/v850/cpu.c

Last change on this file was c0ec0b29, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:51:18

score/cpu/v850: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @brief v850 CPU Initialize
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2012.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 *    notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 *    notice, this list of conditions and the following disclaimer in the
20 *    documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifdef HAVE_CONFIG_H
36#include "config.h"
37#endif
38
39#include <rtems/score/cpuimpl.h>
40#include <rtems/score/isr.h>
41
42#include <string.h> /* for memset */
43
44/*
45 *  v850 Specific Information:
46 *
47 *  So far nothing known to be needed at this point during initialization.
48 */
49void _CPU_Initialize(void)
50{
51}
52
53void _CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error )
54{
55  __asm__ __volatile__ ( "di" );
56  __asm__ __volatile__ ( "mov %0, r10; " : "=r" ((error)) );
57  __asm__ __volatile__ ( "halt" );
58}
59
60/*
61 *  v850 Specific Information:
62 *
63 *  This method returns 0 if interrupts are enabled and 1 if they are disabled.
64 *  The v850 only has two interrupt levels (on and off).
65 */
66uint32_t _CPU_ISR_Get_level( void )
67{
68  unsigned int psw;
69
70  v850_get_psw( psw );
71
72  if ( (psw & V850_PSW_INTERRUPT_DISABLE_MASK) == V850_PSW_INTERRUPT_DISABLE )
73    return 1;
74
75  return 0;
76}
77
78/*
79 *  v850 Specific Information:
80 *
81 *  This method initializes a v850 context control structure.
82 */
83void _CPU_Context_Initialize(
84  Context_Control  *the_context,
85  uint32_t         *stack_base,
86  uint32_t          size,
87  uint32_t          new_level,
88  void             *entry_point,
89  bool              is_fp,
90  void             *tls_area
91)
92{
93  uint32_t  stack_high;  /* highest "stack aligned" address */
94  uint32_t  psw;         /* highest "stack aligned" address */
95
96  memset( the_context, 0, sizeof(Context_Control) );
97
98  /*
99   *  On CPUs with stacks which grow down, we build the stack
100   *  based on the stack_high address.
101   */
102  stack_high = ((uint32_t)(stack_base) + size);
103  stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
104
105  v850_get_psw( psw );
106  psw &= ~V850_PSW_INTERRUPT_DISABLE_MASK;
107  if ( new_level )
108    psw |= V850_PSW_INTERRUPT_DISABLE;
109  else
110    psw |= V850_PSW_INTERRUPT_ENABLE;
111
112  the_context->r31              = (uint32_t) entry_point;
113  the_context->r3_stack_pointer = stack_high;
114  the_context->psw              = psw;
115
116#if 0
117  printk( "the_context = %p\n",      the_context );
118  printk( "stack base  = 0x%08x\n",  stack_base );
119  printk( "stack size  = 0x%08x\n",  size );
120  printk( "sp          = 0x%08x\n",  the_context->r3_stack_pointer );
121  printk( "psw         = 0x%08x\n",  the_context->psw );
122#endif
123}
124
Note: See TracBrowser for help on using the repository browser.