Hung-Te Lin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31766
Change subject: Documentation: Explain FMAP and FMD
......................................................................
Documentation: Explain FMAP and FMD
The Flashmap (FMAP) was not clearly documented. The new flashmap.md
explains where to find more details about that and how / why it was used
in coreboot. Also explained what is FMD and how to use it.
BUG=None
TEST=None (only documentation).
Change-Id: Ia389e56c632096d7c905ed221fd4f140dec382e6
Signed-off-by: Hung-Te Lin <hungte(a)chromium.org>
---
A Documentation/flashmap.md
M Documentation/index.md
D util/cbfstool/README.fmaptool
3 files changed, 116 insertions(+), 69 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/66/31766/1
diff --git a/Documentation/flashmap.md b/Documentation/flashmap.md
new file mode 100644
index 0000000..c6780b6
--- /dev/null
+++ b/Documentation/flashmap.md
@@ -0,0 +1,115 @@
+# Flashmap and Flashmap Descriptor in coreboot
+
+## Flashmap
+
+[Flashmap](https://code.google.com/p/flashmap) (FMAP) is a binary format
+originally developed for Chromium OS to manipulate firmware image and to
+represent the layout of flash chips. With Flashmap, the firmware image is split
+into multiple `fmap_area` (may also be referred as 'regions', or 'sections').
+Each area has a name, offset, size and 16 bits of flags.
+
+coreboot puts most data in the CBFS structure. But many systems, especially
+Chromium OS, need some area to be created in different format and layout. For
+example, Chromium OS has defined a key-value style "Vital Product Data" (VPD)
+that cannot live inside CBFS. Intel firmware also usually need a place to put
+the firmware for management engine. Some ARM SOCs also need to preserve
+calibration data in the fixed location. This is very helpful to manipulate
+non-coreboot data.
+
+As a result, Flashmap is now directly supported by coreboot, and is the
+de facto standard FMAP implementation.
+
+## Flashmap Descriptor
+
+Since coreboot is starting to use a "partition" of Flashmap to describe the
+flash chip layout (both at runtime and when flashing a new image onto a
+chip), the project needs a reasonably expressive plain text format for
+representing such sections in the source tree.
+
+Flashmap Descriptor (FMD) is a [language and
+compiler](https://chromium-review.googlesource.com/#/c/255031) inside coreboot
+utility folder that can be used to generate final firmware images (i.e.
+`coreboot.rom`) formatted by Flashmap.
+
+The FMD in coreboot `utils` folder contains a scanner, parser, semantic
+analyzer, and Flashmap converter. Here's an informal language description:
+
+```
+# <line comment>
+<image name>[@<memory-mapped address>] <image size> {
+ <section name>[(flags)][@<offset from start of image>] [<section size>] [{
+ <subsection name>[@<offset from start of parent section>] [<subsection size>] [{
+ # Sections can be nested as deeply as desired
+ <subsubsection name>[(flags)][@...] [...] [{...}]
+ }]
+ [<subsection name>[(flags)][@...] [...] [{...}]]
+ # There can be many subsections at each level of nesting: they will be inserted
+ # sequentially, and although gaps are allowed, any provided offsets are always
+ # relative to the closest parent node's and must be strictly increasing with neither
+ # overlapping nor degenerate-size sections.
+ }]
+}
+```
+
+Note that the above example contains a few symbols that are actually meta
+syntax, and therefore have neither meaning nor place in a real file. The `<.*>`s
+indicate placeholders for parameters:
+
+* The names are strings, which are provided as single-word (no white space)
+ groups of syntactically unimportant symbols (i.e. every thing except `@`, `{`,
+ and `}`): they are not surrounded by quotes or any other form of delimiter.
+* The other fields are non-negative integers, which may be given as decimal or
+ hexadecimal; in either case, a `K`, `M`, or `G` may be appended (without
+ intermediate white space) as a multiplier.
+* Comments consist of anything one manages to enter, provided it doesn't start a
+ new line.
+
+The `[.*]`s indicate that a portion of the file could be omitted altogether:
+
+* Just because something is noted as optional doesn't mean it is in every case:
+ the answer might actually depend on which other information is---or
+ isn't---provided.
+* The "flag" specifies the attribute or type for given section. The most
+ important supported flag is "CBFS", which indicates the section will contain
+ a CBFS structure.
+* In particular, it is only legal to place a (CBFS) flag on a leaf section; that
+ is, choosing to add child sections excludes the possibility of putting a CBFS
+ in their parent. Such flags are only used to decide where CBFS empty file
+ headers should be created, and do not result in the storage of any additional
+ metadata in the resulting FMAP section.
+
+Additionally, it's important to note these properties of the overall file and
+its values:
+
+* Other than within would-be strings and numbers, white space is ignored. It
+ goes without saying that such power comes with responsibility, which is why
+ this sentence is here.
+* Although the `section name` must be globally unique, one of them may (but is
+ not required to) match the image name.
+* It is a syntax error to supply a number (besides 0) that begins with the
+ character `0`, as there is no intention of adding octals to the mix.
+* The image's memory address should be present on (and only on) layouts for
+ memory-mapped chips.
+* Although it may be evident from above, all `section` offsets are relative only
+ to the immediate parent. There is no way to include an absolute offset (i.e.
+ from the beginning of flash), which means that it is "safe" to reorder the
+ sections within a particular level of nesting, as long as the change doesn't
+ cause their positions and sizes to necessitate overlap or zero sizes.
+* A `section` with omitted offset is assumed to start at as low a position as
+ possible (with no consideration of alignment) and one with omitted size is
+ assumed to fill the remaining space until the next sibling or before the end
+ of its parent.
+* It's fine to omit any `section`'s offset, size, or both, provided its position
+ and size are still unambiguous in the context of its *sibling* sections and
+ its parent's *size*. In particular, knowledge of one .*section 's children or
+ the `section`s' common parent's siblings will not be used for this purpose.
+* Although `section`s are not required to have children, the flash chip as a
+ whole must have at least one.
+* Though the braces after `section`s may be omitted for those that have no
+ children, if they are present, they must contain at least one child.
+
+PL people and sympathizers may wish to examine the formal abstract syntax and
+context-free grammar, which are located in `fmd_scanner.l` and `fmd_scanner.y`,
+respectively. Those interested in the algorithm used to infer omitted values
+will feel at home in `fmd.c`, particularly near the definition of
+`validate_and_complete_info()`.
diff --git a/Documentation/index.md b/Documentation/index.md
index dd8714c..9398458 100644
--- a/Documentation/index.md
+++ b/Documentation/index.md
@@ -186,3 +186,4 @@
* [Utilities](util.md)
* [Release notes for past releases](releases/index.md)
* [Flashing firmware tutorial](flash_tutorial/index.md)
+* [Flashmap and Flashmap Descriptor](flashmap.md)
diff --git a/util/cbfstool/README.fmaptool b/util/cbfstool/README.fmaptool
deleted file mode 100644
index 86fc3b2..0000000
--- a/util/cbfstool/README.fmaptool
+++ /dev/null
@@ -1,69 +0,0 @@
-Flashmap descriptors in coreboot
-================================
-Flashmap (https://code.google.com/p/flashmap) is a binary format for representing the layout of
-flash chips. Since coreboot is starting to use a "partition" of this format to describe the flash
-chip layout---both at runtime and when flashing a new image onto a chip---, the project needed a
-reasonably expressive plaintext format for representing such sections in the source tree. Our
-solution is the fmd ("flashmap descriptor") language, and the files in this directory contain a
-scanner, parser, semantic analyser, and flashmap converter. Here's an informal language description:
-
-# <line comment>
-<image name>[@<memory-mapped address>] <image size> {
- <section name>[(flags)][@<offset from start of image>] [<section size>] [{
- <subsection name>[@<offset from start of parent section>] [<subsection size>] [{
- # Sections can be nested as deeply as desired
- <subsubsection name>[(flags)][@...] [...] [{...}]
- }]
- [<subsection name>[(flags)][@...] [...] [{...}]]
- # There can be many subsections at each level of nesting: they will be inserted
- # sequentially, and although gaps are allowed, any provided offsets are always
- # relative to the closest parent node's and must be strictly increasing with neither
- # overlapping nor degenerate-size sections.
- }]
-}
-
-Note that the above example contains a few symbols that are actually metasyntax, and therefore have
-neither meaning nor place in a real file. The <.*> s indicate placeholders for parameters:
- - The names are strings, which are provided as single-word---no whitespace---groups of
- syntactically unimportant symbols (i.e. everything except @, {, and }): they are not surrounded
- by quotes or any other form of delimiter.
- - The other fields are nonnegative integers, which may be given as decimal or hexadecimal; in
- either case, a K, M, or G may be appended---without intermediate whitespace---as a multiplier.
- - Comments consist of anything one manages to enter, provided it doesn't start a new line.
-The [.*] s indicate that a portion of the file could be omitted altogether:
- - Just because something is noted as optional doesn't mean it is in every case: the answer might
- actually depend on which other information is---or isn't---provided.
- - The "flag" specifies the attribute or type for given section. The most
- important supported flag is "CBFS", which indicates the section will contain a CBFS structure.
- - In particular, it is only legal to place a (CBFS) flag on a leaf section; that is, choosing
- to add child sections excludes the possibility of putting a CBFS in their parent. Such
- flags are only used to decide where CBFS empty file headers should be created, and do not
- result in the storage of any additional metadata in the resulting FMAP section.
-Additionally, it's important to note these properties of the overall file and its values:
- - Other than within would-be strings and numbers, whitespace is ignored. It goes without saying
- that such power comes with responsibility, which is why this sentence is here.
- - Although the .*section names must be globally unique, one of them may---but is not required to---
- match the image name.
- - It is a syntax error to supply a number---besides 0---that begins with the character 0, as there
- is no intention of adding octals to the mix.
- - The image's memory address should be present on---and only on---layouts for memory-mapped chips.
- - Although it may be evident from above, all .*section offsets are relative only to the immediate
- parent. There is no way to include an absolute offset (i.e. from the beginning of flash), which
- means that it is "safe" to reorder the .*section s within a particular level of nesting, as long
- as the change doesn't cause their positions and sizes to necessitate overlap or zero sizes.
- - A .*section with omitted offset is assumed to start at as low a position as possible---with no
- consideration of alignment---and one with omitted size is assumed to fill the remaining space
- until the next sibling or before the end of its parent.
- - It's fine to omit any .*section 's offset, size, or both, provided its position and size are
- still unambiguous in the context of its *sibling* sections and its parent's *size*. In
- particular, knowledge of one .*section 's children or the .*section s' common parent's siblings
- will not be used for this purpose.
- - Although .*section s are not required to have children, the flash chip as a whole must have at
- least one.
- - Though the braces after .*section s may be omitted for those that have no children, if they are
- present, they must contain at least one child.
-
-PL people and sympathizers may wish to examine the formal abstract syntax and context-free grammar,
-which are located in fmd_scanner.l and fmd_scanner.y, respectively. Those interested in the
-algorithm used to infer omitted values will feel at home in fmd.c, particularly near the definition
-of validate_and_complete_info().
--
To view, visit https://review.coreboot.org/c/coreboot/+/31766
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ia389e56c632096d7c905ed221fd4f140dec382e6
Gerrit-Change-Number: 31766
Gerrit-PatchSet: 1
Gerrit-Owner: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-MessageType: newchange
Maxim Polyakov has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31949
Change subject: Doc/mb/asrock/h110m: update info about PEG
......................................................................
Doc/mb/asrock/h110m: update info about PEG
- Now there is no need to additionally configure the FSP
before building;
- PEG works with high link speed 8 GT/s (Gen 3);
- external GPU supported, but dynamic switching between iGPU and PEG
is not yet supported.
Change-Id: Ie0f9db47c0b88052b090cba139f0ae821758935d
Signed-off-by: Maxim Polyakov <max.senia.poliak(a)gmail.com>
---
M Documentation/mainboard/asrock/h110m-dvs.md
1 file changed, 6 insertions(+), 21 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/31949/1
diff --git a/Documentation/mainboard/asrock/h110m-dvs.md b/Documentation/mainboard/asrock/h110m-dvs.md
index 7bc38ff..c9be798 100644
--- a/Documentation/mainboard/asrock/h110m-dvs.md
+++ b/Documentation/mainboard/asrock/h110m-dvs.md
@@ -23,22 +23,10 @@
Please take FSP from the directory `3rdparty/fsp/KabylakeFspBinPkg/` in
the coreboot or download the latest version from [github][FSP github].
-
-You must use [Intel Binary Configuration Tool] BCT to set the following
-parameters in FSP.fd to initialize the PEG x16 port:
-
-```eval_rst
- Peg0Enable = Enable
- Peg0MaxLinkSpeed = Gen3
- Peg0MaxLinkWidth = Auto
-```
-
-BCT creates Fsp_M.fd, Fsp_S.fd and Fsp_T.fd. These files are integrated
-into the coreboot image. If PEG port is not used, you can get these files
-without BTC:
+You must prepare the FSP for integration into the coreboot image:
```bash
-# split FSP.fd
+# split FSP.fd: Fsp_M.fd and Fsp_S.fd should be used in building the image
python 3rdparty/fsp/Tools/SplitFspBin.py split -f 3rdparty/fsp/KabylakeFspBinPkg/Fsp.fd
```
@@ -97,10 +85,9 @@
## Known issues
-- The VGA port doesn't work.
-
-- PEG x16 port training correctly runs only at link speed of 2.5GT/s(gen1).
- It takes more time to research the schematic of this board.
+- The VGA port doesn't work. Discrete graphic card is used as primary
+ device for display output (if CONFIG_ONBOARD_VGA_IS_PRIMARY is not
+ set). Dynamic switching between iGPU and PEG is not yet supported.
- SuperIO GPIO pin is used to reset Realtek chip. However, since the
Logical Device 7 (GPIO6, GPIO7, GPIO8) is not initialized, the network
@@ -121,7 +108,7 @@
- integrated graphics init with libgfxinit (see [Known issues](#known-issues))
- PCIe x1
-- PEG x16 Gen1 (see [Known issues](#known-issues))
+- PEG x16 Gen3
- SATA
- USB
- serial port
@@ -131,7 +118,6 @@
## TODO
-- PEG x16 Gen3
- NCT6791D GPIOs
- onboard network (see [Known issues](#known-issues))
- S3 suspend/resume
@@ -156,7 +142,6 @@
[ASRock H110M-DVS]: https://www.asrock.com/mb/Intel/H110M-DVS%20R2.0/
[FSP github]: https://github.com/IntelFsp/FSP
-[Intel Binary Configuration Tool]: https://github.com/IntelFsp/BCT
[MX25L6473E]: http://www.macronix.com/Lists/Datasheet/Attachments/7380/MX25L6473E,%203V,%…
[flashrom]: https://flashrom.org/Flashrom
[H110M-DVS manual]: http://asrock.pc.cdn.bitgravity.com/Manual/H110M-DVS%20R2.0.pdf
--
To view, visit https://review.coreboot.org/c/coreboot/+/31949
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ie0f9db47c0b88052b090cba139f0ae821758935d
Gerrit-Change-Number: 31949
Gerrit-PatchSet: 1
Gerrit-Owner: Maxim Polyakov <max.senia.poliak(a)gmail.com>
Gerrit-MessageType: newchange
Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/32086
to review the following change.
Change subject: libpayload: Deduplicate strtol and strtoull
......................................................................
libpayload: Deduplicate strtol and strtoull
Our strtol() and strtoull() function contain almost exactly the same
code. This is a) bad in general and b) may cause the code to get out of
sync, such as it recently happened with CB:32029.
This patch changes strtol() to be based on strtoull() so that the main
parsing code exists only once, and also adds a strtoll() to round off
the library. Also fix the bounds imposed by strtoul() to be based on the
actual length of a 'long', not hardcoded to 32-bits (which is not
equivalent on all architectures).
Change-Id: I919c65a773cecdb11739c3f22dd0d182ed50c07f
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M payloads/libpayload/include/stdlib.h
M payloads/libpayload/libc/string.c
2 files changed, 26 insertions(+), 40 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/86/32086/1
diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h
index aaacc87..d4a7844 100644
--- a/payloads/libpayload/include/stdlib.h
+++ b/payloads/libpayload/include/stdlib.h
@@ -196,6 +196,7 @@
* @{
*/
long int strtol(const char *s, char **nptr, int base);
+long long int strtoll(const char *s, char **nptr, int base);
unsigned long int strtoul(const char *s, char **nptr, int base);
unsigned long long int strtoull(const char *s, char **nptr, int base);
long atol(const char *nptr);
diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c
index f563f63..6c257cb 100644
--- a/payloads/libpayload/libc/string.c
+++ b/payloads/libpayload/libc/string.c
@@ -33,6 +33,7 @@
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
+#include <limits.h>
#include <errno.h>
/**
@@ -419,59 +420,43 @@
* @return A signed integer representation of the string
*/
-long int strtol(const char *ptr, char **endptr, int base)
+long long int strtoll(const char *orig_ptr, char **endptr, int base)
{
- int ret = 0;
- int negative = 1;
-
- if (endptr != NULL)
- *endptr = (char *) ptr;
+ const char *ptr = orig_ptr;
+ int is_negative = 0;
/* Purge whitespace */
for( ; *ptr && isspace(*ptr); ptr++);
if (ptr[0] == '-') {
- negative = -1;
+ is_negative = 1;
ptr++;
}
- if (!*ptr)
- return 0;
+ unsigned long long uval = strtoull(ptr, endptr, base);
- /* Determine the base */
+ /* If the whole string is unparseable, endptr should point to start. */
+ if (endptr && *endptr == ptr)
+ *endptr = (char *)orig_ptr;
- if (base == 0) {
- if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
- base = 16;
- else if (ptr[0] == '0') {
- base = 8;
- ptr++;
- }
- else
- base = 10;
- }
+ if (uval > (unsigned long long)LLONG_MAX + !!is_negative)
+ uval = (unsigned long long)LLONG_MAX + !!is_negative;
- /* Base 16 allows the 0x on front - so skip over it */
+ if (is_negative)
+ return -uval;
+ else
+ return uval;
+}
- if (base == 16) {
- if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
- ptr += 2;
- }
-
- /* If the first character isn't valid, then don't
- * bother */
-
- if (!*ptr || !_valid(*ptr, base))
- return 0;
-
- for( ; *ptr && _valid(*ptr, base); ptr++)
- ret = (ret * base) + _offset(*ptr, base);
-
- if (endptr != NULL)
- *endptr = (char *) ptr;
-
- return ret * negative;
+long int strtol(const char *ptr, char **endptr, int base)
+{
+ long long int val = strtoll(ptr, endptr, base);
+ if (val > LONG_MAX)
+ return LONG_MAX;
+ if (val < LONG_MIN)
+ return LONG_MIN;
+ return val;
}
long atol(const char *nptr)
@@ -534,7 +519,7 @@
unsigned long int strtoul(const char *ptr, char **endptr, int base)
{
unsigned long long val = strtoull(ptr, endptr, base);
- if (val > UINT32_MAX) return UINT32_MAX;
+ if (val > ULONG_MAX) return ULONG_MAX;
return val;
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/32086
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I919c65a773cecdb11739c3f22dd0d182ed50c07f
Gerrit-Change-Number: 32086
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange
Hello Nico Huber,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/32085
to review the following change.
Change subject: libpayload: limits.h: Provide reliable definitions for all XXX_MAX/MIN
......................................................................
libpayload: limits.h: Provide reliable definitions for all XXX_MAX/MIN
Our current limits.h only provides (U)INT_MAX constants. This patch adds
most others expected by POSIX. Since some of these may be different
depending on architecture (e.g. 'long' is 32-bit on x86 and 64-bit on
arm64), provide a definition that will automatically figure out the
right value for the data model the compiler is using (as long as it's
using two's complement for signed integers, which I think we can assume
these days).
Change-Id: I1124a41279abd4f53d208270e392e590ca8eaada
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
---
M payloads/libpayload/include/limits.h
1 file changed, 15 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/85/32085/1
diff --git a/payloads/libpayload/include/limits.h b/payloads/libpayload/include/limits.h
index 2fecf23..4238e0e 100644
--- a/payloads/libpayload/include/limits.h
+++ b/payloads/libpayload/include/limits.h
@@ -40,7 +40,20 @@
# endif
#endif
-#define UINT_MAX (unsigned int)0xffffffff
-#define INT_MAX (unsigned int)0x7fffffff
+#define USHRT_MAX ((unsigned short int)~0U)
+#define SHRT_MIN ((short int)(USHRT_MAX & ~(USHRT_MAX >> 1)))
+#define SHRT_MAX ((short int)(USHRT_MAX >> 1))
+
+#define UINT_MAX ((unsigned int)~0U)
+#define INT_MIN ((int)(UINT_MAX & ~(UINT_MAX >> 1)))
+#define INT_MAX ((int)(UINT_MAX >> 1))
+
+#define ULONG_MAX ((unsigned long int)~0UL)
+#define LONG_MIN ((long int)(ULONG_MAX & ~(ULONG_MAX >> 1)))
+#define LONG_MAX ((long int)(ULONG_MAX >> 1))
+
+#define ULLONG_MAX ((unsigned long long int)~0UL)
+#define LLONG_MIN ((long long int)(ULLONG_MAX & ~(ULLONG_MAX >> 1)))
+#define LLONG_MAX ((long long int)(ULLONG_MAX >> 1))
#endif
--
To view, visit https://review.coreboot.org/c/coreboot/+/32085
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I1124a41279abd4f53d208270e392e590ca8eaada
Gerrit-Change-Number: 32085
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange