Call ucore cprintf

master
WangRunji 7 years ago
parent d3aa6039c0
commit 67aa3a0145

@ -35,7 +35,8 @@ mod ucore {
pub fn inode_init(inode: &mut INode, ops: &INodeOps, fs: &mut Fs); pub fn inode_init(inode: &mut INode, ops: &INodeOps, fs: &mut Fs);
pub fn inode_kill(inode: &mut INode); pub fn inode_kill(inode: &mut INode);
pub fn __alloc_fs(type_: i32) -> *mut Fs; pub fn __alloc_fs(type_: i32) -> *mut Fs;
pub fn __panic(file: *const u8, line: i32, fmt: *const u8); pub fn __panic(file: *const u8, line: i32, fmt: *const u8, ...);
pub fn cprintf(fmt: *const u8, ...);
fn cputchar(c: i32); fn cputchar(c: i32);
} }
pub const SFS_TYPE: i32 = 0; // TODO pub const SFS_TYPE: i32 = 0; // TODO
@ -46,6 +47,11 @@ mod ucore {
} }
} }
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)*); });
}
// Exports for ucore // Exports for ucore
static SFS_INODE_OPS: INodeOps = INodeOps::from_rust_inode::<sfs::INode>(); static SFS_INODE_OPS: INodeOps = INodeOps::from_rust_inode::<sfs::INode>();
@ -54,8 +60,8 @@ static SFS_INODE_OPS: INodeOps = INodeOps::from_rust_inode::<sfs::INode>();
#[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 {
use self::ucore::*; use self::ucore::*;
panic!("sfs_do_mount");
let fs = unsafe{__alloc_fs(SFS_TYPE)}; let fs = unsafe{__alloc_fs(SFS_TYPE)};
cprintf!("fs @ %x\n", fs);
let device = unsafe{ Box::from_raw(dev) }; // TODO: fix unsafe let device = unsafe{ Box::from_raw(dev) }; // TODO: fix unsafe
unsafe{&mut (*fs)}.fs = sfs::SimpleFileSystem::open(device).unwrap(); unsafe{&mut (*fs)}.fs = sfs::SimpleFileSystem::open(device).unwrap();
*fs_store = fs; *fs_store = fs;

@ -11,6 +11,7 @@
"linker-flavor": "ld", "linker-flavor": "ld",
"pre-link-args": ["-m32"], "pre-link-args": ["-m32"],
"eliminate-frame-pointer": false, "eliminate-frame-pointer": false,
"no-compiler-rt": true,
"morestack": false, "morestack": false,
"panic-strategy": "abort" "panic-strategy": "abort"
} }
Loading…
Cancel
Save