Skip to content

Commit 55442bf

Browse files
lrgirdwokv2019i
authored andcommitted
qemu: add qemu target with and without MMU for CI and developer usage.
Add a qemu target for SOF that will build with native zephyr support for drivers including xtensa MMU. This will be used for GH worklow ztest validation and as a SDV for userspace work. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent fae6bca commit 55442bf

16 files changed

Lines changed: 201 additions & 2 deletions

File tree

app/boards/qemu_xtensa_dc233c.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
CONFIG_IPC_MAJOR_4=y
3+
CONFIG_ZTEST=y
4+
CONFIG_MM_DRV=y
5+
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
CONFIG_IPC_MAJOR_4=y
3+
CONFIG_USERSPACE=y
4+
CONFIG_ZTEST=y
5+
CONFIG_TEST_USERSPACE=y
6+
CONFIG_MM_DRV=y
7+
CONFIG_ZEPHYR_NATIVE_DRIVERS=y

scripts/set_xtensa_params.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ case "$platform" in
150150
HOST="xtensa-mt8365-elf"
151151
TOOLCHAIN_VER="RG-2018.9-linux"
152152
;;
153+
qemu_xtensa | qemu_xtensa_mmu)
154+
PLATFORM="$1"
155+
XTENSA_CORE=""
156+
HOST="xtensa-zephyr-elf"
157+
TOOLCHAIN_VER=""
158+
;;
153159
*)
154160
>&2 printf 'Unknown xtensa platform=%s\n' "$platform"
155161
return 1
@@ -166,6 +172,8 @@ esac
166172

167173
# For Zephyr unit tests
168174
case "$platform" in
175+
qemu_xtensa | qemu_xtensa_mmu)
176+
ZEPHYR_TOOLCHAIN_VARIANT='zephyr';;
169177
imx8*|mtl|lnl)
170178
ZEPHYR_TOOLCHAIN_VARIANT='xt-clang';;
171179
*) # The previous, main case/esac already caught invalid input.

scripts/xtensa-build-zephyr.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ class PlatformConfig:
227227
"imx", "imx95_evk/mimx9596/m7/ddr",
228228
"", "", "", ""
229229
),
230+
"qemu_xtensa" : PlatformConfig(
231+
"zephyr", "qemu_xtensa/dc233c",
232+
"", "", "zephyr"
233+
),
234+
"qemu_xtensa_mmu" : PlatformConfig(
235+
"zephyr", "qemu_xtensa/dc233c/mmu",
236+
"", "", "zephyr"
237+
),
230238
}
231239

232240
platform_configs = platform_configs_all.copy()
@@ -894,6 +902,7 @@ def build_platforms():
894902
platform_build_dir_name = f"build-{platform}"
895903

896904
PLAT_CONFIG = platform_dict["PLAT_CONFIG"]
905+
897906
build_cmd = ["west"]
898907
build_cmd += ["-v"] * args.verbose
899908
if args.menuconfig:
@@ -1144,8 +1153,9 @@ def install_platform(platform, sof_output_dir, platf_build_environ, platform_wco
11441153
install_key_dir = install_key_dir / args.key_type_subdir
11451154

11461155
os.makedirs(install_key_dir, exist_ok=True)
1147-
# looses file owner and group - file is commonly accessible
1148-
shutil.copy2(abs_build_dir / "zephyr.ri", install_key_dir / output_fwname)
1156+
# looses file owner and group - file is commonly accessible, dont install qemu.
1157+
if platform not in ("qemu_xtensa", "qemu_xtensa_mmu"):
1158+
shutil.copy2(abs_build_dir / "zephyr.ri", install_key_dir / output_fwname)
11491159

11501160
if args.deployable_build and platform_configs[platform].ipc4:
11511161
# IPC4 deployable builds are using separate directories per platforms
@@ -1298,6 +1308,8 @@ def gzip_compress(fname, gzdst=None):
12981308
RI_INFO_UNSUPPORTED += ['imx8', 'imx8x', 'imx8m', 'imx8ulp', 'imx95']
12991309
RI_INFO_UNSUPPORTED += ['rn', 'acp_6_0']
13001310
RI_INFO_UNSUPPORTED += ['mt8186', 'mt8188', 'mt8195', 'mt8196', 'mt8365']
1311+
RI_INFO_UNSUPPORTED += ['qemu_xtensa', 'qemu_xtensa_mmu']
1312+
13011313

13021314
# For temporary workarounds. Unlike _UNSUPPORTED above, the platforms below will print a warning.
13031315
RI_INFO_FIXME = [ ]

src/platform/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ elseif(CONFIG_MT8196)
2525
add_subdirectory(mt8196)
2626
elseif(CONFIG_MT8365)
2727
add_subdirectory(mt8365)
28+
elseif(PLATFORM STREQUAL "qemu_xtensa")
29+
add_subdirectory(qemu_xtensa)
2830
endif()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
add_local_sources(sof platform.c)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2026 Intel Corporation.
4+
*/
5+
6+
#ifndef __PLATFORM_LIB_CLK_H__
7+
#define __PLATFORM_LIB_CLK_H__
8+
9+
/* Dummy clk header for qemu_xtensa */
10+
#define CLK_MAX_CPU_HZ 10000000
11+
#define CPU_LOWEST_FREQ_IDX 0
12+
13+
#endif /* __PLATFORM_LIB_CLK_H__ */
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2026 Intel Corporation.
4+
*/
5+
6+
#ifndef __PLATFORM_LIB_DAI_H__
7+
#define __PLATFORM_LIB_DAI_H__
8+
9+
/* Dummy dai header for qemu_xtensa */
10+
11+
#endif /* __PLATFORM_LIB_DAI_H__ */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2026 Intel Corporation.
4+
*/
5+
6+
#ifndef __PLATFORM_LIB_DMA_H__
7+
#define __PLATFORM_LIB_DMA_H__
8+
9+
/* Dummy dma header for qemu_xtensa */
10+
struct dma;
11+
12+
struct sof_dma {
13+
const struct device *z_dev;
14+
};
15+
16+
#endif /* __PLATFORM_LIB_DMA_H__ */
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2026 Intel Corporation.
4+
*/
5+
6+
#ifndef __PLATFORM_LIB_MAILBOX_H__
7+
#define __PLATFORM_LIB_MAILBOX_H__
8+
9+
/* Dummy mailbox header for qemu_xtensa */
10+
#define MAILBOX_HOSTBOX_BASE 0x10000000
11+
#define MAILBOX_HOSTBOX_SIZE 0x1000
12+
#define MAILBOX_DSPBOX_BASE 0x10005000
13+
#define MAILBOX_DSPBOX_SIZE 0x1000
14+
#define MAILBOX_STREAM_BASE 0x10001000
15+
#define MAILBOX_STREAM_SIZE 0x1000
16+
#define MAILBOX_TRACE_BASE 0x10002000
17+
#define MAILBOX_TRACE_SIZE 0x1000
18+
#define MAILBOX_EXCEPTION_BASE 0x10003000
19+
#define MAILBOX_EXCEPTION_SIZE 0x1000
20+
#define MAILBOX_DEBUG_BASE 0x10004000
21+
#define MAILBOX_DEBUG_SIZE 0x1000
22+
#define MAILBOX_SW_REG_BASE 0x10005000
23+
#define MAILBOX_SW_REG_SIZE 0x1000
24+
25+
#include <stddef.h>
26+
#include <stdint.h>
27+
28+
static inline void mailbox_sw_regs_write(size_t offset, const void *src, size_t bytes) {}
29+
static inline void mailbox_sw_reg_write(size_t offset, uint32_t val) {}
30+
static inline void mailbox_sw_reg_write64(size_t offset, uint64_t val) {}
31+
static inline uint32_t mailbox_sw_reg_read(size_t offset) { return 0; }
32+
static inline uint64_t mailbox_sw_reg_read64(size_t offset) { return 0; }
33+
34+
#endif /* __PLATFORM_LIB_MAILBOX_H__ */

0 commit comments

Comments
 (0)