aboutsummaryrefslogtreecommitdiff
path: root/secure_fw/include/load/partition_static_load.h
blob: f2f9c3d615a16952dfe7583e17d236ea5d75a78d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2021, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#ifndef __PARTITION_STATIC_LOAD_H__
#define __PARTITION_STATIC_LOAD_H__

#include "partition_defs.h"
#include "service_defs.h"

#define PARTITION_GET_PRIOR(flag)           ((flag) & PARTITION_PRI_MASK)
#define TO_THREAD_PRIORITY(x)               (x)

#define STRID_TO_STRING_PTR(strid)          (const char *)(strid)
#define STRING_PTR_TO_STRID(str)            (uintptr_t)(str)

#define ENTRY_TO_POSITION(x)                (uintptr_t)(x)
#define POSITION_TO_ENTRY(x, t)             (t)(x)

#define PTR_TO_POSITION(x)                  (uintptr_t)(x)
#define POSITION_TO_PTR(x, t)               (t)(x)

/* Length of extendable variables in partition static type */
#define STATIC_INFO_EXT_LENGTH              2
/*
 * Argument "ps_ptr" must have be a "struct partition_static_info_t *" type and
 * must be validated before using.
 */
#define STATIC_INFSZ_BYTES(ps_ptr)                                      \
    (sizeof(*(ps_ptr)) + STATIC_INFO_EXT_LENGTH * sizeof(uintptr_t) +   \
     (ps_ptr)->ndeps * sizeof(uint32_t) +                               \
     (ps_ptr)->nservices * sizeof(struct service_static_info_t) +       \
     (ps_ptr)->nassets * sizeof(struct asset_desc_t))

#define STATIC_INF_DEPS(ps_ptr)                                         \
    ((uintptr_t)(ps_ptr + 1) + STATIC_INFO_EXT_LENGTH * sizeof(uintptr_t))
#define STATIC_INF_SERVICE(ps_ptr)                                      \
    ((uintptr_t)STATIC_INF_DEPS(ps_ptr) + (ps_ptr)->ndeps * sizeof(uint32_t))
#define STATIC_INF_ASSET(ps_ptr)                                        \
    ((uintptr_t)STATIC_INF_SERVICE(ps_ptr) +                            \
     (ps_ptr)->nservices * sizeof(struct service_static_info_t))

#endif /* __PARTITION_STATIC_LOAD_H__ */