blob: 3345e9e48cefb096c98c866ddbffe36769c51ea1 [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/**
60 * Partition Memory region as described in FFA v1.0 spec, Table 10
61 */
62struct memory_region {
63 struct string name;
64 /**
65 * Specify PA, VA for S-EL0 partitions or IPA
66 * for S-EL1 partitions - optional.
67 */
68 uintptr_t base_address;
69 /** Page count - mandatory */
70 uint32_t page_count;
71 /** Memory attributes - mandatory */
72 uint32_t attributes;
73};
74
75struct interrupt_info {
76 uint32_t id;
77 uint32_t attributes;
78 bool mpidr_valid;
79 uint64_t mpidr;
80};
81
82/**
83 * Partition Device region as described in FFA v1.0 spec, Table 11
84 */
85struct device_region {
86 /** Device base PA - mandatory */
87 uintptr_t base_address;
88 /** Page count - mandatory */
89 uint32_t page_count;
90 /** Memory attributes - mandatory */
91 uint32_t attributes;
92 /** List of physical interrupt ID's and their attributes - optional */
93 struct interrupt_info interrupts[PARTITION_MAX_INTERRUPTS_PER_DEVICE];
94 /** Count of physical interrupts - optional */
95 uint8_t interrupt_count;
96 /** SMMU ID - optional */
97 uint32_t smmu_id;
98 /** Count of Stream IDs assigned to device - optional */
99 uint8_t stream_count;
100 /** List of Stream IDs assigned to device - optional */
101 uint32_t stream_ids[PARTITION_MAX_STREAMS_PER_DEVICE];
102 /** Exclusive access to an endpoint - optional */
103 bool exclusive_access;
104 /** Name of Device region - optional */
105 struct string name;
106};
107
108/**
109 * RX/TX buffer, reference to memory-region entries that describe RX/TX
110 * buffers in partition manifest.
111 */
112struct rx_tx {
113 bool available;
114 uint32_t rx_phandle;
115 uint32_t tx_phandle;
116 struct memory_region *rx_buffer;
117 struct memory_region *tx_buffer;
118};
119
120/**
121 * Partition manifest as described in FF-A v1.0 spec section 3.1
122 */
123struct ffa_partition_manifest {
124 /** FF-A expected version - mandatory */
125 uint32_t ffa_version;
126 /** UUID - mandatory */
127 struct ffa_uuid uuid;
128 /** Partition id - optional */
J-Alves19e20cf2023-08-02 12:48:55 +0100129 ffa_id_t id;
J-Alves7ec9d6e2023-02-28 16:39:56 +0000130 /** Aux ids for mem transactions - optional */
J-Alves19e20cf2023-08-02 12:48:55 +0100131 ffa_id_t aux_id;
J-Alves7ec9d6e2023-02-28 16:39:56 +0000132
133 /* NOTE: optional name field maps to VM debug_name field */
134
135 /** mandatory */
136 ffa_vcpu_count_t execution_ctx_count;
137 /** EL1 or secure EL1, secure EL0 - mandatory */
138 enum run_time_el run_time_el;
139 /** AArch32 / AArch64 - mandatory */
140 enum execution_state execution_state;
141 /** optional */
142 uintpaddr_t load_addr;
143 /** optional */
144 size_t ep_offset;
145 /** 4/16/64KB - optional */
146 enum xlat_granule xlat_granule;
147 /** Register id from w0/x0-w3/x3 - optional. */
148 uint32_t gp_register_num;
149 /**
150 * Flags the presence of the optional IMPDEF node to define Partition's
151 * Boot Info.
152 */
153 bool boot_info;
154 /** optional */
155 uint16_t boot_order;
156
157 /** Optional RX/TX buffers */
158 struct rx_tx rxtx;
159
160 /** mandatory - direct/indirect msg or both */
161 uint8_t messaging_method;
162 /** mandatory - action in response to non secure interrupt */
163 uint8_t ns_interrupts_action;
164 /** optional - managed exit signaled through vIRQ */
165 bool me_signal_virq;
166 /** optional - receipt of notifications. */
167 bool notification_support;
168 /**
169 * optional - power management messages bitfield.
170 *
171 * See [1] power-management-messages manifest field.
172 *
173 * The Hafnium supported combinations for a MP SP are:
174 * Bit 0 - relay PSCI cpu off message to the SP.
175 * Bit 3 - relay PSCI cpu on to the SP.
176 *
177 * [1]
178 * https://trustedfirmware-a.readthedocs.io/en/latest/components/ffa-manifest-binding.html#partition-properties
179 */
180 uint32_t power_management;
181 /** optional */
182 bool has_primary_scheduler;
183 /** optional - tuples SEPID/SMMUID/streamId */
184 uint32_t stream_ep_ids[1];
185
186 /** Memory regions */
187 uint16_t mem_region_count;
188 struct memory_region mem_regions[PARTITION_MAX_MEMORY_REGIONS];
189 /** Device regions */
190 uint16_t dev_region_count;
191 struct device_region dev_regions[PARTITION_MAX_DEVICE_REGIONS];
192 /** optional - action in response to Other-Secure interrupt */
193 uint8_t other_s_interrupts_action;
194};