blob: 127d3e159045b2b704aafa5eb94833b290910ace [file] [log] [blame]
J-Alves3388b0b2021-04-13 10:39:38 +01001/*
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
J-Alves3388b0b2021-04-13 10:39:38 +01009#include <stdint.h>
10
11#include "hf/ffa.h"
12#include "hf/mm.h"
13#include "hf/std.h"
14
15#include "vmapi/hf/call.h"
16
J-Alves35e61922021-05-06 10:01:05 +010017#include "test/abort.h"
J-Alves3388b0b2021-04-13 10:39:38 +010018#include "test/hftest.h"
Federico Recanati69c554b2022-03-14 15:48:28 +010019#include "test/vmapi/ffa.h"
J-Alves3388b0b2021-04-13 10:39:38 +010020
J-Alvesff7be1b2022-05-23 12:26:36 +010021static struct ffa_boot_info_header* boot_info_header;
22
23struct ffa_boot_info_header* get_boot_info_header(void)
24{
25 return boot_info_header;
26}
27
Olivier Deprez175161a2021-11-23 18:41:09 +010028alignas(4096) uint8_t kstack[MAX_CPUS][4096];
J-Alves3388b0b2021-04-13 10:39:38 +010029
Olivier Deprez175161a2021-11-23 18:41:09 +010030void test_main_sp(bool);
J-Alves3388b0b2021-04-13 10:39:38 +010031
Madhukar Pappireddy538b6882024-08-20 16:50:52 -050032void sp_register_secondary_ep(struct hftest_context* ctx)
J-Alves3388b0b2021-04-13 10:39:38 +010033{
Olivier Deprez175161a2021-11-23 18:41:09 +010034 extern void secondary_ep_entry(void);
Olivier Deprez175161a2021-11-23 18:41:09 +010035
Madhukar Pappireddy538b6882024-08-20 16:50:52 -050036 if (ctx->partition_manifest.execution_ctx_count > 1) {
37 struct ffa_value res;
38 /* Register entry point for secondary vCPUs. */
39 res = ffa_secondary_ep_register((uintptr_t)secondary_ep_entry);
40
41 EXPECT_EQ(res.func, FFA_SUCCESS_32);
42 }
43}
44
45void run_service_set_up(struct hftest_context* ctx, struct fdt* fdt)
46{
47 sp_register_secondary_ep(ctx);
48 hftest_service_set_up(ctx, fdt);
49}
50
Karl Meakin1923faf2025-03-19 14:54:52 +000051[[noreturn]] void kmain(struct ffa_boot_info_header* boot_info_blob)
Madhukar Pappireddy538b6882024-08-20 16:50:52 -050052{
J-Alves3388b0b2021-04-13 10:39:38 +010053 /*
54 * Initialize the stage-1 MMU and identity-map the entire address space.
55 */
56 if (!hftest_mm_init()) {
57 HFTEST_LOG_FAILURE();
58 HFTEST_LOG(HFTEST_LOG_INDENT "Memory initialization failed");
59 abort();
60 }
61
J-Alvesff7be1b2022-05-23 12:26:36 +010062 boot_info_header = boot_info_blob;
63
Olivier Deprez175161a2021-11-23 18:41:09 +010064 test_main_sp(true);
J-Alves3388b0b2021-04-13 10:39:38 +010065
66 /* Do not expect to get to this point, so abort. */
67 abort();
68}