File tree Expand file tree Collapse file tree 5 files changed +41
-38
lines changed Expand file tree Collapse file tree 5 files changed +41
-38
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ fn main() {
4
4
let ld = PathBuf :: from ( env:: var_os ( "OUT_DIR" ) . unwrap ( ) ) . join ( "linker.ld" ) ;
5
5
fs:: write ( & ld, LINKER ) . unwrap ( ) ;
6
6
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
7
+ println ! ( "cargo:rerun-if-env-changed=LOG" ) ;
7
8
println ! ( "cargo:rustc-link-arg=-T{}" , ld. display( ) ) ;
8
9
}
9
10
@@ -14,29 +15,25 @@ MEMORY {
14
15
DRAM : ORIGIN = 0x80200000, LENGTH = 64M
15
16
}
16
17
SECTIONS {
17
- .text : ALIGN(4) {
18
+ .text : {
18
19
*(.text.entry)
19
20
*(.text .text.*)
20
21
} > DRAM
21
- .rodata : ALIGN(8) {
22
- srodata = .;
22
+ .rodata : {
23
23
*(.rodata .rodata.*)
24
24
*(.srodata .srodata.*)
25
- . = ALIGN(8);
26
- erodata = .;
27
25
} > DRAM
28
- .data : ALIGN(8) {
29
- sdata = .;
26
+ .data : {
30
27
*(.data .data.*)
31
28
*(.sdata .sdata.*)
32
- . = ALIGN(8);
33
- edata = .;
34
29
} > DRAM
35
- .bss (NOLOAD) : ALIGN(8) {
30
+ .bss (NOLOAD) : {
36
31
*(.bss.uninit)
32
+ . = ALIGN(8);
37
33
sbss = .;
38
34
*(.bss .bss.*)
39
35
*(.sbss .sbss.*)
36
+ . = ALIGN(8);
40
37
ebss = .;
41
38
} > DRAM
42
39
/DISCARD/ : {
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ extern "C" fn rust_main(hartid: usize, _dtb_pa: usize) -> ! {
47
47
// 测试调用延迟
48
48
let t0 = time:: read ( ) ;
49
49
50
- for _ in 0 ..0xffff {
50
+ for _ in 0 ..0x20000 {
51
51
let _ = sbi_rt:: get_marchid ( ) ;
52
52
}
53
53
@@ -56,21 +56,25 @@ extern "C" fn rust_main(hartid: usize, _dtb_pa: usize) -> ! {
56
56
// 测试中断响应延迟
57
57
let t0 = time:: read ( ) ;
58
58
59
- for _ in 0 ..0xffff {
59
+ for _ in 0 ..0x20000 {
60
60
unsafe {
61
61
core:: arch:: asm!(
62
62
" la {0}, 1f
63
63
csrw stvec, {0}
64
+ mv a0, a2
65
+ mv a1, zero
64
66
ecall
65
67
wfi
66
68
.align 2
67
- 1:
69
+ 1: csrrci zero, sip, 1 << 1
70
+
68
71
" ,
69
72
out( reg) _,
70
73
in( "a7" ) 0x735049 ,
71
74
in( "a6" ) 0 ,
72
- in( "a0" ) 1 << hartid ,
75
+ in( "a0" ) 0 ,
73
76
in( "a1" ) 0 ,
77
+ in( "a2" ) 1 << hartid,
74
78
options( nomem) ,
75
79
) ;
76
80
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ fn main() {
4
4
let ld = & PathBuf :: from ( env:: var_os ( "OUT_DIR" ) . unwrap ( ) ) . join ( "linker.ld" ) ;
5
5
fs:: write ( ld, LINKER ) . unwrap ( ) ;
6
6
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
7
+ println ! ( "cargo:rerun-if-env-changed=LOG" ) ;
7
8
println ! ( "cargo:rustc-link-arg=-T{}" , ld. display( ) ) ;
8
9
}
9
10
Original file line number Diff line number Diff line change @@ -53,10 +53,11 @@ unsafe extern "C" fn mtimer() {
53
53
// mscratch: S sp
54
54
" csrrw sp, mscratch, sp" ,
55
55
// 保护
56
- " sd ra, -1*8(sp)
57
- sd a0, -2*8(sp)
58
- sd a1, -3*8(sp)
59
- sd a2, -4*8(sp)
56
+ " addi sp, sp, -4*8
57
+ sd ra, 0*8(sp)
58
+ sd a0, 1*8(sp)
59
+ sd a1, 2*8(sp)
60
+ sd a2, 3*8(sp)
60
61
" ,
61
62
// 清除 mtimecmp
62
63
" la a0, {clint_ptr}
@@ -70,10 +71,11 @@ unsafe extern "C" fn mtimer() {
70
71
csrrs zero, mip, a0
71
72
" ,
72
73
// 恢复
73
- " ld ra, -1*8(sp)
74
- ld a0, -2*8(sp)
75
- ld a1, -3*8(sp)
76
- ld a2, -4*8(sp)
74
+ " ld ra, 0*8(sp)
75
+ ld a0, 1*8(sp)
76
+ ld a1, 2*8(sp)
77
+ ld a2, 3*8(sp)
78
+ addi sp, sp, 4*8
77
79
" ,
78
80
// 换栈:
79
81
// sp : S sp
@@ -103,9 +105,10 @@ unsafe extern "C" fn msoft() {
103
105
// mscratch: S sp
104
106
" csrrw sp, mscratch, sp" ,
105
107
// 保护
106
- " sd ra, -1*8(sp)
107
- sd a0, -2*8(sp)
108
- sd a1, -3*8(sp)
108
+ " addi sp, sp, -3*8
109
+ sd ra, 0*8(sp)
110
+ sd a0, 1*8(sp)
111
+ sd a1, 2*8(sp)
109
112
" ,
110
113
// 清除 msip 设置 ssip
111
114
" la a0, {clint_ptr}
@@ -115,9 +118,10 @@ unsafe extern "C" fn msoft() {
115
118
csrrsi zero, mip, 1 << 1
116
119
" ,
117
120
// 恢复
118
- " ld ra, -1*8(sp)
119
- ld a0, -2*8(sp)
120
- ld a1, -3*8(sp)
121
+ " ld ra, 0*8(sp)
122
+ ld a0, 1*8(sp)
123
+ ld a1, 2*8(sp)
124
+ addi sp, sp, 3*8
121
125
" ,
122
126
// 换栈:
123
127
// sp : S sp
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ fn main() {
4
4
let ld = PathBuf :: from ( env:: var_os ( "OUT_DIR" ) . unwrap ( ) ) . join ( "linker.ld" ) ;
5
5
fs:: write ( & ld, LINKER ) . unwrap ( ) ;
6
6
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
7
+ println ! ( "cargo:rerun-if-env-changed=LOG" ) ;
7
8
println ! ( "cargo:rustc-link-arg=-T{}" , ld. display( ) ) ;
8
9
}
9
10
@@ -14,29 +15,25 @@ MEMORY {
14
15
DRAM : ORIGIN = 0x80200000, LENGTH = 64M
15
16
}
16
17
SECTIONS {
17
- .text : ALIGN(4) {
18
+ .text : {
18
19
*(.text.entry)
19
20
*(.text .text.*)
20
21
} > DRAM
21
- .rodata : ALIGN(8) {
22
- srodata = .;
22
+ .rodata : {
23
23
*(.rodata .rodata.*)
24
24
*(.srodata .srodata.*)
25
- . = ALIGN(8);
26
- erodata = .;
27
25
} > DRAM
28
- .data : ALIGN(8) {
29
- sdata = .;
26
+ .data : {
30
27
*(.data .data.*)
31
28
*(.sdata .sdata.*)
32
- . = ALIGN(8);
33
- edata = .;
34
29
} > DRAM
35
- .bss (NOLOAD) : ALIGN(8) {
30
+ .bss (NOLOAD) : {
36
31
*(.bss.uninit)
32
+ . = ALIGN(8);
37
33
sbss = .;
38
34
*(.bss .bss.*)
39
35
*(.sbss .sbss.*)
36
+ . = ALIGN(8);
40
37
ebss = .;
41
38
} > DRAM
42
39
/DISCARD/ : {
You can’t perform that action at this time.
0 commit comments