|
|
@ -1,4 +1,7 @@
|
|
|
|
//! C Interfaces for ucore
|
|
|
|
//! C Interfaces for ucore
|
|
|
|
|
|
|
|
//!
|
|
|
|
|
|
|
|
//! NOTE: Must link these sections:
|
|
|
|
|
|
|
|
//! `*.got.*` `*.data.*` `*.rodata.*`
|
|
|
|
|
|
|
|
|
|
|
|
use alloc::{rc::Rc, boxed::Box, BTreeMap};
|
|
|
|
use alloc::{rc::Rc, boxed::Box, BTreeMap};
|
|
|
|
use core::cell::RefCell;
|
|
|
|
use core::cell::RefCell;
|
|
|
@ -12,6 +15,7 @@ use vfs;
|
|
|
|
/// Lang items for bare lib
|
|
|
|
/// Lang items for bare lib
|
|
|
|
mod lang {
|
|
|
|
mod lang {
|
|
|
|
use core;
|
|
|
|
use core;
|
|
|
|
|
|
|
|
use alloc::fmt;
|
|
|
|
|
|
|
|
|
|
|
|
#[lang = "eh_personality"]
|
|
|
|
#[lang = "eh_personality"]
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
@ -22,9 +26,10 @@ mod lang {
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
|
|
|
extern fn panic_fmt(fmt: core::fmt::Arguments, file: &'static str, line: u32) -> ! {
|
|
|
|
use super::ucore::__panic;
|
|
|
|
use super::ucore::__panic;
|
|
|
|
// FIXME: can not use `format`, will cause page fault
|
|
|
|
let mut s = fmt::format(fmt);
|
|
|
|
// let mut s = fmt::format(fmt);
|
|
|
|
s.push('\0');
|
|
|
|
unsafe{ __panic(file.as_ptr(), line as i32, "Rust panic\0".as_ptr()) };
|
|
|
|
let file = format!("{}\0", file);
|
|
|
|
|
|
|
|
unsafe{ __panic(file.as_ptr(), line as i32, s.as_ptr()) };
|
|
|
|
unreachable!()
|
|
|
|
unreachable!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -43,15 +48,29 @@ mod ucore {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! cprintf {
|
|
|
|
#[macro_use]
|
|
|
|
($fmt:expr) => (unsafe{ ::c_interface::ucore::cprintf(concat!($fmt, "\0").as_ptr()); });
|
|
|
|
mod macros {
|
|
|
|
($fmt:expr, $($arg:tt)*) => (unsafe{ ::c_interface::ucore::cprintf(concat!($fmt, "\0").as_ptr(), $($arg)*); });
|
|
|
|
macro_rules! cprintf {
|
|
|
|
|
|
|
|
($fmt:expr) => (unsafe{ ::c_interface::ucore::cprintf(concat!($fmt, "\0").as_ptr()); });
|
|
|
|
|
|
|
|
($fmt:expr, $($arg:tt)*) => (unsafe{ ::c_interface::ucore::cprintf(concat!($fmt, "\0").as_ptr(), $($arg)*); });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! print {
|
|
|
|
|
|
|
|
($($arg:tt)*) => (unsafe{ ::c_interface::ucore::cprintf(format!($($arg)*).as_ptr())});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! println {
|
|
|
|
|
|
|
|
() => (print!("\n"));
|
|
|
|
|
|
|
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
|
|
|
|
|
|
|
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Exports for ucore
|
|
|
|
// Exports for ucore
|
|
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern fn sfs_do_mount(dev: *mut Device, fs_store: &mut *mut Fs) -> ErrorCode {
|
|
|
|
pub extern fn sfs_do_mount(dev: *mut Device, fs_store: &mut *mut Fs) -> ErrorCode {
|
|
|
|
|
|
|
|
print!("hello ucore {}", "!");
|
|
|
|
use sfs;
|
|
|
|
use sfs;
|
|
|
|
let fs = unsafe{ ucore::create_fs_for_sfs(&FS_OPS) };
|
|
|
|
let fs = unsafe{ ucore::create_fs_for_sfs(&FS_OPS) };
|
|
|
|
debug_assert!(!dev.is_null());
|
|
|
|
debug_assert!(!dev.is_null());
|
|
|
|