Files
acrn-hypervisor/hypervisor/common/fdt.c
Yifan Liu a82c08849e hv: fdt: Save and sanity check fdt
Saves physical FDT and do basic sanity checking.

Tracked-On: #8838
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
Acked-by: Wang Yu1 <yu1.wang@intel.com>
2025-11-04 10:59:30 +08:00

38 lines
760 B
C

/*
* Copyright (C) 2025 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <types.h>
#include <libfdt.h>
#include <logmsg.h>
#include <memory.h>
#include <pgtable.h>
#include <fdt_api.h>
/* storage of raw fdt */
static uint8_t host_fdt_raw[MAX_FDT_SIZE];
void init_devtree(uint64_t fdt_paddr)
{
void *fdt = hpa2hva_early(fdt_paddr);
if (fdt_check_header(fdt) == 0) {
if (fdt_totalsize(fdt) >= MAX_FDT_SIZE) {
panic("FDT size 0x%x larger than configured maximum 0x%x",
fdt_totalsize(fdt), MAX_FDT_SIZE);
}
/* copy raw data */
fdt_move(fdt, host_fdt_raw, MAX_FDT_SIZE);
} else {
panic("Device tree not found or not supported", fdt_paddr);
}
}
uint8_t *get_host_fdt(void)
{
return (uint8_t *)host_fdt_raw;
}