Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 1 | /* |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 2 | * Copyright (c) 2022-2024, Arm Limited and Contributors. All rights reserved. |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef FWU_PROTO_H |
| 8 | #define FWU_PROTO_H |
| 9 | |
| 10 | #include <stdint.h> |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 11 | |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 12 | #include "opcodes.h" |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 13 | #include "protocols/common/osf/uuid.h" |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 14 | #include "status.h" |
| 15 | |
| 16 | /** |
| 17 | * The major version number of the FWU-A access protocol. It will be incremented |
| 18 | * on significant updates that may include breaking changes. |
| 19 | */ |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 20 | #define FWU_PROTOCOL_VERSION_MAJOR 1 |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * The minor version number It will be incremented in |
| 24 | * small updates that are unlikely to include breaking changes. |
| 25 | */ |
| 26 | #define FWU_PROTOCOL_VERSION_MINOR 0 |
| 27 | |
| 28 | /** |
| 29 | * Protocol GUIDs defined in FWU-A specification |
| 30 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 31 | #define FWU_UPDATE_AGENT_CANONICAL_UUID "6823a838-1b06-470e-9774-0cce8bfb53fd" |
| 32 | #define FWU_DIRECTORY_CANONICAL_UUID "deee58d9-5147-4ad3-a290-77666e2341a5" |
| 33 | #define FWU_METADATA_CANONICAL_UUID "8a7a84a0-8387-40f6-ab41-a8b9a5a60d23" |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 34 | |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 35 | #define FWU_OPEN_OP_TYPE_READ (0) |
| 36 | #define FWU_OPEN_OP_TYPE_WRITE (1) |
| 37 | |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 38 | /** |
| 39 | * Image directory |
| 40 | */ |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 41 | #define FWU_IMAGE_DIRECTORY_VERSION (2) |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 42 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 43 | struct __attribute__((__packed__)) fwu_image_info_entry { |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 44 | uint8_t img_type_uuid[OSF_UUID_OCTET_LEN]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 45 | uint32_t client_permissions; |
| 46 | uint32_t img_max_size; |
| 47 | uint32_t lowest_accepted_version; |
| 48 | uint32_t img_version; |
| 49 | uint32_t accepted; |
| 50 | uint32_t reserved; |
| 51 | }; |
| 52 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 53 | struct __attribute__((__packed__)) fwu_image_directory { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 54 | uint32_t directory_version; |
| 55 | uint32_t img_info_offset; |
| 56 | uint32_t num_images; |
| 57 | uint32_t correct_boot; |
| 58 | uint32_t img_info_size; |
| 59 | uint32_t reserved; |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 60 | struct fwu_image_info_entry img_info_entry[]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | /** |
| 64 | * Message parameters |
| 65 | */ |
| 66 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 67 | struct __attribute__((__packed__)) fwu_request_header { |
Imre Kis | 6fd73d8 | 2024-07-04 13:36:10 +0200 | [diff] [blame] | 68 | uint32_t func_id; |
| 69 | uint8_t payload[]; |
| 70 | }; |
| 71 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 72 | struct __attribute__((__packed__)) fwu_response_header { |
Imre Kis | 6fd73d8 | 2024-07-04 13:36:10 +0200 | [diff] [blame] | 73 | uint32_t status; |
| 74 | uint8_t payload[]; |
| 75 | }; |
| 76 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 77 | struct __attribute__((__packed__)) fwu_discover_out { |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 78 | int16_t service_status; |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 79 | uint8_t version_major; |
| 80 | uint8_t version_minor; |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 81 | uint16_t off_function_presence; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 82 | uint16_t num_func; |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 83 | uint64_t max_payload_size; |
| 84 | uint32_t flags; |
| 85 | uint32_t vendor_specific_flags; |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 86 | uint8_t function_presence[]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 87 | }; |
| 88 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 89 | struct __attribute__((__packed__)) fwu_begin_staging_in { |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 90 | uint32_t reserved; |
| 91 | uint32_t vendor_flags; |
| 92 | uint32_t partial_update_count; |
| 93 | uint8_t update_guid[]; |
| 94 | }; |
| 95 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 96 | struct __attribute__((__packed__)) fwu_open_in { |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 97 | uint8_t image_type_uuid[OSF_UUID_OCTET_LEN]; |
Imre Kis | 18b387d | 2024-07-02 13:51:07 +0200 | [diff] [blame] | 98 | uint8_t op_type; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 99 | }; |
| 100 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 101 | struct __attribute__((__packed__)) fwu_open_out { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 102 | uint32_t handle; |
| 103 | }; |
| 104 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 105 | struct __attribute__((__packed__)) fwu_write_stream_in { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 106 | uint32_t handle; |
| 107 | uint32_t data_len; |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 108 | uint8_t payload[]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 111 | struct __attribute__((__packed__)) fwu_read_stream_in { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 112 | uint32_t handle; |
| 113 | }; |
| 114 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 115 | struct __attribute__((__packed__)) fwu_read_stream_out { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 116 | uint32_t read_bytes; |
| 117 | uint32_t total_bytes; |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 118 | uint8_t payload[]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 119 | }; |
| 120 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 121 | struct __attribute__((__packed__)) fwu_commit_in { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 122 | uint32_t handle; |
| 123 | uint32_t acceptance_req; |
| 124 | uint32_t max_atomic_len; |
| 125 | }; |
| 126 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 127 | struct __attribute__((__packed__)) fwu_commit_out { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 128 | uint32_t progress; |
| 129 | uint32_t total_work; |
| 130 | }; |
| 131 | |
Imre Kis | 7554c47 | 2024-07-04 10:09:31 +0200 | [diff] [blame] | 132 | struct __attribute__((__packed__)) fwu_accept_image_in { |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 133 | uint32_t reserved; |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 134 | uint8_t image_type_uuid[OSF_UUID_OCTET_LEN]; |
Julian Hall | 536afb1 | 2022-10-12 11:25:55 +0100 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | #endif /* FWU_PROTO_H */ |