]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.S
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / Arm / ArmVirtMmio.S
1 #
2 # Copyright (c) 2014-2018, Linaro Limited. All rights reserved.
3 #
4 # SPDX-License-Identifier: BSD-2-Clause-Patent
5 #
6 #
7
8 GCC_ASM_EXPORT(MmioRead8Internal)
9 GCC_ASM_EXPORT(MmioWrite8Internal)
10 GCC_ASM_EXPORT(MmioRead16Internal)
11 GCC_ASM_EXPORT(MmioWrite16Internal)
12 GCC_ASM_EXPORT(MmioRead32Internal)
13 GCC_ASM_EXPORT(MmioWrite32Internal)
14 GCC_ASM_EXPORT(MmioRead64Internal)
15 GCC_ASM_EXPORT(MmioWrite64Internal)
16
17 //
18 // Reads an 8-bit MMIO register.
19 //
20 // Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
21 // returned. This function must guarantee that all MMIO read and write
22 // operations are serialized.
23 //
24 // @param Address The MMIO register to read.
25 //
26 // @return The value read.
27 //
28 ASM_PFX(MmioRead8Internal):
29 ldrb r0, [r0]
30 dmb
31 bx lr
32
33 //
34 // Writes an 8-bit MMIO register.
35 //
36 // Writes the 8-bit MMIO register specified by Address with the value specified
37 // by Value and returns Value. This function must guarantee that all MMIO read
38 // and write operations are serialized.
39 //
40 // @param Address The MMIO register to write.
41 // @param Value The value to write to the MMIO register.
42 //
43 ASM_PFX(MmioWrite8Internal):
44 dmb st
45 strb r1, [r0]
46 bx lr
47
48 //
49 // Reads a 16-bit MMIO register.
50 //
51 // Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
52 // returned. This function must guarantee that all MMIO read and write
53 // operations are serialized.
54 //
55 // @param Address The MMIO register to read.
56 //
57 // @return The value read.
58 //
59 ASM_PFX(MmioRead16Internal):
60 ldrh r0, [r0]
61 dmb
62 bx lr
63
64 //
65 // Writes a 16-bit MMIO register.
66 //
67 // Writes the 16-bit MMIO register specified by Address with the value specified
68 // by Value and returns Value. This function must guarantee that all MMIO read
69 // and write operations are serialized.
70 //
71 // @param Address The MMIO register to write.
72 // @param Value The value to write to the MMIO register.
73 //
74 ASM_PFX(MmioWrite16Internal):
75 dmb st
76 strh r1, [r0]
77 bx lr
78
79 //
80 // Reads a 32-bit MMIO register.
81 //
82 // Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
83 // returned. This function must guarantee that all MMIO read and write
84 // operations are serialized.
85 //
86 // @param Address The MMIO register to read.
87 //
88 // @return The value read.
89 //
90 ASM_PFX(MmioRead32Internal):
91 ldr r0, [r0]
92 dmb
93 bx lr
94
95 //
96 // Writes a 32-bit MMIO register.
97 //
98 // Writes the 32-bit MMIO register specified by Address with the value specified
99 // by Value and returns Value. This function must guarantee that all MMIO read
100 // and write operations are serialized.
101 //
102 // @param Address The MMIO register to write.
103 // @param Value The value to write to the MMIO register.
104 //
105 ASM_PFX(MmioWrite32Internal):
106 dmb st
107 str r1, [r0]
108 bx lr
109
110 //
111 // Reads a 64-bit MMIO register.
112 //
113 // Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
114 // returned. This function must guarantee that all MMIO read and write
115 // operations are serialized.
116 //
117 // @param Address The MMIO register to read.
118 //
119 // @return The value read.
120 //
121 ASM_PFX(MmioRead64Internal):
122 ldr r1, [r0, #4]
123 ldr r0, [r0]
124 dmb
125 bx lr
126
127 //
128 // Writes a 64-bit MMIO register.
129 //
130 // Writes the 64-bit MMIO register specified by Address with the value specified
131 // by Value and returns Value. This function must guarantee that all MMIO read
132 // and write operations are serialized.
133 //
134 // @param Address The MMIO register to write.
135 // @param Value The value to write to the MMIO register.
136 //
137 ASM_PFX(MmioWrite64Internal):
138 dmb st
139 str r2, [r0]
140 str r3, [r0, #4]
141 bx lr