| 54 | #include "libfdt_internal.h" |
| 55 | |
| 56 | int fdt_check_header(const void *fdt) |
| 57 | { |
| 58 | if (fdt_magic(fdt) == FDT_MAGIC) { |
| 59 | /* Complete tree */ |
| 60 | if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) |
| 61 | return -FDT_ERR_BADVERSION; |
| 62 | if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION) |
| 63 | return -FDT_ERR_BADVERSION; |
| 64 | } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { |
| 65 | /* Unfinished sequential-write blob */ |
| 66 | if (fdt_size_dt_struct(fdt) == 0) |
| 67 | return -FDT_ERR_BADSTATE; |
| 68 | } else { |
| 69 | return -FDT_ERR_BADMAGIC; |
| 70 | } |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) |
| 76 | { |
no outgoing calls
no test coverage detected