source: rtems/cpukit/score/cpu/arm/armv7m-multitasking-start-stop.c @ d9bd5cd6

4.115
Last change on this file since d9bd5cd6 was e377ad7, checked in by Sebastian Huber <sebastian.huber@…>, on 01/07/13 at 07:48:45

arm: Include <rtems/score/cpu.h>

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief ARMV7M Start and Stop Multitasking
5 */
6
7/*
8 * Copyright (c) 2011 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.com/license/LICENSE.
19 */
20
21#ifdef HAVE_CONFIG_H
22  #include "config.h"
23#endif
24
25#include <rtems/score/armv7m.h>
26
27#ifdef ARM_MULTILIB_ARCH_V7M
28
29void __attribute__((naked)) _ARMV7M_Start_multitasking(
30  Context_Control *bsp,
31  Context_Control *heir
32)
33{
34  __asm__ volatile (
35    /* Store BSP context */
36    "stm r0, {r4-r11, lr}\n"
37    "str sp, [r0, %[spctxoff]]\n"
38    /* Restore heir context */
39    "ldr r2, [r1, %[spctxoff]]\n"
40    "msr psp, r2\n"
41    "ldm r1, {r4-r11, lr}\n"
42    /* Enable process stack pointer (PSP) */
43    "mrs r2, control\n"
44    "orr r2, #0x2\n"
45    "msr control, r2\n"
46    /* Return to heir */
47    "bx lr\n"
48    :
49    : [spctxoff] "J" (offsetof(Context_Control, register_sp))
50  );
51}
52
53void __attribute__((naked)) _ARMV7M_Stop_multitasking( Context_Control *bsp )
54{
55  __asm__ volatile (
56    /* Disable interrupts */
57    "mov r2, #0x80\n"
58    "msr basepri_max, r2\n"
59    /* Restore BSP context */
60    "ldr r2, [r0, %[spctxoff]]\n"
61    "msr msp, r2\n"
62    "ldm r0, {r4-r11, lr}\n"
63    /* Disable process stack pointer (PSP) */
64    "mrs r2, control\n"
65    "bic r2, #0x2\n"
66    "msr control, r2\n"
67    /* Return to BSP */
68    "bx lr\n"
69    :
70    : [spctxoff] "J" (offsetof(Context_Control, register_sp))
71  );
72  __builtin_unreachable();
73}
74
75#endif /* ARM_MULTILIB_ARCH_V7M */
Note: See TracBrowser for help on using the repository browser.