blob: 1e2cd6ab5caa0b5a07b8808602c710ce814fc419 [file] [log] [blame]
Ruari Phipps1925b2a2020-09-10 14:05:55 +01001/*
Olivier Deprez6baf5b82021-05-14 19:04:40 +02002 * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
Ruari Phipps1925b2a2020-09-10 14:05:55 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8#include <debug.h>
9#include <errno.h>
10#include <ffa_helpers.h>
Olivier Deprez2765ebf2020-12-16 15:46:14 +010011#include <sp_debug.h>
Daniel Boulbyf3da5912022-04-01 12:31:52 +010012#include <sp_helpers.h>
Ruari Phipps1925b2a2020-09-10 14:05:55 +010013
14#include "ivy.h"
Daniel Boulbyf3da5912022-04-01 12:31:52 +010015#include "sp_tests.h"
Ruari Phipps1925b2a2020-09-10 14:05:55 +010016
17/* Host machine information injected by the build system in the ELF file. */
18extern const char build_message[];
19extern const char version_string[];
20
21void __dead2 ivy_main(void)
22{
Daniel Boulbyce386b12022-03-29 18:36:36 +010023 struct ffa_value ret;
Olivier Deprez6baf5b82021-05-14 19:04:40 +020024 ffa_id_t my_id;
Daniel Boulbyf3da5912022-04-01 12:31:52 +010025 struct mailbox_buffers mb;
Ruari Phipps1925b2a2020-09-10 14:05:55 +010026
Kathleen Capella3cb74252023-03-14 17:51:09 -040027 set_putc_impl(FFA_SVC_SMC_CALL_AS_STDOUT);
Olivier Deprez2765ebf2020-12-16 15:46:14 +010028
Olivier Deprez6baf5b82021-05-14 19:04:40 +020029 /* Get FF-A id. */
Daniel Boulbyce386b12022-03-29 18:36:36 +010030 ret = ffa_id_get();
31 if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
Olivier Deprez6baf5b82021-05-14 19:04:40 +020032 ERROR("Cannot get FF-A id.\n");
33 panic();
34 }
Daniel Boulbyce386b12022-03-29 18:36:36 +010035 my_id = ffa_endpoint_id(ret);
Olivier Deprez24bd1702021-10-05 14:35:17 +020036
Olivier Deprez6baf5b82021-05-14 19:04:40 +020037 NOTICE("Booting Secure Partition (ID: %x)\n", my_id);
Ruari Phipps1925b2a2020-09-10 14:05:55 +010038 NOTICE("%s\n", build_message);
39 NOTICE("%s\n", version_string);
40
41init:
Daniel Boulbyf3da5912022-04-01 12:31:52 +010042 VERBOSE("Mapping RXTX Regions\n");
43 CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
44 if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
45 ERROR("Failed to map RXTX buffers. Error %x\n",
46 ffa_error_code(ret));
47 panic();
48 }
49
50 ffa_tests(&mb);
51
Daniel Boulbyce386b12022-03-29 18:36:36 +010052 ret = ffa_msg_wait();
Olivier Deprez2765ebf2020-12-16 15:46:14 +010053
Ruari Phipps1925b2a2020-09-10 14:05:55 +010054 while (1) {
Daniel Boulbyce386b12022-03-29 18:36:36 +010055 if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_REQ_SMC32) {
56 ERROR("unknown FF-A request %x\n", ffa_func_id(ret));
Ruari Phipps1925b2a2020-09-10 14:05:55 +010057 goto init;
58 }
Olivier Deprez2765ebf2020-12-16 15:46:14 +010059
J-Alvesb3f13d72022-07-04 12:03:17 +010060 VERBOSE("Received request: %lx\n", ret.arg3);
Olivier Deprez2765ebf2020-12-16 15:46:14 +010061
Daniel Boulbyce386b12022-03-29 18:36:36 +010062 ret = ffa_msg_send_direct_resp32(my_id, ffa_dir_msg_source(ret),
63 0, 0, 0, 0, 0);
Ruari Phipps1925b2a2020-09-10 14:05:55 +010064 }
65}