tzc_common.h 2.99 KB
Newer Older
1
/*
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
2
 * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
7
8
9
10
#ifndef TZC_COMMON_H
#define TZC_COMMON_H

#include <utils_def.h>
11
12
13
14
15
16
17

/*
 * Offset of core registers from the start of the base of configuration
 * registers for each region.
 */

/* ID Registers */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
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
#define PID0_OFF					U(0xfe0)
#define PID1_OFF					U(0xfe4)
#define PID2_OFF					U(0xfe8)
#define PID3_OFF					U(0xfec)
#define PID4_OFF					U(0xfd0)
#define CID0_OFF					U(0xff0)
#define CID1_OFF					U(0xff4)
#define CID2_OFF					U(0xff8)
#define CID3_OFF					U(0xffc)

/*
 * What type of action is expected when an access violation occurs.
 * The memory requested is returned as zero. But we can also raise an event to
 * let the system know it happened.
 * We can raise an interrupt(INT) and/or cause an exception(ERR).
 *  TZC_ACTION_NONE    - No interrupt, no Exception
 *  TZC_ACTION_ERR     - No interrupt, raise exception -> sync external
 *                       data abort
 *  TZC_ACTION_INT     - Raise interrupt, no exception
 *  TZC_ACTION_ERR_INT - Raise interrupt, raise exception -> sync
 *                       external data abort
 */
#define TZC_ACTION_NONE			U(0)
#define TZC_ACTION_ERR			U(1)
#define TZC_ACTION_INT			U(2)
#define TZC_ACTION_ERR_INT		(TZC_ACTION_ERR | TZC_ACTION_INT)
44
45
46

/* Bit positions of TZC_ACTION registers */
#define TZC_ACTION_RV_SHIFT				0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#define TZC_ACTION_RV_MASK				U(0x3)
#define TZC_ACTION_RV_LOWOK				U(0x0)
#define TZC_ACTION_RV_LOWERR				U(0x1)
#define TZC_ACTION_RV_HIGHOK				U(0x2)
#define TZC_ACTION_RV_HIGHERR				U(0x3)

/*
 * Controls secure access to a region. If not enabled secure access is not
 * allowed to region.
 */
#define TZC_REGION_S_NONE		U(0)
#define TZC_REGION_S_RD			U(1)
#define TZC_REGION_S_WR			U(2)
#define TZC_REGION_S_RDWR		(TZC_REGION_S_RD | TZC_REGION_S_WR)
61
62
63
64
65

#define TZC_REGION_ATTR_S_RD_SHIFT			30
#define TZC_REGION_ATTR_S_WR_SHIFT			31
#define TZC_REGION_ATTR_F_EN_SHIFT			0
#define TZC_REGION_ATTR_SEC_SHIFT			30
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
66
67
68
#define TZC_REGION_ATTR_S_RD_MASK			U(0x1)
#define TZC_REGION_ATTR_S_WR_MASK			U(0x1)
#define TZC_REGION_ATTR_SEC_MASK			U(0x3)
69
70
71

#define TZC_REGION_ACCESS_WR_EN_SHIFT			16
#define TZC_REGION_ACCESS_RD_EN_SHIFT			0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
72
#define TZC_REGION_ACCESS_ID_MASK			U(0xf)
73
74
75

/* Macros for allowing Non-Secure access to a region based on NSAID */
#define TZC_REGION_ACCESS_RD(nsaid)				\
76
	((U(1) << ((nsaid) & TZC_REGION_ACCESS_ID_MASK)) <<	\
77
78
	 TZC_REGION_ACCESS_RD_EN_SHIFT)
#define TZC_REGION_ACCESS_WR(nsaid)				\
79
	((U(1) << ((nsaid) & TZC_REGION_ACCESS_ID_MASK)) <<	\
80
81
82
83
84
85
86
87
88
	 TZC_REGION_ACCESS_WR_EN_SHIFT)
#define TZC_REGION_ACCESS_RDWR(nsaid)				\
	(TZC_REGION_ACCESS_RD(nsaid) |				\
	TZC_REGION_ACCESS_WR(nsaid))

/* Returns offset of registers to program for a given region no */
#define TZC_REGION_OFFSET(region_size, region_no)	\
				((region_size) * (region_no))

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
89
#ifndef __ASSEMBLY__
90

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
91
92
93
94
#if !ERROR_DEPRECATED
typedef unsigned int tzc_action_t;
typedef unsigned int tzc_region_attributes_t;
#endif
95
96

#endif /* __ASSEMBLY__ */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
97
#endif /* TZC_COMMON_H */