Crate kernel[][src]

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_operations

File operations.

linked_list

Linked lists.

miscdev

Miscellaneous devices.

pages

Kernel page allocation and management.

prelude

The kernel prelude.

print

Printing facilities.

random

Random numbers.

sync

Synchronisation primitives.

user_ptr

User pointers.

Macros

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.

cstr

Creates a new CStr from a string literal.

declare_file_operations

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

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

CStr

A string that is guaranteed to have exactly one NUL byte, which is at the end.

Error

Generic integer kernel error.

KParamGuard

Scoped lock on the kernel parameters of ThisModule.

Mode

Permissions.

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

KernelResult

A Result with an Error error type.