Home | History | Annotate | Download | only in include
      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 
      7 #ifndef __FMAP_H__
      8 #define __FMAP_H__
      9 
     10 #include <inttypes.h>
     11 #include <stddef.h>
     12 
     13 /* FMAP structs. See http://code.google.com/p/flashmap/wiki/FmapSpec */
     14 #define FMAP_NAMELEN 32
     15 #define FMAP_SIGNATURE "__FMAP__"
     16 #define FMAP_SIGNATURE_SIZE 8
     17 #define FMAP_SEARCH_STRIDE 4
     18 #define FMAP_VER_MAJOR 1
     19 typedef struct _FmapHeader {
     20   char        fmap_signature[FMAP_SIGNATURE_SIZE]; /* avoiding endian issues */
     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 typedef struct _FmapAreaHeader {
     30   uint32_t area_offset;
     31   uint32_t area_size;
     32   char     area_name[FMAP_NAMELEN];
     33   uint16_t area_flags;
     34 } __attribute__((packed)) FmapAreaHeader;
     35 
     36 
     37 /* Find and point to the FMAP header within the buffer */
     38 FmapHeader *fmap_find(uint8_t *ptr, size_t size);
     39 
     40 /* Search for an area by name, return pointer to its beginning */
     41 uint8_t *fmap_find_by_name(uint8_t *ptr, size_t size,
     42 			   /* optional, will call fmap_find() if NULL */
     43 			   FmapHeader *fmap,
     44 			   /* The area name to search for */
     45 			   const char *name,
     46 			   /* optional, return pointer to entry if not NULL */
     47 			   FmapAreaHeader **ah);
     48 
     49 #endif  /* __FMAP_H__ */
     50