blob: 089032e82b2b28d449bd9a01a50530a04cf3c8d0 [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
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-Alves35e61922021-05-06 10:01:05 +010018#include "test/abort.h"
J-Alves3388b0b2021-04-13 10:39:38 +010019#include "test/hftest.h"
Federico Recanati69c554b2022-03-14 15:48:28 +010020#include "test/vmapi/ffa.h"
J-Alves3388b0b2021-04-13 10:39:38 +010021
J-Alvesff7be1b2022-05-23 12:26:36 +010022static struct ffa_boot_info_header* boot_info_header;
23
24struct ffa_boot_info_header* get_boot_info_header(void)
25{
26 return boot_info_header;
27}
28
Olivier Deprez175161a2021-11-23 18:41:09 +010029alignas(4096) uint8_t kstack[MAX_CPUS][4096];
J-Alves3388b0b2021-04-13 10:39:38 +010030
Federico Recanati632fa142022-04-27 13:14:58 +020031bool sel1_secure_service = true;
32
Olivier Deprez175161a2021-11-23 18:41:09 +010033void test_main_sp(bool);
J-Alves3388b0b2021-04-13 10:39:38 +010034
J-Alvesff7be1b2022-05-23 12:26:36 +010035noreturn void kmain(struct ffa_boot_info_header* boot_info_blob)
J-Alves3388b0b2021-04-13 10:39:38 +010036{
Olivier Deprez175161a2021-11-23 18:41:09 +010037 extern void secondary_ep_entry(void);
38 struct ffa_value res;
39
J-Alves3388b0b2021-04-13 10:39:38 +010040 /*
41 * Initialize the stage-1 MMU and identity-map the entire address space.
42 */
43 if (!hftest_mm_init()) {
44 HFTEST_LOG_FAILURE();
45 HFTEST_LOG(HFTEST_LOG_INDENT "Memory initialization failed");
46 abort();
47 }
48
Olivier Deprez175161a2021-11-23 18:41:09 +010049 /* Register entry point for secondary vCPUs. */
50 res = ffa_secondary_ep_register((uintptr_t)secondary_ep_entry);
51 EXPECT_EQ(res.func, FFA_SUCCESS_32);
52
J-Alvesff7be1b2022-05-23 12:26:36 +010053 boot_info_header = boot_info_blob;
54
Federico Recanati69c554b2022-03-14 15:48:28 +010055 /* Register RX/TX buffers via FFA_RXTX_MAP */
56 set_up_mailbox();
57
Olivier Deprez175161a2021-11-23 18:41:09 +010058 test_main_sp(true);
J-Alves3388b0b2021-04-13 10:39:38 +010059
60 /* Do not expect to get to this point, so abort. */
61 abort();
62}