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.
- 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-initcrate.
- io
- Memory-mapped IO.
- ioctl
- ioctl()number definitions.
- jump_label 
- Logic for static keys.
- 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 kernelprelude.
- 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 BStrfrom a string literal.
- build_assert 
- Asserts that a boolean expression is trueat compile time.
- build_error 
- Fails the build if the code path calling build_error!can possibly be executed.
- c_str
- Creates a new CStrfrom 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_infoinstead 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 HasListLinkstrait for the given type.
- impl_has_ list_ links_ self_ ptr 
- Implements the HasListLinksandHasSelfPtrtraits 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 ListItemtrait for the given type.
- kvec
- Create a KVeccontaining 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_platform_ driver 
- Declares a kernel module that exposes a single platform driver.
- new_condvar 
- Creates a CondVarinitialiser with the given name and a newly-created lock class.
- new_mutex 
- Creates a Mutexinitialiser with the given name and a newly-created lock class.
- new_poll_ condvar 
- Creates a PollCondVarinitialiser with the given name and a newly-created lock class.
- new_spinlock 
- Creates a SpinLockinitialiser with the given name and a newly-created lock class.
- new_work 
- Creates a Workinitialiser with the given name and a newly-created lock class.
- of_device_ table 
- Create an OF IdTablewith an “alias” for modpost.
- pci_device_ table 
- Create a PCI IdTablewith 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 SeqFilewith 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_MODULEin 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 ModuleorInPlaceModule.