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 {
|
macro_rules! define_entry {
|
||||||
() => {
|
() => {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn _start(init_port: mammoth::zion::z_cap_t) -> ! {
|
pub extern "C" fn _start(init_port: $crate::zion::z_cap_t) -> ! {
|
||||||
extern "C" {
|
$crate::init::parse_init_port(init_port);
|
||||||
fn main() -> z_err_t;
|
$crate::mem::init_heap();
|
||||||
}
|
|
||||||
mammoth::init::parse_init_port(init_port);
|
let resp = main();
|
||||||
mammoth::mem::init_heap();
|
|
||||||
unsafe {
|
$crate::syscall::process_exit(resp);
|
||||||
let err = main();
|
|
||||||
let req = mammoth::zion::ZProcessExitReq { code: err };
|
|
||||||
let _ = mammoth::syscall::syscall(mammoth::zion::kZionProcessExit, &req);
|
|
||||||
}
|
|
||||||
unreachable!()
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use core::ffi::c_void;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn syscall<T>(id: u64, req: &T) -> Result<(), ZError> {
|
fn syscall<T>(id: u64, req: &T) -> Result<(), ZError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let resp = zion::SysCall1(id, req as *const T as *const c_void);
|
let resp = zion::SysCall1(id, req as *const T as *const c_void);
|
||||||
if resp != 0 {
|
if resp != 0 {
|
||||||
|
@ -40,6 +40,12 @@ pub fn debug(msg: &str) {
|
||||||
syscall(zion::kZionDebug, &req).expect("Failed to write");
|
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> {
|
pub fn thread_create(proc_cap: z_cap_t) -> Result<z_cap_t, ZError> {
|
||||||
let mut cap = 0;
|
let mut cap = 0;
|
||||||
syscall(
|
syscall(
|
||||||
|
|
Loading…
Reference in New Issue