blob: 1aafb577f10982a3be11ed6bf0281290f480a027 [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>
Ruari Phipps1925b2a2020-09-10 14:05:55 +010012
13#include "ivy.h"
14
15/* Host machine information injected by the build system in the ELF file. */
16extern const char build_message[];
17extern const char version_string[];
18
19void __dead2 ivy_main(void)
20{
Daniel Boulbyce386b12022-03-29 18:36:36 +010021 struct ffa_value ret;
Olivier Deprez6baf5b82021-05-14 19:04:40 +020022 ffa_id_t my_id;
Ruari Phipps1925b2a2020-09-10 14:05:55 +010023
Olivier Deprez2765ebf2020-12-16 15:46:14 +010024 set_putc_impl(SVC_CALL_AS_STDOUT);
25
Olivier Deprez6baf5b82021-05-14 19:04:40 +020026 /* Get FF-A id. */
Daniel Boulbyce386b12022-03-29 18:36:36 +010027 ret = ffa_id_get();
28 if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
Olivier Deprez6baf5b82021-05-14 19:04:40 +020029 ERROR("Cannot get FF-A id.\n");
30 panic();
31 }
Daniel Boulbyce386b12022-03-29 18:36:36 +010032 my_id = ffa_endpoint_id(ret);
Olivier Deprez24bd1702021-10-05 14:35:17 +020033
Olivier Deprez6baf5b82021-05-14 19:04:40 +020034 NOTICE("Booting Secure Partition (ID: %x)\n", my_id);
Ruari Phipps1925b2a2020-09-10 14:05:55 +010035 NOTICE("%s\n", build_message);
36 NOTICE("%s\n", version_string);
37
38init:
Daniel Boulbyce386b12022-03-29 18:36:36 +010039 ret = ffa_msg_wait();
Olivier Deprez2765ebf2020-12-16 15:46:14 +010040
Ruari Phipps1925b2a2020-09-10 14:05:55 +010041 while (1) {
Daniel Boulbyce386b12022-03-29 18:36:36 +010042 if (ffa_func_id(ret) != FFA_MSG_SEND_DIRECT_REQ_SMC32) {
43 ERROR("unknown FF-A request %x\n", ffa_func_id(ret));
Ruari Phipps1925b2a2020-09-10 14:05:55 +010044 goto init;
45 }
Olivier Deprez2765ebf2020-12-16 15:46:14 +010046
Daniel Boulbyce386b12022-03-29 18:36:36 +010047 VERBOSE("Received request: %lx\n", ret.ret3);
Olivier Deprez2765ebf2020-12-16 15:46:14 +010048
Daniel Boulbyce386b12022-03-29 18:36:36 +010049 ret = ffa_msg_send_direct_resp32(my_id, ffa_dir_msg_source(ret),
50 0, 0, 0, 0, 0);
Ruari Phipps1925b2a2020-09-10 14:05:55 +010051 }
52}