2016-08-14 00:34:27 +02:00
|
|
|
//! # The Redox OS Kernel, version 2
|
|
|
|
//!
|
|
|
|
//! The Redox OS Kernel is a hybrid kernel that supports X86 systems and
|
|
|
|
//! provides Unix-like syscalls for primarily Rust applications
|
2016-08-14 00:53:05 +02:00
|
|
|
//!
|
|
|
|
//! ## Syscalls
|
|
|
|
//! Syscalls in Redox are often handled by userspace `schemes`.
|
|
|
|
//! The essential syscalls in Redox are as follows:
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Open
|
|
|
|
//! `open(path: &str, flags: usize) -> Result<file_descriptor: usize>`
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Open a file, providing a path as a `&str` and flags, defined elsewhere.
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns a number, known as a file descriptor, that is passed to other syscalls
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Close
|
|
|
|
//! `close(file_descriptor: usize) -> Result<()>`
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Close a file descriptor, providing the file descriptor from `open`
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns an error, `EBADF`, if the file descriptor was not found.
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! This potential error is often ignored by userspace
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Duplicate
|
|
|
|
//! `dup(file_descriptor: usize) -> Result<file_descriptor: usize>`
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Duplicate a file descriptor, providing the file descriptor from `open`
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns a new file descriptor, or an error
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Read
|
|
|
|
//! `read(file_descriptor: usize, buffer: &mut [u8]) -> Result<count: usize>`
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Read from a file descriptor, providing the file descriptor from `open` and a mutable buffer
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns the number of bytes actually read, or an error
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Write
|
|
|
|
//! `write(file_descriptor: usize, buffer: &[u8]) -> Result<count: usize>`
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Write to a file descriptor, providing the file descriptor from `open` and a const buffer
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns the number of bytes actually written, or an error
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Stat
|
|
|
|
//! `fstat(file_descriptor: usize, stat: &mut Stat) -> Result<()>`
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Get information from a file descriptor, providing the file descriptor from `open`
|
|
|
|
//! and a mutable Stat struct, defined elsewhere.
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns an error if the operation failed
|
|
|
|
//!
|
2016-08-14 00:57:21 +02:00
|
|
|
//! ### Path
|
|
|
|
//! `fpath(file_descriptor: usize, buffer: &mut [u8]) -> Result<count: usize>`
|
|
|
|
//!
|
2016-08-14 02:21:46 +02:00
|
|
|
//! Read the path of a file descriptor, providing the file descriptor from `open` and
|
|
|
|
//! a mutable buffer.
|
|
|
|
//!
|
2016-08-14 00:53:05 +02:00
|
|
|
//! Returns the number of bytes actually read, or an error
|
2016-08-14 02:21:46 +02:00
|
|
|
//!
|
|
|
|
//! The buffer should be 4096 bytes, to ensure that the entire path will fit.
|
|
|
|
//! An error will be returned, `ENOBUFS`, if the buffer is not long enough for the name.
|
|
|
|
//! In this case, it is recommended to add one page, 4096 bytes, to the buffer and retry.
|
|
|
|
|
|
|
|
#![feature(asm)]
|
2016-08-14 02:58:31 +02:00
|
|
|
#![feature(const_fn)]
|
2016-08-14 17:31:35 +02:00
|
|
|
#![feature(core_intrinsics)]
|
2016-08-14 02:21:46 +02:00
|
|
|
#![feature(lang_items)]
|
|
|
|
#![feature(naked_functions)]
|
|
|
|
#![no_std]
|
|
|
|
|
2016-08-14 17:31:35 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate bitflags;
|
|
|
|
|
|
|
|
/// Print to console
|
|
|
|
macro_rules! print {
|
|
|
|
($($arg:tt)*) => ({
|
|
|
|
use $crate::core::fmt::Write;
|
|
|
|
let _ = write!($crate::arch::serial::SerialConsole::new(), $($arg)*);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Print with new line to console
|
|
|
|
macro_rules! println {
|
|
|
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
|
|
|
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
|
|
|
}
|
|
|
|
|
2016-08-14 02:21:46 +02:00
|
|
|
/// Architecture specific items
|
|
|
|
pub mod arch;
|
|
|
|
|
|
|
|
#[cfg(not(test))]
|
|
|
|
#[lang = "eh_personality"]
|
|
|
|
extern "C" fn eh_personality() {}
|
|
|
|
|
|
|
|
#[cfg(not(test))]
|
|
|
|
/// Required to handle panics
|
|
|
|
#[lang = "panic_fmt"]
|
|
|
|
extern "C" fn panic_fmt() -> ! {loop{}}
|
2016-08-14 17:31:35 +02:00
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
#[no_mangle]
|
|
|
|
/// Required to handle panics
|
|
|
|
pub extern "C" fn _Unwind_Resume() -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|