[PATCH] sandbox: Add more dummy functions to mimic other architectures

Tom Rini trini at konsulko.com
Fri Jul 18 03:15:52 CEST 2025


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 <trini at konsulko.com>
---
 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(-)

diff --git a/arch/sandbox/include/asm/dma-mapping.h b/arch/sandbox/include/asm/dma-mapping.h
index 853b0877b33d..410760c2231a 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 <stelian at popies.net>
+ * Lead Tech Design <www.leadtechdesign.com>
+ */
+
+#ifndef __ASM_SANDBOX_DMA_MAPPING_H
+#define __ASM_SANDBOX_DMA_MAPPING_H
+
+#include <asm/cache.h>
+#include <linux/types.h>
+#include <malloc.h>
+
+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 11ed89e00710..72953828f96a 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 8dced6006bd0..6521274efb01 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
-- 
2.43.0



More information about the U-Boot mailing list