fmap.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
  3. * Use of this source code is governed by a BSD-style license that can be
  4. * found in the LICENSE file.
  5. */
  6. #ifndef __FMAP_H__
  7. #define __FMAP_H__
  8. #include <inttypes.h>
  9. #include <stddef.h>
  10. /* FMAP structs. See http://code.google.com/p/flashmap/wiki/FmapSpec */
  11. #define FMAP_NAMELEN 32
  12. #define FMAP_SIGNATURE "__FMAP__"
  13. #define FMAP_SIGNATURE_SIZE 8
  14. #define FMAP_SEARCH_STRIDE 4
  15. #define FMAP_VER_MAJOR 1
  16. typedef struct _FmapHeader {
  17. /* Avoid endian issues in signature... */
  18. char fmap_signature[FMAP_SIGNATURE_SIZE];
  19. uint8_t fmap_ver_major;
  20. uint8_t fmap_ver_minor;
  21. uint64_t fmap_base;
  22. uint32_t fmap_size;
  23. char fmap_name[FMAP_NAMELEN];
  24. uint16_t fmap_nareas;
  25. } __attribute__((packed)) FmapHeader;
  26. typedef struct _FmapAreaHeader {
  27. uint32_t area_offset;
  28. uint32_t area_size;
  29. char area_name[FMAP_NAMELEN];
  30. uint16_t area_flags;
  31. } __attribute__((packed)) FmapAreaHeader;
  32. /* Find and point to the FMAP header within the buffer */
  33. FmapHeader *fmap_find(uint8_t *ptr, size_t size);
  34. /* Search for an area by name, return pointer to its beginning */
  35. uint8_t *fmap_find_by_name(uint8_t *ptr, size_t size,
  36. /* optional, will call fmap_find() if NULL */
  37. FmapHeader *fmap,
  38. /* The area name to search for */
  39. const char *name,
  40. /* optional, return pointer to entry if not NULL */
  41. FmapAreaHeader **ah);
  42. #endif /* __FMAP_H__ */