1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use core::{cell::UnsafeCell, ptr};
extern "C" {
static BSS_START: UnsafeCell<usize>;
static BSS_END: UnsafeCell<usize>;
static DATA_LOAD: UnsafeCell<usize>;
static DATA_START: UnsafeCell<usize>;
static DATA_END: UnsafeCell<usize>;
}
pub unsafe fn bss_init() {
unsafe {
let length = BSS_END.get() as usize - BSS_START.get() as usize;
ptr::write_bytes(BSS_START.get(), 0, length >> 2);
}
}
pub unsafe fn data_init() {
unsafe {
let length = DATA_END.get() as usize - DATA_START.get() as usize;
ptr::copy_nonoverlapping(DATA_LOAD.get(), DATA_START.get(), length >> 2);
}
}