kernel - Rust
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 module:: InPlaceModule ; pub use module:: Module ; pub use module:: ModuleMetadata ; pub use module:: ThisModule ; pub use ffi ; pub use macros ; pub use uapi; Modules § acpi Advanced Configuration and Power Interface abstractions. alloc Implementation of the kernel’s memory allocation infrastructure. auxiliary Abstractions for the auxiliary bus. bitfield Support for defining bitfields as Rust structures. bitmap Rust API for bitmap. bits Bit manipulation macros. block Types for working with the block layer. bug Support for BUG and WARN functionality. build_ assert Various assertions that happen during build-time. clk Clock abstractions. configfs configfs interface: Userspace-driven Kernel Object Configuration cpu Generic CPU definitions. cpufreq CPU frequency scaling. cpumask CPU Mask abstractions. cred Credentials management. debugfs DebugFS Abstraction 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). dma_buf DMA-buf subsystem abstractions. driver Generic support for drivers of different buses (e.g., PCI, Platform, Amba, etc.). drm DRM subsystem abstractions. error Kernel errors. faux Abstractions for the faux bus. firmware Firmware abstraction fmt Formatting utilities. fs Kernel file systems. fwctl Abstractions for the fwctl subsystem. gpu GPU subsystem abstractions. i2c I2C Driver subsystem id_pool Rust API for an ID pool backed by a BitmapVec . init Extensions to the pin-init crate. interop Infrastructure for interfacing Rust code with C kernel subsystems. interrupt Interrupt controls io Memory-mapped IO. ioctl ioctl() number definitions. iommu Rust support related to IOMMU. iov IO vectors. irq IRQ abstractions. jump_ label Logic for static keys. kunit KUnit-based macros for Rust unit tests. list A linked list implementation. maple_ tree Maple trees. mem Basic utilities for dealing with memory, values, and types. miscdevice Miscdevice support. mm Memory management. module Module-related types and helpers. module_ param Support for module parameters. net Networking. num Additional numerical features for the kernel. of Device Tree / Open Firmware abstractions. opp Operating performance points. 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. processor Processor related primitives. ptr Types and functions to work with pointers and addresses. pwm PWM subsystem abstractions. ratelimit Rate limiting support. rbtree Red-black trees. regulator Regulator abstractions, providing a standard kernel interface to control voltage and current regulators. revocable Revocable objects. rxarray Rust XArray implementation. safety Safety related APIs. scatterlist Abstractions for scatter-gather lists. security Linux Security Modules (LSM). seq_ file Seq file bindings. serdev Abstractions for the serial device bus. sizes Commonly used sizes. soc SoC Driver Abstraction. 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. usb Abstractions for the USB bus. workqueue Work queues. xarray XArray abstraction.
Macros § acpi_ device_ table Create an ACPI IdTable with an “alias” for modpost. 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. bitfield Defines a bitfield struct with bounds-checked accessors for individual bit ranges. c_str Creates a new CStr at compile time. clist_ create Create a C doubly-circular linked list interface CList from a raw list_head pointer. configfs_ attrs Define a list of configfs attributes statically. 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 . declare_ drm_ ioctls Declare the DRM ioctls for a driver. declare_ trace Declare the Rust entry point for a tracepoint. 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. do_ once_ lite Run the given function exactly once. global_ lock Defines a global lock. i2c_ device_ table Create a I2C IdTable with its alias for modpost. impl_ aref_ for_ gem_ obj A macro for implementing AlwaysRefCounted for any GEM object type. impl_ device_ context_ deref Implement core::ops::Deref traits for allowed DeviceContext conversions of a (bus specific) device. impl_ device_ context_ into_ aref Implement core::convert::From , such that all &Device<Ctx> can be converted to an ARef<Device> . impl_ flags Common helper for declaring bitflag and bitmask types. impl_ has_ delayed_ work Used to safely implement the HasDelayedWork<T, ID> trait. impl_ has_ hr_ timer Use to implement the HasHrTimer<T> trait. impl_ has_ work Used to safely implement the HasWork<T, ID> trait. 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_ i2c_ driver Declares a kernel module that exposes a single i2c driver. 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. module_ pwm_ platform_ driver Declares a kernel module that exposes a single PWM driver. module_ serdev_ device_ driver Declares a kernel module that exposes a single serial device bus device driver. module_ usb_ driver Declares a kernel module that exposes a single USB driver. new_ condvar Creates a CondVar initialiser with the given name and a newly-created lock class. new_ delayed_ work Creates a DelayedWork 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_ spinlock_ irq Creates a SpinLockIrq 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 m
The rest of this page is on the live site.