Skip to content

Commit 6bf339e

Browse files
committed
samples: drivers: virtualization: xen: add virtio_backend
backend_sample Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent c2e448b commit 6bf339e

File tree

7 files changed

+106
-0
lines changed

7 files changed

+106
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(xen_virtio_backend)
7+
8+
target_sources(app PRIVATE src/main.c)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. zephyr:code-sample:: xen_virtio_backend
2+
:name: Xen VirtIO Backend
3+
4+
Print "Hello World" to the console.
5+
6+
Overview
7+
********
8+
9+
A simple sample that can be used with any :ref:`supported board <boards>` and
10+
prints "Hello World" to the console.
11+
12+
Building and Running
13+
********************
14+
15+
This application can be built and executed on QEMU as follows:
16+
17+
.. zephyr-app-commands::
18+
:zephyr-app: samples/drivers/virtualization/xen/virtio_backend
19+
:host-os: unix
20+
:board: qemu_x86
21+
:goals: run
22+
:compact:
23+
24+
To build for another board, change "qemu_x86" above to that board's name.
25+
26+
Sample Output
27+
=============
28+
29+
.. code-block:: console
30+
31+
Hello World! x86
32+
33+
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2025 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
virtio-mmio-backend@10004000 {
9+
reg = <0x0 0x10004000 0x0 0x200>;
10+
compatible = "xen,virtio-mmio-backend";
11+
};
12+
13+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2025 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
virtio-mmio-backend@10004000 {
9+
reg = <0x0 0x10004000 0x0 0x200>;
10+
interrupts = <GIC_SPI 42 IRQ_TYPE_EDGE IRQ_DEFAULT_PRIORITY>;
11+
compatible = "xen,virtio-mmio-backend";
12+
};
13+
14+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_VIRTIO=y
2+
CONFIG_LOG=y
3+
CONFIG_HEAP_MEM_POOL_SIZE=1048576
4+
CONFIG_LOG_MODE_IMMEDIATE=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sample:
2+
description: Hello World sample, the simplest Zephyr
3+
application
4+
name: hello world
5+
common:
6+
min_ram: 2
7+
min_flash: 16
8+
tags: introduction
9+
integration_platforms:
10+
- native_sim
11+
harness: console
12+
harness_config:
13+
type: one_line
14+
regex:
15+
- "Hello World! (.*)"
16+
tests:
17+
sample.virtualization.xen.virtio_backend:
18+
tags: introduction
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 TOKITA Hiroshi
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
9+
int main(void)
10+
{
11+
while (1) {
12+
k_yield();
13+
}
14+
15+
return 0;
16+
}

0 commit comments

Comments
 (0)