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