52 #define FDT_INSERT_PAD 1024 61 static const char permitted[] =
",._+?#-";
109 if ( remaining <
sizeof ( *
token ) ) {
113 remaining -=
sizeof ( *token );
114 data = ( ( (
const void * )
token ) +
sizeof ( *token ) );
125 if ( remaining <
len ) {
126 DBGC (
fdt,
"FDT unterminated node name at +%#04x\n",
143 if ( remaining <
sizeof ( *prop ) ) {
144 DBGC (
fdt,
"FDT truncated property at +%#04x\n",
148 desc->data = ( ( (
const void * ) prop ) +
sizeof ( *prop ) );
150 len = (
sizeof ( *prop ) +
desc->len );
151 if ( remaining <
len ) {
152 DBGC (
fdt,
"FDT overlength property at +%#04x\n",
158 DBGC (
fdt,
"FDT property name outside strings " 159 "block at +%#04x\n",
offset );
173 DBGC (
fdt,
"FDT unexpected token %#08x at +%#04x\n",
220 DBGC (
fdt,
"FDT +%#04x has malformed node: %s\n",
226 if (
desc->depth > 0 )
231 DBGC (
fdt,
"FDT +%#04x has spurious node end at " 236 DBGC (
fdt,
"FDT +%#04x has spurious property at " 252 unsigned int target ) {
266 DBGC (
fdt,
"FDT +%#04x has malformed node: %s\n",
272 if (
desc.offset == target ) {
273 DBGC2 (
fdt,
"FDT +%#04x has descendant node +%#04x " 279 DBGC (
fdt,
"FDT +#%04x has no descendant node +%#04x\n",
304 pdepth = (
depth - 1 );
309 *parent =
desc.offset;
316 DBGC (
fdt,
"FDT +%#04x has malformed node: %s\n",
323 *parent =
desc.offset;
327 DBGC2 (
fdt,
"FDT +%#04x has parent node at +%#04x\n",
347 unsigned int *child ) {
361 DBGC (
fdt,
"FDT +%#04x has malformed node: %s\n",
368 DBGC2 (
fdt,
"FDT +%#04x has child node \"%s\" at " 372 *child =
desc.offset;
391 unsigned int *
end ) {
405 DBGC (
fdt,
"FDT +%#04x has malformed node: %s\n",
426 const char *
tmp = path;
436 while ( *
tmp ==
'/' )
453 DBGC2 (
fdt,
"FDT found path \"%s\" at +%#04x\n", path, *
offset );
476 DBGC (
fdt,
"FDT alias \"%s\" is \"%s\"\n",
name, alias );
508 DBGC (
fdt,
"FDT +%#04x has malformed node: %s\n",
515 DBGC2 (
fdt,
"FDT +%#04x has property \"%s\" at " 540 const char *
name,
unsigned int *
count ) {
556 DBGC (
fdt,
"FDT unterminated string property \"%s\"\n",
613 total = (
desc.len /
sizeof ( *cell ) );
615 DBGC (
fdt,
"FDT truncated integer \"%s\"\n",
name );
620 if (
count > (
sizeof ( *
value ) /
sizeof ( *cell ) ) ) {
621 DBGC (
fdt,
"FDT overlength integer \"%s\"\n",
name );
674 if ( *
value != value64 ) {
675 DBGC (
fdt,
"FDT overlength 32-bit integer \"%s\"\n",
name );
696 &phandle ) ) == 0 ) ) {
721 &
regs->address_cells ) ) != 0 ) {
727 &
regs->size_cells ) ) != 0 ) {
732 regs->stride = (
regs->address_cells +
regs->size_cells );
795 unsigned int cell = (
index *
regs->stride );
820 unsigned int cell = ( (
index *
regs->stride ) +
regs->address_cells );
883 DBGC (
fdt,
"FDT malformed MAC address \"%s\":\n",
909 if (
sizeof ( *
hdr ) > max_len ) {
910 DBGC (
fdt,
"FDT length %#zx too short for header\n",
919 if (
fdt->
len > max_len ) {
920 DBGC (
fdt,
"FDT has invalid length %#zx / %#zx\n",
924 DBGC (
fdt,
"FDT version %d at %p+%#04zx (phys %#08lx)\n",
926 virt_to_phys (
hdr ) );
930 DBGC (
fdt,
"FDT has invalid magic value %#08x\n",
937 DBGC (
fdt,
"FDT unsupported version %d\n",
945 DBGC (
fdt,
"FDT structure block at +[%#04x,%#04zx)\n",
949 DBGC (
fdt,
"FDT structure block exceeds table\n" );
954 DBGC (
fdt,
"FDT structure block is misaligned\n" );
964 DBGC (
fdt,
"FDT strings block at +[%#04x,%#04zx)\n",
968 DBGC (
fdt,
"FDT strings block exceeds table\n" );
978 if ( *(--nul) ==
'\0' )
982 DBGC (
fdt,
"FDT strings block shrunk to +[%#04x,%#04zx)\n",
988 DBGC (
fdt,
"FDT memory reservations at +[%#04x,...)\n",
997 DBGC (
fdt,
"FDT free space at +[%#04zx,%#04zx)\n",
1003 DBGC (
fdt,
"FDT model is \"%s\"\n",
1006 DBGC (
fdt,
"FDT boot arguments \"%s\"\n",
1031 DBGC (
fdt,
"FDT image \"%s\" is invalid: %s\n",
1054 assert ( offset <= fdt->used );
1062 DBGC (
fdt,
"FDT is not reallocatable\n" );
1089 DBGC (
fdt,
"FDT structure block now at +[%#04x,%#04zx)\n",
1096 DBGC (
fdt,
"FDT strings block now at +[%#04x,%#04zx)\n",
1102 DBGC (
fdt,
"FDT memory reservations now at +[%#04x,...)\n",
1125 count = (
len /
sizeof ( *token ) );
1159 DBGC (
fdt,
"FDT structure block now at +[%#04x,%#04zx)\n",
1193 DBGC (
fdt,
"FDT strings block now at +[%#04x,%#04zx)\n",
1209 const char *
name,
unsigned int *child ) {
1237 DBGC2 (
fdt,
"FDT +%#04x created child \"%s\" at +%#04x\n",
1254 const void *
data,
size_t len ) {
1278 DBGC2 (
fdt,
"FDT +%#04x erased property \"%s\"\n",
1297 insert = (
sizeof ( *hdr ) +
len );
1338 DBGC (
fdt,
"FDT could not reallocate from +%#04zx to " 1342 DBGC (
fdt,
"FDT reallocated from +%#04zx to +%#04zx\n",
1364 unsigned int chosen;
1424 DBGC ( &
fdt,
"FDT has no base tree\n" );
int fdt_parent(struct fdt *fdt, unsigned int offset, unsigned int *parent)
Find parent node.
static __always_inline void ufree(void *ptr)
Free external memory.
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
static int fdt_match(const struct fdt_descriptor *desc, const char *name)
Compare node name.
#define FDT_STRUCTURE_ALIGN
Alignment of structure block.
#define FDT_NOP
NOP token.
unsigned int reservations
Offset to memory reservation block.
int erase(void)
Completely clear the screen.
int fdt_alias(struct fdt *fdt, const char *name, unsigned int *offset)
Find node by alias.
int(* realloc)(struct fdt *fdt, size_t len)
Reallocate device tree.
static int fdt_urealloc(struct fdt *fdt, size_t len)
Reallocate device tree via urealloc()
size_t len
Length of tree.
int fdt_parse(struct fdt *fdt, struct fdt_header *hdr, size_t max_len)
Parse device tree.
struct golan_inbox_hdr hdr
Message header.
static int fdt_enter(struct fdt *fdt, unsigned int offset, struct fdt_descriptor *desc)
Enter node.
static int fdt_set(struct fdt *fdt, unsigned int offset, const char *name, const void *data, size_t len)
Set property value.
uint64_t address
Base address.
uint16_t size
Buffer size.
int fdt_describe(struct fdt *fdt, unsigned int offset, struct fdt_descriptor *desc)
Describe device tree token.
int fdt_path(struct fdt *fdt, const char *path, unsigned int *offset)
Find node by path.
A device tree region cell size specification.
const char * fdt_strings(struct fdt *fdt, unsigned int offset, const char *name, unsigned int *count)
Find strings property.
#define ENOENT
No such file or directory.
unsigned long long uint64_t
struct image_tag fdt_image __image_tag
The downloaded flattened device tree tag.
size_t strings_len
Length of strings block.
int fdt_mac(struct fdt *fdt, unsigned int offset, struct net_device *netdev)
Get MAC address from property.
uint32_t fdt_token_t
Device tree token.
struct fdt_header * hdr
Tree header.
REQUIRING_SYMBOL(fdt_describe)
#define ENOTSUP
Operation not supported.
struct image * find_image_tag(struct image_tag *tag)
Find image by tag.
struct ena_llq_option desc
Descriptor counts.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int fdt_insert_string(struct fdt *fdt, const char *string, unsigned int *offset)
Insert string in strings block.
uint32_t fdt_phandle(struct fdt *fdt, unsigned int offset)
Get package handle (phandle) property.
static int fdt_bootargs(struct fdt *fdt, const char *cmdline, physaddr_t initrd, size_t initrd_len)
Populate device tree with boot arguments.
#define be32_to_cpu(value)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Access to external ("user") memory.
uint8_t hw_addr_len
Hardware address length.
int fdt_u32(struct fdt *fdt, unsigned int offset, const char *name, uint32_t *value)
Get 32-bit integer property.
static int isalnum(int character)
Check if character is alphanumeric.
#define FDT_MAGIC
Magic signature.
pseudo_bit_t value[0x00020]
static int fdt_property(struct fdt *fdt, unsigned int offset, const char *name, struct fdt_descriptor *desc)
Find property.
void fdt_remove(struct fdt_header *hdr)
Remove device tree.
static struct net_device * netdev
static unsigned int count
Number of entries.
char * strcpy(char *dest, const char *src)
Copy string.
void fdt_reg_cells(struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs)
Get region cell size specification.
const char * fdt_string(struct fdt *fdt, unsigned int offset, const char *name)
Find string property.
unsigned int structure
Offset to structure block.
#define FDT_VERSION
Expected device tree version.
static int fdt_child(struct fdt *fdt, unsigned int offset, const char *name, unsigned int *child)
Find child node.
static int fdt_permitted(char ch)
Check if character is permitted in a name.
#define ERANGE
Result too large.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
size_t len
Length of raw file image.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
char * strchr(const char *src, int character)
Find character within a string.
uint32_t addr
Buffer address.
int fdt_reg_count(struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs)
Get number of regions.
size_t strlen(const char *src)
Get length of string.
int fdt_reg_address(struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs, unsigned int index, uint64_t *address)
Get region address.
static int fdt_insert_nop(struct fdt *fdt, unsigned int offset, size_t len)
Insert FDT_NOP padded space in structure block.
static int fdt_next(struct fdt *fdt, struct fdt_descriptor *desc)
Describe next device tree token.
size_t strnlen(const char *src, size_t max)
Get length of string.
size_t used
Used length of tree.
void * memmove(void *dest, const void *src, size_t len) __nonnull
int fdt_reg(struct fdt *fdt, unsigned int offset, uint64_t *region)
Get unsized single-entry region address.
REQUIRE_OBJECT(config_fdt)
size_t structure_len
Length of structure block.
#define FDT_PROP
Property token.
Network device management.
static int fdt_depth(struct fdt *fdt, unsigned int offset, unsigned int target)
Find node relative depth.
#define cpu_to_be32(value)
uint32_t name_off
Name offset.
#define FDT_END_NODE
End node token.
static __always_inline void * umalloc(size_t size)
Allocate external memory.
void * rwdata
Writable data.
uint32_t end
Ending offset.
#define cpu_to_be64(value)
uint8_t data[48]
Additional event data.
static void fdt_nop(struct fdt *fdt, unsigned int offset, size_t len)
Fill space in structure block with FDT_NOP.
#define FDT_INSERT_PAD
Amount of free space to add whenever we have to reallocate a tree.
static int fdt_insert(struct fdt *fdt, unsigned int offset, size_t len)
Insert empty space.
#define FDT_BEGIN_NODE
Begin node token.
int fdt_parent_reg_cells(struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs)
Get parent region cell size specification.
static int fdt_end(struct fdt *fdt, unsigned int offset, unsigned int *end)
Find end of node.
A device tree token descriptor.
void * urealloc(void *ptr, size_t new_size)
Reallocate external memory.
uint16_t offset
Offset to command line.
#define FDT_DEFAULT_SIZE_CELLS
Default number of size cells, if not specified.
int fdt_reg_size(struct fdt *fdt, unsigned int offset, struct fdt_reg_cells *regs, unsigned int index, uint64_t *size)
Get region size.
int fdt_create(struct fdt_header **hdr, const char *cmdline, physaddr_t initrd, size_t initrd_len)
Create device tree.
int fdt_u64(struct fdt *fdt, unsigned int offset, const char *name, uint64_t *value)
Get 64-bit integer property.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
static int fdt_ensure_child(struct fdt *fdt, unsigned int offset, const char *name, unsigned int *child)
Ensure child node exists.
int fdt_cells(struct fdt *fdt, unsigned int offset, const char *name, unsigned int index, unsigned int count, uint64_t *value)
Get integer property.
const void * data
Property data (if applicable)
#define FDT_DEFAULT_ADDRESS_CELLS
Default number of address cells, if not specified.
struct ll_protocol * ll_protocol
Link-layer protocol.
#define FDT_MAX_ALIGN
Maximum alignment of any block.
unsigned int strings
Offset to strings block.
static int fdt_parse_image(struct fdt *fdt, struct image *image)
Parse device tree image.
void * memset(void *dest, int character, size_t len) __nonnull
struct fdt sysfdt
The system flattened device tree (if present)