walnux/arch
Kerogit 25876e327e arch/avr: fix atomic load functions from arch_atomic.c
For AVR, atomic functions generated by LOAD macro turn into load surrounded
by up_irq_save and up_irq_restore. The generated code was incorrect as can
be seen from disassembly of __atomic_load_4:

in   r18, 0x3f ; store interrupts enabled flag
cli            ; disable interrupts
out  0x3f, r18 ; restore the flag
movw r30, r24  ; copy parameter (address) to pointer register
ld   r22, Z    ; indirect load to return value registers
ldd  r23, Z+1
ldd  r24, Z+2
ldd  r25, Z+3
ret            ; return

The interrupts are disabled to be immediately re-enabled, the load only takes
place after that.

Both up_irq_save and up_irq_restore are defined in inline assembly. Other
architectures (x86/486, Risc-V) mark this assembly with clobbers: memory.
Doing the same thing for AVR alleviates the problem:

in      r18, 0x3f ; store interrupts enabled flag
cli               ; disable interrupts
movw    r30, r24  ; copy address
ld      r22, Z    ; load
ldd     r23, Z+1
ldd     r24, Z+2
ldd     r25, Z+3
out     0x3f, r18 ; restore interrupts enabled flag
ret               ; return

Besides compiling the code and checking the assembly, this was tested
with a custom stress application on AVR128DA28.

Assembly of up_irq_enable is marked in the same way with regards to clobbers.

This patch also removes two functions that are not called from anywhere
(up_irq_disabled, putsreg)

Signed-off-by: Kerogit <kr.git@kerogit.eu>
2025-06-09 21:42:21 +08:00
..
arm arch/arm/src/stm32f0l0g0: UID support for F0, L0 and C0 2025-06-09 08:33:42 -03:00
arm64 arch: Flag all definitions of up_perf_* functions with CONFIG_ARCH_HAVE_PERF_EVENTS 2025-06-06 17:31:10 +08:00
avr arch/avr: fix atomic load functions from arch_atomic.c 2025-06-09 21:42:21 +08:00
ceva Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
dummy
hc style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
mips arch: unify Private Types banners 2025-05-28 10:17:15 +08:00
misoc Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
or1k Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
renesas Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
risc-v arch/riscv/Kconfig: Remove select "ARCH_PERF_EVENTS" from Kconfig 2025-06-06 17:31:10 +08:00
sim arch: unify Private Types banners 2025-05-28 10:17:15 +08:00
sparc Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
tricore Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
x86 Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
x86_64 arch: Flag all definitions of up_perf_* functions with CONFIG_ARCH_HAVE_PERF_EVENTS 2025-06-06 17:31:10 +08:00
xtensa arch: Flag all definitions of up_perf_* functions with CONFIG_ARCH_HAVE_PERF_EVENTS 2025-06-06 17:31:10 +08:00
z16 Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
z80 Revert "Reduce the size of tcb by four bytes." 2025-05-27 16:30:35 +08:00
CMakeLists.txt arch/z80: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
Kconfig style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00