blob: 439827271e3d5bfada26390c9a226bbf6ec763e5 [file] [log] [blame]
Marc Zyngierf35a9202012-10-26 15:40:05 +01001/*
2 * Copyright (C) 2012 ARM Ltd.
3 * Author: Marc Zyngier <marc.zyngier@arm.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __ASM__VIRT_H
19#define __ASM__VIRT_H
20
21#define BOOT_CPU_MODE_EL2 (0x0e12b007)
22
23#ifndef __ASSEMBLY__
24
25/*
26 * __boot_cpu_mode records what mode CPUs were booted in.
27 * A correctly-implemented bootloader must start all CPUs in the same mode:
28 * In this case, both 32bit halves of __boot_cpu_mode will contain the
29 * same value (either 0 if booted in EL1, BOOT_CPU_MODE_EL2 if booted in EL2).
30 *
31 * Should the bootloader fail to do this, the two values will be different.
32 * This allows the kernel to flag an error when the secondaries have come up.
33 */
34extern u32 __boot_cpu_mode[2];
35
Marc Zyngier712c6ff2012-10-19 17:46:27 +010036void __hyp_set_vectors(phys_addr_t phys_vector_base);
37phys_addr_t __hyp_get_vectors(void);
38
Marc Zyngierf35a9202012-10-26 15:40:05 +010039/* Reports the availability of HYP mode */
40static inline bool is_hyp_mode_available(void)
41{
42 return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 &&
43 __boot_cpu_mode[1] == BOOT_CPU_MODE_EL2);
44}
45
46/* Check if the bootloader has booted CPUs in different modes */
47static inline bool is_hyp_mode_mismatched(void)
48{
49 return __boot_cpu_mode[0] != __boot_cpu_mode[1];
50}
51
52#endif /* __ASSEMBLY__ */
53
54#endif /* ! __ASM__VIRT_H */