blob: d9c9cf3a5244c5d24ade64c20928641208863802 [file] [log] [blame]
Anton Komlev4bfd6c52022-06-29 17:10:26 +01001/*
Kevin Penga9ec66f2022-07-05 15:21:16 +08002 * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Anton Komlev4bfd6c52022-06-29 17:10:26 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include <stdint.h>
9
10#include "psa/service.h"
11#include "psa_manifest/tfm_example_partition.h"
Anton Komlev4bfd6c52022-06-29 17:10:26 +010012#include "tfm_sp_log.h"
13
14/**
15 * \brief An example service implementation that prints out an argument from the
16 * client and then starts a timer.
17 */
Kevin Penga9ec66f2022-07-05 15:21:16 +080018psa_status_t tfm_example_service_sfn(const psa_msg_t *msg)
Anton Komlev4bfd6c52022-06-29 17:10:26 +010019{
20 psa_status_t status;
21 uint32_t arg;
Anton Komlev4bfd6c52022-06-29 17:10:26 +010022
23 /* Decode the message */
Kevin Penga9ec66f2022-07-05 15:21:16 +080024 switch (msg->type) {
Anton Komlev4bfd6c52022-06-29 17:10:26 +010025 case PSA_IPC_CONNECT:
26 case PSA_IPC_DISCONNECT:
Kevin Penga9ec66f2022-07-05 15:21:16 +080027 /*
28 * This service does not require any setup or teardown on connect or
Anton Komlev4bfd6c52022-06-29 17:10:26 +010029 * disconnect, so just reply with success.
30 */
31 status = PSA_SUCCESS;
32 break;
33 case PSA_IPC_CALL:
Kevin Penga9ec66f2022-07-05 15:21:16 +080034 if (msg->in_size[0] != sizeof(arg)) {
Anton Komlev4bfd6c52022-06-29 17:10:26 +010035 status = PSA_ERROR_PROGRAMMER_ERROR;
36 break;
37 }
38
39 /* Print arg from client */
Kevin Penga9ec66f2022-07-05 15:21:16 +080040 psa_read(msg->handle, 0, &arg, sizeof(arg));
Anton Komlev4bfd6c52022-06-29 17:10:26 +010041 LOG_INFFMT("[Example partition] Service called! arg=%p\r\n", arg);
42
Anton Komlev4bfd6c52022-06-29 17:10:26 +010043 status = PSA_SUCCESS;
44 break;
45 default:
46 /* Invalid message type */
47 status = PSA_ERROR_PROGRAMMER_ERROR;
48 break;
49 }
50
Kevin Penga9ec66f2022-07-05 15:21:16 +080051 return status;
Anton Komlev4bfd6c52022-06-29 17:10:26 +010052}
53
54/**
55 * \brief The example partition's entry function.
56 */
Kevin Penga9ec66f2022-07-05 15:21:16 +080057psa_status_t tfm_example_partition_main(void)
Anton Komlev4bfd6c52022-06-29 17:10:26 +010058{
Kevin Penga9ec66f2022-07-05 15:21:16 +080059 LOG_INFFMT("Example Partition initializing\r\n");
Anton Komlev4bfd6c52022-06-29 17:10:26 +010060
Kevin Penga9ec66f2022-07-05 15:21:16 +080061 return PSA_SUCCESS;
Anton Komlev4bfd6c52022-06-29 17:10:26 +010062}