Changeset 9a7de8e in rtems


Ignore:
Timestamp:
Mar 16, 2018, 11:40:26 AM (13 months ago)
Author:
David Gibson <david@…>
Branches:
master
Children:
0d851d4
Parents:
c81f432
git-author:
David Gibson <david@…> (03/16/18 11:40:26)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/19/18 05:01:12)
Message:

libfdt: Add fdt_header_size()

We have a couple of places within libfdt and its tests where we need to
find the size of the header, based on the version. Add a helper function
for it.

Signed-off-by: David Gibson <david@…>
Reviewed-by: Simon Glass <sjg@…>
Tested-by: Alexey Kardashevskiy <aik@…>
Reviewed-by: Alexey Kardashevskiy <aik@…>

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dtc/libfdt/fdt.c

    rc81f432 r9a7de8e  
    9797}
    9898
     99size_t fdt_header_size_(uint32_t version)
     100{
     101        if (version <= 1)
     102                return FDT_V1_SIZE;
     103        else if (version <= 2)
     104                return FDT_V2_SIZE;
     105        else if (version <= 3)
     106                return FDT_V3_SIZE;
     107        else if (version <= 16)
     108                return FDT_V16_SIZE;
     109        else
     110                return FDT_V17_SIZE;
     111}
     112
    99113int fdt_check_header(const void *fdt)
    100114{
    101         size_t hdrsize = FDT_V16_SIZE;
     115        size_t hdrsize;
    102116
    103117        if (fdt_magic(fdt) != FDT_MAGIC)
    104118                return -FDT_ERR_BADMAGIC;
     119        hdrsize = fdt_header_size(fdt);
    105120        if ((fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
    106121            || (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION))
     
    108123        if (fdt_version(fdt) < fdt_last_comp_version(fdt))
    109124                return -FDT_ERR_BADVERSION;
    110 
    111         if (fdt_version(fdt) >= 17)
    112                 hdrsize = FDT_V17_SIZE;
    113125
    114126        if ((fdt_totalsize(fdt) < hdrsize)
  • cpukit/include/libfdt.h

    rc81f432 r9a7de8e  
    246246
    247247/**
     248 * fdt_header_size - return the size of the tree's header
     249 * @fdt: pointer to a flattened device tree
     250 */
     251size_t fdt_header_size_(uint32_t version);
     252static inline size_t fdt_header_size(const void *fdt)
     253{
     254        return fdt_header_size_(fdt_version(fdt));
     255}
     256
     257/**
    248258 * fdt_check_header - sanity check a device tree header
     259
    249260 * @fdt: pointer to data which might be a flattened device tree
    250261 *
Note: See TracChangeset for help on using the changeset viewer.