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