blob: 4a2078f5ecc3daae7b13940a6e7a36893c4f8e4e [file] [log] [blame]
Imre Kise1b18a82024-06-28 12:27:59 +02001/*
2 * Copyright (c) 2024, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include "update_agent_interface.h"
8#include "protocols/service/fwu/packed-c/status.h"
9
10int update_agent_discover(struct update_agent *update_agent, struct fwu_discovery_result *result)
11{
12 if (!update_agent->interface->discover)
13 return FWU_STATUS_NOT_AVAILABLE;
14
15 return update_agent->interface->discover(update_agent->context, result);
16}
17
18int update_agent_begin_staging(struct update_agent *update_agent, uint32_t vendor_flags,
19 uint32_t partial_update_count,
20 const struct uuid_octets *update_guid)
21{
22 if (!update_agent->interface->begin_staging)
23 return FWU_STATUS_NOT_AVAILABLE;
24
25 return update_agent->interface->begin_staging(update_agent->context, vendor_flags,
26 partial_update_count, update_guid);
27}
28
29int update_agent_end_staging(struct update_agent *update_agent)
30{
31 if (!update_agent->interface->end_staging)
32 return FWU_STATUS_NOT_AVAILABLE;
33
34 return update_agent->interface->end_staging(update_agent->context);
35}
36
37int update_agent_cancel_staging(struct update_agent *update_agent)
38{
39 if (!update_agent->interface->cancel_staging)
40 return FWU_STATUS_NOT_AVAILABLE;
41
42 return update_agent->interface->cancel_staging(update_agent->context);
43}
44
45int update_agent_open(struct update_agent *update_agent, const struct uuid_octets *uuid,
46 uint8_t op_type, uint32_t *handle)
47{
48 if (!update_agent->interface->open)
49 return FWU_STATUS_NOT_AVAILABLE;
50
51 return update_agent->interface->open(update_agent->context, uuid, op_type, handle);
52}
53
54int update_agent_write_stream(struct update_agent *update_agent, uint32_t handle,
55 const uint8_t *data, size_t data_len)
56{
57 if (!update_agent->interface->write_stream)
58 return FWU_STATUS_NOT_AVAILABLE;
59
60 return update_agent->interface->write_stream(update_agent->context, handle, data, data_len);
61}
62
63int update_agent_read_stream(struct update_agent *update_agent, uint32_t handle, uint8_t *buf,
64 size_t buf_size, size_t *read_len, size_t *total_len)
65{
66 if (!update_agent->interface->read_stream)
67 return FWU_STATUS_NOT_AVAILABLE;
68
69 return update_agent->interface->read_stream(update_agent->context, handle, buf, buf_size,
70 read_len, total_len);
71}
72
73int update_agent_commit(struct update_agent *update_agent, uint32_t handle, bool accepted,
74 uint32_t max_atomic_len, uint32_t *progress, uint32_t *total_work)
75{
76 if (!update_agent->interface->commit)
77 return FWU_STATUS_NOT_AVAILABLE;
78
79 return update_agent->interface->commit(update_agent->context, handle, accepted,
80 max_atomic_len, progress, total_work);
81}
82
83int update_agent_accept_image(struct update_agent *update_agent,
84 const struct uuid_octets *image_type_uuid)
85{
86 if (!update_agent->interface->accept_image)
87 return FWU_STATUS_NOT_AVAILABLE;
88
89 return update_agent->interface->accept_image(update_agent->context, image_type_uuid);
90}
91
92int update_agent_select_previous(struct update_agent *update_agent)
93{
94 if (!update_agent->interface->select_previous)
95 return FWU_STATUS_NOT_AVAILABLE;
96
97 return update_agent->interface->select_previous(update_agent->context);
98}