1 /*
2  * Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include "proxy_fwu_dut.h"
8 
9 #include <cassert>
10 
11 #include "service/fwu/test/fwu_client/remote/remote_fwu_client.h"
12 #include "service/fwu/test/metadata_fetcher/client/client_metadata_fetcher.h"
13 
proxy_fwu_dut(unsigned int num_locations,unsigned int metadata_version,fwu_dut * remote_dut)14 proxy_fwu_dut::proxy_fwu_dut(unsigned int num_locations, unsigned int metadata_version,
15 			     fwu_dut *remote_dut)
16 	: fwu_dut(metadata_version)
17 	, m_num_locations(num_locations)
18 	, m_remote_dut(remote_dut)
19 {
20 }
21 
~proxy_fwu_dut()22 proxy_fwu_dut::~proxy_fwu_dut()
23 {
24 	delete m_remote_dut;
25 	m_remote_dut = NULL;
26 }
27 
boot(bool from_active_bank)28 void proxy_fwu_dut::boot(bool from_active_bank)
29 {
30 	if (m_remote_dut)
31 		m_remote_dut->boot(from_active_bank);
32 }
33 
shutdown(void)34 void proxy_fwu_dut::shutdown(void)
35 {
36 	if (m_remote_dut)
37 		m_remote_dut->shutdown();
38 }
39 
get_boot_info(void) const40 struct boot_info proxy_fwu_dut::get_boot_info(void) const
41 {
42 	assert(m_remote_dut);
43 	return m_remote_dut->get_boot_info();
44 }
45 
create_metadata_checker(bool is_primary) const46 metadata_checker *proxy_fwu_dut::create_metadata_checker(bool is_primary) const
47 {
48 	(void)is_primary;
49 
50 	/* Use service interface to fetch metadata as volume access is no possible */
51 	fwu_client *fwu_client = new remote_fwu_client;
52 	metadata_fetcher *metadata_fetcher = new client_metadata_fetcher(fwu_client);
53 
54 	return fwu_dut::create_metadata_checker(metadata_fetcher, m_num_locations);
55 }
56 
create_fwu_client(void)57 fwu_client *proxy_fwu_dut::create_fwu_client(void)
58 {
59 	/* Access service via RPC */
60 	return new remote_fwu_client;
61 }
62