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