blob: 442abd72bab3d533f9b39c4c71ffd675405a48cf [file] [log] [blame]
Kevin Peng93fb9f52020-09-17 11:45:54 +08001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_HAL_ISOLATION_H__
9#define __TFM_HAL_ISOLATION_H__
10
11#include <stddef.h>
12#include <stdint.h>
13#include "tfm_hal_defs.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* Memory access attributes */
20#define TFM_HAL_ACCESS_EXECUTABLE (1UL << 0)
21#define TFM_HAL_ACCESS_READABLE (1UL << 1)
22#define TFM_HAL_ACCESS_WRITABLE (1UL << 2)
23#define TFM_HAL_ACCESS_UNPRIVILEGED (1UL << 3)
24#define TFM_HAL_ACCESS_DEVICE (1UL << 4)
25#define TFM_HAL_ACCESS_NS (1UL << 5)
26
27/**
28 * \brief Sets up the static isolation boundaries which are constant throughout
29 * the runtime of the system, including the SPE/NSPE and partition
30 * boundaries.
31 *
32 * \return TFM_HAL_SUCCESS - the isolation boundaries have been set up.
33 * TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundaries.
34 */
35enum tfm_hal_status_t tfm_hal_set_up_static_boundaries(void);
36
37/**
38 * \brief This API checks if the memory region defined by base and size
39 * matches the given attributes - attr.
40 * The attributes can include NSPE access, privileged mode, and
41 * read-write permissions.
42 *
43 * \param[in] base The base address of the region.
44 * \param[in] size The size of the region.
45 * \param[in] attr The memory access attributes.
46 *
47 * \return TFM_HAL_SUCCESS - The memory region has the access permissions.
48 * TFM_HAL_ERROR_MEM_FAULT - The memory region has not the access
49 * permissions.
50 * TFM_HAL_ERROR_INVALID_INPUT - Invalid inputs.
51 * TFM_HAL_ERROR_GENERIC - An error occurred.
52 */
53enum tfm_hal_status_t tfm_hal_memory_has_access(uintptr_t base,
54 size_t size,
55 uint32_t attr);
56
57#if TFM_LVL == 3
58/**
59 * \brief Updates the partition isolation boundary for isolation level 3.
60 * The boundary protects the private data of the running partition.
61 * The boundary is updated with SPM switching partition in level 3.
62 *
63 * \param[in] start start address of the partition boundary.
64 * \param[in] end end address of the partition boundary.
65 *
66 * \return TFM_HAL_SUCCESS - the isolation boundary has been set up.
67 * TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundary.
68 */
69enum tfm_hal_status_t tfm_hal_mpu_update_partition_boundary(uintptr_t start,
70 uintptr_t end);
71#endif
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif /* __TFM_HAL_ISOLATION_H__ */