Skip to content

Commit 5b8d418

Browse files
nashifgalak
authored andcommitted
nios2: revert back to builtin sys_io functions
Some time ago we did a cleanup of sys_io function and left nios2 broken, especially on the MAX10 board. Revert back to the original implementation for this architecture. Fixes #35694 Signed-off-by: Anas Nashif <[email protected]>
1 parent 6148ac9 commit 5b8d418

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

include/arch/nios2/arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <devicetree.h>
2323
#include <arch/nios2/nios2.h>
2424
#include <arch/common/sys_bitops.h>
25-
#include <arch/common/sys_io.h>
25+
#include <sys/sys_io.h>
2626
#include <arch/common/ffs.h>
2727

2828
#define ARCH_STACK_PTR_ALIGN 4

include/arch/nios2/asm_inline_gcc.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,43 @@
1414

1515
#ifndef _ASMLANGUAGE
1616
#include <zephyr/types.h>
17+
#include <sys/sys_io.h>
1718
#include <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+
24+
static ALWAYS_INLINE void sys_write32(uint32_t data, mm_reg_t addr)
25+
{
26+
__builtin_stwio((void *)addr, data);
27+
}
28+
29+
static ALWAYS_INLINE uint32_t sys_read32(mm_reg_t addr)
30+
{
31+
return __builtin_ldwio((void *)addr);
32+
}
33+
34+
static ALWAYS_INLINE void sys_write8(uint8_t data, mm_reg_t addr)
35+
{
36+
sys_write32(data, addr);
37+
}
38+
39+
static ALWAYS_INLINE uint8_t sys_read8(mm_reg_t addr)
40+
{
41+
return __builtin_ldbuio((void *)addr);
42+
}
43+
44+
static ALWAYS_INLINE void sys_write16(uint16_t data, mm_reg_t addr)
45+
{
46+
sys_write32(data, addr);
47+
}
48+
49+
static ALWAYS_INLINE uint16_t sys_read16(mm_reg_t addr)
50+
{
51+
return __builtin_ldhuio((void *)addr);
52+
}
53+
1854
#endif /* _ASMLANGUAGE */
1955

2056
#endif /* _ASM_INLINE_GCC_PUBLIC_GCC_H */

include/arch/nios2/nios2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern "C"
5555

5656
#include <zephyr/types.h>
5757
#include <arch/cpu.h>
58-
#include <arch/common/sys_io.h>
58+
#include <sys/sys_io.h>
5959

6060
/*
6161
* Functions for accessing select Nios II general-purpose registers.

0 commit comments

Comments
 (0)