OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are |
| 7 * met: |
| 8 * |
| 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. |
| 11 * * Redistributions in binary form must reproduce the above |
| 12 * copyright notice, this list of conditions and the following disclaimer |
| 13 * in the documentation and/or other materials provided with the |
| 14 * distribution. |
| 15 * * Neither the name of Google Inc. nor the names of its |
| 16 * contributors may be used to endorse or promote products derived from |
| 17 * this software without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 * Alternatively, this software may be distributed under the terms of the |
| 32 * GNU General Public License ("GPL") version 2 as published by the Free |
| 33 * Software Foundation. |
| 34 * |
| 35 * This is ported from the flashmap utility: http://flashmap.googlecode.com |
| 36 */ |
| 37 |
| 38 #ifndef FLASHMAP_LIB_FMAP_H__ |
| 39 #define FLASHMAP_LIB_FMAP_H__ |
| 40 |
| 41 #include <inttypes.h> |
| 42 |
| 43 #define FMAP_SIGNATURE "__FMAP__" |
| 44 #define FMAP_VER_MAJOR 1 /* this header's FMAP minor version */ |
| 45 #define FMAP_VER_MINOR 1 /* this header's FMAP minor version */ |
| 46 #define FMAP_STRLEN 32 /* maximum length for strings, */ |
| 47 /* including null-terminator */ |
| 48 |
| 49 enum fmap_flags { |
| 50 FMAP_AREA_STATIC = 1 << 0, |
| 51 FMAP_AREA_COMPRESSED = 1 << 1, |
| 52 FMAP_AREA_RO = 1 << 2, |
| 53 }; |
| 54 |
| 55 struct fmap_area { |
| 56 uint32_t offset; /* offset relative to base */ |
| 57 uint32_t size; /* size in bytes */ |
| 58 uint8_t name[FMAP_STRLEN]; /* descriptive name */ |
| 59 uint16_t flags; /* flags for this area */ |
| 60 } __attribute__((packed)); |
| 61 /* Mapping of volatile and static regions in firmware binary */ |
| 62 struct fmap { |
| 63 uint64_t signature; /* "__FMAP__" (0x5F5F50414D465F5F) */ |
| 64 uint8_t ver_major; /* major version */ |
| 65 uint8_t ver_minor; /* minor version */ |
| 66 uint64_t base; /* address of the firmware binary */ |
| 67 uint32_t size; /* size of firmware binary in bytes */ |
| 68 uint8_t name[FMAP_STRLEN]; /* name of this firmware binary */ |
| 69 uint16_t nareas; /* number of areas described by |
| 70 fmap_areas[] below */ |
| 71 struct fmap_area areas[]; |
| 72 } __attribute__((packed)); |
| 73 |
| 74 /* |
| 75 * fmap_find - find FMAP signature in a binary image and copy it to buffer |
| 76 * |
| 77 * @flash: flash structure containing read function |
| 78 * @buf: unallocated buffer to store fmap struct |
| 79 * |
| 80 * This function allocates memory which the caller must free. It does no error |
| 81 * checking. The caller is responsible for verifying that the contents are sane. |
| 82 * |
| 83 * returns size of fmap struct to indicate success |
| 84 * returns <0 to indicate failure |
| 85 */ |
| 86 extern int fmap_find(struct flashchip *flash, uint8_t **buf); |
| 87 |
| 88 #endif /* FLASHMAP_LIB_FMAP_H__*/ |
OLD | NEW |