Skip to main content

Crate patina

Crate patina 

Source
Expand description

Software Development Kit (SDK) for Patina

This crate implements the core SDK for Patina and is only part of the Patina solution. For general knowledge on Patina, refer to the Patina book.

§License

Copyright (C) Microsoft Corporation.

SPDX-License-Identifier: Apache-2.0

Modules§

arch
Arch Specific abstractions for Patina.
c_ptr
This module provides C pointer abstractions for safe pointer handling in Rust.
component
Module for creating UEFI components.
debug
Debug and diagnostics facilities for Patina.
error
Module for converting UEFI errors to rusty errors.
guid
Patina GUID type
hash
Hash utilities for Patina
management_mode
Management Mode (MM) definitions for Patina.
mmio
Re-export of the safe-mmio crate.
performance
Patina SDK Performance Module
peripheral
Device interface abstractions for Patina.
pi
Platform Initialization (PI) Specification Definitions and Support Code
protocol
Protocol interface abstraction and implementations for spec-defined protocols.
standard
This module contains industry standard definitions used by Patina.
string
Patina UEFI string types
uefi
UEFI specification definitions and interfaces.

Macros§

bit
A macro to generate a bit mask with the nth bit set.
char8
Builds a &'static Char8Str from a string literal, validated as Latin-1 at compile time.
char16
Builds a &'static Char16Str from a string literal, validated as UCS-2 at compile time.
devpath
Encodes a UEFI text device path as an owned byte array at compile time.
function
Gives a &'static str that is the name of the containing function.
log_debug_assert
Logs an error message and fires a debug_assert!(false) with the same message.
pci_address
Constructs a PCI library address from the given bus, device, function, and register values.
signature
Generates a UEFI-style signature from between 1 to 8 bytes, packing them into a u16, u32 or u64 as appropriate for the parameters passed.
uefi_pages_to_size
Converts a number of UEFI pages to the corresponding size in bytes.
uefi_size_to_pages
Converts a size in bytes to the number of UEFI pages required.
writelncrlf
Writes a line to the Writer target, followed by CRLF.

Structs§

BinaryGuid
A binary-compatible GUID wrapper for use in #[repr(C)] structures.
Char8Array
A fixed capacity, NUL-terminated CHAR8 (ASCII / ISO-Latin-1) string of N bytes.
Char8Str
A borrowed, NUL-terminated CHAR8 (ASCII / ISO-Latin-1) string.
Char8String
An owned, heap-backed, NUL-terminated CHAR8 (ASCII / ISO-Latin-1) string.
Char16Array
A fixed capacity, NUL-terminated UCS-2 (UEFI CHAR16) string of N code units.
Char16Str
A borrowed, NUL-terminated UCS-2 (UEFI CHAR16) string.
Char16String
An owned, heap-backed, NUL-terminated UCS-2 (UEFI CHAR16) string.

Enums§

Guid
A wrapper type for displaying UEFI GUIDs in a human-readable format.
GuidError
Error type for GUID parsing operations
StringError
Error returned when constructing or validating a UEFI string.

Constants§

DEFAULT_CACHE_ATTR
Patina uses write back as the default cache attribute for memory allocations.
SIZE_1GB
1GB, 0x40000000, 2^30
SIZE_1KB
1KB, 1024 bytes, 0x400, 2^10
SIZE_1MB
1MB, 0x100000, 2^20
SIZE_1TB
1TB, 0x10000000000, 2^40
SIZE_2GB
2GB, 0x80000000, 2^31
SIZE_2KB
2KB, 2048 bytes, 0x800, 2^11
SIZE_2MB
2MB, 0x200000, 2^21
SIZE_2TB
2TB, 0x20000000000, 2^41
SIZE_4GB
4GB, 0x100000000, 2^32
SIZE_4KB
4KB, 4096 bytes, 0x1000, 2^12
SIZE_4MB
4MB, 0x400000, 2^22
SIZE_4TB
4TB, 0x40000000000, 2^42
SIZE_8GB
8GB, 0x200000000, 2^33
SIZE_8KB
8KB, 8192 bytes, 0x2000, 2^13
SIZE_8MB
8MB, 0x800000, 2^23
SIZE_8TB
8TB, 0x80000000000, 2^43
SIZE_16GB
16GB, 0x400000000, 2^34
SIZE_16KB
16KB, 16384 bytes, 0x4000, 2^14
SIZE_16MB
16MB, 0x1000000, 2^24
SIZE_16TB
16TB, 0x100000000000, 2^44
SIZE_32GB
32GB, 0x800000000, 2^35
SIZE_32KB
32KB, 32768 bytes, 0x8000, 2^15
SIZE_32MB
32MB, 0x2000000, 2^25
SIZE_32TB
32TB, 0x200000000000, 2^45
SIZE_64GB
64GB, 0x1000000000, 2^36
SIZE_64KB
64KB, 65536 bytes, 0x10000, 2^16
SIZE_64MB
64MB, 0x4000000, 2^26
SIZE_64TB
64TB, 0x400000000000, 2^46
SIZE_128GB
128GB, 0x2000000000, 2^37
SIZE_128KB
128KB, 0x20000, 2^17
SIZE_128MB
128MB, 0x8000000, 2^27
SIZE_128TB
128TB, 0x800000000000, 2^47
SIZE_256GB
256GB, 0x4000000000, 2^38
SIZE_256KB
256KB, 0x40000, 2^18
SIZE_256MB
256MB, 0x10000000, 2^28
SIZE_256TB
256TB, 0x1000000000000, 2^48
SIZE_512GB
512GB, 0x8000000000, 2^39
SIZE_512KB
512KB, 0x80000, 2^19
SIZE_512MB
512MB, 0x20000000, 2^29
UEFI_PAGE_MASK
The mask to apply to an address to get the page offset in UEFI.
UEFI_PAGE_SHIFT
The shift to apply to an address to get the page frame number in UEFI.
UEFI_PAGE_SIZE
EFI memory allocation functions work in units of EFI_PAGEs that are 4KB. This should in no way be confused with the page size of the processor. An EFI_PAGE is just the quanta of memory in EFI.

Functions§

align_down
Aligns the given address down to the nearest boundary specified by align.
align_range
Aligns the given address down to the nearest boundary specified by align. Also calculates the aligned length based on the base and length provided.
align_up
Aligns the given address up to the nearest boundary specified by align.
is_power_of_two
Checks if the given value is a power of two. This function checks if the value x is greater than zero and if it is a power of two.
page_shift_from_alignment
Converts a page-aligned byte granularity to the corresponding bit shift value.

Type Aliases§

OwnedGuid
A GUID that owns its data and has no lifetime dependencies.