Skip to content

PSA: TFM import #10829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Arm Limited. All rights reserved.
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
Expand Down Expand Up @@ -28,7 +28,7 @@
*/
struct tfm_spm_partition_platform_data_t;

#if TFM_LVL != 1
#if defined (TFM_PSA_API) || (TFM_LVL != 1)
/**
* \brief Holds SPM db fields that define the memory regions used by a
* partition.
Expand Down Expand Up @@ -147,7 +147,7 @@ uint32_t tfm_spm_hal_get_ns_MSP(void);
uint32_t tfm_spm_hal_get_ns_entry_point(void);


#if TFM_LVL != 1
#if (TFM_LVL != 1) && !defined(TFM_PSA_API)
/**
* \brief Configure the sandbox for a partition.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ struct tfm_spm_ipc_partition_t {
*/
uint32_t tfm_spm_partition_get_running_partition_id_ext(void);

/**
* \brief Get the current partition mode.
*
* \param[in] partition_idx Index of current partition
*
* \retval TFM_PARTITION_PRIVILEGED_MODE Privileged mode
* \retval TFM_PARTITION_UNPRIVILEGED_MODE Unprivileged mode
*/
uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx);

/******************** Service handle management functions ********************/

/**
Expand Down Expand Up @@ -279,22 +289,38 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
uint32_t minor_version);

/**
* \brief Check the memory reference is valid.
*
* \param[in] buffer Pointer of memory reference
* \param[in] len Length of memory reference in bytes
* \param[in] ns_caller From non-secure caller
* \param[in] access Type of access specified by the
* \ref tfm_memory_access_e
*
* \retval IPC_SUCCESS Success
* \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
* \retval IPC_ERROR_MEMORY_CHECK Check failed
* \brief Check the memory reference is valid.
*
* \param[in] buffer Pointer of memory reference
* \param[in] len Length of memory reference in bytes
* \param[in] ns_caller From non-secure caller
* \param[in] access Type of access specified by the
* \ref tfm_memory_access_e
* \param[in] privileged Privileged mode or unprivileged mode:
* \ref TFM_PARTITION_UNPRIVILEGED_MODE
* \ref TFM_PARTITION_PRIVILEGED_MODE
*
* \retval IPC_SUCCESS Success
* \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
* \retval IPC_ERROR_MEMORY_CHECK Check failed
*/
int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller,
enum tfm_memory_access_e access);
enum tfm_memory_access_e access,
uint32_t privileged);

/* This function should be called before schedule function */
void tfm_spm_init(void);

/*
* PendSV specified function.
*
* Parameters :
* ctxb - State context storage pointer
*
* Notes:
* This is a staging API. Scheduler should be called in SPM finally and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of this comment should this be marked as deprecated in some way?

* this function will be obsoleted later.
*/
void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ struct tfm_thrd_ctx *tfm_thrd_curr_thread(void);
*/
struct tfm_thrd_ctx *tfm_thrd_next_thread(void);

/*
* Start scheduler for existing threads
*
* Parameters:
* pth - pointer of the caller context collecting thread
*
* Notes :
* This function should be called only ONCE to start the scheduler.
* Caller needs to provide a thread object to collect current context.
* The usage of the collected context is caller defined.
*/
void tfm_thrd_start_scheduler(struct tfm_thrd_ctx *pth);

/*
* Activate a scheduling action after exception.
*
Expand All @@ -201,23 +214,19 @@ void tfm_thrd_context_switch(struct tfm_state_context_ext *ctxb,
struct tfm_thrd_ctx *next);

/*
* Exit current running thread.
* Svcall to exit current running thread.
*
* Notes :
* Remove current thread out of schedulable list.
*/
void tfm_thrd_do_exit(void);
void tfm_svcall_thrd_exit(void);

/*
* PendSV specified function.
*
* Parameters :
* ctxb - State context storage pointer
* Exit current running thread for client.
*
* Notes:
* This is a staging API. Scheduler should be called in SPM finally and
* this function will be obsoleted later.
* Must be called in thread mode.
*/
void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb);
void tfm_thrd_exit(void);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why abbreviate so aggressively? tfm_thread_exit(), anyone?


#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
#include "tfm_svc.h"
#include "psa_client.h"

__attribute__((naked))
__attribute__((naked, section("SFN")))
uint32_t psa_framework_version(void)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_FRAMEWORK_VERSION));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
uint32_t psa_version(uint32_t sid)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_VERSION));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_CONNECT));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
psa_status_t psa_call(psa_handle_t handle,
const psa_invec *in_vec,
size_t in_len,
Expand All @@ -46,7 +46,7 @@ psa_status_t psa_call(psa_handle_t handle,
: : "I" (TFM_SVC_PSA_CALL));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_close(psa_handle_t handle)
{
__ASM volatile("SVC %0 \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "psa_client.h"
#include "psa_service.h"

__attribute__((naked))
__attribute__((naked, section("SFN")))
psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)

{
Expand All @@ -20,23 +20,23 @@ psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)
: : "I" (TFM_SVC_PSA_WAIT));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
psa_status_t psa_get(psa_signal_t signal, psa_msg_t *msg)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_GET));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_set_rhandle(psa_handle_t msg_handle, void *rhandle)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_SET_RHANDLE));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
void *buffer, size_t num_bytes)

Expand All @@ -46,15 +46,15 @@ size_t psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
: : "I" (TFM_SVC_PSA_READ));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
size_t psa_skip(psa_handle_t msg_handle, uint32_t invec_idx, size_t num_bytes)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_SKIP));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
const void *buffer, size_t num_bytes)
{
Expand All @@ -63,31 +63,31 @@ void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx,
: : "I" (TFM_SVC_PSA_WRITE));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_reply(psa_handle_t msg_handle, psa_status_t retval)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_REPLY));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_notify(int32_t partition_id)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_NOTIFY));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_clear(void)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_CLEAR));
}

__attribute__((naked))
__attribute__((naked, section("SFN")))
void psa_eoi(psa_signal_t irq_signal)
{
__ASM volatile("SVC %0 \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,10 @@

/* This file contains the ARCH code for ARM V8M */

/*
* Thread exit zone.
* This function is set as the return address of thread entry and only
* privileged thread could return here. Un-privileged thread triggers
* fault if it tries to jump here and it gets exit by fault handler.
*
* The reason of putting this function here is for fault handler checking.
* Function address could be checked in fault handler to know it is a REAL
* thread exit or just an exception.
*/
__attribute__((section("SFN")))
static void exit_zone(void)
{
tfm_thrd_do_exit();
tfm_thrd_exit();
}

void tfm_initialize_context(struct tfm_state_context *ctx,
Expand Down
Loading