blob: ab3a92f21c04574059b595781901e0f8879a0840 [file] [log] [blame]
David Brazdil7a462ec2019-08-15 12:27:47 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010019#include "hf/ffa.h"
David Brazdil7a462ec2019-08-15 12:27:47 +010020#include "hf/memiter.h"
David Brazdil136f2942019-09-23 14:11:03 +010021#include "hf/string.h"
Andrew Scullae9962e2019-10-03 16:51:16 +010022#include "hf/vm.h"
David Brazdil0dbb41f2019-09-09 18:03:35 +010023
David Brazdil080ee312020-02-25 15:30:30 -080024#define MANIFEST_INVALID_ADDRESS UINT64_MAX
25
David Brazdil0dbb41f2019-09-09 18:03:35 +010026/**
David Brazdil7a462ec2019-08-15 12:27:47 +010027 * Holds information about one of the VMs described in the manifest.
28 */
29struct manifest_vm {
30 /* Properties defined for both primary and secondary VMs. */
David Brazdil136f2942019-09-23 14:11:03 +010031 struct string debug_name;
32 struct string kernel_filename;
Andrew Scullae9962e2019-10-03 16:51:16 +010033 struct smc_whitelist smc_whitelist;
David Brazdil7a462ec2019-08-15 12:27:47 +010034
David Brazdile6f83222019-09-23 14:47:37 +010035 union {
36 /* Properties specific to the primary VM. */
37 struct {
David Brazdil080ee312020-02-25 15:30:30 -080038 uint64_t boot_address;
David Brazdile6f83222019-09-23 14:47:37 +010039 struct string ramdisk_filename;
40 } primary;
41 /* Properties specific to secondary VMs. */
42 struct {
43 uint64_t mem_size;
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010044 ffa_vcpu_count_t vcpu_count;
David Brazdile6f83222019-09-23 14:47:37 +010045 } secondary;
46 };
David Brazdil7a462ec2019-08-15 12:27:47 +010047};
48
49/**
50 * Hafnium manifest parsed from FDT.
51 */
52struct manifest {
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010053 bool ffa_tee_enabled;
54 ffa_vm_count_t vm_count;
David Brazdil7a462ec2019-08-15 12:27:47 +010055 struct manifest_vm vm[MAX_VMS];
56};
57
58enum manifest_return_code {
59 MANIFEST_SUCCESS = 0,
David Brazdila2358d42020-01-27 18:51:38 +000060 MANIFEST_ERROR_FILE_SIZE,
61 MANIFEST_ERROR_NO_ROOT_NODE,
David Brazdil7a462ec2019-08-15 12:27:47 +010062 MANIFEST_ERROR_NO_HYPERVISOR_FDT_NODE,
David Brazdil74e9c3b2019-08-28 11:09:08 +010063 MANIFEST_ERROR_NOT_COMPATIBLE,
David Brazdil7a462ec2019-08-15 12:27:47 +010064 MANIFEST_ERROR_RESERVED_VM_ID,
65 MANIFEST_ERROR_NO_PRIMARY_VM,
66 MANIFEST_ERROR_TOO_MANY_VMS,
67 MANIFEST_ERROR_PROPERTY_NOT_FOUND,
68 MANIFEST_ERROR_MALFORMED_STRING,
David Brazdil0dbb41f2019-09-09 18:03:35 +010069 MANIFEST_ERROR_STRING_TOO_LONG,
David Brazdil7a462ec2019-08-15 12:27:47 +010070 MANIFEST_ERROR_MALFORMED_INTEGER,
71 MANIFEST_ERROR_INTEGER_OVERFLOW,
Andrew Scullae9962e2019-10-03 16:51:16 +010072 MANIFEST_ERROR_MALFORMED_INTEGER_LIST,
Andrew Scullb2c3a242019-11-04 13:52:36 +000073 MANIFEST_ERROR_MALFORMED_BOOLEAN,
David Brazdil7a462ec2019-08-15 12:27:47 +010074};
75
76enum manifest_return_code manifest_init(struct manifest *manifest,
David Brazdila2358d42020-01-27 18:51:38 +000077 struct memiter *manifest_fdt);
David Brazdil7a462ec2019-08-15 12:27:47 +010078
79const char *manifest_strerror(enum manifest_return_code ret_code);