Moved process exit to syscall helper.
Final call moved so syscall is private now. Also cleans up the macro a fair bit.
This commit is contained in:
parent
c2f9f5388b
commit
d4f60f4942
|
@ -50,18 +50,13 @@ macro_rules! debug {
|
|||
macro_rules! define_entry {
|
||||
() => {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _start(init_port: mammoth::zion::z_cap_t) -> ! {
|
||||
extern "C" {
|
||||
fn main() -> z_err_t;
|
||||
}
|
||||
mammoth::init::parse_init_port(init_port);
|
||||
mammoth::mem::init_heap();
|
||||
unsafe {
|
||||
let err = main();
|
||||
let req = mammoth::zion::ZProcessExitReq { code: err };
|
||||
let _ = mammoth::syscall::syscall(mammoth::zion::kZionProcessExit, &req);
|
||||
}
|
||||
unreachable!()
|
||||
pub extern "C" fn _start(init_port: $crate::zion::z_cap_t) -> ! {
|
||||
$crate::init::parse_init_port(init_port);
|
||||
$crate::mem::init_heap();
|
||||
|
||||
let resp = main();
|
||||
|
||||
$crate::syscall::process_exit(resp);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use core::ffi::c_void;
|
|||
use core::panic::PanicInfo;
|
||||
|
||||
#[must_use]
|
||||
pub fn syscall<T>(id: u64, req: &T) -> Result<(), ZError> {
|
||||
fn syscall<T>(id: u64, req: &T) -> Result<(), ZError> {
|
||||
unsafe {
|
||||
let resp = zion::SysCall1(id, req as *const T as *const c_void);
|
||||
if resp != 0 {
|
||||
|
@ -40,6 +40,12 @@ pub fn debug(msg: &str) {
|
|||
syscall(zion::kZionDebug, &req).expect("Failed to write");
|
||||
}
|
||||
|
||||
pub fn process_exit(code: u64) -> ! {
|
||||
let _ = syscall(zion::kZionProcessExit, &zion::ZProcessExitReq { code });
|
||||
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
pub fn thread_create(proc_cap: z_cap_t) -> Result<z_cap_t, ZError> {
|
||||
let mut cap = 0;
|
||||
syscall(
|
||||
|
|
Loading…
Reference in New Issue