| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "efi.h" |
| 5 |
|
| 6 |
struct devicetree_state { |
| 7 |
EFI_PHYSICAL_ADDRESS addr; |
| 8 |
size_t pages; |
| 9 |
void *orig; |
| 10 |
}; |
| 11 |
|
| 12 |
enum { |
| 13 |
FDT_BEGIN_NODE = 1, |
| 14 |
FDT_END_NODE = 2, |
| 15 |
FDT_PROP = 3, |
| 16 |
FDT_NOP = 4, |
| 17 |
FDT_END = 9, |
| 18 |
}; |
| 19 |
|
| 20 |
typedef struct FdtHeader { |
| 21 |
uint32_t magic; |
| 22 |
uint32_t total_size; |
| 23 |
uint32_t off_dt_struct; |
| 24 |
uint32_t off_dt_strings; |
| 25 |
uint32_t off_mem_rsv_map; |
| 26 |
uint32_t version; |
| 27 |
uint32_t last_comp_version; |
| 28 |
uint32_t boot_cpuid_phys; |
| 29 |
uint32_t size_dt_strings; |
| 30 |
uint32_t size_dt_struct; |
| 31 |
} FdtHeader; |
| 32 |
|
| 33 |
bool firmware_devicetree_exists(void); |
| 34 |
EFI_STATUS devicetree_match(const void *uki_dtb, size_t uki_dtb_length); |
| 35 |
EFI_STATUS devicetree_match_by_compatible(const void *uki_dtb, size_t uki_dtb_length, const char *compat); |
| 36 |
EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, char16_t *name); |
| 37 |
EFI_STATUS devicetree_install_from_memory( |
| 38 |
struct devicetree_state *state, const void *dtb_buffer, size_t dtb_length); |
| 39 |
void devicetree_cleanup(struct devicetree_state *state); |