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.
cred
Credentials management.
device
Generic devices that are part of the kernel’s driver model.
device_id
Generic implementation of device IDs.
devres
Devres abstraction
dma
Direct memory access (DMA).
driver
Generic support for drivers of different buses (e.g., PCI, Platform, Amba, etc.).
error
Kernel errors.
faux
Abstractions for the faux bus.
firmware
Firmware abstraction
fs
Kernel file systems.
init
Extensions to the pin-init crate.
io
Memory-mapped IO.
ioctl
ioctl() number definitions.
jump_label
Logic for static keys.
kunit
KUnit-based macros for Rust unit tests.
list
A linked list implementation.
miscdevice
Miscdevice support.
net
Networking.
of
Device Tree / Open Firmware abstractions.
page
Kernel page allocation and management.
pci
Abstractions for the PCI bus.
pid_namespace
Pid namespaces.
platform
Abstractions for the platform bus.
prelude
The kernel prelude.
print
Printing facilities.
rbtree
Red-black trees.
revocable
Revocable objects.
security
Linux Security Modules (LSM).
seq_file
Seq file bindings.
sizes
Commonly used sizes.
str
String representations.
sync
Synchronisation primitives.
task
Tasks (threads and processes).
time
Time related primitives.
tracepoint
Logic for tracepoints.
transmute
Traits for transmuting types.
types
Kernel types.
uaccess
Slices to user space memory regions.
workqueue
Work queues.

Macros§

asm
Wrapper around asm! configured for use in the kernel.
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.
current_pid_ns
Returns the currently running task’s pid namespace.
dbg
std::dbg, but using pr_info instead of eprintln.
declare_trace
Declare the Rust entry point for a tracepoint.
define_list_arc_field_getter
Defines getters for a ListArcField.
dev_alert
Prints an alert-level message (level 1) prefixed with device information.
dev_crit
Prints a critical-level message (level 2) prefixed with device information.
dev_dbg
Prints a debug-level message (level 7) prefixed with device information.
dev_emerg
Prints an emergency-level message (level 0) prefixed with device information.
dev_err
Prints an error-level message (level 3) prefixed with device information.
dev_info
Prints an info-level message (level 6) prefixed with device information.
dev_notice
Prints a notice-level message (level 5) prefixed with device information.
dev_warn
Prints a warning-level message (level 4) prefixed with device information.
dma_read
Reads a field of an item from an allocated region of structs.
dma_write
Writes to a field of an item from an allocated region of structs.
fmt
A convenience alias for core::format_args.
global_lock
Defines a global lock.
impl_has_hr_timer
Use to implement the HasHrTimer<T> trait.
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.
kvec
Create a KVec containing the arguments.
module_device_table
Create device table alias for modpost.
module_driver
Declares a kernel module that exposes a single driver.
module_firmware
Create firmware .modinfo entries.
module_pci_driver
Declares a kernel module that exposes a single PCI driver.
module_phy_driver
Declares a kernel module for PHYs drivers.
module_platform_driver
Declares a kernel module that exposes a single platform driver.
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_poll_condvar
Creates a PollCondVar 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.
of_device_table
Create an OF IdTable with an “alias” for modpost.
pci_device_table
Create a PCI IdTable with its alias for modpost.
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).
seq_print
Write to a SeqFile with the ordinary Rust formatting syntax.
static_assert
Static assert (i.e. compile-time assert).
static_branch_unlikely
Branch based on a static key.
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§

InPlaceModule
A module that is pinned and initialised in-place.
Module
The top level entrypoint to implementing a kernel module.
ModuleMetadata
Metadata attached to a Module or InPlaceModule.