#ifndef ZIMAGE /* * For the kernel proper, we need to find out the CPU boot mode long after * boot, so we need to store it in a writable variable. * * This is not in .bss, because we set it sufficiently early that the boot-time * zeroing of .bss would clobber it.
*/
.data
.align 2
ENTRY(__boot_cpu_mode)
.long 0
.text
/* * Save the primary CPU boot mode. Requires 2 scratch registers.
*/
.macro store_primary_cpu_mode reg1, reg2
mrs \reg1, cpsr
and \reg1, \reg1, #MODE_MASK
str_l \reg1, __boot_cpu_mode, \reg2
.endm
/* * Compare the current mode with the one saved on the primary CPU. * If they don't match, record that fact. The Z bit indicates * if there's a match or not. * Requires 2 additional scratch registers.
*/
.macro compare_cpu_mode_with_primary mode, reg1, reg2
adr_l \reg2, __boot_cpu_mode
ldr \reg1, [\reg2]
cmp \mode, \reg1 @ matches primary CPU boot mode?
orrne \reg1, \reg1, #BOOT_CPU_MODE_MISMATCH
strne \reg1, [\reg2] @ record what happened and give up
.endm
/* * The zImage loader only runs on one CPU, so we don't bother with mult-CPU * consistency checking:
*/
.macro compare_cpu_mode_with_primary mode, reg1, reg2
cmp \mode, \mode
.endm
#endif /* ZIMAGE */
/* * Hypervisor stub installation functions. * * These must be called with the MMU and D-cache off. * They are not ABI compliant and are only intended to be called from the kernel * entry points in head.S.
*/
@ Call this from the primary CPU
ENTRY(__hyp_stub_install)
store_primary_cpu_mode r4, r5
ENDPROC(__hyp_stub_install)
@ fall through...
@ Secondary CPUs should call here
ENTRY(__hyp_stub_install_secondary)
mrs r4, cpsr
and r4, r4, #MODE_MASK
/* * If the secondary has booted with a different mode, give up * immediately.
*/
compare_cpu_mode_with_primary r4, r5, r6
retne lr
/* * Once we have given up on one CPU, we do not try to install the * stub hypervisor on the remaining ones: because the saved boot mode * is modified, it can't compare equal to the CPSR mode field any * more. * * Otherwise...
*/
cmp r4, #HYP_MODE
retne lr @ give up if the CPU is not in HYP mode
/* * Configure HSCTLR to set correct exception endianness/instruction set * state etc. * Turn off all traps * Eventually, CPU-specific code might be needed -- assume not for now * * This code relies on the "eret" instruction to synchronize the * various coprocessor accesses. This is done when we switch to SVC * (see safe_svcmode_maskall).
*/
@ Now install the hypervisor stub:
W(adr) r7, __hyp_stub_vectors
mcr p15, 4, r7, c12, c0, 0 @ set hypervisor vector base (HVBAR)
@ Disable all traps, so we don't get any nasty surprise
mov r7, #0
mcr p15, 4, r7, c1, c1, 0 @ HCR
mcr p15, 4, r7, c1, c1, 2 @ HCPTR
mcr p15, 4, r7, c1, c1, 3 @ HSTR
/* * __hyp_set_vectors is only used when ZIMAGE must bounce between HYP * and SVC. For the kernel itself, the vectors are set once and for * all by the stubs.
*/
ENTRY(__hyp_set_vectors)
mov r1, r0
mov r0, #HVC_SET_VECTORS
__HVC(0)
ret lr
ENDPROC(__hyp_set_vectors)
ENTRY(__hyp_soft_restart)
mov r1, r0
mov r0, #HVC_SOFT_RESTART
__HVC(0)
ret lr
ENDPROC(__hyp_soft_restart)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.