blob: 301a1a10d6b73457ff526c1607c439498fed24f9 [file] [log] [blame]
Wedson Almeida Filho22c973a2018-10-27 16:25:42 +01001/*
Andrew Walbran692b3252019-03-07 15:51:31 +00002 * Copyright 2018 The Hafnium Authors.
Wedson Almeida Filho22c973a2018-10-27 16:25:42 +01003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Andrew Scull75e28632018-08-08 20:09:14 +010017#include "offsets.h"
18
19.section .text.cpu_entry, "ax"
Andrew Walbran375f4532019-07-09 16:54:37 +010020.global cpu_entry
Andrew Scull75e28632018-08-08 20:09:14 +010021cpu_entry:
22 /* Disable interrupts. */
23 msr DAIFSet, #0xf
24
Andrew Scull75e28632018-08-08 20:09:14 +010025 /* Use SPx (instead of SP0). */
26 msr spsel, #1
27
28 /* Prepare the stack. */
29 ldr x30, [x0, #CPU_STACK_BOTTOM]
30 mov sp, x30
31
32 /* Configure exception handlers. */
33 adrp x30, vector_table_el2
34 add x30, x30, :lo12:vector_table_el2
35 msr vbar_el2, x30
36
Wedson Almeida Filho00df6c72018-10-18 11:19:24 +010037 /* Call into C code, x0 holds the cpu pointer. */
Andrew Scull75e28632018-08-08 20:09:14 +010038 bl cpu_main
39
40 /* Run the vcpu returned by cpu_main. */
41 bl vcpu_restore_all_and_run
42
43 /* Loop forever waiting for interrupts. */
440: wfi
45 b 0b