blob: 2b01050b5d2068e1c75ccc9f39d6260bb13e246a [file] [log] [blame]
J-Alves84c24b52020-12-02 11:05:05 +00001/*
2 * Copyright 2020 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/arch/vm/interrupts.h"
13
14#include "hf/mm.h"
15
16#include "hftest_common.h"
17#include "test/hftest.h"
18
19alignas(4096) uint8_t kstack[4096];
20
J-Alves57caa382022-01-27 13:54:50 +000021static 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
J-Alves84c24b52020-12-02 11:05:05 +000028extern struct hftest_test hftest_begin[];
29extern struct hftest_test hftest_end[];
30
Olivier Deprezea0e0192022-06-03 08:47:52 +020031static noreturn void hftest_wait(void)
32{
33 for (;;) {
34 interrupt_wait();
35 }
36}
37
J-Alves57caa382022-01-27 13:54:50 +000038void kmain(void* boot_info_blob)
J-Alves84c24b52020-12-02 11:05:05 +000039{
40 /* Dummy fdt. It is not really used */
41 struct fdt fdt;
42
43 /*
44 * Initialize the stage-1 MMU and identity-map the entire address space.
45 */
46 if ((VM_TOOLCHAIN == 1) && !hftest_mm_init()) {
47 HFTEST_LOG("Memory initialization failed.");
48 goto out;
49 }
50
J-Alves57caa382022-01-27 13:54:50 +000051 boot_info_header = boot_info_blob;
52
J-Alves84c24b52020-12-02 11:05:05 +000053 /*
54 * Install the exception handler with no IRQ callback for now, so that
55 * exceptions are logged.
56 */
57 exception_setup(NULL, NULL);
58
59 hftest_use_list(hftest_begin, hftest_end - hftest_begin);
60
61 hftest_command(&fdt);
62
63out:
64 hftest_ctrl_finish();
Olivier Deprezea0e0192022-06-03 08:47:52 +020065 hftest_wait();
J-Alves84c24b52020-12-02 11:05:05 +000066}