From 493c3da3ac530229ca4c4caadd5df041f6c25eb2 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Thu, 17 Jul 2025 19:15:52 -0600 Subject: sandbox: Add more dummy functions to mimic other architectures This adds more common functions found on other architectures that will allow for more compile-testing of drivers. These are either dummy functions as we do not need them or mappings to existing functions, similar to how other architectures handle it. Signed-off-by: Tom Rini --- arch/sandbox/include/asm/dma-mapping.h | 27 +++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 13 +++++++++++++ arch/sandbox/include/asm/processor.h | 3 ++- 3 files changed, 42 insertions(+), 1 deletion(-) (limited to 'arch/sandbox/include') diff --git a/arch/sandbox/include/asm/dma-mapping.h b/arch/sandbox/include/asm/dma-mapping.h index 853b0877b33..410760c2231 100644 --- a/arch/sandbox/include/asm/dma-mapping.h +++ b/arch/sandbox/include/asm/dma-mapping.h @@ -1 +1,28 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copied from arch/arm/include/asm/dma-mapping.h which is: + * + * (C) Copyright 2007 + * Stelian Pop + * Lead Tech Design + */ + +#ifndef __ASM_SANDBOX_DMA_MAPPING_H +#define __ASM_SANDBOX_DMA_MAPPING_H + +#include +#include +#include + +static inline void *dma_alloc_coherent(size_t len, unsigned long *handle) +{ + *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, ROUND(len, ARCH_DMA_MINALIGN)); + return (void *)*handle; +} + +static inline void dma_free_coherent(void *addr) +{ + free(addr); +} + +#endif diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 11ed89e0071..72953828f96 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -12,6 +12,9 @@ static inline void sync(void) { } +#define mb() sync() +#define dmb() sync() + enum sandboxio_size_t { SB_SIZE_8, SB_SIZE_16, @@ -53,6 +56,16 @@ void sandbox_write(void *addr, unsigned int val, enum sandboxio_size_t size); #define writeq(v, addr) sandbox_write((void *)addr, v, SB_SIZE_64) #endif +#define readb_relaxed readb +#define readw_relaxed readw +#define readl_relaxed readl +#define readq_relaxed readq + +#define writeb_relaxed writeb +#define writew_relaxed writew +#define writel_relaxed writel +#define writeq_relaxed writeq + /* * Clear and set bits in one shot. These macros can be used to clear and * set multiple bits in a register using a single call. These macros can diff --git a/arch/sandbox/include/asm/processor.h b/arch/sandbox/include/asm/processor.h index 8dced6006bd..6521274efb0 100644 --- a/arch/sandbox/include/asm/processor.h +++ b/arch/sandbox/include/asm/processor.h @@ -6,6 +6,7 @@ #ifndef _ASM_PROCESSOR_H #define _ASM_PROCESSOR_H -/* This file is required for PCI */ +/* Assorted dummy functions */ +#define cpu_relax() #endif -- cgit v1.3.1 From d68db76b95b106227a40fcf41ebf4dccb2225a0e Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 4 Aug 2025 15:50:08 -0600 Subject: sandbox: Add an additional dummy sync macro There are some drivers which call a "dmb" for a type of sync. Add that as well to sandbox. Signed-off-by: Tom Rini --- arch/sandbox/include/asm/io.h | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/sandbox/include') diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 72953828f96..cd3f5d6fd40 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -14,6 +14,7 @@ static inline void sync(void) #define mb() sync() #define dmb() sync() +#define wmb() sync() enum sandboxio_size_t { SB_SIZE_8, -- cgit v1.3.1 From 58998fed9e63e8310a96229565d2996ad29d191e Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 12 Aug 2025 11:59:07 -0600 Subject: sandbox: Improve dummy local_irq_save implementation Normally, local_save_flags is used as part of the local_irq_* macros, so remove that as it's unused. Make local_irq_save do something to the passed variable so that it won't trigger unused variable warnings later. Signed-off-by: Tom Rini --- arch/sandbox/include/asm/system.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'arch/sandbox/include') diff --git a/arch/sandbox/include/asm/system.h b/arch/sandbox/include/asm/system.h index 7933b6292e2..73f34683b27 100644 --- a/arch/sandbox/include/asm/system.h +++ b/arch/sandbox/include/asm/system.h @@ -7,10 +7,9 @@ #define __ASM_SANDBOX_SYSTEM_H /* Define this as nops for sandbox architecture */ -#define local_irq_save(x) +#define local_irq_save(x) do { (x) = 0; } while (0) #define local_irq_enable() #define local_irq_disable() -#define local_save_flags(x) #define local_irq_restore(x) #endif -- cgit v1.3.1 From 66ff673a8e9f56d2c08a32d12867094c77ea5fd3 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 12 Aug 2025 11:59:08 -0600 Subject: sandbox: Add generic asm/atomic.h In order to compile code that uses on sandbox, we must provide this header. RISC-V shows us today how to do so with the generic header implementation, so copy that. Signed-off-by: Tom Rini --- arch/sandbox/include/asm/atomic.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 arch/sandbox/include/asm/atomic.h (limited to 'arch/sandbox/include') diff --git a/arch/sandbox/include/asm/atomic.h b/arch/sandbox/include/asm/atomic.h new file mode 100644 index 00000000000..2fe49f52f34 --- /dev/null +++ b/arch/sandbox/include/asm/atomic.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Based on arch/riscv/include/asm/atomic.h which is: + * Copyright 2023 SiFive, Inc. + */ + +#ifndef __SANDBOX_ATOMIC_H +#define __SANDBOX_ATOMIC_H + +/* use the generic asm/atomic.h until we define a better one */ + +#include +#include + +#endif -- cgit v1.3.1