blob: 4bd53cdb9920e3a41a76142c9313e6c658b33cb6 [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
Andrew Walbranbc342d42019-02-05 16:56:02 +00009#include <stdint.h>
10
Andrew Walbran0fc4d412019-11-06 17:22:32 +000011#include "hf/arch/vm/interrupts.h"
12
David Brazdil711fbe92019-08-06 13:39:58 +010013#include "hf/mm.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000014
Andrew Walbranbc342d42019-02-05 16:56:02 +000015#include "hftest_common.h"
Andrew Walbran1e7c7742019-12-13 17:10:02 +000016#include "test/hftest.h"
Andrew Walbranbc342d42019-02-05 16:56:02 +000017
J-Alvese44e18e2024-10-29 14:11:16 +000018alignas(4096) uint8_t kstack[2 * 4096];
Andrew Walbranbc342d42019-02-05 16:56:02 +000019
David Brazdilb856be62020-03-25 10:14:55 +000020void kmain(const void *fdt_ptr)
Andrew Walbranbc342d42019-02-05 16:56:02 +000021{
David Brazdilb856be62020-03-25 10:14:55 +000022 struct fdt fdt;
23 size_t fdt_len;
Andrew Walbranbc342d42019-02-05 16:56:02 +000024
David Brazdil711fbe92019-08-06 13:39:58 +010025 /*
26 * Initialize the stage-1 MMU and identity-map the entire address space.
27 */
28 if ((VM_TOOLCHAIN == 1) && !hftest_mm_init()) {
29 HFTEST_LOG("Memory initialization failed.");
David Brazdil17e76652020-01-29 14:44:19 +000030 goto out;
David Brazdil711fbe92019-08-06 13:39:58 +010031 }
32
Andrew Walbran0fc4d412019-11-06 17:22:32 +000033 /*
34 * Install the exception handler with no IRQ callback for now, so that
35 * exceptions are logged.
36 */
Fuad Tabba3e9b0222019-11-11 16:47:50 +000037 exception_setup(NULL, NULL);
Andrew Walbran0fc4d412019-11-06 17:22:32 +000038
David Brazdilb856be62020-03-25 10:14:55 +000039 if (!fdt_size_from_header(fdt_ptr, &fdt_len) ||
40 !fdt_init_from_ptr(&fdt, fdt_ptr, fdt_len)) {
41 HFTEST_LOG("Unable to init FDT.");
42 goto out;
43 }
44
J-Alves070a40d2021-01-21 14:35:12 +000045 hftest_command(&fdt);
David Brazdil17e76652020-01-29 14:44:19 +000046
47out:
48 hftest_ctrl_finish();
Olivier Deprezea0e0192022-06-03 08:47:52 +020049 hftest_ctrl_reboot();
Andrew Walbranbc342d42019-02-05 16:56:02 +000050}