source: rtems/cpukit/score/cpu/arm/cpu.c @ 4f5d1c9f

4.104.115
Last change on this file since 4f5d1c9f was 39c8fdb, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 01/12/10 at 15:03:22

add support for lpc32xx

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file
3 *
4 * ARM support code.
5 */
6
7/*
8 *  COPYRIGHT (c) 2000 Canon Research Centre France SA.
9 *  Emmanuel Raguet, mailto:raguet@crf.canon.fr
10 *
11 *  Copyright (c) 2002 Advent Networks, Inc
12 *      Jay Monkman <jmonkman@adventnetworks.com>
13 *
14 *  Copyright (c) 2007 Ray xu <rayx.cn@gmail.com>
15 *
16 *  Copyright (c) 2009 embedded brains GmbH
17 *
18 *  The license and distribution terms for this file may be
19 *  found in the file LICENSE in this distribution or at
20 *  http://www.rtems.com/license/LICENSE.
21 *
22 *  $Id$
23 */
24
25#include <rtems/system.h>
26#include <rtems.h>
27#include <rtems/bspIo.h>
28#include <rtems/score/isr.h>
29#include <rtems/score/wkspace.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/cpu.h>
32
33/*
34 * This variable can be used to change the running mode of the execution
35 * contexts.
36 */
37uint32_t arm_cpu_mode = 0x13;
38
39void _CPU_Context_Initialize(
40  Context_Control *the_context,
41  uint32_t *stack_base,
42  uint32_t size,
43  uint32_t new_level,
44  void *entry_point,
45  bool is_fp
46)
47{
48  the_context->register_sp = (uint32_t) stack_base + size ;
49  the_context->register_lr = (uint32_t) entry_point;
50  the_context->register_cpsr = new_level | arm_cpu_mode;
51}
52
53/* Preprocessor magic for stringification of x */
54#define _CPU_ISR_LEVEL_DO_STRINGOF( x) #x
55#define _CPU_ISR_LEVEL_STRINGOF( x) _CPU_ISR_LEVEL_DO_STRINGOF( x)
56
57void _CPU_ISR_Set_level( uint32_t level )
58{
59  uint32_t arm_switch_reg;
60
61  asm volatile (
62    ARM_SWITCH_TO_ARM
63    "mrs %[arm_switch_reg], cpsr\n"
64    "bic %[arm_switch_reg], #" _CPU_ISR_LEVEL_STRINGOF( CPU_MODES_INTERRUPT_MASK ) "\n"
65    "orr %[arm_switch_reg], %[level]\n"
66    "msr cpsr, %0\n"
67    ARM_SWITCH_BACK
68    : [arm_switch_reg] "=&r" (arm_switch_reg)
69    : [level] "r" (level)
70  );
71}
72
73uint32_t _CPU_ISR_Get_level( void )
74{
75  ARM_SWITCH_REGISTERS;
76  uint32_t level;
77
78  asm volatile (
79    ARM_SWITCH_TO_ARM
80    "mrs %[level], cpsr\n"
81    "and %[level], #" _CPU_ISR_LEVEL_STRINGOF( CPU_MODES_INTERRUPT_MASK ) "\n"
82    ARM_SWITCH_BACK
83    : [level] "=&r" (level) ARM_SWITCH_ADDITIONAL_OUTPUT
84  );
85
86  return level;
87}
88
89void _CPU_ISR_install_vector(
90  uint32_t vector,
91  proc_ptr new_handler,
92  proc_ptr *old_handler
93)
94{
95  /* Redirection table starts at the end of the vector table */
96  volatile uint32_t *table = (volatile uint32_t *) (MAX_EXCEPTIONS * 4);
97
98  uint32_t current_handler = table [vector];
99
100  /* The current handler is now the old one */
101  if (old_handler != NULL) {
102    *old_handler = (proc_ptr) current_handler;
103  }
104
105  /* Write only if necessary to avoid writes to a maybe read-only memory */
106  if (current_handler != (uint32_t) new_handler) {
107    table [vector] = (uint32_t) new_handler;
108  }
109}
110
111void _CPU_Install_interrupt_stack( void )
112{
113  /* This function is empty since the BSP must set up the interrupt stacks */
114}
115
116void _CPU_Initialize( void )
117{
118  /* Do nothing */
119}
Note: See TracBrowser for help on using the repository browser.