blob: cfedc61225fd4667bb5268c50da94de9814f6676 [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
David Brazdil0dbb41f2019-09-09 18:03:35 +010019#include "hf/fdt.h"
David Brazdil7a462ec2019-08-15 12:27:47 +010020#include "hf/memiter.h"
21#include "hf/spci.h"
David Brazdil136f2942019-09-23 14:11:03 +010022#include "hf/string.h"
Andrew Scullae9962e2019-10-03 16:51:16 +010023#include "hf/vm.h"
David Brazdil0dbb41f2019-09-09 18:03:35 +010024
25/**
David Brazdil7a462ec2019-08-15 12:27:47 +010026 * Holds information about one of the VMs described in the manifest.
27 */
28struct manifest_vm {
29 /* Properties defined for both primary and secondary VMs. */
David Brazdil136f2942019-09-23 14:11:03 +010030 struct string debug_name;
31 struct string kernel_filename;
Andrew Scullae9962e2019-10-03 16:51:16 +010032 struct smc_whitelist smc_whitelist;
David Brazdil7a462ec2019-08-15 12:27:47 +010033
David Brazdile6f83222019-09-23 14:47:37 +010034 union {
35 /* Properties specific to the primary VM. */
36 struct {
37 struct string ramdisk_filename;
38 } primary;
39 /* Properties specific to secondary VMs. */
40 struct {
41 uint64_t mem_size;
42 spci_vcpu_count_t vcpu_count;
43 } secondary;
44 };
David Brazdil7a462ec2019-08-15 12:27:47 +010045};
46
47/**
48 * Hafnium manifest parsed from FDT.
49 */
50struct manifest {
David Brazdil0251b942019-09-10 15:59:50 +010051 spci_vm_count_t vm_count;
David Brazdil7a462ec2019-08-15 12:27:47 +010052 struct manifest_vm vm[MAX_VMS];
53};
54
55enum manifest_return_code {
56 MANIFEST_SUCCESS = 0,
David Brazdil7a462ec2019-08-15 12:27:47 +010057 MANIFEST_ERROR_NO_HYPERVISOR_FDT_NODE,
David Brazdil74e9c3b2019-08-28 11:09:08 +010058 MANIFEST_ERROR_NOT_COMPATIBLE,
David Brazdil7a462ec2019-08-15 12:27:47 +010059 MANIFEST_ERROR_RESERVED_VM_ID,
60 MANIFEST_ERROR_NO_PRIMARY_VM,
61 MANIFEST_ERROR_TOO_MANY_VMS,
62 MANIFEST_ERROR_PROPERTY_NOT_FOUND,
63 MANIFEST_ERROR_MALFORMED_STRING,
David Brazdil0dbb41f2019-09-09 18:03:35 +010064 MANIFEST_ERROR_STRING_TOO_LONG,
David Brazdil74e9c3b2019-08-28 11:09:08 +010065 MANIFEST_ERROR_MALFORMED_STRING_LIST,
David Brazdil7a462ec2019-08-15 12:27:47 +010066 MANIFEST_ERROR_MALFORMED_INTEGER,
67 MANIFEST_ERROR_INTEGER_OVERFLOW,
Andrew Scullae9962e2019-10-03 16:51:16 +010068 MANIFEST_ERROR_MALFORMED_INTEGER_LIST,
David Brazdil7a462ec2019-08-15 12:27:47 +010069};
70
71enum manifest_return_code manifest_init(struct manifest *manifest,
David Brazdil0dbb41f2019-09-09 18:03:35 +010072 const struct fdt_node *fdt_root);
David Brazdil7a462ec2019-08-15 12:27:47 +010073
74const char *manifest_strerror(enum manifest_return_code ret_code);