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 <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 
18 #include "test/abort.h"
19 #include "test/hftest.h"
20 
21 alignas(4096) uint8_t kstack[4096];
22 
23 extern struct hftest_test hftest_begin[];
24 extern struct hftest_test hftest_end[];
25 
26 void test_main_secondary(size_t mem_size);
27 
kmain(size_t mem_size)28 noreturn void kmain(size_t mem_size)
29 {
30 	/*
31 	 * Initialize the stage-1 MMU and identity-map the entire address space.
32 	 */
33 	if (!hftest_mm_init()) {
34 		HFTEST_LOG_FAILURE();
35 		HFTEST_LOG(HFTEST_LOG_INDENT "Memory initialization failed");
36 		abort();
37 	}
38 
39 	/* Run tests. */
40 	test_main_secondary(mem_size);
41 
42 	/* Do not expect to be run again, so abort. */
43 	abort();
44 }
45