source: rtems/cpukit/score/cpu/arm/armv7m-context-switch.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.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief ARM7M CPU Context Switch
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
30void __attribute__((naked)) _CPU_Context_switch(
31  Context_Control *executing,
32  Context_Control *heir
33)
34{
35  __asm__ volatile (
36    "movw r2, #:lower16:_Per_CPU_Information\n"
37    "movt r2, #:upper16:_Per_CPU_Information\n"
38    "ldr r3, [r2, %[isrpcpuoff]]\n"
39    "stm r0, {r4-r11, lr}\n"
40#ifdef ARM_MULTILIB_VFP
41    "add r4, r0, %[d8off]\n"
42    "vstm r4, {d8-d15}\n"
43#endif
44    "str sp, [r0, %[spctxoff]]\n"
45    "str r3, [r0, %[isrctxoff]]\n"
46    "ldr r3, [r1, %[isrctxoff]]\n"
47    "ldr sp, [r1, %[spctxoff]]\n"
48#ifdef ARM_MULTILIB_VFP
49    "add r4, r1, %[d8off]\n"
50    "vldm r4, {d8-d15}\n"
51#endif
52    "ldm r1, {r4-r11, lr}\n"
53    "str r3, [r2, %[isrpcpuoff]]\n"
54    "bx lr\n"
55    :
56    : [spctxoff] "J" (offsetof(Context_Control, register_sp)),
57      [isrctxoff] "J" (offsetof(Context_Control, isr_nest_level)),
58      [isrpcpuoff] "J" (offsetof(Per_CPU_Control, isr_nest_level)),
59      [d8off] "J" (ARM_CONTEXT_CONTROL_D8_OFFSET)
60  );
61}
62
63#endif /* ARM_MULTILIB_ARCH_V7M */
Note: See TracBrowser for help on using the repository browser.