source: rtems/cpukit/score/cpu/arm/cpu_asm.S @ f28f5c4

4.115
Last change on this file since f28f5c4 was f28f5c4, checked in by Sebastian Huber <sebastian.huber@…>, on 06/30/14 at 14:47:06

arm: Use local label in _CPU_Context_restore()

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreCPU
5 *
6 * @brief ARM architecture support implementation.
7 */
8
9/*
10 *  This file contains all assembly code for the ARM implementation
11 *  of RTEMS.
12 *
13 *  Copyright (c) 2007 by Ray Xu, <Rayx.cn@gmail.com>
14 *          Thumb support added.
15 *
16 *  Copyright (c) 2002 by Advent Networks, Inc.
17 *          Jay Monkman <jmonkman@adventnetworks.com>
18 *
19 *  COPYRIGHT (c) 2000 Canon Research Centre France SA.
20 *  Emmanuel Raguet, mailto:raguet@crf.canon.fr
21 *
22 *  The license and distribution terms for this file may be
23 *  found in the file LICENSE in this distribution or at
24 *  http://www.rtems.org/license/LICENSE.
25 *
26 */
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include <rtems/asm.h>
33#include <rtems/score/cpu.h>
34
35#ifdef ARM_MULTILIB_ARCH_V4
36
37        .text
38
39/*
40 *  void _CPU_Context_switch( run_context, heir_context )
41 *  void _CPU_Context_restore( run_context, heir_context )
42 *
43 *  This routine performs a normal non-FP context.
44 *
45 *  R0 = run_context    R1 = heir_context
46 *
47 *  This function copies the current registers to where r0 points, then
48 *  restores the ones from where r1 points.
49 *
50 *  Using the ldm/stm opcodes save 2-3 us on 100 MHz ARM9TDMI with
51 *  a 16 bit data bus.
52 *
53 */
54
55DEFINE_FUNCTION_ARM(_CPU_Context_switch)
56/* Start saving context */
57        mrs     r2, CPSR
58        stmia   r0,  {r2, r4, r5, r6, r7, r8, r9, r10, r11, r13, r14}
59
60#ifdef ARM_MULTILIB_VFP_D32
61        add     r3, r0, #ARM_CONTEXT_CONTROL_D8_OFFSET
62        vstm    r3, {d8-d15}
63#endif
64
65#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER
66        mrc     p15, 0, r3, c13, c0, 3
67        str     r3, [r0, #ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET]
68#endif
69
70#ifdef RTEMS_SMP
71        /* The executing context no longer executes on this processor */
72        dmb
73        mov     r3, #0
74        strb    r3, [r0, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
75
76        /* Wait for heir context to stop execution */
771:
78        ldrb    r3, [r1, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
79        cmp     r3, #0
80        bne     1b
81
82        /* The heir context executes now on this processor */
83        dmb
84        mov     r3, #1
85        strb    r3, [r1, #ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET]
86#endif
87
88/* Start restoring context */
89.L_restore:
90#ifdef ARM_MULTILIB_HAS_LOAD_STORE_EXCLUSIVE
91        clrex
92#endif
93
94#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER
95        ldr     r3, [r1, #ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET]
96        mcr     p15, 0, r3, c13, c0, 3
97#endif
98
99#ifdef ARM_MULTILIB_VFP_D32
100        add     r3, r1, #ARM_CONTEXT_CONTROL_D8_OFFSET
101        vldm    r3, {d8-d15}
102#endif
103
104        ldmia   r1,  {r2, r4, r5, r6, r7, r8, r9, r10, r11, r13, r14}
105        msr     CPSR_fsxc, r2
106#ifdef __thumb__
107        bx      lr
108        nop
109#else
110        mov     pc, lr
111#endif
112/*
113 *  void _CPU_Context_restore( new_context )
114 *
115 *  This function copies the restores the registers from where r0 points.
116 *  It must match _CPU_Context_switch()
117 *
118 */
119DEFINE_FUNCTION_ARM(_CPU_Context_restore)
120        mov     r1, r0
121        b       .L_restore
122
123#endif /* ARM_MULTILIB_ARCH_V4 */
Note: See TracBrowser for help on using the repository browser.