Add more special redox functions

parent c6d42dd9
Pipeline #2233 passed with stages
in 10 minutes and 31 seconds
......@@ -10,6 +10,10 @@ extern "C" {
#ifdef __redox__
ssize_t redox_fpath(int fd, void * buf, size_t count);
void * redox_physalloc(size_t size);
int redox_physfree(void * physical_address, size_t size);
void * redox_physmap(void * physical_address, size_t size, int flags);
int redox_physunmap(void * virtual_address);
#endif
......
use core::slice;
use core::{ptr, slice};
use platform::sys::e;
use platform::types::*;
use super::e;
#[no_mangle]
pub unsafe extern "C" fn redox_fpath(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t {
e(syscall::fpath(fd as usize, slice::from_raw_parts_mut(buf as *mut u8, count))) as ssize_t
}
#[no_mangle]
pub unsafe extern "C" fn redox_physalloc(size: size_t) -> *mut c_void {
let res = e(syscall::physalloc(size));
if res == !0 {
return ptr::null_mut();
} else {
return res as *mut c_void
}
}
#[no_mangle]
pub unsafe extern "C" fn redox_physfree(physical_address: *mut c_void, size: size_t) -> c_int {
e(syscall::physfree(physical_address as usize, size)) as c_int
}
#[no_mangle]
pub unsafe extern "C" fn redox_physmap(physical_address: *mut c_void, size: size_t, flags: c_int) -> *mut c_void {
let res = e(syscall::physmap(physical_address as usize, size, flags as usize));
if res == !0 {
return ptr::null_mut();
} else {
return res as *mut c_void
}
}
#[no_mangle]
pub unsafe extern "C" fn redox_physunmap(virtual_address: *mut c_void) -> c_int {
e(syscall::physunmap(virtual_address as usize)) as c_int
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment