| 40 | #[no_mangle] |
| 41 | #[link_section = ".text.entry"] |
| 42 | pub extern "C" fn _start(argc: usize, argv: usize) -> ! { |
| 43 | unsafe { |
| 44 | HEAP.lock() |
| 45 | .init(HEAP_SPACE.as_ptr() as usize, USER_HEAP_SIZE); |
| 46 | } |
| 47 | let mut v: Vec<&'static str> = Vec::new(); |
| 48 | for i in 0..argc { |
| 49 | let str_start = |
| 50 | unsafe { ((argv + i * core::mem::size_of::<usize>()) as *const usize).read_volatile() }; |
| 51 | let len = (0usize..) |
| 52 | .find(|i| unsafe { ((str_start + *i) as *const u8).read_volatile() == 0 }) |
| 53 | .unwrap(); |
| 54 | v.push( |
| 55 | core::str::from_utf8(unsafe { |
| 56 | core::slice::from_raw_parts(str_start as *const u8, len) |
| 57 | }) |
| 58 | .unwrap(), |
| 59 | ); |
| 60 | } |
| 61 | exit(main(argc, v.as_slice())); |
| 62 | } |
| 63 | |
| 64 | #[linkage = "weak"] |
| 65 | #[no_mangle] |