Skip to contentSkip to conversation

sandbox: Add more dummy functions to mimic other architectures

PATCH In review Tom Rini 1 participant 2 messages Jul 18, 2025 – Aug 11, 2025

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 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.

---
 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(-)
arch/sandbox/include/asm/dma-mapping.h +27 -0
index 853b0877b33d..410760c2231a 100644
@@ -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 <[email protected]>
+ * 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
arch/sandbox/include/asm/io.h +13 -0
index 11ed89e00710..72953828f96a 100644
@@ -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
arch/sandbox/include/asm/processor.h +2 -1
index 8dced6006bd0..6521274efb01 100644
@@ -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
Signature · 1 line
2.43.0
author
#1 lore raw
Quoted 6 lines · Tom Rini

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.

Applied to u-boot/next, thanks!

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

      commit: 493c3da3ac530229ca4c4caadd5df041f6c25eb2
Signature · 1 line
Tom