1 /*
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 <stdint.h>
10 
11 #include "hf/arch/vm/interrupts.h"
12 
13 #include "hf/mm.h"
14 
15 #include "hftest_common.h"
16 #include "test/hftest.h"
17 
18 alignas(4096) uint8_t kstack[4096];
19 
20 static struct ffa_boot_info_header* boot_info_header;
21 
get_boot_info_header(void)22 struct ffa_boot_info_header* get_boot_info_header(void)
23 {
24 	return boot_info_header;
25 }
26 
hftest_wait(void)27 [[noreturn]] static void hftest_wait(void)
28 {
29 	for (;;) {
30 		interrupt_wait();
31 	}
32 }
33 
kmain(struct ffa_boot_info_header * boot_info_blob)34 void kmain(struct ffa_boot_info_header* boot_info_blob)
35 {
36 	/* Dummy fdt. It is not really used */
37 	struct fdt fdt;
38 
39 	/*
40 	 * Initialize the stage-1 MMU and identity-map the entire address space.
41 	 */
42 	if ((VM_TOOLCHAIN == 1) && !hftest_mm_init()) {
43 		HFTEST_LOG("Memory initialization failed.");
44 		goto out;
45 	}
46 
47 	boot_info_header = boot_info_blob;
48 
49 	/*
50 	 * Install the exception handler with no IRQ callback for now, so that
51 	 * exceptions are logged.
52 	 */
53 	exception_setup(NULL, NULL);
54 
55 	hftest_command(&fdt);
56 
57 out:
58 	hftest_ctrl_finish();
59 	hftest_wait();
60 }
61