在ARM平台上启动2个nimbos,分别实现timer注入 #52
luodeb
started this conversation in
Show and tell
Replies: 3 comments 9 replies
-
多串口QEMU如果不能正常启动,考虑使用修改版的qemu git clone https://github.com/luodeb/qemu.git
./configure --enable-slirp --target-list=aarch64-softmmu,aarch64-linux-user --prefix=/path/to/qemu-9.2.0
make -j
make install
|
Beta Was this translation helpful? Give feedback.
0 replies
-
多平台下的适配同步
(1) crates/axvcpu/src/exit.rs #[non_exhaustive]
#[derive(Debug)]
pub enum AxVcpuFunction {
SetTimer { deadline: u64 },
None,
}
...
pub enum AxVCpuExitReason {
...
VcpuFuncCall(AxVcpuFunction),
...(2) arceos-umhv/arceos-vmm/src/vmm/vcpus.rs AxVCpuExitReason::VcpuFuncCall(func) => match func {
AxVcpuFunction::SetTimer { deadline } => {
let now = axhal::time::monotonic_time_nanos();
register_timer(deadline + now, |_| {
trace!("Timer expired: {}", axhal::time::monotonic_time_nanos());
let gich = axhal::irq::MyVgic::get_gich();
let hcr = gich.get_hcr();
gich.set_hcr(hcr | 1 << 0);
let mut lr = 0;
lr |= 30 << 0;
lr |= 1 << 19;
lr |= 1 << 28;
gich.set_lr(0, lr);
});
}
AxVcpuFunction::None => {}
_ => {
warn!("Unhandled AxVcpuFunction");
}
},我看到riscv也需要类似的东西,SbiCall,所以我们其实可以统一一下
let gich = axhal::irq::MyVgic::get_gich();
let hcr = gich.get_hcr();
gich.set_hcr(hcr | 1 << 0);
let mut lr = 0;
lr |= 30 << 0;
lr |= 1 << 19;
lr |= 1 << 28;
gich.set_lr(0, lr);这一部分非常的hack,需要在axhal中实现类似的方法,
AxVCpuExitReason::SysRegRead { addr, reg } => {
let exit = AxArchEmuRegs::<U>::emu_register_handle_read(
(*addr).into(),
*reg,
vcpu.clone(),
);
break AxVCpuExitReason::VcpuFuncCall(exit);
}
AxVCpuExitReason::SysRegWrite { addr, value } => {
let exit = AxArchEmuRegs::<U>::emu_register_handle_write(
(*addr).into(),
*value,
vcpu.clone(),
);
break AxVCpuExitReason::VcpuFuncCall(exit);
}
fn handle_read(&self, addr: GuestPhysAddr, width: usize, vcpu: &dyn VCpuIf) 定义一个统一的数据结构来传递vcpu_id,vcpu_num等信息,暂时没写,只传了整个vcpu
BOOT_PT_L1[2] = PageTableEntry::new_page(
PhysAddr::new(0x8000_0000),
MemFlags::READ | MemFlags::WRITE | MemFlags::EXECUTE,
true,
); |
Beta Was this translation helpful? Give feedback.
9 replies
-
|
asd |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Clone代码
新建创建项目的
clone.sh,然后bash clone.sh自动创建项目编译nimbos
因为加载到任意地址的功能还没有实现,所以只能通过硬配置来做,得单独编译两个nimbos
nimbos(VM1)
nimbos(VM2)
创建
disk.img文件生成一个disk.img,然后将编译好的nimbos.bin重命名并放入里面
启动VMM
就可以正常注入timer了
VM1
NN NN iii bb OOOOO SSSSS NNN NN mm mm mmmm bb OO OO SS NN N NN iii mmm mm mm bbbbbb OO OO SSSSS NN NNN iii mmm mm mm bb bb OO OO SS NN NN iii mmm mm mm bbbbbb OOOO0 SSSSS ___ ____ ___ ___ |__ \ / __ \ |__ \ |__ \ __/ / / / / / __/ / __/ / / __/ / /_/ / / __/ / __/ /____/ \____/ /____/ /____/ arch = aarch64 platform = qemu-virt-arm build_mode = release log_level = info Initializing kernel heap at: [0xffff0000401200e0, 0xffff0000405200e0) [INFO nimbos] Logging is enabled. Initializing frame allocator at: [PA:0x40521000, PA:0x48000000) Mapping .text: [0xffff000040080000, 0xffff000040094000) Mapping .rodata: [0xffff000040094000, 0xffff00004009b000) Mapping .data: [0xffff00004009b000, 0xffff00004011a000) Mapping .bss: [0xffff00004011e000, 0xffff000040521000) Mapping boot stack: [0xffff00004011a000, 0xffff00004011e000) Mapping physical memory: [0xffff000040521000, 0xffff000048000000) [ 0.280129 1:9 arceos_vmm::vmm::vcpus:243] VM[2] Vcpu[0] waiting for running [ 0.280591 1:9 arceos_vmm::vmm::vcpus:246] VM[2] Vcpu[0] running... Mapping MMIO: [0xffff000009000000, 0xffff000009001000) Mapping MMIO: [0xffff000008000000, 0xffff000008020000) Initializing drivers... [ 0.291414 0:8 arm_vgic::interrupt:76] Setting interrupt 30 enable to true Initializing task manager... /**** APPS **** cyclictest exit fantastic_text forktest forktest2 forktest_simple forktest_simple_c forktree hello_c hello_world matrix poweroff sleep sleep_simple stack_overflow thread_simple user_shell usertests yield **************/ Running tasks... test kernel task: pid = TaskId(2), arg = 0xdead [ 0.294993 INFO nimbos::task::structs][0:2] task exit with code 0 test kernel task: pid = TaskId(3), arg = 0xbeef [ 0.296126 INFO nimbos::task::structs][0:3] task exit with code 0 [ 0.296457 INFO nimbos::arch::aarch64::context][0:4] user task start: entry=0x211cfc, ustack=0xfffffffff000, kstack=0xffff000040138000 Rust user shell >> [ 0.298106 1:9 arm_vgic::interrupt:76] Setting interrupt 30 enable to true [ 3.349047 0:8 axhal::irq:23] Unhandled IRQ 33 s[ 3.583202 0:8 axhal::irq:23] Unhandled IRQ 33 l[ 3.898013 0:8 axhal::irq:23] Unhandled IRQ 33 e[ 4.067715 0:8 axhal::irq:23] Unhandled IRQ 33 e[ 4.214772 0:8 axhal::irq:23] Unhandled IRQ 33 p[ 4.829631 0:8 axhal::irq:23] Unhandled IRQ 33 [ 4.830637 INFO nimbos::arch::aarch64::context][0:5] user task start: entry=0x211d28, ustack=0xffffffffee10, kstack=0xffff000040134000 [ 4.832135 INFO nimbos::arch::aarch64::context][0:6] user task start: entry=0x210744, ustack=0xffffffffef40, kstack=0xffff000040130000 sleep 1 x 1 seconds. sleep 2 x 1 seconds. sleep 3 x 1 seconds. sleep 4 x 1 seconds. sleep 5 x 1 seconds. [ 9.879593 INFO nimbos::task::structs][0:6] task exit with code 0 use 5048222 usecs. sleep passed! [ 9.880587 INFO nimbos::task::structs][0:5] task exit with code 0 Shell: Process 5 exited with code 0 >> QEMU: TerminatedVM2
Beta Was this translation helpful? Give feedback.
All reactions