Crate kernel[][src]

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.

Modules

buffer

Struct for writing to a pre-allocated buffer with the write! macro.

c_types

C types for the bindings.

chrdev

Character devices.

file

Files and file descriptors.

file_operations

File operations.

io_buffer

Buffers used in IO.

iov_iter

IO vector iterators.

linked_list

Linked lists.

miscdev

Miscellaneous devices.

of

Devicetree and Open Firmware abstractions.

pages

Kernel page allocation and management.

platdev

Platform devices.

prelude

The kernel prelude.

print

Printing facilities.

random

Random numbers.

rbtree

Red-black trees.

security

Linux Security Modules (LSM).

str

String representations.

sync

Synchronisation primitives.

sysctl

System control.

task

Tasks (threads and processes).

traits

Traits useful to drivers, and their implementations for common types.

user_ptr

User pointers.

Macros

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.

condvar_init

Safely initialises a CondVar with the given name, generating a new lock class.

container_of

Produces a pointer to an object from a pointer to one of its fields.

declare_file_operations

Defines the FileOperations::TO_USE field based on a list of fields to be populated.

from_kernel_result

Transforms a crate::error::Result<T> to a kernel C integer result.

mutex_init

Safely initialises a Mutex with the given name, generating a new lock class.

offset_of

Calculates the offset of a field from the beginning of the struct it belongs to.

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_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).

spinlock_init

Safely initialises a SpinLock with the given name, generating a new lock class.

static_assert

Static assert (i.e. compile-time assert).

Structs

Error

Generic integer kernel error.

KParamGuard

Scoped lock on the kernel parameters of ThisModule.

Mode

Permissions.

ScopeGuard

Runs a cleanup function/closure when dropped.

ThisModule

Equivalent to THIS_MODULE in the C API.

Constants

PAGE_SIZE

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

Traits

KernelModule

The top level entrypoint to implementing a kernel module.

Type Definitions

Result

A Result with an Error error type.