source: rtems/cpukit/score/cpu/or1k/cpu.c @ 700f97e

4.115
Last change on this file since 700f97e was 94d45f6, checked in by Hesham ALMatary <heshamelmatary@…>, on 08/12/14 at 15:57:42

Add support for OpenRISC - Fixed issues

This work is based on the old or32 port (that has been
removed back in 2005) authored by Chris Ziomkowski. The patch includes the
basic functions every port should implement like: context switch, exception
handling, OpenRISC ABI and machine definitions and configurations.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  Opencore OR1K CPU Dependent Source
3 *
4 *  COPYRIGHT (c) 2014 Hesham ALMatary <heshamelmatary@gmail.com>
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 */
13
14#include <rtems/system.h>
15#include <rtems/score/isr.h>
16#include <rtems/score/wkspace.h>
17#include <bsp/linker-symbols.h>
18#include <rtems/score/cpu.h>
19
20/**
21 * @brief Performs processor dependent initialization.
22 */
23void _CPU_Initialize(void)
24{
25  /* Do nothing */
26}
27
28/**
29 * @brief Sets the hardware interrupt level by the level value.
30 *
31 * @param[in] level for or1k can only range over two values:
32 * 0 (enable interrupts) and 1 (disable interrupts). In future
33 * implementations if fast context switch is implemented, the level
34 * can range from 0 to 15. @see OpenRISC architecture manual.
35 *
36 */
37void _CPU_ISR_Set_level(uint32_t level)
38{
39  uint32_t sr = 0;
40  level = (level > 0)? 1 : 0;
41
42  /* map level bit to or1k interrupt enable/disable bit in sr register */
43  level <<= CPU_OR1K_SPR_SR_SHAMT_IEE;
44
45  sr = _OR1K_mfspr(CPU_OR1K_SPR_SR);
46
47  if (level == 0){ /* Enable all interrupts */
48    sr |= CPU_OR1K_SPR_SR_IEE | CPU_OR1K_SPR_SR_TEE;
49
50  } else{
51    sr &= ~CPU_OR1K_SPR_SR_IEE;
52  }
53
54  _OR1K_mtspr(CPU_OR1K_SPR_SR, sr);
55 }
56
57uint32_t  _CPU_ISR_Get_level( void )
58{
59  uint32_t sr = 0;
60
61  sr = _OR1K_mfspr(CPU_OR1K_SPR_SR);
62
63  return (sr & CPU_OR1K_SPR_SR_IEE)? 0 : 1;
64}
65
66void _CPU_ISR_install_raw_handler(
67  uint32_t   vector,
68  proc_ptr    new_handler,
69  proc_ptr   *old_handler
70)
71{
72}
73
74void _CPU_ISR_install_vector(
75  uint32_t    vector,
76  proc_ptr    new_handler,
77  proc_ptr   *old_handler
78)
79{
80   proc_ptr *table =
81     (proc_ptr *) bsp_start_vector_table_begin;
82   proc_ptr current_handler;
83
84   ISR_Level level;
85
86  _ISR_Disable( level );
87
88  current_handler = table [vector];
89
90  /* The current handler is now the old one */
91  if (old_handler != NULL) {
92    *old_handler = (proc_ptr) current_handler;
93  }
94
95  /* Write only if necessary to avoid writes to a maybe read-only memory */
96  if (current_handler != new_handler) {
97    table [vector] = new_handler;
98  }
99
100   _ISR_Enable( level );
101}
102
103void _CPU_Install_interrupt_stack( void )
104{
105}
106
107void _CPU_Thread_Idle_body( void )
108{
109  do {
110     _OR1K_CPU_Sleep();
111  } while (1);
112}
Note: See TracBrowser for help on using the repository browser.