J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2021 The Hafnium Authors. |
| 3 | * |
| 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. |
| 7 | */ |
| 8 | |
| 9 | #include <stdalign.h> |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | #include "hf/ffa.h" |
| 13 | #include "hf/mm.h" |
| 14 | #include "hf/std.h" |
| 15 | |
| 16 | #include "vmapi/hf/call.h" |
| 17 | |
| 18 | #include "test/hftest.h" |
| 19 | |
| 20 | alignas(4096) uint8_t kstack[4096]; |
| 21 | |
| 22 | HFTEST_ENABLE(); |
| 23 | |
| 24 | static struct hftest_context global_context; |
| 25 | |
| 26 | struct hftest_context *hftest_get_context(void) |
| 27 | { |
| 28 | return &global_context; |
| 29 | } |
| 30 | |
| 31 | void test_main_sp(void); |
| 32 | |
| 33 | noreturn void abort(void) |
| 34 | { |
| 35 | HFTEST_LOG("Service contained failures."); |
| 36 | /* Cause a fault, as a secondary can't power down the machine. */ |
| 37 | *((volatile uint8_t *)1) = 1; |
| 38 | |
| 39 | /* This should never be reached, but to make the compiler happy... */ |
| 40 | for (;;) { |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | noreturn void kmain(void) |
| 45 | { |
| 46 | /* |
| 47 | * Initialize the stage-1 MMU and identity-map the entire address space. |
| 48 | */ |
| 49 | if (!hftest_mm_init()) { |
| 50 | HFTEST_LOG_FAILURE(); |
| 51 | HFTEST_LOG(HFTEST_LOG_INDENT "Memory initialization failed"); |
| 52 | abort(); |
| 53 | } |
| 54 | |
| 55 | test_main_sp(); |
| 56 | |
| 57 | /* Do not expect to get to this point, so abort. */ |
| 58 | abort(); |
| 59 | } |