Wedson Almeida Filho | 22c973a | 2018-10-27 16:25:42 +0100 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Wedson Almeida Filho | 22c973a | 2018-10-27 16:25:42 +0100 | [diff] [blame] | 3 | * |
| 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 Scull | 75e2863 | 2018-08-08 20:09:14 +0100 | [diff] [blame] | 17 | #include "offsets.h" |
| 18 | |
| 19 | .section .text.cpu_entry, "ax" |
Andrew Walbran | 375f453 | 2019-07-09 16:54:37 +0100 | [diff] [blame] | 20 | .global cpu_entry |
Andrew Scull | 75e2863 | 2018-08-08 20:09:14 +0100 | [diff] [blame] | 21 | cpu_entry: |
| 22 | /* Disable interrupts. */ |
| 23 | msr DAIFSet, #0xf |
| 24 | |
Andrew Scull | 75e2863 | 2018-08-08 20:09:14 +0100 | [diff] [blame] | 25 | /* 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 Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 37 | /* Call into C code, x0 holds the cpu pointer. */ |
Andrew Scull | 75e2863 | 2018-08-08 20:09:14 +0100 | [diff] [blame] | 38 | 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. */ |
| 44 | 0: wfi |
| 45 | b 0b |