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, alloc 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 macros;
pub use crate::error::to_result;
pub use crate::error::Error;
pub use crate::error::Result;
pub use crate::types::bit;
pub use crate::types::bits_iter;
pub use crate::types::ARef;
pub use crate::types::AlwaysRefCounted;
pub use crate::types::Bit;
pub use crate::types::Bool;
pub use crate::types::Either;
pub use crate::types::Either::Left;
pub use crate::types::Either::Right;
pub use crate::types::False;
pub use crate::types::ForeignOwnable;
pub use crate::types::Mode;
pub use crate::types::Opaque;
pub use crate::types::ScopeGuard;
pub use crate::types::True;

Modules

Character devices.
Common clock framework.
Credentials management.
Delay functions for operations like sleeping.
Generic devices that are part of the kernel’s driver model.
Generic support for drivers of different buses (e.g., PCI, Platform, Amba, etc.).
Kernel errors.
Files and file descriptors.
File systems.
Support for gpio device drivers.
Hardware Random Number Generator.
Buffers used in IO.
Memory-mapped IO.
IO vector iterators.
Interrupts and interrupt chips.
Kernel async functionality.
KUnit-based macros for Rust unit tests.
Linked lists.
Miscellaneous devices.
Memory management.
Networking core.
Devicetree and Open Firmware abstractions.
Kernel page allocation and management.
Platform devices and drivers.
Power management interfaces.
The kernel prelude.
Printing facilities.
Random numbers.
Red-black trees.
Revocable objects.
Linux Security Modules (LSM).
String representations.
Synchronisation primitives.
sysctlCONFIG_SYSCTL
System control.
Tasks (threads and processes).
Kernel types.
Intrusive circular doubly-linked lists.
User pointers.
Work queues.

Macros

Creates a new BStr from a string literal.
Asserts that a boolean expression is true at compile time.
Fails the build if the code path calling build_error! can possibly be executed.
Creates a new CStr from a string literal.
Safely initialises a CondVar with the given name, generating a new lock class.
Produces a pointer to an object from a pointer to one of its fields.
Counts the number of comma-separated entries surrounded by braces.
Counts the number of parenthesis-delimited, comma-separated items.
std::dbg, but using pr_info instead of eprintln.
Defines the file system parameters of a given file system context.
Defines a new constant IdArray with a concise syntax.
Defines a new constant IdTable with a concise syntax.
Defines a const open firmware device id table that also carries per-entry data/context/info.
Prints an alert-level message (level 1) prefixed with device information.
Prints a critical-level message (level 2) prefixed with device information.
Prints a debug-level message (level 7) prefixed with device information.
Prints an emergency-level message (level 0) prefixed with device information.
Prints an error-level message (level 3) prefixed with device information.
Prints an info-level message (level 6) prefixed with device information.
Prints a notice-level message (level 5) prefixed with device information.
Prints a warning-level message (level 4) prefixed with device information.
Converts a comma-separated list of pairs into an array with the first element. That is, it discards the second element of the pair.
A convenience alias for core::format_args.
Registers a gpio chip with the rest of the kernel.
Registers a gpio chip and its irq chip with the rest of the kernel.
Implements the WorkAdapter trait for a type where its Work instance is a field.
Implements the WorkAdapter trait for an adapter type.
Automatically initialises static instances of synchronisation primitives.
Initialises a work item.
Initialises a work item with the given adapter.
Declares a kernel module that exposes a single driver.
Declares a kernel module that exposes a single file system.
Declares a kernel module that exposes a single misc device.
Declares a kernel module that exposes a single platform driver.
Safely initialises a Mutex with the given name, generating a new lock class.
Calculates the offset of a field from the beginning of the struct it belongs to.
Prints an alert-level message (level 1).
Continues a previous log message in the same line.
Prints a critical-level message (level 2).
Prints a debug-level message (level 7).
Prints an emergency-level message (level 0).
Prints an error-level message (level 3).
Prints an info-level message (level 6).
Prints a notice-level message (level 5).
Prints a warning-level message (level 4).
Safely initialises a RawSpinLock with the given name, generating a new lock class.
Safely initialises a Revocable instance with the given name, generating a new lock class.
Safely initialises a RwSemaphore with the given name, generating a new lock class.
Converts a comma-separated list of pairs into an array with the second element. That is, it discards the first element of the pair.
Spawns a new task to run in the given executor.
Spawns a new work item to run in the work queue.
Safely initialises a SpinLock with the given name, generating a new lock class.
Static assert (i.e. compile-time assert).

Structs

Scoped lock on the kernel parameters of ThisModule.
Equivalent to THIS_MODULE in the C API.

Constants

Page size defined in terms of the PAGE_SHIFT macro from C.

Traits

The top level entrypoint to implementing a kernel module.