File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -34,20 +34,51 @@ extern "C" fn rust_main(hartid: usize, _dtb_pa: usize) -> ! {
34
34
static mut ebss: u64 ;
35
35
}
36
36
unsafe { r0:: zero_bss ( & mut sbss, & mut ebss) } ;
37
+ // 初始化打印
37
38
unsafe { UART = MaybeUninit :: new ( MmioSerialPort :: new ( 0x1000_0000 ) ) } ;
38
39
rcore_console:: init_console ( & Console ) ;
39
40
rcore_console:: set_log_level ( option_env ! ( "LOG" ) ) ;
40
41
rcore_console:: test_log ( ) ;
42
+ // 打开软中断
43
+ unsafe {
44
+ sie:: set_ssoft ( ) ;
45
+ sstatus:: set_sie ( ) ;
46
+ } ;
47
+ // 测试调用延迟
48
+ let t0 = time:: read ( ) ;
41
49
50
+ for _ in 0 ..0xffff {
51
+ let _ = sbi_rt:: get_marchid ( ) ;
52
+ }
53
+
54
+ let t1 = time:: read ( ) ;
55
+ log:: info!( "marchid duration = {}" , t1 - t0) ;
56
+ // 测试中断响应延迟
42
57
let t0 = time:: read ( ) ;
43
58
44
59
for _ in 0 ..0xffff {
45
- let _ = sbi_rt:: send_ipi ( 1 << hartid, 0 ) ;
60
+ unsafe {
61
+ core:: arch:: asm!(
62
+ " la {0}, 1f
63
+ csrw stvec, {0}
64
+ ecall
65
+ wfi
66
+ .align 2
67
+ 1:
68
+ " ,
69
+ out( reg) _,
70
+ in( "a7" ) 0x735049 ,
71
+ in( "a6" ) 0 ,
72
+ in( "a0" ) 1 << hartid,
73
+ in( "a1" ) 0 ,
74
+ options( nomem) ,
75
+ ) ;
76
+ }
46
77
}
47
78
48
79
let t1 = time:: read ( ) ;
80
+ log:: info!( "ipi duration = {}" , t1 - t0) ;
49
81
50
- log:: info!( "{}" , t1 - t0) ;
51
82
system_reset ( Shutdown , NoReason ) ;
52
83
unreachable ! ( )
53
84
}
You can’t perform that action at this time.
0 commit comments