summaryrefslogtreecommitdiff
path: root/include/plat/common/platform.h
blob: 9b560003bf8211189365d644df8c08618cc8e25c (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of ARM nor the names of its contributors may be used
 * to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __PLATFORM_H__
#define __PLATFORM_H__

#include <stdint.h>
#include <xlat_tables.h>

void tftf_plat_arch_setup(void);
void tftf_early_platform_setup(void);
void tftf_platform_setup(void);

void tftf_enable_mmu(void);
void tftf_configure_mmu(void);

unsigned long long tftf_platform_get_time(void);
void tftf_platform_end(void);
void tftf_platform_reset(void);
void tftf_platform_watchdog_set(void);
void tftf_platform_watchdog_reset(void);

unsigned int platform_get_primary_core_mpid(void);
unsigned tftf_platform_core_whoami(void);

unsigned tftf_platform_core_pos_to_mpid(unsigned core_pos);

/* Gets a handle for the initialised IO entity */
void plat_get_nvm_handle(uintptr_t *handle);

/*
 * Handy optimization to prevent the caller from traversing through affinity
 * levels which are not present while detecting the platform topology.
 */
int plat_get_max_afflvl(void);

/*
 * This function allows to query the platform topology, Test cases can use it
 * to query the platform to determine how many affinity instances are present
 * at a particular level for a given mpidr e.g. consider a dual cluster platform
 * where each cluster has 4 cpus. A call to this function with (0, 0x100) will
 * return the number of cpus implemented under cluster 1 i.e. 4.
 * Similarly a call with (1, 0x100) will return 2 i.e. the number of clusters.
 * This is because we are effectively asking how many affinity level 1 instances
 * are implemented under affinity level 2 instance 0.
 */
unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr);

/*
 * This function allows to detect the state of an affinity instance in the
 * platform topology. Test cases can query the platform to determine whether
 * an affinity instance is present or absent. This caters for topologies where
 * an intermediate affinity level instance is missing e.g. consider a platform
 * which implements a single cluster with 4 cpus and there is another cpu
 * sitting directly on the interconnect along with the cluster. The mpidrs of
 * the cluster would range from 0x0-0x3. The mpidr of the single cpu would be
 * 0x100 to highlight that it does not belong to cluster 0. Cluster 1 is however
 * missing but needs to be accounted to reach this single cpu in the topology
 * tree. Hence it will be marked as PSCI_AFF_ABSENT. This is not applicable to
 * the FVP but depicted as an example.
 */
unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr);

/*******************************************************************************
 * Optional functions. A default, weak implementation of those functions is
 * provided, it may be overridden by platform code.
 ******************************************************************************/
unsigned int platform_get_core_pos(unsigned long mpidr);
unsigned int platform_is_primary_cpu(unsigned long mpidr);
unsigned long platform_get_stack(unsigned long mpidr);

const mmap_region_t *tftf_platform_get_mmap(void);

#endif /* __PLATFORM_H__ */