Skip to main content

Crate kernel

Crate kernel 

Source
Expand description

The kernel crate.

This crate contains the kernel APIs that have been ported or wrapped for usage by Rust code in the kernel and is shared by all of them.

In other words, all the rest of the Rust code in the kernel (e.g. kernel modules written in Rust) depends on core and this crate.

If you need a kernel C API that is not ported or wrapped yet here, then do so first instead of bypassing this crate.

Re-exports§

pub use ffi;
pub use macros;
pub use uapi;

Modules§

alloc
Implementation of the kernel’s memory allocation infrastructure.
block
Types for working with the block layer.
device
Generic devices that are part of the kernel’s driver model.
error
Kernel errors.
firmware
Firmware abstraction
init
API to safely and fallibly initialize pinned structs using in-place constructors.
ioctl
ioctl() number definitions.
list
A linked list implementation.
net
Networking.
page
Kernel page allocation and management.
prelude
The kernel prelude.
print
Printing facilities.
rbtree
Red-black trees.
sizes
Commonly used sizes.
str
String representations.
sync
Synchronisation primitives.
task
Tasks (threads and processes).
time
Time related primitives.
types
Kernel types.
uaccess
Slices to user space memory regions.
workqueue
Work queues.

Macros§

assert_pinned
Asserts that a field on a struct using #[pin_data] is marked with #[pin] ie. that it is structurally pinned.
b_str
Creates a new BStr from a string literal.
build_assert
Asserts that a boolean expression is true at compile time.
build_error
Fails the build if the code path calling build_error! can possibly be executed.
c_str
Creates a new CStr from a string literal.
container_of
Produces a pointer to an object from a pointer to one of its fields.
current
Returns the currently running task.
dbg
std::dbg, but using pr_info instead of eprintln.
define_list_arc_field_getter
Defines getters for a ListArcField.
fmt
A convenience alias for core::format_args.
impl_has_list_links
Implements the HasListLinks trait for the given type.
impl_has_list_links_self_ptr
Implements the HasListLinks and HasSelfPtr traits for the given type.
impl_has_work
Used to safely implement the HasWork<T, ID> trait.
impl_list_arc_safe
Declares that this type supports ListArc.
impl_list_item
Implements the ListItem trait for the given type.
init
Construct an in-place initializer for structs.
kvec
Create a KVec containing the arguments.
new_condvar
Creates a CondVar initialiser with the given name and a newly-created lock class.
new_mutex
Creates a Mutex initialiser with the given name and a newly-created lock class.
new_spinlock
Creates a SpinLock initialiser with the given name and a newly-created lock class.
new_work
Creates a Work initialiser with the given name and a newly-created lock class.
pin_init
Construct an in-place, pinned initializer for structs.
pr_alert
Prints an alert-level message (level 1).
pr_cont
Continues a previous log message in the same line.
pr_crit
Prints a critical-level message (level 2).
pr_debug
Prints a debug-level message (level 7).
pr_emerg
Prints an emergency-level message (level 0).
pr_err
Prints an error-level message (level 3).
pr_info
Prints an info-level message (level 6).
pr_notice
Prints a notice-level message (level 5).
pr_warn
Prints a warning-level message (level 4).
stack_pin_init
Initialize and pin a type directly on the stack.
stack_try_pin_init
Initialize and pin a type directly on the stack.
static_assert
Static assert (i.e. compile-time assert).
try_init
Construct an in-place fallible initializer for structs.
try_pin_init
Construct an in-place, fallible pinned initializer for structs.

Structs§

ThisModule
Equivalent to THIS_MODULE in the C API.

Traits§

Module
The top level entrypoint to implementing a kernel module.