blob: 10e9ef09184e2e071fcaff887c4a4d189ddd7f96 [file] [log] [blame]
Andrew Walbranbc342d42019-02-05 16:56:02 +00001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * 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.
Andrew Walbranbc342d42019-02-05 16:56:02 +00007 */
8
9#include <stdalign.h>
10#include <stdint.h>
11
Andrew Walbran0fc4d412019-11-06 17:22:32 +000012#include "hf/arch/vm/interrupts.h"
13
David Brazdil711fbe92019-08-06 13:39:58 +010014#include "hf/mm.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000015
Andrew Walbranbc342d42019-02-05 16:56:02 +000016#include "hftest_common.h"
Andrew Walbran1e7c7742019-12-13 17:10:02 +000017#include "test/hftest.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000018
19alignas(4096) uint8_t kstack[4096];
20
21extern struct hftest_test hftest_begin[];
22extern struct hftest_test hftest_end[];
23
David Brazdilb856be62020-03-25 10:14:55 +000024void kmain(const void *fdt_ptr)
Andrew Walbranbc342d42019-02-05 16:56:02 +000025{
David Brazdilb856be62020-03-25 10:14:55 +000026 struct fdt fdt;
27 size_t fdt_len;
Andrew Walbranbc342d42019-02-05 16:56:02 +000028
David Brazdil711fbe92019-08-06 13:39:58 +010029 /*
30 * Initialize the stage-1 MMU and identity-map the entire address space.
31 */
32 if ((VM_TOOLCHAIN == 1) && !hftest_mm_init()) {
33 HFTEST_LOG("Memory initialization failed.");
David Brazdil17e76652020-01-29 14:44:19 +000034 goto out;
David Brazdil711fbe92019-08-06 13:39:58 +010035 }
36
Andrew Walbran0fc4d412019-11-06 17:22:32 +000037 /*
38 * Install the exception handler with no IRQ callback for now, so that
39 * exceptions are logged.
40 */
Fuad Tabba3e9b0222019-11-11 16:47:50 +000041 exception_setup(NULL, NULL);
Andrew Walbran0fc4d412019-11-06 17:22:32 +000042
Andrew Walbranbc342d42019-02-05 16:56:02 +000043 hftest_use_list(hftest_begin, hftest_end - hftest_begin);
44
David Brazdilb856be62020-03-25 10:14:55 +000045 if (!fdt_size_from_header(fdt_ptr, &fdt_len) ||
46 !fdt_init_from_ptr(&fdt, fdt_ptr, fdt_len)) {
47 HFTEST_LOG("Unable to init FDT.");
48 goto out;
49 }
50
J-Alves070a40d2021-01-21 14:35:12 +000051 hftest_command(&fdt);
David Brazdil17e76652020-01-29 14:44:19 +000052
53out:
54 hftest_ctrl_finish();
Andrew Walbranbc342d42019-02-05 16:56:02 +000055}