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