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 | |
J-Alves | 35e6192 | 2021-05-06 10:01:05 +0100 | [diff] [blame] | 18 | #include "test/abort.h" |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 19 | #include "test/hftest.h" |
Federico Recanati | 69c554b | 2022-03-14 15:48:28 +0100 | [diff] [blame] | 20 | #include "test/vmapi/ffa.h" |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 21 | |
J-Alves | ff7be1b | 2022-05-23 12:26:36 +0100 | [diff] [blame] | 22 | static struct ffa_boot_info_header* boot_info_header; |
| 23 | |
| 24 | struct ffa_boot_info_header* get_boot_info_header(void) |
| 25 | { |
| 26 | return boot_info_header; |
| 27 | } |
| 28 | |
Olivier Deprez | 175161a | 2021-11-23 18:41:09 +0100 | [diff] [blame] | 29 | alignas(4096) uint8_t kstack[MAX_CPUS][4096]; |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 30 | |
Olivier Deprez | 175161a | 2021-11-23 18:41:09 +0100 | [diff] [blame] | 31 | void test_main_sp(bool); |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 32 | |
Madhukar Pappireddy | 538b688 | 2024-08-20 16:50:52 -0500 | [diff] [blame^] | 33 | void sp_register_secondary_ep(struct hftest_context* ctx) |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 34 | { |
Olivier Deprez | 175161a | 2021-11-23 18:41:09 +0100 | [diff] [blame] | 35 | extern void secondary_ep_entry(void); |
Olivier Deprez | 175161a | 2021-11-23 18:41:09 +0100 | [diff] [blame] | 36 | |
Madhukar Pappireddy | 538b688 | 2024-08-20 16:50:52 -0500 | [diff] [blame^] | 37 | if (ctx->partition_manifest.execution_ctx_count > 1) { |
| 38 | struct ffa_value res; |
| 39 | /* Register entry point for secondary vCPUs. */ |
| 40 | res = ffa_secondary_ep_register((uintptr_t)secondary_ep_entry); |
| 41 | |
| 42 | EXPECT_EQ(res.func, FFA_SUCCESS_32); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void run_service_set_up(struct hftest_context* ctx, struct fdt* fdt) |
| 47 | { |
| 48 | sp_register_secondary_ep(ctx); |
| 49 | hftest_service_set_up(ctx, fdt); |
| 50 | } |
| 51 | |
| 52 | noreturn void kmain(struct ffa_boot_info_header* boot_info_blob) |
| 53 | { |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 54 | /* |
| 55 | * Initialize the stage-1 MMU and identity-map the entire address space. |
| 56 | */ |
| 57 | if (!hftest_mm_init()) { |
| 58 | HFTEST_LOG_FAILURE(); |
| 59 | HFTEST_LOG(HFTEST_LOG_INDENT "Memory initialization failed"); |
| 60 | abort(); |
| 61 | } |
| 62 | |
J-Alves | ff7be1b | 2022-05-23 12:26:36 +0100 | [diff] [blame] | 63 | boot_info_header = boot_info_blob; |
| 64 | |
Olivier Deprez | 175161a | 2021-11-23 18:41:09 +0100 | [diff] [blame] | 65 | test_main_sp(true); |
J-Alves | 3388b0b | 2021-04-13 10:39:38 +0100 | [diff] [blame] | 66 | |
| 67 | /* Do not expect to get to this point, so abort. */ |
| 68 | abort(); |
| 69 | } |