Balint Dobszay | b2ff2bc | 2024-12-19 18:59:38 +0100 | [diff] [blame] | 1 | // SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 2 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
| 3 | |
| 4 | #![allow(non_camel_case_types)] |
| 5 | |
| 6 | use zerocopy_derive::*; |
| 7 | |
| 8 | /// Table 5.8: Boot information descriptor |
| 9 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 10 | #[repr(C, packed)] |
| 11 | pub(crate) struct boot_info_descriptor { |
| 12 | /// Offset 0, length 16: Name of boot information passed to the consumer. |
| 13 | pub(crate) name: [u8; 16], |
| 14 | /// Offset 16, length 1: Type of boot information passed to the consumer. |
| 15 | /// - Bit\[7\]: Boot information type. |
| 16 | /// + b’0: Standard boot information. |
| 17 | /// + b’1: Implementation defined boot information. |
| 18 | /// - Bits\[6:0\]: Boot information identifier. |
| 19 | /// + Standard boot information (bit\[7\] = b’0). |
| 20 | /// * 0: Flattened device tree (FDT). |
| 21 | /// * 1: Hand-Off Block (HOB) List. |
| 22 | /// * All other identifiers are reserved. |
| 23 | /// + Implementation defined identifiers (bit\[7\] = b’ 1). |
| 24 | /// * Identifier is defined by the implementation. |
| 25 | pub(crate) typ: u8, |
| 26 | /// Offset 17, length 1: Reserved (MBZ) |
| 27 | pub(crate) reserved: u8, |
| 28 | /// Offset 18, length 2: Flags to describe properties of boot information associated with this |
| 29 | /// descriptor. |
| 30 | /// - Bits\[15:4\]: Reserved (MBZ). |
| 31 | /// - Bits\[3:2\]: Format of Contents field. |
| 32 | /// + b’0: Address of boot information identified by the Name and Type fields. |
| 33 | /// + b’1: Value of boot information identified by the Name and Type fields. |
| 34 | /// + All other bit encodings are reserved for future use. |
| 35 | /// - Bits\[1:0\]: Format of Name field. |
| 36 | /// + b’0: Null terminated string. |
| 37 | /// + b’1: UUID encoded in little-endian byte order. |
| 38 | /// + All other bit encodings are reserved for future use. |
| 39 | pub(crate) flags: u16, |
| 40 | /// Offset 20, length 4: Size (in bytes) of boot information identified by the Name and Type |
| 41 | /// fields |
| 42 | pub(crate) size: u32, |
| 43 | /// Offset 24, length 8: Value or address of boot information identified by the Name and Type |
| 44 | /// fields. |
| 45 | /// |
| 46 | /// If in the Flags field, bit\[3:2\] = b'0, |
| 47 | /// * The address has the same attributes as the boot information blob address described in |
| 48 | /// 5.4.3 Boot information address. |
| 49 | /// * Size field contains the length (in bytes) of boot information at the specified address. |
| 50 | /// |
| 51 | /// If in the Flags field, bit\[3:2\] = b’1, |
| 52 | /// * Size field contains the exact size of the value specified in this field. |
| 53 | /// * Size is >=1 bytes and <= 8 bytes. |
| 54 | pub(crate) contents: u64, |
| 55 | } |
| 56 | |
| 57 | /// Table 5.9: Boot information header |
| 58 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 59 | #[repr(C, packed)] |
| 60 | pub(crate) struct boot_info_header { |
| 61 | /// Offset 0, length 4: Hexadecimal value 0x0FFA to identify the header |
| 62 | pub(crate) signature: u32, |
| 63 | /// Offset 4, length 4: Version of the boot information blob encoded as in FFA_VERSION_GET |
| 64 | pub(crate) version: u32, |
| 65 | /// Offset 8, length 4: Size of boot information blob spanning contiguous memory |
| 66 | pub(crate) boot_info_blob_size: u32, |
| 67 | /// Offset 12, length 4: Size of each boot information descriptor in the array |
| 68 | pub(crate) boot_info_desc_size: u32, |
| 69 | /// Offset 16, length 4: Count of boot information descriptors in the array |
| 70 | pub(crate) boot_info_desc_count: u32, |
| 71 | /// Offset 20, length 4: Offset to array of boot information descriptors |
| 72 | pub(crate) boot_info_array_offset: u32, |
| 73 | /// Offset 24, length 8: Reserved (MBZ) |
| 74 | pub(crate) reserved: u64, |
| 75 | } |
Balint Dobszay | 2338bd3 | 2024-12-19 19:00:14 +0100 | [diff] [blame] | 76 | |
| 77 | /// Table 13.37: Partition information descriptor |
| 78 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 79 | #[repr(C, packed)] |
| 80 | pub(crate) struct partition_info_descriptor { |
| 81 | /// Offset 0, length 2: 16-bit ID of the partition, stream or auxiliary endpoint. |
| 82 | pub(crate) partition_id: u16, |
| 83 | /// Offset 2, length 2: |
| 84 | /// - Number of execution contexts implemented by this partition if Bit\[5:4\] = b’00 in the |
| 85 | /// Partition properties field. |
| 86 | /// - ID of the proxy endpoint for a dependent peripheral device if Bit\[5:4\] = b’10 in the |
| 87 | /// Partition properties field. |
| 88 | /// - Reserved and MBZ for all other encodings of the Partition properties field. |
| 89 | pub(crate) exec_ctx_count_or_proxy_id: u16, |
| 90 | /// Offset 4, length 4: Flags to determine partition properties. |
| 91 | /// - Bit\[3:0\] has the following encoding if Bit\[5:4\] = b’00. It is Reserved and MBZ otherwise. |
| 92 | /// + Bit\[0\] has the following encoding: |
| 93 | /// * b’0: Does not support receipt of direct requests |
| 94 | /// * b’1: Supports receipt of direct requests. Count of execution contexts must be either 1 |
| 95 | /// or equal to the number of PEs in the system. |
| 96 | /// + bit\[1\] has the following encoding: |
| 97 | /// * b’0: Cannot send direct requests. |
| 98 | /// * b’1: Can send direct requests. |
| 99 | /// + bit\[2\] has the following encoding: |
| 100 | /// * b’0: Cannot send and receive indirect messages. |
| 101 | /// * b’1: Can send and receive indirect messages. |
| 102 | /// + bit\[3\] has the following encoding: |
| 103 | /// * b’0: Does not support receipt of notifications. |
| 104 | /// * b’1: Supports receipt of notifications. |
| 105 | /// - bit\[5:4\] has the following encoding: |
| 106 | /// + b’00: Partition ID is a PE endpoint ID. |
| 107 | /// + b’01: Partition ID is a SEPID for an independent peripheral device. |
| 108 | /// + b’10: Partition ID is a SEPID for an dependent peripheral device. |
| 109 | /// + b’11: Partition ID is an auxiliary ID. |
| 110 | /// - bit\[6\] has the following encoding: |
| 111 | /// + b’0: Partition must not be informed about each VM that is created by the Hypervisor. |
| 112 | /// + b’1: Partition must be informed about each VM that is created by the Hypervisor. |
| 113 | /// + bit\[6\] is used only if the following conditions are true. It is Reserved (MBZ) in all |
| 114 | /// other scenarios. |
| 115 | /// * This ABI is invoked at the Non-secure physical FF-A instance. |
| 116 | /// * The partition is an SP that supports receipt of direct requests i.e. Bit\[0\] = b’1. |
| 117 | /// - bit\[7\] has the following encoding: |
| 118 | /// + b’0: Partition must not be informed about each VM that is destroyed by the Hypervisor. |
| 119 | /// + b’1: Partition must be informed about each VM that is destroyed by the Hypervisor. |
| 120 | /// + bit\[7\] is used only if the following conditions are true. It is Reserved (MBZ) in all |
| 121 | /// other scenarios. |
| 122 | /// * This ABI is invoked at the Non-secure physical FF-A instance. |
| 123 | /// * The partition is an SP that supports receipt of direct requests i.e. Bit\[0\] = b’1. |
| 124 | /// - bit\[8\] has the following encoding: |
| 125 | /// + b’0: Partition runs in the AArch32 execution state. |
| 126 | /// + b’1: Partition runs in the AArch64 execution state. |
| 127 | /// - bit\[31:9\]: Reserved (MBZ). |
| 128 | pub(crate) partition_props: u32, |
| 129 | /// Offset 8, length 16: |
| 130 | /// - UUID of the partition, stream or auxiliary endpoint if the Nil UUID was specified in w1-w4 |
| 131 | /// as an input parameter. |
| 132 | /// - This field is reserved and MBZ if a non-Nil UUID was was specified in w1-w4 as an input |
| 133 | /// parameter. |
| 134 | pub(crate) uuid: [u8; 16], |
| 135 | } |
Balint Dobszay | c758dd4 | 2025-01-15 18:10:40 +0100 | [diff] [blame] | 136 | |
| 137 | /// Table 10.13: Composite memory region descriptor |
| 138 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 139 | #[repr(C, packed)] |
| 140 | pub(crate) struct composite_memory_region_descriptor { |
| 141 | /// Offset 0, length 4: Size of the memory region described as the count of 4K pages. Must be |
| 142 | /// equal to the sum of page counts specified in each constituent memory region descriptor. |
| 143 | pub(crate) total_page_count: u32, |
| 144 | /// Offset 4, length 4: Count of address ranges specified using constituent memory region |
| 145 | /// descriptors |
| 146 | pub(crate) address_range_count: u32, |
| 147 | /// Offset 8, length 8: Reserved (MBZ) |
| 148 | pub(crate) reserved: u64, |
| 149 | } |
| 150 | |
| 151 | /// Table 10.14: Constituent memory region descriptor |
| 152 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 153 | #[repr(C, packed)] |
| 154 | pub(crate) struct constituent_memory_region_descriptor { |
| 155 | /// Offset 0, length 8: Base VA, PA or IPA of constituent memory region aligned to the page size |
| 156 | /// (4K) granularity |
| 157 | pub(crate) address: u64, |
| 158 | /// Offset 8, length 4: Number of 4K pages in constituent memory region |
| 159 | pub(crate) page_count: u32, |
| 160 | /// Offset 12, length 4: Reserved (MBZ) |
| 161 | pub(crate) reserved: u32, |
| 162 | } |
| 163 | |
| 164 | /// Table 10.15: Memory access permissions descriptor |
| 165 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 166 | #[repr(C, packed)] |
| 167 | pub(crate) struct memory_access_permission_descriptor { |
| 168 | /// Offset 0, length 2: 16-bit ID of endpoint to which the memory access permissions apply |
| 169 | pub(crate) endpoint_id: u16, |
| 170 | /// Offset 2, length 1: Permissions used to access a memory region |
| 171 | pub(crate) memory_access_permissions: u8, |
| 172 | /// Offset 3, length 1: ABI specific flags |
| 173 | pub(crate) flags: u8, |
| 174 | } |
| 175 | |
| 176 | /// Table 10.16: Endpoint memory access descriptor |
| 177 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 178 | #[repr(C, packed)] |
| 179 | pub(crate) struct endpoint_memory_access_descriptor { |
| 180 | /// Offset 0, length 4: Memory access permissions descriptor as specified in Table 10.15 |
| 181 | pub(crate) access_perm_desc: memory_access_permission_descriptor, |
| 182 | /// Offset 4, length 4: Offset to the composite memory region descriptor to which the endpoint |
| 183 | /// access permissions apply. Offset must be calculated from the base address of the data |
| 184 | /// structure this descriptor is included in. An offset value of 0 indicates that the endpoint |
| 185 | /// access permissions apply to a memory region description identified by the Handle parameter |
| 186 | /// specified in the data structure that includes this one. |
| 187 | pub(crate) composite_offset: u32, |
| 188 | /// Offset 8, length 8: Reserved (MBZ) |
| 189 | pub(crate) reserved: u64, |
| 190 | } |
| 191 | |
| 192 | /// Table 10.20: Memory transaction descriptor |
| 193 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 194 | #[repr(C, packed)] |
| 195 | pub(crate) struct memory_transaction_descriptor { |
| 196 | /// Offset 0, length 2: ID of the Owner endpoint |
| 197 | pub(crate) sender_endpoint_id: u16, |
| 198 | /// Offset 2, length 2: Memory region attributes |
| 199 | pub(crate) memory_region_attributes: u16, |
| 200 | /// Offset 4, length 4: Flags |
| 201 | pub(crate) flags: u32, |
| 202 | /// Offset 8, length 8: Globally unique Handle to identify a memory region |
| 203 | pub(crate) handle: u64, |
| 204 | /// Offset 16, length 8: Tag |
| 205 | pub(crate) tag: u64, |
| 206 | /// Offset 24, length 4: Size of each endpoint memory access descriptor in the array |
| 207 | pub(crate) endpoint_mem_access_desc_size: u32, |
| 208 | /// Offset 28, length 4: Count of endpoint memory access descriptors |
| 209 | pub(crate) endpoint_mem_access_desc_count: u32, |
| 210 | /// Offset 32, length 4: 16-byte aligned offset from the base address of this descriptor to the |
| 211 | /// first element of the Endpoint memory access descriptor array |
| 212 | pub(crate) endpoint_mem_access_desc_array_offset: u32, |
| 213 | /// Offset 36, length 12: Reserved (MBZ) |
| 214 | pub(crate) reserved1: u32, |
| 215 | pub(crate) reserved2: u64, |
| 216 | } |
| 217 | |
| 218 | /// Table 16.25: Descriptor to relinquish a memory region |
| 219 | #[derive(Default, FromBytes, IntoBytes, KnownLayout, Immutable)] |
| 220 | #[repr(C, packed)] |
| 221 | pub(crate) struct memory_relinquish_descriptor { |
| 222 | /// Offset 0, length 8: Globally unique Handle to identify a memory region |
| 223 | pub(crate) handle: u64, |
| 224 | /// Offset 8, length 4: Flags |
| 225 | pub(crate) flags: u32, |
| 226 | /// Offset 12, length 4: Count of endpoint ID entries in the Endpoint array |
| 227 | pub(crate) endpoint_count: u32, |
| 228 | } |