source: rtems/cpukit/score/cpu/arm/armv7m-isr-dispatch.c @ 8ae37323

4.115
Last change on this file since 8ae37323 was 8ae37323, checked in by Sebastian Huber <sebastian.huber@…>, on 08/10/14 at 16:36:30

arm: Add support for FPv4-SP floating point unit

This floating point unit is available in Cortex-M4 processors and
defined by ARMv7-M. This adds basic support for other VFP-D16 variants.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief ARMV7M ISR Dispatch
5 */
6
7/*
8 * Copyright (c) 2011-2014 Sebastian Huber.  All rights reserved.
9 *
10 *  embedded brains GmbH
11 *  Obere Lagerstr. 30
12 *  82178 Puchheim
13 *  Germany
14 *  <rtems@embedded-brains.de>
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#ifdef HAVE_CONFIG_H
22  #include "config.h"
23#endif
24
25#include <rtems/score/armv7m.h>
26#include <rtems/score/percpu.h>
27
28#ifdef ARM_MULTILIB_ARCH_V7M
29
30static void __attribute__((naked)) _ARMV7M_Thread_dispatch( void )
31{
32  __asm__ volatile (
33    "bl _Thread_Dispatch\n"
34    /* FIXME: SVC, binutils bug */
35    ".short 0xdf00\n"
36    "nop\n"
37  );
38}
39
40static void _ARMV7M_Trigger_lazy_floating_point_context_save( void )
41{
42#ifdef ARM_MULTILIB_VFP
43  __asm__ volatile (
44    "vmov.f32 s0, s0\n"
45  );
46#endif
47}
48
49void _ARMV7M_Pendable_service_call( void )
50{
51  ARMV7M_Exception_frame *ef;
52
53  _ISR_Nest_level = 1;
54
55  _ARMV7M_SCB->icsr = ARMV7M_SCB_ICSR_PENDSVCLR;
56  _ARMV7M_Trigger_lazy_floating_point_context_save();
57
58  ef = (ARMV7M_Exception_frame *) _ARMV7M_Get_PSP();
59  --ef;
60  _ARMV7M_Set_PSP( (uint32_t) ef );
61
62  /*
63   * According to "ARMv7-M Architecture Reference Manual" section B1.5.6
64   * "Exception entry behavior" the return address is half-word aligned.
65   */
66  ef->register_pc = (void *)
67    ((uintptr_t) _ARMV7M_Thread_dispatch & ~((uintptr_t) 1));
68
69  ef->register_xpsr = 0x01000000U;
70}
71
72void _ARMV7M_Supervisor_call( void )
73{
74  ARMV7M_Exception_frame *ef;
75
76  _ARMV7M_Trigger_lazy_floating_point_context_save();
77
78  ef = (ARMV7M_Exception_frame *) _ARMV7M_Get_PSP();
79  ++ef;
80  _ARMV7M_Set_PSP( (uint32_t) ef );
81
82  _ISR_Nest_level = 0;
83  RTEMS_COMPILER_MEMORY_BARRIER();
84
85  if ( _Thread_Dispatch_necessary ) {
86    _ARMV7M_Pendable_service_call();
87  }
88}
89
90#endif /* ARM_MULTILIB_ARCH_V7M */
Note: See TracBrowser for help on using the repository browser.