Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fdt #6

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion bsp/qemu-virt64-aarch64/.config
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
#
CONFIG_RT_HYPERVISOR=y
CONFIG_RT_USING_NVHE=y
CONFIG_ARM64_ERRATUM_1530923=y
# CONFIG_ARM64_ERRATUM_1530923 is not set
CONFIG_MAX_VM_NUM=4
CONFIG_MAX_OS_NUM=3

Expand Down
56 changes: 56 additions & 0 deletions bsp/qemu-virt64-aarch64/applications/timer_sample.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-08-24 yangjie the first version
*/
/*
* 程序清单:定时器例程
*
* 这个例程会创建两个动态定时器,一个是单次定时,一个是周期性定时
* 并让周期定时器运行一段时间后停止运行
*/
#include <rtthread.h>
/* 定时器的控制块 */
static rt_timer_t timer1;
static rt_timer_t timer2;
static int cnt = 0;
/* 定时器1超时函数 */
static void timeout1(void *parameter)
{
rt_kprintf("periodic timer is timeout %d\n", cnt);
/* 运行第10次,停止周期定时器 */
if (cnt++ >= 9)
{
rt_timer_stop(timer1);
rt_kprintf("periodic timer was stopped! \n");
}
}
/* 定时器2超时函数 */
static void timeout2(void *parameter)
{
rt_kprintf("one shot timer is timeout\n");
}
int timer_sample(void)
{
/* 创建定时器1 周期定时器 */
timer1 = rt_timer_create("timer1", timeout1,
RT_NULL, 10,
RT_TIMER_FLAG_PERIODIC);
/* 启动定时器1 */
if (timer1 != RT_NULL)
rt_timer_start(timer1);
/* 创建定时器2 单次定时器 */
timer2 = rt_timer_create("timer2", timeout2,
RT_NULL, 30,
RT_TIMER_FLAG_ONE_SHOT);
/* 启动定时器2 */
if (timer2 != RT_NULL)
rt_timer_start(timer2);
return 0;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT(timer_sample, timer sample);
Binary file modified bsp/qemu-virt64-aarch64/dump.dtb
Binary file not shown.
67 changes: 52 additions & 15 deletions bsp/qemu-virt64-aarch64/dump.dts
Original file line number Diff line number Diff line change
Expand Up @@ -381,38 +381,75 @@
compatible = "fixed-clock";
};

os_image {
nums = <1>;

os@0 {
vm {
vm@0 {
device_type = "virtual_machine";
vm_name = "qemu_vm0";
type = "rt-thread";
vmid = <0>;
type = <1>;
image_address = <0x0 0x45000000>;
entry = <0x0 0x40008000>;
vcpus = <1>;
kernel_image = "Image";
image_address = <0x0 0x46000000>;
vcpu_affinity = <1>;
memory = <0x0 0x40000000 0x0 0x600000>;
phymem = <0x0 0x47000000 0x0 0x1000000>;

vm0_device { /* need fix */
#address-cells = <0x1>;
#size-cells = <0x1>;

vtimer_irq = <27>;

vm0_vgic {
compatible = "arm,gicv3";
#address-cells = <0x1>;
#size-cells = <0x1>;
maintenance_interrupts = <25>;
virq_num = <128>;
/* GICD, GICR */
reg = <0x08000000 0x10000>, <0x080a0000 0x2000>;
};

vm0_vc {
virtual_device;
compatible = "rt_thread,vm_console";
reg = <0x09000000 0x00001000>;
interrupts = <0 0 33>;
};
};
};

vm@1 {
device_type = "virtual_machine";
vmid = <1>;
type = <1>;
image_address = <0x0 0x45000000>;
entry = <0x0 0x40008000>;
vcpus = <1>;
vcpu_affinity = <1>;
memory = <0x0 0x40000000 0x0 0x00600000>;
memory = <0x0 0x40000000 0x0 0x600000>;
phymem = <0x0 0x47000000 0x0 0x1000000>;

os0_device { /* need fix */
vm1_device { /* need fix */
#address-cells = <0x1>;
#size-cells = <0x1>;

vtimer_irq = <27>;

os0_vgic {
vm1_vgic {
compatible = "arm,gicv3";
#address-cells = <0x1>;
#size-cells = <0x1>;
reg = <0x2f000000 0x10000>, <0x2c000000 0x2000>;
maintenance_interrupts = <25>;
virq_num = <128>;
/* GICD, GICR */
reg = <0x08000000 0x10000>, <0x080a0000 0x2000>;
};

os0_vm_console {
vm1_vc {
virtual_device;
compatible = "rt_thread,vm_console";
reg = <0x20001000 0x2000>;
interrupts = <0 0 4>;
reg = <0x09000000 0x00001000>;
interrupts = <0 0 33>;
};
};
};
Expand Down
1 change: 0 additions & 1 deletion bsp/qemu-virt64-aarch64/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@

#define RT_HYPERVISOR
#define RT_USING_NVHE
#define ARM64_ERRATUM_1530923
#define MAX_VM_NUM 4
#define MAX_OS_NUM 3

Expand Down
53 changes: 53 additions & 0 deletions components/hypervisor/hyp_debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-10-28 Suqier first version
*/

#ifndef __HYP_DEBUG_H__
#define __HYP_DEBUG_H__

#include <rtthread.h>

typedef enum
{
HYP_LOG_ERR = 0, /* Error */
HYP_LOG_WARN, /* Warning */
HYP_LOG_INFO, /* Info */
HYP_LOG_DEBUG /* Debug */
}HYP_LOG_LVL;

#define HYP_LOG_LEVEL HYP_LOG_DEBUG

#define NONE "\033[m"
#define LIGHT_RED "\033[1;31m" /* error */
#define LIGHT_GREEN "\033[1;32m" /* success */
#define YELLOW "\033[1;33m" /* warning */
#define WHITE "\033[1;37m" /* info */
#define LIGHT_BLUE "\033[1;34m" /* debug */

#define hyp_err(fmt, ...) rt_kprintf(LIGHT_RED "[ERROR] "fmt"\n" NONE, ##__VA_ARGS__)

#define hyp_warn(fmt, ...) \
do{ \
if (HYP_LOG_LEVEL >= HYP_LOG_WARN) \
rt_kprintf(YELLOW "[WARN_] "fmt"\n" NONE, ##__VA_ARGS__); \
}while(0)

#define hyp_info(fmt, ...) \
do{ \
if (HYP_LOG_LEVEL >= HYP_LOG_INFO) \
rt_kprintf(WHITE "[INFO_] "fmt"\n" NONE, ##__VA_ARGS__); \
}while(0)

#define hyp_debug(fmt, ...) \
do{ \
if (HYP_LOG_LEVEL >= HYP_LOG_DEBUG) \
rt_kprintf(LIGHT_BLUE "[DEBUG] "fmt"\n" NONE, ##__VA_ARGS__); \
}while(0)

#endif /* __HYP_DEBUG_H__ */
2 changes: 1 addition & 1 deletion components/hypervisor/hyp_fdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifndef __HYP_FDT_H__
#define __HYP_FDT_H__

#include <fdt.h>
#include "packages/fdt/inc/fdt.h"



Expand Down
Loading