Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Hafnium Authors. |
| 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style |
| 5 | * license that can be found in the LICENSE file or at |
| 6 | * https://opensource.org/licenses/BSD-3-Clause. |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 9 | #include <stdint.h> |
| 10 | |
Andrew Walbran | 0fc4d41 | 2019-11-06 17:22:32 +0000 | [diff] [blame] | 11 | #include "hf/arch/vm/interrupts.h" |
| 12 | |
David Brazdil | 711fbe9 | 2019-08-06 13:39:58 +0100 | [diff] [blame] | 13 | #include "hf/mm.h" |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 14 | |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 15 | #include "hftest_common.h" |
Andrew Walbran | 1e7c774 | 2019-12-13 17:10:02 +0000 | [diff] [blame] | 16 | #include "test/hftest.h" |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 17 | |
J-Alves | e44e18e | 2024-10-29 14:11:16 +0000 | [diff] [blame] | 18 | alignas(4096) uint8_t kstack[2 * 4096]; |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 19 | |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 20 | void kmain(const void *fdt_ptr) |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 21 | { |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 22 | struct fdt fdt; |
| 23 | size_t fdt_len; |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 24 | |
David Brazdil | 711fbe9 | 2019-08-06 13:39:58 +0100 | [diff] [blame] | 25 | /* |
| 26 | * Initialize the stage-1 MMU and identity-map the entire address space. |
| 27 | */ |
| 28 | if ((VM_TOOLCHAIN == 1) && !hftest_mm_init()) { |
| 29 | HFTEST_LOG("Memory initialization failed."); |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 30 | goto out; |
David Brazdil | 711fbe9 | 2019-08-06 13:39:58 +0100 | [diff] [blame] | 31 | } |
| 32 | |
Andrew Walbran | 0fc4d41 | 2019-11-06 17:22:32 +0000 | [diff] [blame] | 33 | /* |
| 34 | * Install the exception handler with no IRQ callback for now, so that |
| 35 | * exceptions are logged. |
| 36 | */ |
Fuad Tabba | 3e9b022 | 2019-11-11 16:47:50 +0000 | [diff] [blame] | 37 | exception_setup(NULL, NULL); |
Andrew Walbran | 0fc4d41 | 2019-11-06 17:22:32 +0000 | [diff] [blame] | 38 | |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 39 | if (!fdt_size_from_header(fdt_ptr, &fdt_len) || |
| 40 | !fdt_init_from_ptr(&fdt, fdt_ptr, fdt_len)) { |
| 41 | HFTEST_LOG("Unable to init FDT."); |
| 42 | goto out; |
| 43 | } |
| 44 | |
J-Alves | 070a40d | 2021-01-21 14:35:12 +0000 | [diff] [blame] | 45 | hftest_command(&fdt); |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 46 | |
| 47 | out: |
| 48 | hftest_ctrl_finish(); |
Olivier Deprez | ea0e019 | 2022-06-03 08:47:52 +0200 | [diff] [blame] | 49 | hftest_ctrl_reboot(); |
Andrew Walbran | bc342d4 | 2019-02-05 16:56:02 +0000 | [diff] [blame] | 50 | } |