Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 1 | /* |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include "sp.h" |
| 8 | #include <ffa_api.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 9 | #include <components/rpc/common/endpoint/rpc_interface.h> |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 10 | #include <components/rpc/ffarpc/endpoint/ffarpc_call_ep.h> |
| 11 | #include <components/service/secure_storage/provider/secure_flash_store/sfs_provider.h> |
| 12 | #include <components/service/common/provider/service_provider.h> |
| 13 | #include <sp_api.h> |
| 14 | #include <sp_rxtx.h> |
| 15 | #include <trace.h> |
| 16 | |
| 17 | uint16_t own_id = 0; |
| 18 | static uint8_t tx_buffer[4096] __aligned(4096); |
| 19 | static uint8_t rx_buffer[4096] __aligned(4096); |
| 20 | |
| 21 | void sp_main(struct ffa_init_info *init_info) |
| 22 | { |
| 23 | ffa_result ffa_res; |
| 24 | sp_result sp_res; |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 25 | struct rpc_interface *sfs_iface; |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 26 | struct ffa_call_ep ffa_call_ep; |
| 27 | struct ffa_direct_msg req_msg; |
| 28 | struct ffa_direct_msg resp_msg; |
| 29 | struct sfs_provider sfs_provider; |
| 30 | |
| 31 | /* Boot */ |
| 32 | (void) init_info; |
| 33 | |
| 34 | ffa_res = ffa_id_get(&own_id); |
| 35 | if (ffa_res != FFA_OK) { |
| 36 | EMSG("id get error: %d", ffa_res); |
| 37 | } |
| 38 | |
| 39 | sp_res = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer)); |
| 40 | if (sp_res != SP_RESULT_OK) { |
| 41 | EMSG("rxtx map error: %d", sp_res); |
| 42 | } |
| 43 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 44 | sfs_iface = sfs_provider_init(&sfs_provider); |
| 45 | ffa_call_ep_init(&ffa_call_ep, sfs_iface); |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 46 | |
| 47 | /* End of boot phase */ |
| 48 | ffa_msg_wait(&req_msg); |
| 49 | |
| 50 | while (1) { |
| 51 | if (req_msg.function_id == FFA_MSG_SEND_DIRECT_REQ_32) { |
| 52 | ffa_call_ep_receive(&ffa_call_ep, &req_msg, &resp_msg); |
| 53 | |
| 54 | ffa_msg_send_direct_resp(req_msg.destination_id, |
| 55 | req_msg.source_id, resp_msg.args[0], resp_msg.args[1], |
| 56 | resp_msg.args[2], resp_msg.args[3], resp_msg.args[4], |
| 57 | &req_msg); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void sp_interrupt_handler(uint32_t interrupt_id) |
| 63 | { |
| 64 | (void)interrupt_id; |
| 65 | } |