aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / uefi-raw / src / protocol / tcg / v1.rs
| 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 2 | |
| 3 | //! [TCG] (Trusted Computing Group) protocol for [TPM] (Trusted Platform |
| 4 | //! Module) 1.1 and 1.2. |
| 5 | //! |
| 6 | //! This protocol is defined in the [TCG EFI Protocol Specification _for |
| 7 | //! TPM Family 1.1 or 1.2_][spec]. |
| 8 | //! |
| 9 | //! [spec]: https://trustedcomputinggroup.org/resource/tcg-efi-protocol-specification/ |
| 10 | //! [TCG]: https://trustedcomputinggroup.org/ |
| 11 | //! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module |
| 12 | |
| 13 | use crate::{Guid, PhysicalAddress, Status, guid}; |
| 14 | use core::ffi::c_void; |
| 15 | |
| 16 | /// Information about the protocol and the TPM device. |
| 17 | #[repr(C)] |
| 18 | #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd)] |
| 19 | pub struct TcgBootServiceCapability { |
| 20 | pub size: u8, |
| 21 | pub structure_version: TcgVersion, |
| 22 | pub protocol_spec_version: TcgVersion, |
| 23 | pub hash_algorithm_bitmap: u8, |
| 24 | pub tpm_present_flag: u8, |
| 25 | pub tpm_deactivated_flag: u8, |
| 26 | } |
| 27 | |
| 28 | /// Version information. |
| 29 | #[repr(C)] |
| 30 | #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd)] |
| 31 | pub struct TcgVersion { |
| 32 | /// Major version. |
| 33 | pub major: u8, |
| 34 | /// Minor version. |
| 35 | pub minor: u8, |
| 36 | |
| 37 | pub rev_major: u8, |
| 38 | pub rev_minor: u8, |
| 39 | } |
| 40 | |
| 41 | /// Protocol for interacting with TPM 1.1 and 1.2 devices. |
| 42 | #[derive(Debug)] |
| 43 | #[repr(C)] |
| 44 | pub struct TcgProtocol { |
| 45 | pub status_check: unsafe extern "efiapi" fn( |
| 46 | this: *mut Self, |
| 47 | protocol_capability: *mut TcgBootServiceCapability, |
| 48 | feature_flags: *mut u32, |
| 49 | event_log_location: *mut PhysicalAddress, |
| 50 | event_log_last_entry: *mut PhysicalAddress, |
| 51 | ) -> Status, |
| 52 | |
| 53 | pub hash_all: unsafe extern "efiapi" fn( |
| 54 | this: *mut Self, |
| 55 | hash_data: *const u8, |
| 56 | hash_data_len: u64, |
| 57 | algorithm_id: u32, |
| 58 | hashed_data_len: *mut u64, |
| 59 | hashed_data_result: *mut *mut u8, |
| 60 | ) -> Status, |
| 61 | |
| 62 | pub log_event: unsafe extern "efiapi" fn( |
| 63 | this: *mut Self, |
| 64 | event: *const c_void, |
| 65 | event_number: *mut u32, |
| 66 | flags: u32, |
| 67 | ) -> Status, |
| 68 | |
| 69 | pub pass_through_to_tpm: unsafe extern "efiapi" fn( |
| 70 | this: *mut Self, |
| 71 | tpm_input_parameter_block_size: u32, |
| 72 | tpm_input_parameter_block: *const u8, |
| 73 | tpm_output_parameter_block_size: u32, |
| 74 | tpm_output_parameter_block: *mut u8, |
| 75 | ) -> Status, |
| 76 | |
| 77 | pub hash_log_extend_event: unsafe extern "efiapi" fn( |
| 78 | this: *mut Self, |
| 79 | hash_data: PhysicalAddress, |
| 80 | hash_data_len: u64, |
| 81 | algorithm_id: u32, |
| 82 | event: *mut c_void, |
| 83 | event_number: *mut u32, |
| 84 | event_log_last_entry: *mut PhysicalAddress, |
| 85 | ) -> Status, |
| 86 | } |
| 87 | |
| 88 | impl TcgProtocol { |
| 89 | pub const GUID: Guid = guid!("f541796d-a62e-4954-a775-9584f61b9cdd"); |
| 90 | } |