Imre Kis | 5efe9e8 | 2021-09-03 17:35:16 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include "components/rpc/ffarpc/endpoint/sel1_sp/sel1_sp_ffarpc_call_ep.h" |
| 7 | #include "components/service/log/provider/log_provider.h" |
| 8 | #include <ffa.h> |
| 9 | #include <kernel/pseudo_sp.h> |
| 10 | #include <stdio.h> |
| 11 | #include <trace.h> |
| 12 | |
| 13 | #define SP_NAME "log.psp" |
| 14 | |
| 15 | #define SP_LOG_UUID \ |
| 16 | { \ |
| 17 | 0xda9dffbd, 0xd590, 0x40ed, \ |
| 18 | { \ |
| 19 | 0x97, 0x5f, 0x19, 0xc6, 0x5a, 0x3d, 0x52, 0xd3 \ |
| 20 | } \ |
| 21 | } |
| 22 | |
| 23 | static void optee_log_puts(const char *str) |
| 24 | { |
| 25 | trace_ext_puts(str); |
| 26 | } |
| 27 | |
| 28 | static struct log_interface optee_log_interface = { .puts = optee_log_puts }; |
| 29 | |
| 30 | static TEE_Result sp_log_main(uint32_t session_id) |
| 31 | { |
| 32 | struct sp_session *s = sp_get_session(session_id); |
| 33 | struct thread_smc_args args = { 0 }; |
| 34 | struct log_provider log_provider = { 0 }; |
| 35 | struct rpc_interface *log_iface = NULL; |
| 36 | struct ffa_call_ep ffa_call_ep = { 0 }; |
| 37 | uint16_t caller_id = 0; |
| 38 | uint16_t own_id = 0; |
| 39 | |
| 40 | DMSG("SEL1 log SP init"); |
| 41 | |
| 42 | pseudo_sp_ffa(s, &args); |
| 43 | |
| 44 | log_iface = log_provider_init(&log_provider, &optee_log_interface); |
| 45 | ffa_call_ep_init(&ffa_call_ep, log_iface); |
| 46 | |
| 47 | while (true) { |
| 48 | caller_id = ((args.a1 >> 16) & 0xffff); |
| 49 | own_id = (args.a1 & 0xffff); |
| 50 | |
| 51 | ffa_call_ep_receive(&ffa_call_ep, &args, &args); |
| 52 | |
| 53 | args.a0 = FFA_MSG_SEND_DIRECT_RESP_32; |
| 54 | args.a1 = ((own_id) << 16) | caller_id; |
| 55 | args.a2 = 0x00; |
| 56 | args.a3 = 0x00; /* RC = 0 */ |
| 57 | pseudo_sp_ffa(s, &args); |
| 58 | } |
| 59 | |
| 60 | return TEE_SUCCESS; |
| 61 | } |
| 62 | |
| 63 | pseudo_sp_register(.uuid = SP_LOG_UUID, .name = SP_NAME, .invoke_command_entry_point = sp_log_main); |