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§
Modules§
- alloc
- Implementation of the kernel’s memory allocation infrastructure.
- auxiliary
- Abstractions for the auxiliary bus.
- 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.
- mm
- Memory management.
- 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. - 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. - auxiliary_
device_ table - Create a auxiliary
IdTable
with its alias for modpost. - 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 usingpr_info
instead ofeprintln
.- 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_
device_ context_ deref - Implement
core::ops::Deref
traits for allowedDeviceContext
conversions of a (bus specific) device. - impl_
device_ context_ into_ aref - Implement
core::convert::From
, such that all&Device<Ctx>
can be converted to anARef<Device>
. - 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
andHasSelfPtr
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_
auxiliary_ driver - Declares a kernel module that exposes a single auxiliary driver.
- 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
struct
s. - try_
pin_ init - Construct an in-place, fallible pinned initializer for
struct
s.
Structs§
- This
Module - Equivalent to
THIS_MODULE
in the C API.
Traits§
- InPlace
Module - A module that is pinned and initialised in-place.
- Module
- The top level entrypoint to implementing a kernel module.
- Module
Metadata - Metadata attached to a
Module
orInPlaceModule
.