| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#ifndef VBOOT_REFERENCE_FMAP_H_ |
| 7 |
#define VBOOT_REFERENCE_FMAP_H_ |
| 8 |
|
| 9 |
#include <inttypes.h> |
| 10 |
#include <stddef.h> |
| 11 |
|
| 12 |
|
| 13 |
#define FMAP_NAMELEN 32 |
| 14 |
#define FMAP_SIGNATURE "__FMAP__" |
| 15 |
#define FMAP_SIGNATURE_SIZE 8 |
| 16 |
#define FMAP_SEARCH_STRIDE 4 |
| 17 |
#define FMAP_VER_MAJOR 1 |
| 18 |
typedef struct _FmapHeader { |
| 19 |
|
| 20 |
char fmap_signature[FMAP_SIGNATURE_SIZE]; |
| 21 |
uint8_t fmap_ver_major; |
| 22 |
uint8_t fmap_ver_minor; |
| 23 |
uint64_t fmap_base; |
| 24 |
uint32_t fmap_size; |
| 25 |
char fmap_name[FMAP_NAMELEN]; |
| 26 |
uint16_t fmap_nareas; |
| 27 |
} __attribute__((packed)) FmapHeader; |
| 28 |
|
| 29 |
enum fmap_flags { |
| 30 |
FMAP_AREA_STATIC = 1 << 0, |
| 31 |
FMAP_AREA_COMPRESSED = 1 << 1, |
| 32 |
FMAP_AREA_RO = 1 << 2, |
| 33 |
|
| 34 |
FMAP_AREA_PRESERVE = 1 << 3, |
| 35 |
}; |
| 36 |
|
| 37 |
typedef struct _FmapAreaHeader { |
| 38 |
uint32_t area_offset; |
| 39 |
uint32_t area_size; |
| 40 |
char area_name[FMAP_NAMELEN]; |
| 41 |
uint16_t area_flags; |
| 42 |
} __attribute__((packed)) FmapAreaHeader; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
FmapHeader *fmap_find(uint8_t *ptr, size_t size); |
| 47 |
|
| 48 |
|
| 49 |
uint8_t *fmap_find_by_name(uint8_t *ptr, size_t size, |
| 50 |
|
| 51 |
FmapHeader *fmap, |
| 52 |
|
| 53 |
const char *name, |
| 54 |
|
| 55 |
FmapAreaHeader **ah); |
| 56 |
|
| 57 |
#endif |