blob: 05d3fb6e1d226007d701e858142364913e006962 [file] [log] [blame]
Stefan Reinauer357bb2d2012-08-09 13:44:38 -07001/*
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
36#ifndef FLASHMAP_LIB_FMAP_H__
37#define FLASHMAP_LIB_FMAP_H__
38
39#include <stdint.h>
40
Julius Wernera7902ed2015-01-14 13:12:10 -080041#define FMAP_REVERSED_SIGNATURE "__PAMF__" /* avoid magic number in .rodata */
Stefan Reinauer357bb2d2012-08-09 13:44:38 -070042#define FMAP_VER_MAJOR 1 /* this header's FMAP minor version */
43#define FMAP_VER_MINOR 1 /* this header's FMAP minor version */
44#define FMAP_STRLEN 32 /* maximum length for strings, */
45 /* including null-terminator */
46
47enum fmap_flags {
48 FMAP_AREA_STATIC = 1 << 0,
49 FMAP_AREA_COMPRESSED = 1 << 1,
50 FMAP_AREA_RO = 1 << 2,
51};
52
53/* Mapping of volatile and static regions in firmware binary */
54struct fmap_area {
55 uint32_t offset; /* offset relative to base */
56 uint32_t size; /* size in bytes */
57 uint8_t name[FMAP_STRLEN]; /* descriptive name */
58 uint16_t flags; /* flags for this area */
59} __attribute__((packed));
60
61struct fmap {
62 uint8_t signature[8]; /* "__FMAP__" (0x5F5F464D41505F5F) */
63 uint8_t ver_major; /* major version */
64 uint8_t ver_minor; /* minor version */
65 uint64_t base; /* address of the firmware binary */
66 uint32_t size; /* size of firmware binary in bytes */
67 uint8_t name[FMAP_STRLEN]; /* name of this firmware binary */
68 uint16_t nareas; /* number of areas described by
69 fmap_areas[] below */
70 struct fmap_area areas[];
71} __attribute__((packed));
72
73
74/* coreboot specific function prototypes */
75const struct fmap *fmap_find(void);
76const struct fmap_area *find_fmap_area(const struct fmap *fmap,
77 const char name[]);
78int find_fmap_entry(const char name[], void **pointer);
79#endif /* FLASHMAP_LIB_FMAP_H__*/