1 /* 2 * Copyright (c) 2016 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_ARCH_NIOS2_ASM_INLINE_GCC_H_ 8 #define ZEPHYR_INCLUDE_ARCH_NIOS2_ASM_INLINE_GCC_H_ 9 10 /* 11 * The file must not be included directly 12 * Include arch/cpu.h instead 13 */ 14 15 #ifndef _ASMLANGUAGE 16 #include <zephyr/types.h> 17 #include <zephyr/sys/sys_io.h> 18 #include <zephyr/toolchain.h> 19 20 /* Using the *io variants of these instructions to prevent issues on 21 * devices that have an instruction/data cache 22 */ 23 sys_write32(uint32_t data,mm_reg_t addr)24static ALWAYS_INLINE void sys_write32(uint32_t data, mm_reg_t addr) 25 { 26 __builtin_stwio((void *)addr, data); 27 } 28 sys_read32(mm_reg_t addr)29static ALWAYS_INLINE uint32_t sys_read32(mm_reg_t addr) 30 { 31 return __builtin_ldwio((void *)addr); 32 } 33 sys_write8(uint8_t data,mm_reg_t addr)34static ALWAYS_INLINE void sys_write8(uint8_t data, mm_reg_t addr) 35 { 36 sys_write32(data, addr); 37 } 38 sys_read8(mm_reg_t addr)39static ALWAYS_INLINE uint8_t sys_read8(mm_reg_t addr) 40 { 41 return __builtin_ldbuio((void *)addr); 42 } 43 sys_write16(uint16_t data,mm_reg_t addr)44static ALWAYS_INLINE void sys_write16(uint16_t data, mm_reg_t addr) 45 { 46 sys_write32(data, addr); 47 } 48 sys_read16(mm_reg_t addr)49static ALWAYS_INLINE uint16_t sys_read16(mm_reg_t addr) 50 { 51 return __builtin_ldhuio((void *)addr); 52 } 53 54 #endif /* _ASMLANGUAGE */ 55 56 #endif /* _ASM_INLINE_GCC_PUBLIC_GCC_H */ 57