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" |
| 21 | |
| 22 | /** |
| 23 | * Holds information about one of the VMs described in the manifest. |
| 24 | */ |
| 25 | struct manifest_vm { |
| 26 | /* Properties defined for both primary and secondary VMs. */ |
| 27 | struct memiter debug_name; |
| 28 | |
| 29 | /* Properties specific to secondary VMs. */ |
| 30 | struct { |
| 31 | struct memiter kernel_filename; |
| 32 | uint64_t mem_size; |
| 33 | spci_vcpu_count_t vcpu_count; |
| 34 | } secondary; |
| 35 | }; |
| 36 | |
| 37 | /** |
| 38 | * Hafnium manifest parsed from FDT. |
| 39 | */ |
| 40 | struct manifest { |
| 41 | spci_vm_count_t num_vms; |
| 42 | struct manifest_vm vm[MAX_VMS]; |
| 43 | }; |
| 44 | |
| 45 | enum manifest_return_code { |
| 46 | MANIFEST_SUCCESS = 0, |
| 47 | MANIFEST_ERROR_CORRUPTED_FDT, |
| 48 | MANIFEST_ERROR_NO_ROOT_FDT_NODE, |
| 49 | MANIFEST_ERROR_NO_HYPERVISOR_FDT_NODE, |
| 50 | MANIFEST_ERROR_RESERVED_VM_ID, |
| 51 | MANIFEST_ERROR_NO_PRIMARY_VM, |
| 52 | MANIFEST_ERROR_TOO_MANY_VMS, |
| 53 | MANIFEST_ERROR_PROPERTY_NOT_FOUND, |
| 54 | MANIFEST_ERROR_MALFORMED_STRING, |
| 55 | MANIFEST_ERROR_MALFORMED_INTEGER, |
| 56 | MANIFEST_ERROR_INTEGER_OVERFLOW, |
| 57 | }; |
| 58 | |
| 59 | enum manifest_return_code manifest_init(struct manifest *manifest, |
| 60 | struct memiter *fdt); |
| 61 | |
| 62 | const char *manifest_strerror(enum manifest_return_code ret_code); |