mirror of
https://github.com/ipxe/ipxe
synced 2026-05-22 00:03:42 +03:00
[fdtmem] Add ability to parse FDT memory map for a relocation address
Add code to parse the devicetree memory nodes, memory reservations block, and reserved memory nodes to construct an ordered and non-overlapping description of the system memory map, and use this to identify a suitable address to which iPXE may be relocated at runtime. We choose to place iPXE on a superpage boundary (as required by the paging code), and to use the highest available address within accessible memory. This mirrors the approach taken for x86 BIOS builds, where we have long assumed that any image format that we might need to support may require specific fixed addresses towards the bottom of the memory map, but is very unlikely to require specific fixed addresses towards the top of the memory map (since those addresses may not exist, depending on the amount of installed RAM). Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -76,6 +76,14 @@ struct fdt_prop {
|
||||
/** Maximum alignment of any block */
|
||||
#define FDT_MAX_ALIGN 8
|
||||
|
||||
/** A memory reservation */
|
||||
struct fdt_reservation {
|
||||
/** Starting address */
|
||||
uint64_t start;
|
||||
/** Length of reservation */
|
||||
uint64_t size;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** A device tree */
|
||||
struct fdt {
|
||||
/** Tree data */
|
||||
@@ -143,6 +151,23 @@ struct fdt_reg_cells {
|
||||
extern struct image_tag fdt_image __image_tag;
|
||||
extern struct fdt sysfdt;
|
||||
|
||||
/**
|
||||
* Get memory reservations
|
||||
*
|
||||
* @v fdt Device tree
|
||||
* @ret rsv Memory reservations
|
||||
*/
|
||||
static inline const struct fdt_reservation *
|
||||
fdt_reservations ( struct fdt *fdt ) {
|
||||
|
||||
return ( fdt->raw + fdt->reservations );
|
||||
}
|
||||
|
||||
/** Iterate over memory reservations */
|
||||
#define for_each_fdt_reservation( rsv, fdt ) \
|
||||
for ( rsv = fdt_reservations ( (fdt) ) ; \
|
||||
( (rsv)->start || (rsv)->size ) ; rsv++ )
|
||||
|
||||
extern int fdt_describe ( struct fdt *fdt, unsigned int offset,
|
||||
struct fdt_descriptor *desc );
|
||||
extern int fdt_path ( struct fdt *fdt, const char *path,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _IPXE_FDTMEM_H
|
||||
#define _IPXE_FDTMEM_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Flattened Device Tree memory map
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ipxe/fdt.h>
|
||||
|
||||
extern physaddr_t fdtmem_relocate ( struct fdt_header *hdr, size_t limit );
|
||||
|
||||
#endif /* _IPXE_FDTMEM_H */
|
||||
Reference in New Issue
Block a user