arm_tzc400.c 2.06 KB
Newer Older
1
/*
Roberto Vargas's avatar
Roberto Vargas committed
2
 * Copyright (c) 2014-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
 */

7
8
9
10
11
#include <platform_def.h>

#include <common/debug.h>
#include <drivers/arm/tzc400.h>

12
#include <arm_def.h>
13
#include <arm_spm_def.h>
Roberto Vargas's avatar
Roberto Vargas committed
14
#include <plat_arm.h>
15
16
17
18
19
20
21

/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak plat_arm_security_setup


/*******************************************************************************
 * Initialize the TrustZone Controller for ARM standard platforms.
22
23
 * When booting an EL3 payload, this is simplified: we configure region 0 with
 * secure access only and do not enable any other region.
24
 ******************************************************************************/
25
void arm_tzc400_setup(const arm_tzc_regions_info_t *tzc_regions)
26
{
27
#ifndef EL3_PAYLOAD_BASE
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
28
	unsigned int region_index = 1U;
29
30
31
32
33
34
35
	const arm_tzc_regions_info_t *p;
	const arm_tzc_regions_info_t init_tzc_regions[] = {
		ARM_TZC_REGIONS_DEF,
		{0}
	};
#endif

36
37
	INFO("Configuring TrustZone Controller\n");

38
	tzc400_init(PLAT_ARM_TZC_BASE);
39
40

	/* Disable filters. */
41
	tzc400_disable_filters();
42

43
#ifndef EL3_PAYLOAD_BASE
44
45
46
47
	if (tzc_regions == NULL)
		p = init_tzc_regions;
	else
		p = tzc_regions;
48

49
	/* Region 0 set to no access by default */
50
	tzc400_configure_region0(TZC_REGION_S_NONE, 0);
51

52
53
54
55
56
57
58
	/* Rest Regions set according to tzc_regions array */
	for (; p->base != 0ULL; p++) {
		tzc400_configure_region(PLAT_ARM_TZC_FILTERS, region_index,
			p->base, p->end, p->sec_attr, p->nsaid_permissions);
		region_index++;
	}

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
59
	INFO("Total %u regions set.\n", region_index);
60
61
62

#else /* if defined(EL3_PAYLOAD_BASE) */

63
64
	/* Allow Secure and Non-secure access to DRAM for EL3 payloads */
	tzc400_configure_region0(TZC_REGION_S_RDWR, PLAT_ARM_TZC_NS_DEV_ACCESS);
65

66
#endif /* EL3_PAYLOAD_BASE */
67
68
69
70
71

	/*
	 * Raise an exception if a NS device tries to access secure memory
	 * TODO: Add interrupt handling support.
	 */
72
	tzc400_set_action(TZC_ACTION_ERR);
73
74

	/* Enable filters. */
75
	tzc400_enable_filters();
76
77
78
79
}

void plat_arm_security_setup(void)
{
80
	arm_tzc400_setup(NULL);
81
}