blob: cef1bede0e7fc23f71be7180c1d13e6c3614db40 [file] [log] [blame]
J-Alves7ec9d6e2023-02-28 16:39:56 +00001/*
2 * Copyright 2023 The Hafnium Authors.
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://opensource.org/licenses/BSD-3-Clause.
7 */
8
9#pragma once
10
11#include <stdint.h>
12
13#include "hf/addr.h"
14#include "hf/memiter.h"
15#include "hf/string.h"
16
17#include "vmapi/hf/ffa.h"
18
19#define MANIFEST_INVALID_ADDRESS UINT64_MAX
20#define MANIFEST_INVALID_ID UINT32_MAX
21
22#define SP_RTX_BUF_NAME_SIZE 10
23
24/** FF-A manifest memory and device regions attributes. */
25#define MANIFEST_REGION_ATTR_READ (UINT32_C(1) << 0)
26#define MANIFEST_REGION_ATTR_WRITE (UINT32_C(1) << 1)
27#define MANIFEST_REGION_ATTR_EXEC (UINT32_C(1) << 2)
28#define MANIFEST_REGION_ATTR_SECURITY (UINT32_C(1) << 3)
29
30#define MANIFEST_REGION_ALL_ATTR_MASK \
31 (MANIFEST_REGION_ATTR_READ | MANIFEST_REGION_ATTR_WRITE | \
32 MANIFEST_REGION_ATTR_EXEC | MANIFEST_REGION_ATTR_SECURITY)
33
34#define MANIFEST_POWER_MANAGEMENT_CPU_OFF_SUPPORTED (UINT32_C(1) << 0)
35#define MANIFEST_POWER_MANAGEMENT_CPU_ON_SUPPORTED (UINT32_C(1) << 3)
36#define MANIFEST_POWER_MANAGEMENT_NONE_MASK (UINT32_C(0))
37#define MANIFEST_POWER_MANAGEMENT_ALL_MASK \
38 (MANIFEST_POWER_MANAGEMENT_CPU_OFF_SUPPORTED | \
39 MANIFEST_POWER_MANAGEMENT_CPU_ON_SUPPORTED)
40
41/* Highest possible value for the boot-order field. */
42#define DEFAULT_BOOT_ORDER 0xFFFF
43#define DEFAULT_BOOT_GP_REGISTER UINT32_C(-1)
44
45enum run_time_el {
46 EL1 = 0,
47 S_EL0,
48 S_EL1,
49 SUPERVISOR_MODE,
50 SECURE_USER_MODE,
Daniel Boulby874d5432023-04-27 12:40:24 +010051 SECURE_SUPERVISOR_MODE,
52 EL0
J-Alves7ec9d6e2023-02-28 16:39:56 +000053};
54
55enum execution_state { AARCH64 = 0, AARCH32 };
56
57enum xlat_granule { PAGE_4KB = 0, PAGE_16KB, PAGE_64KB };
58
59/**
Madhukar Pappireddy3c2b7912023-10-11 14:47:27 -050060 * Properties of the DMA capable device upstream of an SMMU as specified in the
61 * memory region description of the partition manifest.
62 */
63struct dma_device_properties {
64 /** SMMU ID - optional */
65 uint32_t smmu_id;
66 /** IMPDEF id tracking DMA peripheral device - optional */
67 uint8_t dma_device_id;
68 /** Count of Stream IDs assigned to device - optional */
69 uint8_t stream_count;
70 /** List of Stream IDs assigned to device - optional */
71 uint32_t stream_ids[PARTITION_MAX_STREAMS_PER_DEVICE];
72 /** Instruction and data access permissions - optional */
73 uint32_t dma_access_permissions;
74};
75
76/**
77 * Partition Memory region as described in FFA v1.2 spec, Table 5.2 along with
78 * an implementation defined struct to track the properties of a DMA capable
79 * device that has access to this memory region.
J-Alves7ec9d6e2023-02-28 16:39:56 +000080 */
81struct memory_region {
82 struct string name;
83 /**
84 * Specify PA, VA for S-EL0 partitions or IPA
85 * for S-EL1 partitions - optional.
86 */
87 uintptr_t base_address;
88 /** Page count - mandatory */
89 uint32_t page_count;
90 /** Memory attributes - mandatory */
91 uint32_t attributes;
Madhukar Pappireddy3c2b7912023-10-11 14:47:27 -050092 /** DMA device properties - optional */
93 struct dma_device_properties dma_prop;
J-Alves7ec9d6e2023-02-28 16:39:56 +000094};
95
96struct interrupt_info {
97 uint32_t id;
98 uint32_t attributes;
99 bool mpidr_valid;
100 uint64_t mpidr;
101};
102
103/**
Madhukar Pappireddy3c2b7912023-10-11 14:47:27 -0500104 * Partition Device region as described in FFA v1.2 spec, Table 5.3 along with
105 * few implementation defined fields.
J-Alves7ec9d6e2023-02-28 16:39:56 +0000106 */
107struct device_region {
108 /** Device base PA - mandatory */
109 uintptr_t base_address;
110 /** Page count - mandatory */
111 uint32_t page_count;
112 /** Memory attributes - mandatory */
113 uint32_t attributes;
114 /** List of physical interrupt ID's and their attributes - optional */
115 struct interrupt_info interrupts[PARTITION_MAX_INTERRUPTS_PER_DEVICE];
116 /** Count of physical interrupts - optional */
117 uint8_t interrupt_count;
118 /** SMMU ID - optional */
119 uint32_t smmu_id;
Madhukar Pappireddye032af52023-10-11 14:52:58 -0500120 /** IMPDEF id tracking DMA peripheral device - optional */
121 uint8_t dma_device_id;
J-Alves7ec9d6e2023-02-28 16:39:56 +0000122 /** Count of Stream IDs assigned to device - optional */
123 uint8_t stream_count;
124 /** List of Stream IDs assigned to device - optional */
125 uint32_t stream_ids[PARTITION_MAX_STREAMS_PER_DEVICE];
126 /** Exclusive access to an endpoint - optional */
127 bool exclusive_access;
128 /** Name of Device region - optional */
129 struct string name;
130};
131
132/**
133 * RX/TX buffer, reference to memory-region entries that describe RX/TX
134 * buffers in partition manifest.
135 */
136struct rx_tx {
137 bool available;
138 uint32_t rx_phandle;
139 uint32_t tx_phandle;
140 struct memory_region *rx_buffer;
141 struct memory_region *tx_buffer;
142};
143
144/**
145 * Partition manifest as described in FF-A v1.0 spec section 3.1
146 */
147struct ffa_partition_manifest {
148 /** FF-A expected version - mandatory */
149 uint32_t ffa_version;
Kathleen Capella422b10b2023-06-30 18:28:27 -0400150 /** UUID - at least one UUID mandatory */
151 uint16_t uuid_count;
152 struct ffa_uuid uuids[PARTITION_MAX_UUIDS];
J-Alves7ec9d6e2023-02-28 16:39:56 +0000153 /** Partition id - optional */
J-Alves19e20cf2023-08-02 12:48:55 +0100154 ffa_id_t id;
J-Alves7ec9d6e2023-02-28 16:39:56 +0000155 /** Aux ids for mem transactions - optional */
J-Alves19e20cf2023-08-02 12:48:55 +0100156 ffa_id_t aux_id;
J-Alves7ec9d6e2023-02-28 16:39:56 +0000157
158 /* NOTE: optional name field maps to VM debug_name field */
159
160 /** mandatory */
161 ffa_vcpu_count_t execution_ctx_count;
162 /** EL1 or secure EL1, secure EL0 - mandatory */
163 enum run_time_el run_time_el;
164 /** AArch32 / AArch64 - mandatory */
165 enum execution_state execution_state;
166 /** optional */
167 uintpaddr_t load_addr;
168 /** optional */
169 size_t ep_offset;
170 /** 4/16/64KB - optional */
171 enum xlat_granule xlat_granule;
172 /** Register id from w0/x0-w3/x3 - optional. */
173 uint32_t gp_register_num;
174 /**
175 * Flags the presence of the optional IMPDEF node to define Partition's
176 * Boot Info.
177 */
178 bool boot_info;
179 /** optional */
180 uint16_t boot_order;
181
182 /** Optional RX/TX buffers */
183 struct rx_tx rxtx;
184
185 /** mandatory - direct/indirect msg or both */
Kathleen Capellaf71dee42023-08-08 16:24:14 -0400186 uint16_t messaging_method;
J-Alves7ec9d6e2023-02-28 16:39:56 +0000187 /** mandatory - action in response to non secure interrupt */
188 uint8_t ns_interrupts_action;
189 /** optional - managed exit signaled through vIRQ */
190 bool me_signal_virq;
191 /** optional - receipt of notifications. */
192 bool notification_support;
193 /**
194 * optional - power management messages bitfield.
195 *
196 * See [1] power-management-messages manifest field.
197 *
198 * The Hafnium supported combinations for a MP SP are:
199 * Bit 0 - relay PSCI cpu off message to the SP.
200 * Bit 3 - relay PSCI cpu on to the SP.
201 *
202 * [1]
203 * https://trustedfirmware-a.readthedocs.io/en/latest/components/ffa-manifest-binding.html#partition-properties
204 */
205 uint32_t power_management;
206 /** optional */
207 bool has_primary_scheduler;
208 /** optional - tuples SEPID/SMMUID/streamId */
209 uint32_t stream_ep_ids[1];
210
211 /** Memory regions */
212 uint16_t mem_region_count;
213 struct memory_region mem_regions[PARTITION_MAX_MEMORY_REGIONS];
214 /** Device regions */
215 uint16_t dev_region_count;
216 struct device_region dev_regions[PARTITION_MAX_DEVICE_REGIONS];
Madhukar Pappireddye032af52023-10-11 14:52:58 -0500217 /** DMA device count. */
218 uint8_t dma_device_count;
219
J-Alves7ec9d6e2023-02-28 16:39:56 +0000220 /** optional - action in response to Other-Secure interrupt */
221 uint8_t other_s_interrupts_action;
222};