MdePkg/BaseIoLibIntrinsicArmVirt ARM: avoid double word loads and stores
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / Arm / ArmVirtMmio.S
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
14GCC_ASM_EXPORT(MmioRead8Internal)\r
15GCC_ASM_EXPORT(MmioWrite8Internal)\r
16GCC_ASM_EXPORT(MmioRead16Internal)\r
17GCC_ASM_EXPORT(MmioWrite16Internal)\r
18GCC_ASM_EXPORT(MmioRead32Internal)\r
19GCC_ASM_EXPORT(MmioWrite32Internal)\r
20GCC_ASM_EXPORT(MmioRead64Internal)\r
21GCC_ASM_EXPORT(MmioWrite64Internal)\r
22\r
23//\r
24// Reads an 8-bit MMIO register.\r
25//\r
26// Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r
27// returned. This function must guarantee that all MMIO read and write\r
28// operations are serialized.\r
29//\r
30// @param Address The MMIO register to read.\r
31//\r
32// @return The value read.\r
33//\r
34ASM_PFX(MmioRead8Internal):\r
35 ldrb r0, [r0]\r
36 dmb\r
37 bx lr\r
38\r
39//\r
40// Writes an 8-bit MMIO register.\r
41//\r
42// Writes the 8-bit MMIO register specified by Address with the value specified\r
43// by Value and returns Value. This function must guarantee that all MMIO read\r
44// and write operations are serialized.\r
45//\r
46// @param Address The MMIO register to write.\r
47// @param Value The value to write to the MMIO register.\r
48//\r
49ASM_PFX(MmioWrite8Internal):\r
50 dmb st\r
51 strb r1, [r0]\r
52 bx lr\r
53\r
54//\r
55// Reads a 16-bit MMIO register.\r
56//\r
57// Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r
58// returned. This function must guarantee that all MMIO read and write\r
59// operations are serialized.\r
60//\r
61// @param Address The MMIO register to read.\r
62//\r
63// @return The value read.\r
64//\r
65ASM_PFX(MmioRead16Internal):\r
66 ldrh r0, [r0]\r
67 dmb\r
68 bx lr\r
69\r
70//\r
71// Writes a 16-bit MMIO register.\r
72//\r
73// Writes the 16-bit MMIO register specified by Address with the value specified\r
74// by Value and returns Value. This function must guarantee that all MMIO read\r
75// and write operations are serialized.\r
76//\r
77// @param Address The MMIO register to write.\r
78// @param Value The value to write to the MMIO register.\r
79//\r
80ASM_PFX(MmioWrite16Internal):\r
81 dmb st\r
82 strh r1, [r0]\r
83 bx lr\r
84\r
85//\r
86// Reads a 32-bit MMIO register.\r
87//\r
88// Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r
89// returned. This function must guarantee that all MMIO read and write\r
90// operations are serialized.\r
91//\r
92// @param Address The MMIO register to read.\r
93//\r
94// @return The value read.\r
95//\r
96ASM_PFX(MmioRead32Internal):\r
97 ldr r0, [r0]\r
98 dmb\r
99 bx lr\r
100\r
101//\r
102// Writes a 32-bit MMIO register.\r
103//\r
104// Writes the 32-bit MMIO register specified by Address with the value specified\r
105// by Value and returns Value. This function must guarantee that all MMIO read\r
106// and write operations are serialized.\r
107//\r
108// @param Address The MMIO register to write.\r
109// @param Value The value to write to the MMIO register.\r
110//\r
111ASM_PFX(MmioWrite32Internal):\r
112 dmb st\r
113 str r1, [r0]\r
114 bx lr\r
115\r
116//\r
117// Reads a 64-bit MMIO register.\r
118//\r
119// Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r
120// returned. This function must guarantee that all MMIO read and write\r
121// operations are serialized.\r
122//\r
123// @param Address The MMIO register to read.\r
124//\r
125// @return The value read.\r
126//\r
127ASM_PFX(MmioRead64Internal):\r
9cabe9d4
AB
128 ldr r1, [r0, #4]\r
129 ldr r0, [r0]\r
9095d37b
LG
130 dmb\r
131 bx lr\r
132\r
133//\r
134// Writes a 64-bit MMIO register.\r
135//\r
136// Writes the 64-bit MMIO register specified by Address with the value specified\r
137// by Value and returns Value. This function must guarantee that all MMIO read\r
138// and write operations are serialized.\r
139//\r
140// @param Address The MMIO register to write.\r
141// @param Value The value to write to the MMIO register.\r
142//\r
143ASM_PFX(MmioWrite64Internal):\r
144 dmb st\r
9cabe9d4
AB
145 str r2, [r0]\r
146 str r3, [r0, #4]\r
9095d37b 147 bx lr\r