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