blob: 4bcacb1f4aa0b8d93d19bdac808dcfea8ec466de [file] [log] [blame]
Julian Hall536afb12022-10-12 11:25:55 +01001/*
Imre Kis18b387d2024-07-02 13:51:07 +02002 * Copyright (c) 2022-2024, Arm Limited and Contributors. All rights reserved.
Julian Hall536afb12022-10-12 11:25:55 +01003 *
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 Szing3c446242023-03-31 01:53:15 +020011
Julian Hall536afb12022-10-12 11:25:55 +010012#include "opcodes.h"
Gyorgy Szing3c446242023-03-31 01:53:15 +020013#include "protocols/common/osf/uuid.h"
Julian Hall536afb12022-10-12 11:25:55 +010014#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 Kis18b387d2024-07-02 13:51:07 +020020#define FWU_PROTOCOL_VERSION_MAJOR 1
Julian Hall536afb12022-10-12 11:25:55 +010021
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 Szing3c446242023-03-31 01:53:15 +020031#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 Hall536afb12022-10-12 11:25:55 +010034
Imre Kis18b387d2024-07-02 13:51:07 +020035#define FWU_OPEN_OP_TYPE_READ (0)
36#define FWU_OPEN_OP_TYPE_WRITE (1)
37
Julian Hall536afb12022-10-12 11:25:55 +010038/**
39 * Image directory
40 */
Imre Kis18b387d2024-07-02 13:51:07 +020041#define FWU_IMAGE_DIRECTORY_VERSION (2)
Julian Hall536afb12022-10-12 11:25:55 +010042
Imre Kis7554c472024-07-04 10:09:31 +020043struct __attribute__((__packed__)) fwu_image_info_entry {
Gyorgy Szing3c446242023-03-31 01:53:15 +020044 uint8_t img_type_uuid[OSF_UUID_OCTET_LEN];
Julian Hall536afb12022-10-12 11:25:55 +010045 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 Kis7554c472024-07-04 10:09:31 +020053struct __attribute__((__packed__)) fwu_image_directory {
Julian Hall536afb12022-10-12 11:25:55 +010054 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 Kis7554c472024-07-04 10:09:31 +020060 struct fwu_image_info_entry img_info_entry[];
Julian Hall536afb12022-10-12 11:25:55 +010061};
62
63/**
64 * Message parameters
65 */
66
Imre Kis7554c472024-07-04 10:09:31 +020067struct __attribute__((__packed__)) fwu_request_header {
Imre Kis6fd73d82024-07-04 13:36:10 +020068 uint32_t func_id;
69 uint8_t payload[];
70};
71
Imre Kis7554c472024-07-04 10:09:31 +020072struct __attribute__((__packed__)) fwu_response_header {
Imre Kis6fd73d82024-07-04 13:36:10 +020073 uint32_t status;
74 uint8_t payload[];
75};
76
Imre Kis7554c472024-07-04 10:09:31 +020077struct __attribute__((__packed__)) fwu_discover_out {
Imre Kis18b387d2024-07-02 13:51:07 +020078 int16_t service_status;
Gyorgy Szing3c446242023-03-31 01:53:15 +020079 uint8_t version_major;
80 uint8_t version_minor;
Imre Kis18b387d2024-07-02 13:51:07 +020081 uint16_t off_function_presence;
Julian Hall536afb12022-10-12 11:25:55 +010082 uint16_t num_func;
Imre Kis18b387d2024-07-02 13:51:07 +020083 uint64_t max_payload_size;
84 uint32_t flags;
85 uint32_t vendor_specific_flags;
Gyorgy Szing3c446242023-03-31 01:53:15 +020086 uint8_t function_presence[];
Julian Hall536afb12022-10-12 11:25:55 +010087};
88
Imre Kis7554c472024-07-04 10:09:31 +020089struct __attribute__((__packed__)) fwu_begin_staging_in {
Imre Kis18b387d2024-07-02 13:51:07 +020090 uint32_t reserved;
91 uint32_t vendor_flags;
92 uint32_t partial_update_count;
93 uint8_t update_guid[];
94};
95
Imre Kis7554c472024-07-04 10:09:31 +020096struct __attribute__((__packed__)) fwu_open_in {
Gyorgy Szing3c446242023-03-31 01:53:15 +020097 uint8_t image_type_uuid[OSF_UUID_OCTET_LEN];
Imre Kis18b387d2024-07-02 13:51:07 +020098 uint8_t op_type;
Julian Hall536afb12022-10-12 11:25:55 +010099};
100
Imre Kis7554c472024-07-04 10:09:31 +0200101struct __attribute__((__packed__)) fwu_open_out {
Julian Hall536afb12022-10-12 11:25:55 +0100102 uint32_t handle;
103};
104
Imre Kis7554c472024-07-04 10:09:31 +0200105struct __attribute__((__packed__)) fwu_write_stream_in {
Julian Hall536afb12022-10-12 11:25:55 +0100106 uint32_t handle;
107 uint32_t data_len;
Gyorgy Szing3c446242023-03-31 01:53:15 +0200108 uint8_t payload[];
Julian Hall536afb12022-10-12 11:25:55 +0100109};
110
Imre Kis7554c472024-07-04 10:09:31 +0200111struct __attribute__((__packed__)) fwu_read_stream_in {
Julian Hall536afb12022-10-12 11:25:55 +0100112 uint32_t handle;
113};
114
Imre Kis7554c472024-07-04 10:09:31 +0200115struct __attribute__((__packed__)) fwu_read_stream_out {
Julian Hall536afb12022-10-12 11:25:55 +0100116 uint32_t read_bytes;
117 uint32_t total_bytes;
Gyorgy Szing3c446242023-03-31 01:53:15 +0200118 uint8_t payload[];
Julian Hall536afb12022-10-12 11:25:55 +0100119};
120
Imre Kis7554c472024-07-04 10:09:31 +0200121struct __attribute__((__packed__)) fwu_commit_in {
Julian Hall536afb12022-10-12 11:25:55 +0100122 uint32_t handle;
123 uint32_t acceptance_req;
124 uint32_t max_atomic_len;
125};
126
Imre Kis7554c472024-07-04 10:09:31 +0200127struct __attribute__((__packed__)) fwu_commit_out {
Julian Hall536afb12022-10-12 11:25:55 +0100128 uint32_t progress;
129 uint32_t total_work;
130};
131
Imre Kis7554c472024-07-04 10:09:31 +0200132struct __attribute__((__packed__)) fwu_accept_image_in {
Julian Hall536afb12022-10-12 11:25:55 +0100133 uint32_t reserved;
Gyorgy Szing3c446242023-03-31 01:53:15 +0200134 uint8_t image_type_uuid[OSF_UUID_OCTET_LEN];
Julian Hall536afb12022-10-12 11:25:55 +0100135};
136
137#endif /* FWU_PROTO_H */