Add ifdtool, utility to read / modify Intel Firmware Descriptor images
[coreboot.git] / util / ifdtool / ifdtool.h
1 /*
2  * ifdtool - dump Intel Firmware Descriptor information
3  *
4  * Copyright (C) 2011 The ChromiumOS Authors.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18  */
19
20 #include <stdint.h>
21 #define IFDTOOL_VERSION "1.0"
22
23 enum spi_frequency {
24         SPI_FREQUENCY_20MHZ = 0,
25         SPI_FREQUENCY_33MHZ = 1,
26         SPI_FREQUENCY_50MHZ = 4,
27 };
28
29 // flash descriptor
30 typedef struct {
31         uint32_t flvalsig;
32         uint32_t flmap0;
33         uint32_t flmap1;
34         uint32_t flmap2;
35         uint8_t  reserved[0xefc - 0x20];
36         uint32_t flumap1;
37 } __attribute__((packed)) fdbar_t;
38
39 // regions
40 typedef struct {
41         uint32_t flreg0;
42         uint32_t flreg1;
43         uint32_t flreg2;
44         uint32_t flreg3;
45         uint32_t flreg4;
46 } __attribute__((packed)) frba_t;
47
48 // component section
49 typedef struct {
50         uint32_t flcomp;
51         uint32_t flill;
52         uint32_t flpb;
53 } __attribute__((packed)) fcba_t;
54
55 // pch strap
56 typedef struct {
57         uint32_t pchstrp0;
58         uint32_t pchstrp1;
59         uint32_t pchstrp2;
60         uint32_t pchstrp3;
61         uint32_t pchstrp4;
62         uint32_t pchstrp5;
63         uint32_t pchstrp6;
64         uint32_t pchstrp7;
65         uint32_t pchstrp8;
66         uint32_t pchstrp9;
67         uint32_t pchstrp10;
68         uint32_t pchstrp11;
69         uint32_t pchstrp12;
70         uint32_t pchstrp13;
71         uint32_t pchstrp14;
72         uint32_t pchstrp15;
73 } __attribute__((packed)) fpsba_t;
74
75 // master
76 typedef struct {
77         uint32_t flmstr1;
78         uint32_t flmstr2;
79         uint32_t flmstr3;
80 } __attribute__((packed)) fmba_t;
81
82 // processor strap
83 typedef struct {
84         uint32_t data[8];
85 } __attribute__((packed)) fmsba_t;
86
87