mirror of
https://github.com/ipxe/ipxe
synced 2026-01-26 09:23:49 +03:00
[fdt] Generalise access to "reg" property
The "reg" property is also used by non-device nodes, such as the nodes describing the system memory map. Provide generalised functionality for parsing the "#address-cells", "#size-cells", and "reg" properties. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/device.h>
|
||||
#include <ipxe/dma.h>
|
||||
#include <ipxe/fdt.h>
|
||||
|
||||
/** A devicetree device */
|
||||
struct dt_device {
|
||||
@@ -25,18 +26,10 @@ struct dt_device {
|
||||
/** Driver-private data */
|
||||
void *priv;
|
||||
|
||||
/** Number of address cells for child devices */
|
||||
uint32_t address_cells;
|
||||
/** Number of size cells for child devices */
|
||||
uint32_t size_cells;
|
||||
/** Register cell size specification */
|
||||
struct fdt_reg_cells regs;
|
||||
};
|
||||
|
||||
/** Default number of address cells, if not specified */
|
||||
#define DT_DEFAULT_ADDRESS_CELLS 2
|
||||
|
||||
/** Default number of size cells, if not specified */
|
||||
#define DT_DEFAULT_SIZE_CELLS 1
|
||||
|
||||
/** A devicetree driver */
|
||||
struct dt_driver {
|
||||
/** Driver name */
|
||||
|
||||
@@ -124,6 +124,22 @@ struct fdt_descriptor {
|
||||
int depth;
|
||||
};
|
||||
|
||||
/** A device tree region cell size specification */
|
||||
struct fdt_reg_cells {
|
||||
/** Number of address cells */
|
||||
uint32_t address_cells;
|
||||
/** Number of size cells */
|
||||
uint32_t size_cells;
|
||||
/** Number of address cells plus number of size cells */
|
||||
unsigned int stride;
|
||||
};
|
||||
|
||||
/** Default number of address cells, if not specified */
|
||||
#define FDT_DEFAULT_ADDRESS_CELLS 2
|
||||
|
||||
/** Default number of size cells, if not specified */
|
||||
#define FDT_DEFAULT_SIZE_CELLS 1
|
||||
|
||||
extern struct image_tag fdt_image __image_tag;
|
||||
extern struct fdt sysfdt;
|
||||
|
||||
@@ -144,6 +160,16 @@ extern int fdt_u64 ( struct fdt *fdt, unsigned int offset, const char *name,
|
||||
uint64_t *value );
|
||||
extern int fdt_u32 ( struct fdt *fdt, unsigned int offset, const char *name,
|
||||
uint32_t *value );
|
||||
extern void fdt_reg_cells ( struct fdt *fdt, unsigned int offset,
|
||||
struct fdt_reg_cells *regs );
|
||||
extern int fdt_reg_count ( struct fdt *fdt, unsigned int offset,
|
||||
struct fdt_reg_cells *regs );
|
||||
extern int fdt_reg_address ( struct fdt *fdt, unsigned int offset,
|
||||
struct fdt_reg_cells *regs, unsigned int index,
|
||||
uint64_t *address );
|
||||
extern int fdt_reg_size ( struct fdt *fdt, unsigned int offset,
|
||||
struct fdt_reg_cells *regs, unsigned int index,
|
||||
uint64_t *size );
|
||||
extern int fdt_mac ( struct fdt *fdt, unsigned int offset,
|
||||
struct net_device *netdev );
|
||||
extern int fdt_parse ( struct fdt *fdt, struct fdt_header *hdr,
|
||||
|
||||
Reference in New Issue
Block a user