mirror of
https://github.com/dgibson/dtc.git
synced 2025-12-08 12:45:29 -05:00
libfdt: Sequential write support
This patch adds code to libfdt to create flat trees from scratch, writing sequentially.
This commit is contained in:
parent
3aa4cfd66b
commit
063693a9e4
10 changed files with 386 additions and 11 deletions
22
fdt_ro.c
22
fdt_ro.c
|
|
@ -25,12 +25,24 @@
|
|||
|
||||
static int check_header(const struct fdt_header *fdt)
|
||||
{
|
||||
if (fdt32_to_cpu(fdt->magic) != FDT_MAGIC)
|
||||
uint32_t magic = fdt32_to_cpu(fdt->magic);
|
||||
uint32_t version = fdt32_to_cpu(fdt->version);
|
||||
uint32_t last_comp_version = fdt32_to_cpu(fdt->last_comp_version);
|
||||
|
||||
if (magic == FDT_MAGIC) {
|
||||
/* Complete tree */
|
||||
if (version < FDT_FIRST_SUPPORTED_VERSION)
|
||||
return FDT_ERR_BADVERSION;
|
||||
if (last_comp_version > FDT_LAST_SUPPORTED_VERSION)
|
||||
return FDT_ERR_BADVERSION;
|
||||
} else if (magic == SW_MAGIC) {
|
||||
/* Unfinished sequential-write blob */
|
||||
if (SW_SIZE_DT_STRUCT(fdt) == 0)
|
||||
return FDT_ERR_BADSTATE;
|
||||
} else {
|
||||
return FDT_ERR_BADMAGIC;
|
||||
if (fdt32_to_cpu(fdt->version) < FDT_FIRST_SUPPORTED_VERSION)
|
||||
return FDT_ERR_BADVERSION;
|
||||
if (fdt32_to_cpu(fdt->last_comp_version) > FDT_LAST_SUPPORTED_VERSION)
|
||||
return FDT_ERR_BADVERSION;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue