]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Arm/GccInline.c
Clean up MdePkg source to correct some coding style issues, etc.
[mirror_edk2.git] / MdePkg / Library / BaseLib / Arm / GccInline.c
1 /** @file
2 GCC inline implementation of BaseLib processor specific functions.
3
4 Copyright (c) 2006 - 2010, Intel Corporation<BR>
5 Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "BaseLibInternals.h"
17
18 /**
19 Requests CPU to pause for a short period of time.
20
21 Requests CPU to pause for a short period of time. Typically used in MP
22 systems to prevent memory starvation while waiting for a spin lock.
23
24 **/
25 VOID
26 EFIAPI
27 CpuPause (
28 VOID
29 )
30 {
31 __asm__ __volatile__ (
32 "nop\n\t"
33 "nop\n\t"
34 "nop\n\t"
35 "nop\n\t"
36 "nop\n\t"
37 );
38 }
39
40 /**
41 Transfers control to a function starting with a new stack.
42
43 This internal worker function transfers control to the function
44 specified by EntryPoint using the new stack specified by NewStack
45 and passing in the parameters specified by Context1 and Context2.
46 Context1 and Context2 are optional and may be NULL.
47 The function EntryPoint must never return.
48
49 @param EntryPoint The pointer to the function to enter.
50 @param Context1 The first parameter to pass in.
51 @param Context2 The second Parameter to pass in
52 @param NewStack The new Location of the stack
53
54 **/
55 VOID
56 EFIAPI
57 InternalSwitchStackAsm (
58 SWITCH_STACK_ENTRY_POINT EntryPoint,
59 VOID *Context1,
60 VOID *Context2,
61 VOID *NewStack
62 )
63 {
64 __asm__ __volatile__ (
65 "mov lr, %0\n\t"
66 "mov sp, %3\n\t"
67 "mov %r0, %1\n\t"
68 "mov %r1, %2\n\t"
69 "bx lr\n\t"
70 : /* no output operand */
71 : "r" (EntryPoint),
72 "r" (Context1),
73 "r" (Context2),
74 "r" (NewStack)
75 );
76 }