David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | #include "hf/memiter.h" |
| 20 | #include "hf/spci.h" |
David Brazdil | 136f294 | 2019-09-23 14:11:03 +0100 | [diff] [blame] | 21 | #include "hf/string.h" |
Andrew Scull | ae9962e | 2019-10-03 16:51:16 +0100 | [diff] [blame] | 22 | #include "hf/vm.h" |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 23 | |
| 24 | /** |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 25 | * Holds information about one of the VMs described in the manifest. |
| 26 | */ |
| 27 | struct manifest_vm { |
| 28 | /* Properties defined for both primary and secondary VMs. */ |
David Brazdil | 136f294 | 2019-09-23 14:11:03 +0100 | [diff] [blame] | 29 | struct string debug_name; |
| 30 | struct string kernel_filename; |
Andrew Scull | ae9962e | 2019-10-03 16:51:16 +0100 | [diff] [blame] | 31 | struct smc_whitelist smc_whitelist; |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 32 | |
David Brazdil | e6f8322 | 2019-09-23 14:47:37 +0100 | [diff] [blame] | 33 | union { |
| 34 | /* Properties specific to the primary VM. */ |
| 35 | struct { |
| 36 | struct string ramdisk_filename; |
| 37 | } primary; |
| 38 | /* Properties specific to secondary VMs. */ |
| 39 | struct { |
| 40 | uint64_t mem_size; |
| 41 | spci_vcpu_count_t vcpu_count; |
| 42 | } secondary; |
| 43 | }; |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * Hafnium manifest parsed from FDT. |
| 48 | */ |
| 49 | struct manifest { |
David Brazdil | 0251b94 | 2019-09-10 15:59:50 +0100 | [diff] [blame] | 50 | spci_vm_count_t vm_count; |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 51 | struct manifest_vm vm[MAX_VMS]; |
| 52 | }; |
| 53 | |
| 54 | enum manifest_return_code { |
| 55 | MANIFEST_SUCCESS = 0, |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame^] | 56 | MANIFEST_ERROR_FILE_SIZE, |
| 57 | MANIFEST_ERROR_NO_ROOT_NODE, |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 58 | MANIFEST_ERROR_NO_HYPERVISOR_FDT_NODE, |
David Brazdil | 74e9c3b | 2019-08-28 11:09:08 +0100 | [diff] [blame] | 59 | MANIFEST_ERROR_NOT_COMPATIBLE, |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 60 | MANIFEST_ERROR_RESERVED_VM_ID, |
| 61 | MANIFEST_ERROR_NO_PRIMARY_VM, |
| 62 | MANIFEST_ERROR_TOO_MANY_VMS, |
| 63 | MANIFEST_ERROR_PROPERTY_NOT_FOUND, |
| 64 | MANIFEST_ERROR_MALFORMED_STRING, |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 65 | MANIFEST_ERROR_STRING_TOO_LONG, |
David Brazdil | 74e9c3b | 2019-08-28 11:09:08 +0100 | [diff] [blame] | 66 | MANIFEST_ERROR_MALFORMED_STRING_LIST, |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 67 | MANIFEST_ERROR_MALFORMED_INTEGER, |
| 68 | MANIFEST_ERROR_INTEGER_OVERFLOW, |
Andrew Scull | ae9962e | 2019-10-03 16:51:16 +0100 | [diff] [blame] | 69 | MANIFEST_ERROR_MALFORMED_INTEGER_LIST, |
Andrew Scull | b2c3a24 | 2019-11-04 13:52:36 +0000 | [diff] [blame] | 70 | MANIFEST_ERROR_MALFORMED_BOOLEAN, |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | enum manifest_return_code manifest_init(struct manifest *manifest, |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame^] | 74 | struct memiter *manifest_fdt); |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame] | 75 | |
| 76 | const char *manifest_strerror(enum manifest_return_code ret_code); |