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> |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 11 | #include <components/service/secure_storage/factory/storage_factory.h> |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 12 | #include <components/service/secure_storage/frontend/secure_storage_provider/secure_storage_provider.h> |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 13 | #include <sp_api.h> |
Imre Kis | 76e8a3c | 2021-04-16 16:54:17 +0200 | [diff] [blame] | 14 | #include <sp_messaging.h> |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 15 | #include <sp_rxtx.h> |
| 16 | #include <trace.h> |
| 17 | |
| 18 | uint16_t own_id = 0; |
| 19 | static uint8_t tx_buffer[4096] __aligned(4096); |
| 20 | static uint8_t rx_buffer[4096] __aligned(4096); |
| 21 | |
| 22 | void sp_main(struct ffa_init_info *init_info) |
| 23 | { |
| 24 | ffa_result ffa_res; |
| 25 | sp_result sp_res; |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 26 | struct rpc_interface *secure_storage_iface; |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 27 | struct ffa_call_ep ffa_call_ep; |
Imre Kis | 76e8a3c | 2021-04-16 16:54:17 +0200 | [diff] [blame] | 28 | struct sp_msg req_msg = { 0 }; |
| 29 | struct sp_msg resp_msg = { 0 }; |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 30 | struct secure_storage_provider secure_storage_provider; |
| 31 | struct storage_backend *storage_backend; |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 32 | |
| 33 | /* Boot */ |
| 34 | (void) init_info; |
| 35 | |
| 36 | ffa_res = ffa_id_get(&own_id); |
| 37 | if (ffa_res != FFA_OK) { |
| 38 | EMSG("id get error: %d", ffa_res); |
| 39 | } |
| 40 | |
| 41 | sp_res = sp_rxtx_buffer_map(tx_buffer, rx_buffer, sizeof(rx_buffer)); |
| 42 | if (sp_res != SP_RESULT_OK) { |
| 43 | EMSG("rxtx map error: %d", sp_res); |
| 44 | } |
| 45 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 46 | storage_backend = storage_factory_create(storage_factory_security_class_INTERNAL_TRUSTED); |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 47 | secure_storage_iface = secure_storage_provider_init(&secure_storage_provider, storage_backend); |
| 48 | ffa_call_ep_init(&ffa_call_ep, secure_storage_iface); |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 49 | |
| 50 | /* End of boot phase */ |
Imre Kis | 76e8a3c | 2021-04-16 16:54:17 +0200 | [diff] [blame] | 51 | sp_msg_wait(&req_msg); |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 52 | |
| 53 | while (1) { |
Imre Kis | 76e8a3c | 2021-04-16 16:54:17 +0200 | [diff] [blame] | 54 | ffa_call_ep_receive(&ffa_call_ep, &req_msg, &resp_msg); |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 55 | |
Imre Kis | 76e8a3c | 2021-04-16 16:54:17 +0200 | [diff] [blame] | 56 | resp_msg.source_id = req_msg.destination_id; |
| 57 | resp_msg.destination_id = req_msg.source_id; |
| 58 | |
| 59 | sp_msg_send_direct_resp(&resp_msg, &req_msg); |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | |
| 63 | void sp_interrupt_handler(uint32_t interrupt_id) |
| 64 | { |
| 65 | (void)interrupt_id; |
| 66 | } |