]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseIoLibIntrinsic/Arm/ArmVirtMmio.asm
MdePkg/BaseIoLibIntrinsicArmVirt ARM: avoid double word loads and stores
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / Arm / ArmVirtMmio.asm
1 ;
2 ; Copyright (c) 2014-2018, Linaro Limited. All rights reserved.
3 ;
4 ; This program and the accompanying materials are licensed and made available
5 ; under the terms and conditions of the BSD License which accompanies this
6 ; distribution. The full text of the license may be found at
7 ; http:;opensource.org/licenses/bsd-license.php
8 ;
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 ;
12
13
14 AREA IoLibMmio, CODE, READONLY
15
16 EXPORT MmioRead8Internal
17 EXPORT MmioWrite8Internal
18 EXPORT MmioRead16Internal
19 EXPORT MmioWrite16Internal
20 EXPORT MmioRead32Internal
21 EXPORT MmioWrite32Internal
22 EXPORT MmioRead64Internal
23 EXPORT MmioWrite64Internal
24
25 ;
26 ; Reads an 8-bit MMIO register.
27 ;
28 ; Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
29 ; returned. This function must guarantee that all MMIO read and write
30 ; operations are serialized.
31 ;
32 ; @param Address The MMIO register to read.
33 ;
34 ; @return The value read.
35 ;
36 MmioRead8Internal
37 ldrb r0, [r0]
38 dmb
39 bx lr
40
41 ;
42 ; Writes an 8-bit MMIO register.
43 ;
44 ; Writes the 8-bit MMIO register specified by Address with the value specified
45 ; by Value and returns Value. This function must guarantee that all MMIO read
46 ; and write operations are serialized.
47 ;
48 ; @param Address The MMIO register to write.
49 ; @param Value The value to write to the MMIO register.
50 ;
51 MmioWrite8Internal
52 dmb st
53 strb r1, [r0]
54 bx lr
55
56 ;
57 ; Reads a 16-bit MMIO register.
58 ;
59 ; Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
60 ; returned. This function must guarantee that all MMIO read and write
61 ; operations are serialized.
62 ;
63 ; @param Address The MMIO register to read.
64 ;
65 ; @return The value read.
66 ;
67 MmioRead16Internal
68 ldrh r0, [r0]
69 dmb
70 bx lr
71
72 ;
73 ; Writes a 16-bit MMIO register.
74 ;
75 ; Writes the 16-bit MMIO register specified by Address with the value specified
76 ; by Value and returns Value. This function must guarantee that all MMIO read
77 ; and write operations are serialized.
78 ;
79 ; @param Address The MMIO register to write.
80 ; @param Value The value to write to the MMIO register.
81 ;
82 MmioWrite16Internal
83 dmb st
84 strh r1, [r0]
85 bx lr
86
87 ;
88 ; Reads a 32-bit MMIO register.
89 ;
90 ; Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
91 ; returned. This function must guarantee that all MMIO read and write
92 ; operations are serialized.
93 ;
94 ; @param Address The MMIO register to read.
95 ;
96 ; @return The value read.
97 ;
98 MmioRead32Internal
99 ldr r0, [r0]
100 dmb
101 bx lr
102
103 ;
104 ; Writes a 32-bit MMIO register.
105 ;
106 ; Writes the 32-bit MMIO register specified by Address with the value specified
107 ; by Value and returns Value. This function must guarantee that all MMIO read
108 ; and write operations are serialized.
109 ;
110 ; @param Address The MMIO register to write.
111 ; @param Value The value to write to the MMIO register.
112 ;
113 MmioWrite32Internal
114 dmb st
115 str r1, [r0]
116 bx lr
117
118 ;
119 ; Reads a 64-bit MMIO register.
120 ;
121 ; Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
122 ; returned. This function must guarantee that all MMIO read and write
123 ; operations are serialized.
124 ;
125 ; @param Address The MMIO register to read.
126 ;
127 ; @return The value read.
128 ;
129 MmioRead64Internal
130 ldr r1, [r0, #4]
131 ldr r0, [r0]
132 dmb
133 bx lr
134
135 ;
136 ; Writes a 64-bit MMIO register.
137 ;
138 ; Writes the 64-bit MMIO register specified by Address with the value specified
139 ; by Value and returns Value. This function must guarantee that all MMIO read
140 ; and write operations are serialized.
141 ;
142 ; @param Address The MMIO register to write.
143 ; @param Value The value to write to the MMIO register.
144 ;
145 MmioWrite64Internal
146 dmb st
147 str r2, [r0]
148 str r3, [r0, #4]
149 bx lr
150
151 END