diff --git a/.gitignore b/.gitignore
index ed667765fb..11a6173283 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,3 @@
-payloads/libpayload/install/
-payloads/nvramcui/build
-payloads/nvramcui/libpayload
junit.xml
abuild*.xml
.config
@@ -11,46 +8,8 @@ defconfig
.ccwrap
build/
coreboot-builds/
-payloads/coreinfo/lpbuild/
-payloads/coreinfo/lp.config*
-payloads/external/depthcharge/depthcharge/
-payloads/external/FILO/filo/
-payloads/external/GRUB2/grub2/
-payloads/external/LinuxBoot/linuxboot/
-payloads/external/SeaBIOS/seabios/
-payloads/external/tianocore/tianocore/
-payloads/external/tint/tint/
-payloads/external/U-Boot/u-boot/
-payloads/external/Memtest86Plus/memtest86plus/
-payloads/external/iPXE/ipxe/
-util/crossgcc/acpica-unix-*/
-util/crossgcc/binutils-*/
-util/crossgcc/build-*BINUTILS/
-util/crossgcc/build-*EXPAT/
-util/crossgcc/build-*GCC/
-util/crossgcc/build-*GDB/
-util/crossgcc/build-*GMP/
-util/crossgcc/build-*LIBELF/
-util/crossgcc/build-*MPC/
-util/crossgcc/build-*MPFR/
-util/crossgcc/build-*PYTHON/
-util/crossgcc/build-*LVM/
-util/crossgcc/build-*IASL/
-util/crossgcc/expat-*/
-util/crossgcc/gcc-*/
-util/crossgcc/gdb-*/
-util/crossgcc/gmp-*/
-util/crossgcc/libelf-*/
-util/crossgcc/mingwrt-*/
-util/crossgcc/mpc-*/
-util/crossgcc/mpfr-*/
-util/crossgcc/Python-*/
-util/crossgcc/*.src/
-util/crossgcc/tarballs/
-util/crossgcc/w32api-*/
-util/crossgcc/xgcc/
-util/crossgcc/xgcc-*/
-util/crossgcc/xgcc
+coreboot-builds*/
+
site-local
*.\#
@@ -59,13 +18,15 @@ site-local
*.debug
!Kconfig.debug
*.elf
+*.fd
*.o
*.o.d
*.out
*.pyc
*.sw[po]
/*.rom
-coreboot-builds*/
+.test
+.dependencies
# Development friendly files
tags
@@ -75,61 +36,9 @@ tags
xgcc/
tarballs/
-#
-# KDE editors create lots of backup files whenever
-# a file is edited, so just ignore them
+# editor backup files, temporary files, IDE project files
*~
*.kate-swp
-# Ignore Kdevelop project file
*.kdev4
-util/*/.dependencies
-util/*/.test
-util/amdfwtool/amdfwtool
-util/archive/archive
-util/bincfg/bincfg
-util/board_status/board-status
-util/bucts/bucts
-util/cbfstool/cbfs-compression-tool
-util/cbfstool/cbfstool
-util/cbfstool/fmaptool
-util/cbfstool/ifwitool
-util/cbfstool/rmodtool
-util/cbmem/.dependencies
-util/cbmem/cbmem
-util/dumpmmcr/dumpmmcr
-util/ectool/ectool
-util/futility/futility
-util/genprof/genprof
-util/getpir/getpir
-util/ifdtool/ifdtool
-util/intelmetool/intelmetool
-util/inteltool/.dependencies
-util/inteltool/inteltool
-util/intelvbttool/intelvbttool
-util/k8resdump/k8resdump
-util/lbtdump/lbtdump
-util/mptable/mptable
-util/msrtool/Makefile
-util/msrtool/Makefile.deps
-util/msrtool/msrtool
-util/nvramtool/.dependencies
-util/nvramtool/nvramtool
-util/optionlist/Options.wiki
-util/pmh7tool/pmh7tool
-util/runfw/googlesnow
-util/superiotool/superiotool
-util/vgabios/testbios
-util/autoport/autoport
-util/kbc1126/kbc1126_ec_dump
-util/kbc1126/kbc1126_ec_insert
-
-Documentation/*.aux
-Documentation/*.idx
-Documentation/*.log
-Documentation/*.toc
-Documentation/*.out
-Documentation/*.pdf
-Documentation/_build
-
doxygen/*
diff --git a/.gitmodules b/.gitmodules
index 2a9c60f8bb..0ed79be37c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -51,3 +51,10 @@
url = https://review.coreboot.org/qc_blobs.git
update = none
ignore = dirty
+[submodule "3rdparty/intel-sec-tools"]
+ path = 3rdparty/intel-sec-tools
+ url = ../9esec-security-tooling.git
+[submodule "3rdparty/stm"]
+ path = 3rdparty/stm
+ url = ../STM
+ branch = stmpe
diff --git a/3rdparty/amd_blobs b/3rdparty/amd_blobs
index 1ac6d42bf3..b12744905d 160000
--- a/3rdparty/amd_blobs
+++ b/3rdparty/amd_blobs
@@ -1 +1 @@
-Subproject commit 1ac6d42bf336af639ae849933cbb818e51b1ffd1
+Subproject commit b12744905dd20c77154db99a379543f61a3e3e7f
diff --git a/3rdparty/arm-trusted-firmware b/3rdparty/arm-trusted-firmware
index ace23683be..a4c979ade4 160000
--- a/3rdparty/arm-trusted-firmware
+++ b/3rdparty/arm-trusted-firmware
@@ -1 +1 @@
-Subproject commit ace23683beb81354d6edbc61c087ab8c384d0631
+Subproject commit a4c979ade4438dfdd69c1b6e23b64e88eb648183
diff --git a/3rdparty/blobs b/3rdparty/blobs
index bbe5d99780..a59fb6e389 160000
--- a/3rdparty/blobs
+++ b/3rdparty/blobs
@@ -1 +1 @@
-Subproject commit bbe5d99780d2d085e92d9bae2c0f7b6787419d72
+Subproject commit a59fb6e3892f0629d43769a07ee7f1048a0ae1f8
diff --git a/3rdparty/fsp b/3rdparty/fsp
index 2263d48a00..e7138bf115 160000
--- a/3rdparty/fsp
+++ b/3rdparty/fsp
@@ -1 +1 @@
-Subproject commit 2263d48a006d8653df1fc742c3f7d5ffd6b75d68
+Subproject commit e7138bf11508b8b82350bd17fb611b67c0c64e6b
diff --git a/3rdparty/intel-microcode b/3rdparty/intel-microcode
index 33b7b2f381..0e4288f81f 160000
--- a/3rdparty/intel-microcode
+++ b/3rdparty/intel-microcode
@@ -1 +1 @@
-Subproject commit 33b7b2f3817e362111cd91910026ab8907f21710
+Subproject commit 0e4288f81f806620c65f70ee2bcf94b69d574096
diff --git a/3rdparty/intel-sec-tools b/3rdparty/intel-sec-tools
new file mode 160000
index 0000000000..a86ff5d400
--- /dev/null
+++ b/3rdparty/intel-sec-tools
@@ -0,0 +1 @@
+Subproject commit a86ff5d400983d685d4389c07433452c7a503300
diff --git a/3rdparty/libgfxinit b/3rdparty/libgfxinit
index 3318bf2680..bc0588e482 160000
--- a/3rdparty/libgfxinit
+++ b/3rdparty/libgfxinit
@@ -1 +1 @@
-Subproject commit 3318bf26803c77d41b18bef6d7ae4e051b97f9f2
+Subproject commit bc0588e482b1320d5739900b00a45033f5b587f4
diff --git a/3rdparty/qc_blobs b/3rdparty/qc_blobs
index 126fef6b99..6b7fe498eb 160000
--- a/3rdparty/qc_blobs
+++ b/3rdparty/qc_blobs
@@ -1 +1 @@
-Subproject commit 126fef6b996237403039aa603945fc4caa75c8d6
+Subproject commit 6b7fe498eb782b8f9758f28dd53bb0697be0d0b0
diff --git a/3rdparty/stm b/3rdparty/stm
new file mode 160000
index 0000000000..1f3258261a
--- /dev/null
+++ b/3rdparty/stm
@@ -0,0 +1 @@
+Subproject commit 1f3258261a4f4d6c60ec4447c7a03acf2509b984
diff --git a/3rdparty/vboot b/3rdparty/vboot
index 68de90c7e2..48195e5878 160000
--- a/3rdparty/vboot
+++ b/3rdparty/vboot
@@ -1 +1 @@
-Subproject commit 68de90c7e2f4a27d3a76489199176d2ab8f56de1
+Subproject commit 48195e5878006ac2cf74cb7f02953ab06c68202d
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
new file mode 100644
index 0000000000..a8f5d5f6fa
--- /dev/null
+++ b/Documentation/.gitignore
@@ -0,0 +1,7 @@
+*.aux
+*.idx
+*.log
+*.toc
+*.out
+*.pdf
+_build
diff --git a/Documentation/arch/x86/index.md b/Documentation/arch/x86/index.md
index f5546d18d5..0e14115db8 100644
--- a/Documentation/arch/x86/index.md
+++ b/Documentation/arch/x86/index.md
@@ -5,18 +5,21 @@ This section contains documentation about coreboot on x86 architecture.
* [x86 PAE support](pae.md)
## State of x86_64 support
-At the moment there's no single board that supports x86_64 or to be exact
-`ARCH_RAMSTAGE_X86_64` and `ARCH_ROMSTAGE_X86_64`.
+At the moment there's only experimental x86_64 support.
+The `emulation/qemu-i440fx` and `emulation/qemu-q35` boards do support
+*ARCH_RAMSTAGE_X86_64* , *ARCH_POSTCAR_X86_64* and *ARCH_ROMSTAGE_X86_64*.
-In order to add support for x86_64 the following assumptions are made:
+In order to add support for x86_64 the following assumptions were made:
* The CPU supports long mode
* All memory returned by malloc must be below 4GiB in physical memory
* All code that is to be run must be below 4GiB in physical memory
* The high dword of pointers is always zero
* The reference implementation is qemu
* The CPU supports 1GiB hugepages
+* x86 payloads are loaded below 4GiB in physical memory and are jumped
+ to in *protected mode*
-## Assuptions for all stages using the reference implementation
+## Assumptions for all stages using the reference implementation
* 0-4GiB are identity mapped using 2MiB-pages as WB
* Memory above 4GiB isn't accessible
* page tables reside in memory mapped ROM
@@ -37,18 +40,16 @@ The page tables contains the following structure:
At the moment *$n* is 4, which results in identity mapping the lower 4 GiB.
-## Steps to add basic support for x86_64
-* Add x86_64 toolchain support - *DONE*
-* Fix compilation errors - *DONE*
-* Fix linker errors - *TODO*
-* Add x86_64 rmodule support - *DONE*
-* Add x86_64 exception handlers - *DONE*
-* Setup page tables for long mode - *DONE*
-* Add assembly code for long mode - *DONE*
-* Add assembly code for SMM - *DONE*
-* Add assembly code for postcar stage - *TODO*
-* Add assembly code to return to protected mode - *TODO*
-* Implement reference code for mainboard `emulation/qemu-q35` - *TODO*
+## Basic x86_64 support
+Basic support for x86_64 has been implemented for QEMU mainboard target.
+
+## Reference implementation
+The reference implementation is
+* [QEMU i440fx](../../mainboard/emulation/qemu-i440fx.md)
+* [QEMU Q35](../../mainboard/emulation/qemu-q35.md)
+
+## TODO
+* Identity map memory above 4GiB in ramstage
## Future work
@@ -64,3 +65,33 @@ At the moment *$n* is 4, which results in identity mapping the lower 4 GiB.
* Test how well CAR works with x86_64 and paging
* Improve mode switches
* Test libgfxinit / VGA Option ROMs / FSP
+
+## Known bugs on real hardware
+
+According to Intel x86_64 mode hasn't been validated in CAR environments.
+Until now it could be verified on various Intel platforms and no issues have
+been found.
+
+## Known bugs on KVM enabled qemu
+
+The `x86_64` reference code runs fine in qemu soft-cpu, but has serious issues
+when using KVM mode on some machines. The workaround is to *not* place
+page-tables in ROM, as done in
+[CB:49228](https://review.coreboot.org/c/coreboot/+/49228).
+
+Here's a list of known issues:
+
+* After entering long mode, the FPU doesn't work anymore, including accessing
+ MMX registers. It works fine before entering long mode. It works fine when
+ switching back to protected mode. Other registers, like SSE registers, are
+ working fine.
+* Reading from virtual memory, when the page tables are stored in ROM, causes
+ the MMU to abort the "page table walking" mechanism when the lower address
+ bits of the virtual address to be translated have a specific pattern.
+ Instead of loading the correct physical page, the one containing the
+ page tables in ROM will be loaded and used, which breaks code and data as
+ the page table doesn't contain the expected data. This in turn leads to
+ undefined behaviour whenever the 'wrong' address is being read.
+* Disabling paging in compability mode crashes the CPU.
+* Returning from long mode to compability mode crashes the CPU.
+* Entering long mode crashes on AMD host platforms.
diff --git a/Documentation/cbfstool/index.md b/Documentation/cbfstool/index.md
new file mode 100644
index 0000000000..f99b612855
--- /dev/null
+++ b/Documentation/cbfstool/index.md
@@ -0,0 +1,5 @@
+# cbfstool
+
+Contents:
+
+* [Handling memory mapped boot media](mmap_windows.md)
diff --git a/Documentation/cbfstool/mmap_windows.md b/Documentation/cbfstool/mmap_windows.md
new file mode 100644
index 0000000000..66685f30e8
--- /dev/null
+++ b/Documentation/cbfstool/mmap_windows.md
@@ -0,0 +1,77 @@
+# cbfstool: Handling memory mapped boot media
+
+`cbfstool` is a utility used for managing coreboot file system (CBFS)
+components in a ROM image. x86 platforms are special since they have
+the SPI flash boot media memory mapped into host address space at
+runtime. This requires `cbfstool` to deal with two separate address
+spaces for any CBFS components that are eXecute-In-Place (XIP) - one
+is the SPI flash address space and other is the host address space
+where the SPI flash gets mapped.
+
+By default, all x86 platforms map a maximum of 16MiB of SPI flash at
+the top of 4G in host address space. If the flash is greater than
+16MiB, then only the top 16MiB of the flash is mapped in the host
+address space. If the flash is smaller than 16MiB, then the entire SPI
+flash is mapped at the top of 4G and the rest of the space remains
+unused.
+
+In more recent platforms like Tiger Lake (TGL), it is possible to map
+more than 16MiB of SPI flash. Since the host address space has legacy
+fixed device addresses mapped below `4G - 16M`, the SPI flash is split
+into separate windows when being mapped to the host address space.
+Default decode window of maximum 16MiB size still lives just below the
+4G boundary. The additional decode window is free to live in any
+available MMIO space that the SoC chooses.
+
+Following diagram shows different combinations of SPI flash being
+mapped into host address space when using multiple windows:
+
+![MMAP window combinations with different flash sizes][mmap_windows]
+
+*(a) SPI flash of size 16MiB (b) SPI flash smaller than 16MiB (c) SPI flash
+of size (16MiB+ext window size) (d) SPI flash smaller than (16MiB+ext
+window size)*
+
+The location of standard decode window is fixed in host address space
+`(4G - 16M) to 4G`. However, the platform is free to choose where the
+extended window lives in the host address space. Since `cbfstool`
+needs to know the exact location of the extended window, it allows the
+platform to pass in two parameters `ext-win-base` and `ext-win-size`
+that provide the base and the size of the extended window in host
+address space.
+
+`cbfstool` creates two memory map windows using the knowledge about the
+standard decode window and the information passed in by the platform
+about the extended decode window. These windows are useful in
+converting addresses from one space to another (flash space and host
+space) when dealing with XIP components.
+
+## Assumptions
+
+1. Top 16MiB is still decoded in the fixed decode window just below 4G
+ boundary.
+1. Rest of the SPI flash below the top 16MiB is mapped at the top of
+ the extended window. Even though the platform might support a
+ larger extended window, the SPI flash part used by the mainboard
+ might not be large enough to be mapped in the entire window. In
+ such cases, the mapping is assumed to be in the top part of the
+ extended window with the bottom part remaining unused.
+
+## Example
+
+If the platform supports extended window and the SPI flash size is
+greater, then `cbfstool` creates a mapping for the extended window as
+well.
+
+```
+ext_win_base = 0xF8000000
+ext_win_size = 32 * MiB
+ext_win_limit = ext_win_base + ext_win_size - 1 = 0xF9FFFFFF
+```
+
+If SPI flash is 32MiB, then top 16MiB is mapped from `0xFF000000 -
+0xFFFFFFFF` whereas the bottom 16MiB is mapped from `0xF9000000 -
+0xF9FFFFFF`. The extended window `0xF8000000 - 0xF8FFFFFF` remains
+unused.
+
+[mmap_windows]: mmap_windows.svg
diff --git a/Documentation/cbfstool/mmap_windows.svg b/Documentation/cbfstool/mmap_windows.svg
new file mode 100644
index 0000000000..617c60e743
--- /dev/null
+++ b/Documentation/cbfstool/mmap_windows.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Documentation/community/language_style.md b/Documentation/community/language_style.md
new file mode 100644
index 0000000000..97f9601286
--- /dev/null
+++ b/Documentation/community/language_style.md
@@ -0,0 +1,136 @@
+# Language style
+
+Following our [Code of Conduct](code_of_conduct.md) the project aims to
+be a space where people are considerate in natural language communication:
+
+There are terms in computing that were probably considered benign when
+introduced but are uncomfortable to some. The project aims to de-emphasize
+such terms in favor of alternatives that are at least as expressive -
+but often manage to be even more descriptive.
+
+## Political Correctness
+
+A common thread in discussions was that the project merely follows some
+fad, or that this is a "political correctness" measure, designed to please
+one particular "team". While the project doesn't exist in a vacuum and
+so there are outside influences on project members, the proposal wasn't
+made with the purpose of demonstrating allegiance to any given cause -
+except one:
+
+There are people who feel uncomfortable with some terms being used,
+_especially_ when that use takes them out of their grave context
+(e.g. slave when discussing slavery) and applies them to a rather benign
+topic (e.g. coordination of multiple technical systems), taking away
+the gravity of the term.
+
+That gets especially jarring when people aren't exposed to such terms
+in abstract sociological discussions but when they stand for real issues
+they encountered.
+
+When having to choose between using a well-established term that
+affects people negatively who could otherwise contribute more happily
+and undisturbed or an alternative just-as-good term that doesn't, the
+decision should be simple.
+
+## Token gesture
+
+The other major point of contention is that such decisions are a token
+gesture that doesn't change anything. It's true: No slave is freed
+because coreboot rejects the use of the word.
+
+coreboot is ambitious enough as-is, in that the project offers
+an alternative approach to firmware, sometimes against the vested
+interests (and deep pockets) of the leaders of a multi-billion dollar
+industry. Changing the preferred vocabulary isn't another attempt at
+changing the world, it's one thing we do to try to make coreboot (and
+coreboot only) a comfortable environment for everybody.
+
+## For everybody
+
+For everybody, but with a qualifier: We have certain community etiquette,
+and we define some behavior we don't accept in our community, both
+detailed in the Code of Conduct.
+
+Other than that, we're trying to accommodate people: The CoC lays out
+that language should be interpreted as friendly by default, and to be
+graceful in light of accidents. This also applies to the use of terms
+that the project tries to avoid: The consequence of the use of such
+terms (unless obviously employed to provoke a reaction - in that case,
+please contact the arbitration team as outlined in the Code of Conduct)
+should be a friendly reminder. The project is slow to sanction and that
+won't change just because the wrong kind of words is used.
+
+## Interfacing with the world
+
+The project doesn't exist in a vacuum, and that also applies to the choice
+of words made by other initiatives in low-level technology. When JEDEC
+calls the participants of a SPI transaction "master" and "slave", there's
+little we can do about that. We _could_ decide to use different terms,
+but that wouldn't make things easier but harder, because such a deliberate
+departure means that the original terms (and their original use) gain
+lots of visibility every time (so there's no practical advantage) while
+adding confusion, and therefore even more attention, to that situation.
+
+Sometimes there are abbreviations that can be used as substitutes,
+and in that case the recommendation is to do that.
+
+As terms that we found to be best avoided are replaced in such
+initiatives, we can follow up. Members of the community with leverage
+in such organizations are encouraged to raise the concern there.
+
+## Dealing with uses
+
+There are existing uses in our documentation and code. When we decide to
+retire a term that doesn't mean that everybody is supposed to stop doing
+whatever they're doing and spend their time on purging terms. Instead,
+ongoing development should look for alternatives (and so this could come
+up in review).
+
+People can go through existing code and docs and sort out older instances,
+and while that's encouraged it's no "stop the world" event. Changes
+in flight in review may still be merged with such terms intact, but if
+there's more work required for other reasons, we'd encourage moving away
+from such terms.
+
+This document has a section on retired terms, presenting the rationale
+as well as alternative terms that could be used instead. The main goal is
+to be expressive: There's no point in just picking any alternative term,
+choose something that explains the purpose well.
+
+As mentioned, missteps will happen. Point them out, but assume no ill
+intent for as long as you can manage.
+
+## Discussing words to remove from active use
+
+There ought to be some process when terminology is brought up as a
+negative to avoid. Do not to tell people that "they're feeling wrong"
+when they have a negative reaction to certain terms, but also try to
+avoid being offended for the sake of others.
+
+When bringing up a term, on the project's mailing list or, if you don't
+feel safe doing that, by contacting the arbitration team, explain what's
+wrong with the term and offer alternatives for uses within coreboot.
+
+With a term under discussion, see if there's particular value for us to
+continue using the term (maybe in limited situations, like continuing
+to use "slave" in SPI related code).
+
+Once the arbitration team considers the topic discussed completely and
+found a consensus, it will present a decision in a leadership meeting. It
+should explain why a term should or should not be used and in the latter
+case offer alternatives. These decisions shall then be added to this
+document.
+
+## Retired terminology
+
+### slave
+
+Replacing this term for something else had the highest approval rating
+in early discussions, so it seems pretty universally considered a bad
+choice and therefore should be avoided where possible.
+
+An exception is made where it's a term used in current standards and data
+sheets: Trying to "hide" the term in such cases only puts a spotlight
+on it every time code and data sheet are compared.
+
+Alternatives: subordinate, secondary, follower
diff --git a/Documentation/conf.py b/Documentation/conf.py
index f82fa0e182..3180fd9720 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -48,7 +48,7 @@ try:
except ImportError:
print("Error: Please install sphinxcontrib.ditaa for ASCII art conversion\n")
else:
- extensions += 'sphinxcontrib.ditaa'
+ extensions += ['sphinxcontrib.ditaa']
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/Documentation/drivers/index.md b/Documentation/drivers/index.md
index e215c6ab11..40d747da9d 100644
--- a/Documentation/drivers/index.md
+++ b/Documentation/drivers/index.md
@@ -4,6 +4,9 @@ The drivers can be found in `src/drivers`. They are intended for onboard
and plugin devices, significantly reducing integration complexity and
they allow to easily reuse existing code accross platforms.
+* [Intel DPTF](dptf.md)
* [IPMI KCS](ipmi_kcs.md)
* [SMMSTORE](smmstore.md)
* [SoundWire](soundwire.md)
+* [SMMSTOREv2](smmstorev2.md)
+* [USB4 Retimer](retimer.md)
diff --git a/Documentation/drivers/retimer.md b/Documentation/drivers/retimer.md
new file mode 100644
index 0000000000..d83b50b26f
--- /dev/null
+++ b/Documentation/drivers/retimer.md
@@ -0,0 +1,40 @@
+# USB4 Retimers
+
+# Introduction
+As USB speeds continue to increase (up to 5G, 10G, and even 20G or higher in
+newer revisions of the spec), it becomes more difficult to maintain signal
+integrity for longer traces. Devices such as retimers and redrivers can be used
+to help signals maintain their integrity over long distances.
+
+A redriver is a device that boosts the high-frequency content of a signal in
+order to compensate for the attenuation typically caused by travelling through
+various circuit components (PCB, connectors, CPU, etc.). Redrivers are not
+protocol-aware, which makes them relatively simple. However, their effectiveness
+is limited, and may not work at all in some scenarios.
+
+A retimer is a device that retransmits a fresh copy of the signal it receives,
+by doing CDR and retransmitting the data (i.e., it is protocol-aware). Since
+this is a digital component, it may have firmware.
+
+
+# Driver Usage
+
+Some operating systems may have the ability to update firmware on USB4 retimers,
+and ultimately will need some way to power the device on and off so that its new
+firmware can be loaded. This is achieved by providing a GPIO signal that can be
+used for this purpose; its active state must be the one in which power is
+applied to the retimer. This driver will generate the required ACPI AML code
+which will toggle the GPIO in response to the kernel's request (through the
+`_DSM` ACPI method). Simply put something like the following in your devicetree:
+
+```
+device pci 0.0 on
+ chip drivers/intel/usb4/retimer
+ register "power_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_HIGH(GPP_A0)"
+ device generic 0 on end
+ end
+end
+```
+
+replacing the GPIO with the appropriate pin and polarity.
+
diff --git a/Documentation/drivers/smmstorev2.md b/Documentation/drivers/smmstorev2.md
new file mode 100644
index 0000000000..cb79b8b6b8
--- /dev/null
+++ b/Documentation/drivers/smmstorev2.md
@@ -0,0 +1,221 @@
+# SMM based flash storage driver Version 2
+
+This documents the API exposed by the x86 system management based
+storage driver.
+
+## SMMSTOREv2
+
+SMMSTOREv2 is a [SMM] mediated driver to read from, write to and erase
+a predefined region in flash. It can be enabled by setting
+`CONFIG_SMMSTORE=y` and `CONFIG_SMMSTORE_V2=y` in menuconfig.
+
+This can be used by the OS or the payload to implement persistent
+storage to hold for instance configuration data, without needing to
+implement a (platform specific) storage driver in the payload itself.
+
+### Storage size and alignment
+
+SMMSTORE version 2 requires a minimum alignment of 64 KiB, which should
+be supported by all flash chips. Not having to perform read-modify-write
+operations is desired, as it reduces complexity and potential for bugs.
+
+This can be used by a FTW (FaultTolerantWrite) implementation that uses
+at least two regions in an A/B update scheme. The FTW implementation in
+EDK2 uses three different regions in the store:
+
+- The variable store
+- The FTW spare block
+- The FTW working block
+
+All regions must be block-aligned, and the FTW spare size must be larger
+than that of the variable store. FTW working block can be much smaller.
+With 64 KiB as block size, the minimum size of the FTW-enabled store is:
+
+- The variable store: 1 block = 64 KiB
+- The FTW spare block: 2 blocks = 2 * 64 KiB
+- The FTW working block: 1 block = 64 KiB
+
+Therefore, the minimum size for EDK2 FTW is 4 blocks, or 256 KiB.
+
+## API
+
+The API provides read and write access to an unformatted block storage.
+
+### Storage region
+
+By default SMMSTOREv2 will operate on a separate FMAP region called
+`SMMSTORE`. The default generated FMAP will include such a region. On
+systems with a locked FMAP, e.g. in an existing vboot setup with a
+locked RO region, the option exists to add a cbfsfile called `smm_store`
+in the `RW_LEGACY` (if CHROMEOS) or in the `COREBOOT` FMAP regions. It
+is recommended for new builds using a handcrafted FMD that intend to
+make use of SMMSTORE to include a sufficiently large `SMMSTORE` FMAP
+region. It is mandatory to align the `SMMSTORE` region to 64KiB for
+compatibility with the largest flash erase operation.
+
+When a default generated FMAP is used, the size of the FMAP region is
+equal to `CONFIG_SMMSTORE_SIZE`. UEFI payloads expect at least 64 KiB.
+To support a fault tolerant write mechanism, at least a multiple of
+this size is recommended.
+
+### Communication buffer
+
+To prevent malicious ring0 code to access arbitrary memory locations,
+SMMSTOREv2 uses a communication buffer in CBMEM/HOB for all transfers.
+This buffer has to be at least 64 KiB in size and must be installed
+before calling any of the SMMSTORE read or write operations. Usually,
+coreboot will install this buffer to transfer data between ring0 and
+the [SMM] handler.
+
+In order to get the communication buffer address, the payload or OS
+has to read the coreboot table with tag `0x0039`, containing:
+
+```C
+struct lb_smmstorev2 {
+ uint32_t tag;
+ uint32_t size;
+ uint32_t num_blocks; /* Number of writeable blocks in SMM */
+ uint32_t block_size; /* Size of a block in byte. Default: 64 KiB */
+ uint32_t mmap_addr; /* MMIO address of the store for read only access */
+ uint32_t com_buffer; /* Physical address of the communication buffer */
+ uint32_t com_buffer_size; /* Size of the communication buffer in byte */
+ uint8_t apm_cmd; /* The command byte to write to the APM I/O port */
+ uint8_t unused[3]; /* Set to zero */
+};
+```
+
+The absence of this coreboot table entry indicates that there's no
+SMMSTOREv2 support.
+
+### Blocks
+
+The SMMSTOREv2 splits the SMMSTORE FMAP partition into smaller chunks
+called *blocks*. Every block is at least the size of 64KiB to support
+arbitrary NOR flash erase ops. A payload or OS must make no further
+assumptions about the block or communication buffer size.
+
+### Generating the SMI
+
+SMMSTOREv2 is called via an SMI, which is generated via a write to the
+IO port defined in the smi_cmd entry of the FADT ACPI table. `%al`
+contains `APM_CNT_SMMSTORE=0xed` and is written to the smi_cmd IO
+port. `%ah` contains the SMMSTOREv2 command. `%ebx` contains the
+parameter buffer to the SMMSTOREv2 command.
+
+### Return values
+
+If a command succeeds, SMMSTOREv2 will return with
+`SMMSTORE_RET_SUCCESS=0` in `%eax`. On failure SMMSTORE will return
+`SMMSTORE_RET_FAILURE=1`. For unsupported SMMSTORE commands
+`SMMSTORE_REG_UNSUPPORTED=2` is returned.
+
+**NOTE 1**: The caller **must** check the return value and should make
+no assumption on the returned data if `%eax` does not contain
+`SMMSTORE_RET_SUCCESS`.
+
+**NOTE 2**: If the SMI returns without changing `%ax`, it can be assumed
+that the SMMSTOREv2 feature is not installed.
+
+### Calling arguments
+
+SMMSTOREv2 supports 3 subcommands that are passed via `%ah`, the
+additional calling arguments are passed via `%ebx`.
+
+**NOTE**: The size of the struct entries are in the native word size of
+smihandler. This means 32 bits in almost all cases.
+
+#### - SMMSTORE_CMD_INIT = 4
+
+This installs the communication buffer to use and thus enables the
+SMMSTORE handler. This command can only be executed once and is done
+by the firmware. Calling this function at runtime has no effect.
+
+The additional parameter buffer `%ebx` contains a pointer to the
+following struct:
+
+```C
+struct smmstore_params_init {
+ uint32_t com_buffer;
+ uint32_t com_buffer_size;
+} __packed;
+```
+
+INPUT:
+- `com_buffer`: Physical address of the communication buffer (CBMEM)
+- `com_buffer_size`: Size in bytes of the communication buffer
+
+#### - SMMSTORE_CMD_RAW_READ = 5
+
+SMMSTOREv2 allows reading arbitrary data. It is up to the caller to
+initialize the store with meaningful data before using it.
+
+The additional parameter buffer `%ebx` contains a pointer to the
+following struct:
+
+```C
+struct smmstore_params_raw_read {
+ uint32_t bufsize;
+ uint32_t bufoffset;
+ uint32_t block_id;
+} __packed;
+```
+
+INPUT:
+- `bufsize`: Size of data to read within the communication buffer
+- `bufoffset`: Offset within the communication buffer
+- `block_id`: Block to read from
+
+#### - SMMSTORE_CMD_RAW_WRITE = 6
+
+SMMSTOREv2 allows writing arbitrary data. It is up to the caller to
+erase a block before writing it.
+
+The additional parameter buffer `%ebx` contains a pointer to
+the following struct:
+
+```C
+struct smmstore_params_raw_write {
+ uint32_t bufsize;
+ uint32_t bufoffset;
+ uint32_t block_id;
+} __packed;
+```
+
+INPUT:
+- `bufsize`: Size of data to write within the communication buffer
+- `bufoffset`: Offset within the communication buffer
+- `block_id`: Block to write to
+
+#### - SMMSTORE_CMD_RAW_CLEAR = 7
+
+SMMSTOREv2 allows clearing blocks. A cleared block will read as `0xff`.
+By providing multiple blocks the caller can implement a fault tolerant
+write mechanism. It is up to the caller to clear blocks before writing
+to them.
+
+
+```C
+struct smmstore_params_raw_clear {
+ uint32_t block_id;
+} __packed;
+```
+
+INPUT:
+- `block_id`: Block to erase
+
+#### Security
+
+Pointers provided by the payload or OS are checked to not overlap with
+SMM. This protects the SMM handler from being compromised.
+
+As all information is exchanged using the communication buffer and
+coreboot tables, there's no risk that a malicious application capable
+of issuing SMIs could extract arbitrary data or modify the currently
+running kernel.
+
+## External links
+
+* [A Tour Beyond BIOS Implementing UEFI Authenticated Variables in SMM with EDKI](https://software.intel.com/sites/default/files/managed/cf/ea/a_tour_beyond_bios_implementing_uefi_authenticated_variables_in_smm_with_edkii.pdf)
+Note that this differs significantly from coreboot's implementation.
+
+[SMM]: ../security/smm.md
diff --git a/Documentation/getting_started/gerrit_guidelines.md b/Documentation/getting_started/gerrit_guidelines.md
index 59f675a2ff..4547f919ce 100644
--- a/Documentation/getting_started/gerrit_guidelines.md
+++ b/Documentation/getting_started/gerrit_guidelines.md
@@ -43,15 +43,42 @@ employer is aware and you are authorized to submit the code. For
clarification, see the Developer's Certificate of Origin in the coreboot
[Signed-off-by policy](https://www.coreboot.org/Development_Guidelines#Sign-off_Procedure).
-* Let non-trivial patches sit in a review state for at least 24 hours
-before submission. Remember that there are coreboot developers in timezones
-all over the world, and everyone should have a chance to contribute.
-Trivial patches would be things like whitespace changes or spelling fixes,
-in general those that don’t impact the final binary output. The
-24-hour period would start at submission, and would be restarted at any
-update which significantly changes any part of the patch. Patches can be
-'Fast-tracked' and submitted in under 24 hours with the agreement of at
-least 3 +2 votes.
+* In general, patches should remain open for review for at least 24 hours
+since the last significant modification to the change. The purpose is to
+let coreboot developers around the world have a chance to review. Complex
+reworks, even if they don't change the purpose of the patch but the way
+it's implemented, should restart the wait period.
+
+* A change can go in without the wait period if its purpose is to fix
+a recently-introduced issue (build, boot or OS-level compatibility, not
+necessarily identified by coreboot.org facilities). Its commit message
+has to explain what change introduced the problem and the nature of
+the problem so that the emergency need becomes apparent. The change
+itself should be as limited in scope and impact as possible to make it
+simple to assess the impact. Such a change can be merged early with 3
+Code-Review+2. For emergency fixes that affect a single project (SoC,
+mainboard, ...) it's _strongly_ recommended to get a review by somebody
+not involved with that project to ensure that the documentation of the
+issue is clear enough.
+
+* Trivial changes that deal with minor issues like inconsistencies in
+whitespace or spelling fixes that don't impact the final binary output
+also don't need to wait. Such changes should point out in their commit
+messages how the the author verified that the binary output is identical
+(e.g. a TIMELESS build for a given configuration). When submitting
+such changes early, the submitter must be different from the author
+and must document the intent in the Gerrit discussion, e.g. "landed the
+change early because it's trivial". Note that trivial fixes shouldn't
+necessarily be expedited: Just like they're not critical enough for
+things to go wrong because of them, they're not critical enough to
+require quick handling. This exception merely serves to acknowledge that
+a round-the-world review just isn't necessary for some types of changes.
+
+* As explained in our Code of Conduct, we try to assume the best of each
+other in this community. It's okay to discuss mistakes (e.g. isolated
+instances of non-trivial and non-critical changes submitted early) but
+try to keep such inquiries blameless. If a change leads to problems with
+our code, the focus should be on fixing the issue, not on assigning blame.
* Do not +2 patches that you authored or own, even for something as trivial
as whitespace fixes. When working on your own patches, it’s easy to
diff --git a/Documentation/getting_started/gpio.md b/Documentation/getting_started/gpio.md
index 81a06eb410..13aeed5bd2 100644
--- a/Documentation/getting_started/gpio.md
+++ b/Documentation/getting_started/gpio.md
@@ -88,11 +88,6 @@ configurations together into a set of macros, e.g.,
```C
/* Native function configuration */
#define PAD_CFG_NF(pad, pull, rst, func)
- /*
- * Set native function with RX Level/Edge configuration and disable
- * input/output buffer if necessary
- */
- #define PAD_CFG_NF_BUF_TRIG(pad, pull, rst, func, bufdis, trig)
/* General purpose output, no pullup/down. */
#define PAD_CFG_GPO(pad, val, rst)
/* General purpose output, with termination specified */
diff --git a/Documentation/getting_started/kconfig.md b/Documentation/getting_started/kconfig.md
index ecdfe62d4a..037371bd34 100644
--- a/Documentation/getting_started/kconfig.md
+++ b/Documentation/getting_started/kconfig.md
@@ -52,7 +52,7 @@ command line.
not have an answer yet, it stops and queries the user for the desired value.
- olddefconfig - Generates a config, using the default value for any symbols not
listed in the .config file.
-- savedefconfig - Creates a ‘mini-config’ file, stripping out all of the symbols
+- savedefconfig - Creates a ‘defconfig’ file, stripping out all of the symbols
that were left as default values. This is very useful for debugging, and is
how config files should be saved.
- silentoldconfig - This evaluates the .config file the same way that the
@@ -398,6 +398,8 @@ default <expr> \[if <expr>\]
- If there is no 'default' entry for a symbol, it gets set to 'n', 0, 0x0, or
“” depending on the type, however the 'bool' type is the only type that
should be left without a default value.
+- If possible, the declaration should happen before all default entries to make
+ it visible in Kconfig tools like menuconfig.
--------------------------------------------------------------------------------
diff --git a/Documentation/index.md b/Documentation/index.md
index a7c4869db2..fd1ecb1639 100644
--- a/Documentation/index.md
+++ b/Documentation/index.md
@@ -166,6 +166,7 @@ Contents:
* [Project Ideas](contributing/project_ideas.md)
* [Documentation Ideas](contributing/documentation_ideas.md)
* [Code of Conduct](community/code_of_conduct.md)
+* [Language style](community/language_style.md)
* [Community forums](community/forums.md)
* [Project services](community/services.md)
* [coreboot at conferences](community/conferences.md)
diff --git a/Documentation/lib/fw_config.md b/Documentation/lib/fw_config.md
index 63a56dcd7b..dcf1bb4e95 100644
--- a/Documentation/lib/fw_config.md
+++ b/Documentation/lib/fw_config.md
@@ -73,18 +73,18 @@ return true.
## Firmware Configuration Value
-The 32bit value used as the firmware configuration bitmask is meant to be determined at runtime
+The 64-bit value used as the firmware configuration bitmask is meant to be determined at runtime
but could also be defined at compile time if needed.
There are two supported sources for providing this information to coreboot.
### CBFS
-The value can be provided with a 32bit raw value in CBFS that is read by coreboot. The value
+The value can be provided with a 64-bit raw value in CBFS that is read by coreboot. The value
can be set at build time but also adjusted in an existing image with `cbfstool`.
To enable this select the `CONFIG_FW_CONFIG_CBFS` option in the build configuration and add a
-raw 32bit value to CBFS with the name of the current prefix at `CONFIG_FW_PREFIX/fw_config`.
+raw 64-bit value to CBFS with the name of the current prefix at `CONFIG_FW_PREFIX/fw_config`.
When `fw_config_probe_device()` or `fw_config_probe()` is called it will look for the specified
file in CBFS use the value it contains when matching fields and options.
@@ -291,8 +291,8 @@ field and option to check.
struct fw_config {
const char *field_name;
const char *option_name;
- uint32_t mask;
- uint32_t value;
+ uint64_t mask;
+ uint64_t value;
};
```
diff --git a/Documentation/lib/payloads/fit.md b/Documentation/lib/payloads/fit.md
index c6ccc7b868..ef5e892c36 100644
--- a/Documentation/lib/payloads/fit.md
+++ b/Documentation/lib/payloads/fit.md
@@ -5,6 +5,7 @@
## Supported architectures
+* aarch32
* aarch64
* riscv
@@ -26,6 +27,13 @@ The section must be named in order to be found by the FIT parser:
The FIT parser needs architecure support.
+### aarch32
+The source code can be found in `src/arch/arm/fit_payload.c`.
+
+On aarch32 the kernel (a section named 'kernel') must be in **Image**
+format and it needs a devicetree (a section named 'fdt') to boot.
+The kernel will be placed close to "*DRAMSTART*".
+
### aarch64
The source code can be found in `src/arch/arm64/fit_payload.c`.
diff --git a/Documentation/mainboard/asus/a88xm-e.md b/Documentation/mainboard/asus/a88xm-e.md
new file mode 100644
index 0000000000..77615313e0
--- /dev/null
+++ b/Documentation/mainboard/asus/a88xm-e.md
@@ -0,0 +1,170 @@
+# ASUS A88XM-E
+
+This page describes how to run coreboot on the [ASUS A88XM-E].
+
+## Technology
+
+Both "Trinity" and "Richland" FM2 desktop processing units are working,
+the CPU architecture in these CPUs/APUs are [Piledriver],
+and their GPU is [TeraScale 3] (VLIW4-based).
+
+Kaveri is non-working at the moment (FM2+),
+the CPU architecture in these CPUs/APUs are [Steamroller],
+and their GPU is [Sea Islands] (GCN2-based).
+
+A10 Richland is recommended for the best performance and working IOMMU.
+
+```eval_rst
++------------------+--------------------------------------------------+
+| A88XM-E | |
++------------------+--------------------------------------------------+
+| DDR voltage IC | Nuvoton 3101S |
++------------------+--------------------------------------------------+
+| Network | Realtek RTL8111G |
++------------------+--------------------------------------------------+
+| Northbridge | Integrated into CPU with IMC and GPU (APUs only) |
++------------------+--------------------------------------------------+
+| Southbridge | Bolton-D4 |
++------------------+--------------------------------------------------+
+| Sound IC | Realtek ALC887 |
++------------------+--------------------------------------------------+
+| Super I/O | ITE IT8603E |
++------------------+--------------------------------------------------+
+| VRM controller | DIGI VRM ASP1206 |
++------------------+--------------------------------------------------+
+```
+
+## Flashing coreboot
+
+```eval_rst
++---------------------+------------+
+| Type | Value |
++=====================+============+
+| Socketed flash | yes |
++---------------------+------------+
+| Model | [GD25Q64] |
++---------------------+------------+
+| Size | 8 MiB |
++---------------------+------------+
+| Package | DIP-8 |
++---------------------+------------+
+| Write protection | yes |
++---------------------+------------+
+| Dual BIOS feature | no |
++---------------------+------------+
+| Internal flashing | yes |
++---------------------+------------+
+```
+
+### Internal programming
+
+The main SPI flash can be accessed using [flashrom], if the
+AmdSpiRomProtect modules have been deleted in the factory image previously.
+
+### External flashing
+
+Using a PLCC Extractor or any other appropriate tool, carefully remove the
+DIP-8 BIOS chip from its' socket while avoiding the bent pins, if possible.
+To flash it, use a [flashrom]-supported USB CH341A programmer - preferably with a
+green PCB - and double check that it's giving a 3.3V voltage on the socket pins.
+
+## Integrated graphics
+
+### Retrieve the VGA optionrom ("Retrieval via Linux kernel" method)
+
+Make sure a proprietary UEFI is flashed and boot Linux with iomem=relaxed flag.
+Some Linux drivers (e.g. radeon for AMD) make option ROMs like the video blob
+available to user space via sysfs. To use that to get the blob you need to
+enable it first. To that end you need to determine the path within /sys
+corresponding to your graphics chip. It looks like this:
+
+ # /sys/devices/pci:/::./rom.
+
+You can get the respective information with lspci, for example:
+
+ # lspci -tv
+ # -[0000:00]-+-00.0 Advanced Micro Devices, Inc. [AMD] Family 16h Processor Root Complex
+ # +-01.0 Advanced Micro Devices, Inc. [AMD/ATI] Kabini [Radeon HD 8210]
+ # ...
+
+Here the the needed bits (for the ROM of the Kabini device) are:
+
+ # PCI domain: (almost always) 0000
+ # PCI bus: (also very commonly) 00
+ # PCI slot: 01 (logical slot; different from any physical slots)
+ # PCI function: 0 (a PCI device might have multiple functions... shouldn't matter here)
+
+To enable reading of the ROM you need to write 1 to the respective file, e.g.:
+
+ # echo 1 > /sys/devices/pci0000:00/0000:00:01.0/rom
+
+The same file should then contain the video blob and it should be possible to simply copy it, e.g.:
+
+ # cp /sys/devices/pci0000:00/0000:00:01.0/rom vgabios.bin
+
+romheaders should print reasonable output for this file.
+
+This version is usable for all the GPUs.
+ 1002,9901 Trinity (Radeon HD 7660D)
+ 1002,9904 Trinity (Radeon HD 7560D)
+ 1002,990c Richland (Radeon HD 8670D)
+ 1002,990e Richland (Radeon HD 8570D)
+ 1002,9991 Trinity (Radeon HD 7540D)
+ 1002,9993 Trinity (Radeon HD 7480D)
+ 1002,9996 Richland (Radeon HD 8470D)
+ 1002,9998 Richland (Radeon HD 8370D)
+ 1002,999d Richland (Radeon HD 8550D)
+ 1002,130f Kaveri (Radeon R7)
+
+## Known issues
+
+- AHCI hot-plug
+- S3 resume (sometimes)
+- Windows 7 can't boot because of the incomplete ACPI implementation
+- XHCI
+
+### XHCI ports can break after using any of the blobs, restarting the
+board with factory image makes it work again as fallback.
+Tested even with/without the Bolton and Hudson blobs.
+
+## Untested
+
+- audio over HDMI
+
+## TODOs
+
+- one ATOMBIOS module for all the integrated GPUs
+- manage to work with Kaveri/Godavary (they are using a binaryPI)
+- IRQ routing is done incorrect way - common problem of fam15h boards
+
+## Working
+
+- ACPI
+- CPU frequency scaling
+- flashrom under coreboot
+- Gigabit Ethernet
+- Hardware monitoring
+- Integrated graphics
+- KVM virtualization
+- Onboard audio
+- PCI
+- PCIe
+- PS/2 keyboard mouse (during payload, bootloader)
+- SATA
+- Serial port
+- SuperIO based fan control
+- USB (disabling XHCI controller makes to work as fallback USB2.0 ports)
+- IOMMU
+
+## Extra resources
+
+- [Board manual]
+
+[ASUS A88XM-E]: https://www.asus.com/Motherboards/A88XME/
+[Board manual]: https://dlcdnets.asus.com/pub/ASUS/mb/SocketFM2/A88XM-E/E9125_A88XM-E.pdf
+[flashrom]: https://flashrom.org/Flashrom
+[GD25Q64]: http://www.elm-tech.com/ja/products/spi-flash-memory/gd25q64/gd25q64.pdf
+[Piledriver]: https://en.wikipedia.org/wiki/Piledriver_%28microarchitecture%29#APU_lines
+[Sea Islands]: https://en.wikipedia.org/wiki/Graphics_Core_Next#GCN_2nd_generation
+[Steamroller]: https://en.wikipedia.org/wiki/Steamroller_(microarchitecture)
+[TeraScale 3]: https://en.wikipedia.org/wiki/TeraScale_%28microarchitecture%29#TeraScale_3
diff --git a/Documentation/mainboard/clevo/n130wu/index.md b/Documentation/mainboard/clevo/n130wu/index.md
new file mode 100644
index 0000000000..326756199b
--- /dev/null
+++ b/Documentation/mainboard/clevo/n130wu/index.md
@@ -0,0 +1,47 @@
+# Clevo N130WU
+
+## Hardware
+### Technology
+```eval_rst
++------------------+--------------------------------+
+| CPU | Intel i7-8550U |
++------------------+--------------------------------+
+| PCH | Intel Sunrise Point LP |
++------------------+--------------------------------+
+| EC / Super IO | ITE IT8587E |
++------------------+--------------------------------+
+| Coprocessor | Intel ME |
++------------------+--------------------------------+
+```
+
+### Flash chip
+```eval_rst
++---------------------+-----------------+
+| Type | Value |
++=====================+=================+
+| Model | GD25Q64B |
++---------------------+-----------------+
+| Socketed flash | no |
++---------------------+-----------------+
+| Size | 8 MiB |
++---------------------+-----------------+
+| In circuit flashing | Yes |
++---------------------+-----------------+
+| Package | SOIC-8 |
++---------------------+-----------------+
+| Write protection | No |
++---------------------+-----------------+
+| Dual BIOS feature | No |
++---------------------+-----------------+
+| Internal flashing | Yes |
++---------------------+-----------------+
+```
+
+## Board status
+### Working
+### Not Working
+### Work in progress
+### Untested
+
+## Also known as
+* TUXEDO InfinityBook Pro 13 v3
diff --git a/Documentation/mainboard/emulation/qemu-i440fx.md b/Documentation/mainboard/emulation/qemu-i440fx.md
new file mode 100644
index 0000000000..059ad123c5
--- /dev/null
+++ b/Documentation/mainboard/emulation/qemu-i440fx.md
@@ -0,0 +1,64 @@
+# qemu i440fx mainboard
+
+## Running coreboot in qemu
+Emulators like qemu don't need a firmware to do hardware init.
+The hardware starts in the configured state already.
+
+The coreboot port allows to test non mainboard specific code.
+As you can easily attach a debugger, it's a good target for
+experimental code.
+
+## coreboot x86_64 support
+coreboot historically runs in 32-bit protected mode, even though the
+processor supports x86_64 instructions (long mode).
+
+The qemu-i440fx mainboard has been ported to x86_64 and will serve as
+reference platform to enable additional platforms.
+
+To enable the support set the Kconfig option ``CONFIG_CPU_QEMU_X86_64=y``.
+
+## Installing qemu
+
+On debian you can install qemu by running:
+```bash
+$ sudo apt-get install qemu
+```
+
+On redhat you can install qemu by running:
+```bash
+$ sudo dnf install qemu
+```
+
+## Running coreboot
+
+### To run the i386 version of coreboot (default)
+Running on qemu-system-i386 will require a 32 bit operating system.
+
+```bash
+qemu-system-i386 -bios build/coreboot.rom -serial stdio -M pc
+```
+
+### To run the experimental x86_64 version of coreboot
+Running on qemu-system-x86_64 allows to run a 32 bit or 64 bit operating system,
+as well as firmware.
+
+```bash
+qemu-system-x86_64 -bios build/coreboot.rom -serial stdio -M pc
+```
+
+## Finding bugs
+To test coreboot's x86 code it's recommended to run on a x86 host and enable KVM.
+It will not only run faster, but is closer to real hardware. If you see the
+following message:
+
+ KVM internal error. Suberror: 1
+ emulation failure
+
+something went wrong. The same bug will likely cause a FAULT on real hardware,
+too.
+
+To enable KVM run:
+
+```bash
+qemu-system-x86_64 -bios build/coreboot.rom -serial stdio -M pc -accel kvm -cpu host
+```
diff --git a/Documentation/mainboard/emulation/qemu-q35.md b/Documentation/mainboard/emulation/qemu-q35.md
new file mode 100644
index 0000000000..00163e89fc
--- /dev/null
+++ b/Documentation/mainboard/emulation/qemu-q35.md
@@ -0,0 +1,64 @@
+# qemu q35 mainboard
+
+## Running coreboot in qemu
+Emulators like qemu don't need a firmware to do hardware init.
+The hardware starts in the configured state already.
+
+The coreboot port allows to test non mainboard specific code.
+As you can easily attach a debugger, it's a good target for
+experimental code.
+
+## coreboot x86_64 support
+coreboot historically runs in 32-bit protected mode, even though the
+processor supports x86_64 instructions (long mode).
+
+The qemu-q35 mainboard has been ported to x86_64 and will serve as
+reference platform to enable additional platforms.
+
+To enable the support set the Kconfig option ``CONFIG_CPU_QEMU_X86_64=y``.
+
+## Installing qemu
+
+On debian you can install qemu by running:
+```bash
+$ sudo apt-get install qemu
+```
+
+On redhat you can install qemu by running:
+```bash
+$ sudo dnf install qemu
+```
+
+## Running coreboot
+### To run the i386 version of coreboot (default)
+Running on qemu-system-i386 will require a 32 bit operating system.
+
+```bash
+qemu-system-i386 -bios build/coreboot.rom -serial stdio -M q35
+```
+
+### To run the experimental x86_64 version of coreboot
+Running on `qemu-system-x86_64` allows to run a 32 bit or 64 bit operating system
+and firmware.
+
+```bash
+qemu-system-x86_64 -bios build/coreboot.rom -serial stdio -M q35
+```
+
+## Finding bugs
+To test coreboot's x86 code it's recommended to run on a x86 host and enable KVM.
+It will not only run faster, but is closer to real hardware. If you see the
+following message:
+
+ KVM internal error. Suberror: 1
+ emulation failure
+
+something went wrong. The same bug will likely cause a FAULT on real hardware,
+too.
+
+To enable KVM run:
+
+```bash
+qemu-system-x86_64 -bios build/coreboot.rom -serial stdio -M q35 -accel kvm -cpu host
+```
+
diff --git a/Documentation/mainboard/facebook/monolith.md b/Documentation/mainboard/facebook/monolith.md
index cdd32089e6..022a4e5ef1 100644
--- a/Documentation/mainboard/facebook/monolith.md
+++ b/Documentation/mainboard/facebook/monolith.md
@@ -2,7 +2,7 @@
This page describes how to run coreboot on the Facebook Monolith.
-Please note: the coreboot implementation for this boards is in its
+Please note: the coreboot implementation for this board is in its
Beta state and isn't fully tested yet.
## Required blobs
@@ -104,7 +104,7 @@ solution. Wires need to be connected to be able to flash using an external progr
- SMBus
- Initialization with FSP
- SeaBIOS payload (commit a5cab58e9a3fb6e168aba919c5669bea406573b4)
-- TianoCore payload (commit a5cab58e9a3fb6e168aba919c5669bea406573b4)
+- TianoCore payload (commit 860a8d95c2ee89c9916d6e11230f246afa1cd629)
- LinuxBoot (kernel kernel-4_19_97) (uroot commit 9c9db9dbd6b532f5f91a511a0de885c6562aadd7)
- eMMC
diff --git a/Documentation/mainboard/hp/2560p.md b/Documentation/mainboard/hp/2560p.md
new file mode 100644
index 0000000000..0b51a89e38
--- /dev/null
+++ b/Documentation/mainboard/hp/2560p.md
@@ -0,0 +1,99 @@
+# HP EliteBook 2560p
+
+This page is about the notebook [HP EliteBook 2560p].
+
+## Release status
+
+HP EliteBook 2560p was released in 2011 and is now end of life.
+It can be bought from a secondhand market like Taobao or eBay.
+
+## Required proprietary blobs
+
+The following blobs are required to operate the hardware:
+1. EC firmware
+2. Intel ME firmware
+
+EC firmware can be retrieved from the HP firmware update image, or the firmware
+backup of the laptop. EC Firmware is part of the coreboot build process.
+The guide on extracting EC firmware and using it to build coreboot is in
+document [HP Laptops with KBC1126 Embedded Controller](hp_kbc1126_laptops).
+
+Intel ME firmware is in the flash chip. It is not needed when building coreboot.
+
+## Programming
+
+The flash chip is located between the memory slots and the PCH,
+covered by the base enclosure, which needs to be removed according to
+the [Maintenance and Service Guide] to access the flash chip. An SPI
+flash programmer using 3.3V voltage such as a ch341a programmer, and
+an SOIC-8 clip can be used to read and flash the chip in-circuit.
+
+Pin 1 of the flash chip is at the side near the PCH.
+
+
+
+For more details have a look at the general [flashing tutorial].
+
+## Debugging
+
+The board can be debugged with EHCI debug. The EHCI debug port is the back
+bottom USB port.
+
+Schematic of this laptop can be found on [Lab One].
+
+## Test status
+
+### Known issues
+
+- GRUB payload freezes if at_keyboard module is in the GRUB image
+ ([bug #141])
+
+### Untested
+
+- Optical Drive
+- VGA
+- Fingerprint Reader
+- Modem
+
+### Working
+
+- Integrated graphics init with libgfxinit
+- SATA
+- Audio: speaker and microphone
+- Ethernet
+- WLAN
+- WWAN
+- Bluetooth
+- ExpressCard
+- SD Card Reader
+- SmartCard Reader
+- eSATA
+- USB
+- DisplayPort
+- Keyboard, touchpad and trackpoint
+- EC ACPI support and thermal control
+- Dock: all USB ports, DisplayPort, eSATA
+- TPM
+- Internal flashing when IFD is unlocked
+- Using `me_cleaner`
+
+
+## Technology
+
+```eval_rst
++------------------+--------------------------------------------------+
+| CPU | Intel Sandy/Ivy Bridge (FCPGA988) |
++------------------+--------------------------------------------------+
+| PCH | Intel Cougar Point QM67 |
++------------------+--------------------------------------------------+
+| EC | SMSC KBC1126 |
++------------------+--------------------------------------------------+
+| Coprocessor | Intel Management Engine |
++------------------+--------------------------------------------------+
+```
+
+[HP EliteBook 2560p]: https://support.hp.com/us-en/product/hp-elitebook-2560p-notebook-pc/5071201
+[Maintenance and Service Guide]: http://h10032.www1.hp.com/ctg/Manual/c03011618
+[flashing tutorial]: ../../flash_tutorial/ext_power.md
+[Lab One]: https://www.laboneinside.com/hp-elitebook-2560p-schematic-diagram/
+[bug #141]: https://ticket.coreboot.org/issues/141
diff --git a/Documentation/mainboard/hp/2560p_flash.webp b/Documentation/mainboard/hp/2560p_flash.webp
new file mode 100644
index 0000000000..8583fa0845
Binary files /dev/null and b/Documentation/mainboard/hp/2560p_flash.webp differ
diff --git a/Documentation/mainboard/hp/folio_9480m.md b/Documentation/mainboard/hp/folio_9480m.md
new file mode 100644
index 0000000000..20eed08a66
--- /dev/null
+++ b/Documentation/mainboard/hp/folio_9480m.md
@@ -0,0 +1,156 @@
+# HP EliteBook Folio 9480m
+
+This page is about the notebook [HP EliteBook Folio 9480m].
+
+## Release status
+
+HP EliteBook Folio 9480m was released in 2014 and is now end of life.
+It can be bought from a secondhand market like Taobao or eBay.
+
+## Required proprietary blobs
+
+The following blobs are required to operate the hardware:
+
+1. EC firmware
+2. Intel ME firmware
+3. mrc.bin
+
+HP EliteBook Folio 9480m uses SMSC MEC1322 as its embedded controller.
+The EC firmware is stored in the flash chip, but we don't need to touch it
+or use it in the coreboot build process.
+
+Intel ME firmware is in the flash chip. It is not needed when building coreboot.
+
+The Haswell memory reference code binary is needed when building coreboot.
+Please see [mrc.bin](../../northbridge/intel/haswell/mrc.bin).
+
+## Programming
+
+Before flashing, remove the battery and the hard drive cover according to the
+[Maintenance and Service Guide] of this laptop.
+
+
+
+HP EliteBook Folio 9480m has two flash chips, a 16MiB system flash, and a 2MiB
+private flash. To install coreboot, we need to program both flash chips.
+Read [HP Sure Start] for detailed information.
+
+To access the system flash, we need to connect the AC adapter to the machine,
+then clip on the flash chip with an SOIC-8 clip. An [STM32-based flash programmer]
+made with an STM32 development board is tested to work.
+
+To access the private flash chip, we can use a ch341a based flash programmer and
+flash the chip with the AC adapter disconnected.
+
+Before flashing coreboot, we need to do the following:
+
+1. Erase the private flash to disable the IFD protection
+2. Modify the IFD to shrink the BIOS region, so that we'll not use or override
+ the protected bootblock and PEI region, as well as the EC firmware
+
+To erase the private flash chip, attach it with the flash programmer via the SOIC-8 clip,
+then run:
+
+ flashrom -p --erase
+
+To modify the IFD, we need a new flash layout. The flash layout of the OEM firmware is:
+
+ 00000000:00000fff fd
+ 00001000:00002fff gbe
+ 00003000:005fffff me
+ 00600000:00ffffff bios
+
+The default coreboot configuration sets the flash chip size to 12MiB, so set the end of the
+BIOS region to 0xbfffff in the new layout. The modified IFD is as follows (Platform Data
+region pd is the region protected by HP Sure Start):
+
+ 00000000:00000fff fd
+ 00001000:00002fff gbe
+ 00003000:005fffff me
+ 00600000:00bfffff bios
+ 00eb5000:00ffffff pd
+
+Write the above layout in a file, and use ifdtool to modify the IFD of a flash image.
+Suppose the above layout file is ``layout.txt`` and the origin content of the system flash
+is in ``factory-sys.rom``, run:
+
+ ifdtool -n layout.txt factory-sys.rom
+
+Then a flash image with a new IFD will be in ``factory-sys.rom.new``.
+
+Flash the IFD of the system flash:
+
+ flashrom -p --ifd -i fd -w factory-sys.rom.new
+
+Then flash the coreboot image:
+
+ # first extend the 12M coreboot.rom to 16M
+ fallocate -l 16M build/coreboot.rom
+ flashrom -p --ifd -i bios -w build/coreboot.rom
+
+After coreboot is installed, the coreboot firmware can be updated with internal flashing:
+
+ flashrom -p internal --ifd -i bios --noverify-all -w build/coreboot.rom
+
+## Debugging
+
+The board can be debugged with EHCI debug. The EHCI debug port is the USB port on the left.
+
+## Test status
+
+### Known issues
+
+- GRUB payload freezes just like previous EliteBook laptops
+- Sometimes the PCIe WLAN module can not be found in the OS after booting to the system
+- Sometimes all the USB devices can not be found in the OS after S3 resume
+
+### Untested
+
+- Fingerprint reader
+- Smart Card reader
+
+### Working
+
+- i5-4310U CPU with 4G+4G memory
+- SATA and M.2 SATA disk
+- Ethernet
+- WLAN
+- WWAN
+- SD card reader
+- USB
+- Keyboard and touchpad
+- DisplayPort
+- VGA
+- Dock
+- Audio output from speaker and headphone jack
+- Webcam
+- TPM
+- EC ACPI
+- S3 resume
+- Arch Linux with Linux 5.8.9
+- Memory initialization with mrc.bin version 1.6.1 Build 2
+- Graphics initialization with libgfxinit
+- Payload: SeaBIOS, Tianocore
+- EC firmware
+ - KBC Revision 92.15 from OEM firmware version 01.33
+ - KBC Revision 92.17 from OEM firmware version 01.50
+- Internal flashing under coreboot
+
+## Technology
+
+```eval_rst
++------------------+-----------------------------+
+| CPU | Intel Haswell-ULT |
++------------------+-----------------------------+
+| PCH | Intel Lynx Point Low Power |
++------------------+-----------------------------+
+| EC | SMSC MEC1322 |
++------------------+-----------------------------+
+| Coprocessor | Intel Management Engine |
++------------------+-----------------------------+
+```
+
+[HP EliteBook Folio 9480m]: https://support.hp.com/us-en/product/hp-elitebook-folio-9480m-notebook-pc/7089926
+[Maintenance and Service Guide]: http://h10032.www1.hp.com/ctg/Manual/c05228980
+[STM32-based flash programmer]: https://github.com/dword1511/stm32-vserprog
+[HP Sure Start]: hp_sure_start.md
diff --git a/Documentation/mainboard/hp/folio_9480m_flash.webp b/Documentation/mainboard/hp/folio_9480m_flash.webp
new file mode 100644
index 0000000000..1abc306517
Binary files /dev/null and b/Documentation/mainboard/hp/folio_9480m_flash.webp differ
diff --git a/Documentation/mainboard/hp/hp_sure_start.md b/Documentation/mainboard/hp/hp_sure_start.md
new file mode 100644
index 0000000000..a07d9d02c7
--- /dev/null
+++ b/Documentation/mainboard/hp/hp_sure_start.md
@@ -0,0 +1,60 @@
+# HP Sure Start
+
+According to the [HP Sure Start Technical Whitepaper], HP Sure Start is a chipset
+and processor independent firmware intrusion detection and automatic repair system.
+It is implemented in HP notebooks since 2013, and desktops since 2015.
+
+This document talks about some mechanism of HP Sure Start on some machines, and
+the method to bypass it.
+
+## Laptops with SMSC MEC1322 embedded controller
+
+Haswell EliteBook, ZBook and ProBook 600 series use SMSC MEC1322 embedded controller.
+The EC firmware implements HP Sure Start.
+
+A Haswell EliteBook has two flash chips. According to the strings in the EC firmware,
+the 16MiB flash chip that stores the BIOS firmware is called the *system flash*, and
+the 2MiB flash chip that stores part of the system flash content is called the
+*private flash*. A Haswell ProBook 600 series laptop also uses MEC1322 and has similar
+EC firmware, but the HP Sure Start functions are not enabled.
+
+The private flash is connected to the EC, and is not accessible by the OS.
+It contains the following:
+
+- HP Sure Start policy header (starting with the string "POLI")
+- A copy of the Intel Flash Descriptor
+- A copy of the GbE firmware
+- Machine Unique Data (MUD)
+- Hashes of the IFD, GbE firmware and MUD, the hash algorithm is unknown
+- A copy of the bootblock, UEFI PEI stage, and microcode
+
+If the IFD of the system flash does not match the hash in the private flash, for example,
+modifying the IFD with ``ifdtool -u`` or ``me_cleaner -S``, the EC will recover the IFD.
+
+If the content of the private flash is lost, the EC firmware will still copy the IFD,
+bootblock and PEI to the private flash. However, the IFD is not protected after that.
+
+HP Sure Start also verifies bootblock, PEI, and microcode without using the private flash.
+EC firmware reads them from an absolute address of the system flash chip, which is
+hardcoded in the EC firmware. It looks like this verification is done with a digital
+signature. If the PEI volume is modified, EC firmware will recover it using the copy
+in the private flash. If the private flash has no valid copies of the PEI volume, and
+the PEI volume is modified, the machine will refuse to boot with the CapsLock LED blinking.
+
+## Bypassing HP Sure Start
+
+First search the mainboard for the flash chips. If there are two flash chips,
+the smaller one may be the private flash.
+
+For Intel boards, try to modify the IFD with ``ifdtool -u``, power on and shut down
+the machine, then read the flash again. If the IFD is not modified, it is likely to
+be recovered from the private flash. Find the private flash and erase it, then the IFD
+can be modified.
+
+To bypass the bootblock and PEI verification, we can modify the IFD to make the
+BIOS region not overlap with the protected region. Since the EC firmware is usually
+located at the high address of the flash chip (and in the protected region),
+we can leave it untouched, and do not need to extract the EC firmware to put it in
+the coreboot image.
+
+[HP Sure Start Technical Whitepaper]: http://h10032.www1.hp.com/ctg/Manual/c05163901
diff --git a/Documentation/mainboard/index.md b/Documentation/mainboard/index.md
index 3a7dd31742..b55876016a 100644
--- a/Documentation/mainboard/index.md
+++ b/Documentation/mainboard/index.md
@@ -16,6 +16,7 @@ This section contains documentation about coreboot on specific mainboards.
## ASUS
+- [A88XM-E](asus/a88xm-e.md)
- [F2A85-M](asus/f2a85-m.md)
- [P5Q](asus/p5q.md)
- [P8H61-M LX](asus/p8h61-m_lx.md)
@@ -26,6 +27,10 @@ This section contains documentation about coreboot on specific mainboards.
- [CN81XX EVB SFF](cavium/cn8100_sff_evb.md)
+## Clevo
+
+- [N130WU / N131WU](clevo/n130wu/index.md)
+
## Dell
- [OptiPlex 9010 SFF](dell/optiplex_9010.md)
@@ -37,6 +42,8 @@ The boards in this section are not real mainboards, but emulators.
- [Spike RISC-V emulator](emulation/spike-riscv.md)
- [Qemu RISC-V emulator](emulation/qemu-riscv.md)
- [Qemu AArch64 emulator](emulation/qemu-aarch64.md)
+- [Qemu x86 Q35](emulation/qemu-q35.md)
+- [Qemu x86 PC](emulation/qemu-i440fx.md)
## Facebook
@@ -59,7 +66,10 @@ The boards in this section are not real mainboards, but emulators.
### EliteBook series
- [HP Laptops with KBC1126 EC](hp/hp_kbc1126_laptops.md)
+- [HP Sure Start](hp/hp_sure_start.md)
+- [EliteBook 2560p](hp/2560p.md)
- [EliteBook 8760w](hp/8760w.md)
+- [EliteBook Folio 9480m](hp/folio_9480m.md)
## Intel
@@ -67,6 +77,10 @@ The boards in this section are not real mainboards, but emulators.
- [IceLake RVP](intel/icelake_rvp.md)
- [KBLRVP11](intel/kblrvp11.md)
+## Kontron
+
+- [mAL-10](kontron/mal10.md)
+
## Lenovo
- [Mainboard codenames](lenovo/codenames.md)
@@ -76,15 +90,15 @@ The boards in this section are not real mainboards, but emulators.
- [X2xx common](lenovo/x2xx_series.md)
- [vboot](lenovo/vboot.md)
-### Arrandale series
-
-- [T410](lenovo/t410.md)
-
### GM45 series
- [X200 / T400 / T500 / X301 common](lenovo/montevina_series.md)
- [X301](lenovo/x301.md)
+### Arrandale series
+
+- [T410](lenovo/t410.md)
+
### Sandy Bridge series
- [T420](lenovo/t420.md)
@@ -115,6 +129,7 @@ The boards in this section are not real mainboards, but emulators.
## OCP
+- [Delta Lake](ocp/deltalake.md)
- [Tioga Pass](ocp/tiogapass.md)
## Open Cellular
@@ -135,6 +150,10 @@ The boards in this section are not real mainboards, but emulators.
- [Hermes](prodrive/hermes.md)
+## Purism
+
+- [Librem Mini](purism/librem_mini.md)
+
## Protectli
- [FW2B / FW4B](protectli/fw2b_fw4b.md)
@@ -158,6 +177,10 @@ The boards in this section are not real mainboards, but emulators.
- [Lemur Pro](system76/lemp9.md)
+## Texas Instruments
+
+- [Beaglebone Black](ti/beaglebone-black.md)
+
## UP
- [Squared](up/squared/index.md)
diff --git a/Documentation/mainboard/kontron/mal10.md b/Documentation/mainboard/kontron/mal10.md
new file mode 100644
index 0000000000..b2eefc3df2
--- /dev/null
+++ b/Documentation/mainboard/kontron/mal10.md
@@ -0,0 +1,106 @@
+# Kontron mAL10 Computer-on-Modules platform
+
+The Kontron [mAL10] COMe is a credit card sized Computer-on-Modules
+platform based on the Intel Atom E3900 Series, Pentium and Celeron
+processors.
+
+## Technology
+
+```eval_rst
++------------------+----------------------------------+
+| COMe Type | mini pin-out type 10 |
++------------------+----------------------------------+
+| SoC | Intel Atom x5-E3940 (4 core) |
++------------------+----------------------------------+
+| GPU | Intel HD Graphics 500 |
++------------------+----------------------------------+
+| Coprocessor | Intel TXE 3.0 |
++------------------+----------------------------------+
+| RAM | 8GB DDR3L |
++------------------+----------------------------------+
+| eMMC Flash | 32GB eMMC pSLC |
++------------------+----------------------------------+
+| USB3 | x2 |
++------------------+----------------------------------+
+| USB2 | x6 |
++------------------+----------------------------------+
+| SATA | x2 |
++------------------+----------------------------------+
+| LAN | Intel I210IT, I211AT |
++------------------+----------------------------------+
+| Super IO/EC | Kontron CPLD/EC |
++------------------+----------------------------------+
+| HWM | NCT7802 |
++------------------+----------------------------------+
+```
+
+## Building coreboot
+
+The following commands will build a working image:
+
+```bash
+make distclean
+make defconfig KBUILD_DEFCONFIG=configs/config.kontron_mal10
+make
+```
+## Payloads
+- SeaBIOS
+- Tianocore
+- Linux as payload
+
+## Flashing coreboot
+
+The SPI flash can be accessed internally using [flashrom].
+The following command is used to flash BIOS region.
+
+```bash
+$ flashrom -p internal --ifd -i bios -w coreboot.rom --noverify-all
+```
+
+## Hardware Monitor
+
+The Nuvoton [NCT7802Y] is a hardware monitoring IC, capable of monitor critical
+system parameters including power supply voltages, fan speeds, and temperatures.
+The remote inputs can be connected to CPU/GPU thermal diode or any thermal diode
+sensors and thermistor.
+
+- 6 temperature sensors;
+- 5 voltage sensors;
+- 3 fan speed sensors;
+- 4 sets of temperature setting points.
+
+PECI is not supported by Apollo Lake Pentium/Celeron/Atom processors and the CPU
+temperature value is taken from a thermal resistor (NTC) that is placed very
+close to the CPU.
+
+## Known issues
+
+- Works only with Tianocore "UEFIPayload" payload edk2-stable201903-1569-g3e63a91
+ Booting with the "CorebootPayload" [crashes].
+- Tianocore outputs video through an external GPU only.
+
+## Untested
+
+- IGD/LVDS
+- SDIO
+
+## Tested and working
+
+- Kontron CPLD/EC (Serial ports, I2C port)
+- NCT7802 [HWM](#Hardware Monitor)
+- USB2/3
+- Gigabit Ethernet ports
+- eMMC
+- SATA
+- PCIe ports
+- IGD/DP
+
+## TODO
+- Onboard audio (codec IDT 92HD73C1X5, currently disabled)
+- S3 suspend/resume
+
+[mAL10]: https://www.kontron.com/products/iot/iot-industry-4.0/iot-ready-boards-and-modules/com-express/com-express-mini/come-mal10-e2-.html
+[W25Q128FV]: https://www.winbond.com/resource-files/w25q128fv%20rev.m%2005132016%20kms.pdf
+[flashrom]: https://flashrom.org/Flashrom
+[NCT7802Y]: https://www.nuvoton.com/products/cloud-computing/hardware-monitors/desktop-server-series/nct7802y/?__locale=en
+[crashes]: https://pastebin.com/cpCfrPCL
diff --git a/Documentation/mainboard/lenovo/montevina_series.md b/Documentation/mainboard/lenovo/montevina_series.md
index 62e87969f9..b513c97e9b 100644
--- a/Documentation/mainboard/lenovo/montevina_series.md
+++ b/Documentation/mainboard/lenovo/montevina_series.md
@@ -9,6 +9,15 @@ the chip in your machine through flashrom:
Note that this does not allow you to determine whether the chip is in a SOIC-8
or a SOIC-16 package.
+## Installing with ME firmware
+
+To install coreboot and keep ME working, you don't need to do anything special
+with the flash descriptor. Only flash the `bios` region externally and don't
+touch any other regions:
+```console
+# flashrom -p YOUR_PROGRAMMER -w coreboot.rom --ifd -i bios
+```
+
## Installing without ME firmware
```eval_rst
@@ -89,7 +98,7 @@ $ make
```
If your flash is not 8 MB, you need to change values of `flcomp_density1` and
-`flreg1_limit` in the ifd-x200.set file according to following table:
+`flreg1_limit` in the `ifd-x200.set` file according to following table:
```eval_rst
+-----------------+-------+-------+--------+
@@ -127,15 +136,6 @@ Chipset --->
Then build coreboot and flash whole `build/coreboot.rom` to the chip.
-## Installing with ME firmware
-
-To install coreboot and keep ME working, you don't need to do anything special
-with the flash descriptor. Just flash only `bios` externally and don't touch any
-other regions:
-```console
-# flashrom -p YOUR_PROGRAMMER -w coreboot.rom --ifd -i bios
-```
-
## Flash layout
The flash layouts of the OEM firmware are as follows:
diff --git a/Documentation/mainboard/lenovo/t440p.md b/Documentation/mainboard/lenovo/t440p.md
index 08df76fdca..f364f07784 100644
--- a/Documentation/mainboard/lenovo/t440p.md
+++ b/Documentation/mainboard/lenovo/t440p.md
@@ -30,7 +30,6 @@ the laptop able to power on.
## Known Issues
-- No audio output when using a headphone
- Cannot get the mainboard serial number from the mainboard: the OEM
UEFI firmware gets the serial number from an "emulated EEPROM" via
I/O port 0x1630/0x1634, but it's still unknown how to make it work
diff --git a/Documentation/mainboard/ocp/deltalake.md b/Documentation/mainboard/ocp/deltalake.md
index c4c3284b8f..9ef2357c0f 100644
--- a/Documentation/mainboard/ocp/deltalake.md
+++ b/Documentation/mainboard/ocp/deltalake.md
@@ -1,29 +1,33 @@
# OCP Delta Lake
This page describes coreboot support status for the [OCP] (Open Compute Project)
-Delta Lake server platform.
+Delta Lake server platform. This page is updated following each 4-weeks
+build/test/release cycle.
## Introduction
OCP Delta Lake server platform is a component of multi-host server system
Yosemite-V3. Both were announced by Facebook and Intel in [OCP virtual summit 2020].
-Delta Lake server is a single socket Cooper Lake Scalable Processor server.
+Delta Lake server is a single socket Cooper Lake Scalable Processor (CPX-SP) server.
Yosemite-V3 has multiple configurations. Depending on configurations, it may
host up to 4 Delta Lake servers in one sled.
-Yosemite-V3 and Delta Lake are currently in DVT phase. Facebook, Intel and partners
-jointly develop FSP/coreboot/LinuxBoot stack on Delta Lake as an alternative solution.
+The Yosemite-V3 program is in PVT phase. Facebook, Intel and partners
+jointly develop FSP/coreboot/LinuxBoot stack on Delta Lake as an alternative
+solution. This development reached EVT exit equivalent status.
## Required blobs
This board currently requires:
- FSP blob: The blob (Intel Cooper Lake Scalable Processor Firmware Support Package)
is not yet available to the public. It will be made public some time after the MP
- (Mass Production) of CooperLake Scalable Processor when the FSP is mature.
-- Microcode: Not yet available to the public.
-- ME binary: Not yet available to the public.
+ (Mass Production) of CPX-SP.
+- Microcode: Available through github.com:otcshare/Intel-Generic-Microcode.git.
+- ME binary: Ignition binary will be made public some time after the MP
+ of CPX-SP.
+- ACM binaries: only required for CBnT enablement.
## Payload
- LinuxBoot: This is necessary only if you use LinuxBoot as coreboot payload.
@@ -46,6 +50,16 @@ To power off/on the host:
To connect to console through SOL (Serial Over Lan):
sol-util slotx
+## Firmware configurations
+[ChromeOS VPD] is used to store most of the firmware configurations.
+RO_VPD region holds default values, while RW_VPD region holds customized
+values.
+
+VPD variables supported are:
+- firmware_version: This variable holds overall firmware version. coreboot
+ uses that value to populate smbios type 1 version field.
+- DeltaLake specific VPDs: check mb/ocp/deltalake/vpd.h.
+
## Working features
The solution is developed using LinuxBoot payload with Linux kernel 5.2.9, and [u-root]
as initramfs.
@@ -55,58 +69,81 @@ as initramfs.
- Type 2 -- Baseboard Information
- Type 3 -- System Enclosure or Chassis
- Type 4 -- Processor Information
+ - Type 7 -- Cache Information
- Type 8 -- Port Connector Information
- Type 9 -- PCI Slot Information
- Type 11 -- OEM String
- - Type 13 -- BIOS Language Information
- Type 16 -- Physical Memory Array
+ - Type 17 -- Memory Device
- Type 19 -- Memory Array Mapped Address
+ - Type 32 -- System Boot Information
+ - Type 38 -- IPMI Device Information
+ - Type 41 -- Onboard Devices Extended Information
- Type 127 -- End-of-Table
-
- BMC integration:
- BMC readiness check
- IPMI commands
- watchdog timer
- POST complete pin acknowledgement
+ - Check BMC version: ipmidump -device
- SEL record generation
+- Converged Bootguard and TXT (CBnT)
+ - TPM
+ - Bootguard profile 0T
+ - TXT
+ - SRTM (verified through tboot)
+ - memory secret clearance upon ungraceful shutdown
- Early serial output
- port 80h direct to GPIO
-- ACPI tables: APIC/DSDT/FACP/FACS/HPET/MCFG/SPMI/SRAT/SLIT/SSDT
+- ACPI tables: APIC/DMAR/DSDT/FACP/FACS/HPET/MCFG/SPMI/SRAT/SLIT/SSDT
- Skipping memory training upon subsequent reboots by using MRC cache
- BMC crash dump
- Error injection through ITP
+- Versions
+ - Check FSP version: cbmem | grep LB_TAG_PLATFORM_BLOB_VERSION
+ - Check Microcode version: cat /proc/cpuinfo | grep microcode
+- Devices:
+ - Boot drive
+ - NIC card
+ - All 5 data drives
+- Power button
+- localboot
+- netboot from IPv6
+- basic memory hardware error injection/detection (SMI handler not upstreamed)
+- basic PCIe hardware error injection/detection (SMI handler not upstreamed)
-## Firmware configurations
-[ChromeOS VPD] is used to store most of the firmware configurations.
-RO_VPD region holds default values, while RW_VPD region holds customized
-values.
+## Stress/performance tests passed
+- OS warm reboot (1000 cycles)
+- DC reboot (1000 cycles)
+- AC reboot (1000 cycle)
+- Mprime test (6 hours)
+- StressAppTest (6 hours)
+- Ptugen (6 hours)
-VPD variables supported are:
-- firmware_version: This variable holds overall firmware version. coreboot
- uses that value to populate smbios type 1 version field.
+## Performance tests on par with traditional firmware
+- coremark
+- SpecCPU
+- Linkpack
+- Iperf(IPv6)
+- FIO
+
+## Other tests passed
+- Power
+- Thermal
## Known issues
-- Even though CPX-SP FSP is based on FSP 2.2 framework, it does not
- support FSP_USES_CB_STACK. An IPS ticket is filed with Intel.
-- VT-d is not supported. An IPS ticket is filed with Intel.
-- PCIe bifuration is not supported. An IPS ticket is filed with Intel.
-- ME based power capping. This is a bug in ME. An IPS ticket is filed
- with Intel.
-- RO_VPD region as well as other RO regions are not write protected.
-- HECI is not set up correctly, so BMC is not able to get PCH and DIMM
- temperature sensor readings.
+- MLC (Intel Memory Latency Check) and stream performance issue
+- HECI access at OS run time:
+ - spsInfoLinux64 command fail to return ME version
+ - ptugen command fail to get memory power
## Feature gaps
-- Delta Lake DVT is not supported, as we only have Delta Lake EVT servers
- at the moment.
-- SMBIOS:
- - Type 7 -- Cache Information
- - Type 17 -- Memory Device
- - Type 38 -- IPMI Device Information
- - Type 41 -- Onboard Devices Extended Information
-- ACPI:
- - DMAR
-- PFR/CBnT
+- flashrom command not able to update ME region
+- ACPI APEI tables
+- PCIe hotplug, Virtual Pin Ports
+- PCIe Live Error Recovery
+- RO_VPD region as well as other RO regions are not write protected
+- Not able to selectively enable/disable core
## Technology
@@ -116,7 +153,7 @@ VPD variables supported are:
+------------------------+---------------------------------------------+
| BMC | Aspeed AST 2500 |
+------------------------+---------------------------------------------+
-| PCH | Intel Lewisburg C621 |
+| PCH | Intel Lewisburg C620 Series |
+------------------------+---------------------------------------------+
```
diff --git a/Documentation/mainboard/purism/librem_mini.jpg b/Documentation/mainboard/purism/librem_mini.jpg
new file mode 100644
index 0000000000..004235d013
Binary files /dev/null and b/Documentation/mainboard/purism/librem_mini.jpg differ
diff --git a/Documentation/mainboard/purism/librem_mini.md b/Documentation/mainboard/purism/librem_mini.md
new file mode 100644
index 0000000000..f8ee00d6d5
--- /dev/null
+++ b/Documentation/mainboard/purism/librem_mini.md
@@ -0,0 +1,129 @@
+# Purism Librem Mini (v1, v2)
+
+This page describes how to run coreboot on the [Purism Librem Mini].
+
+```eval_rst
++------------------+--------------------------------------------------+
+| CPU | Intel Core i7-8565U/8665U (v1) |
+| | Intel Core i7-10510U (v2) |
++------------------+--------------------------------------------------+
+| PCH | Whiskey Lake / Cannon Point LP (v1) |
+| | Comet Lake LP Premium (Comet Lake-U) (v2) |
++------------------+--------------------------------------------------+
+| Super I/O, EC | ITE IT8528E |
++------------------+--------------------------------------------------+
+| Coprocessor | Intel Management Engine (CSME 12.x) (v1) |
+| | Intel Management Engine (CSME 14.x) (v2) |
++------------------+--------------------------------------------------+
+```
+
+
+
+
+## Required proprietary blobs
+
+To build a minimal working coreboot image some blobs are required (assuming
+only the BIOS region is being modified).
+
+```eval_rst
++-----------------+---------------------------------+---------------------+
+| Binary file | Apply | Required / Optional |
++=================+=================================+=====================+
+| FSP-M, FSP-S | Intel Firmware Support Package | Required |
++-----------------+---------------------------------+---------------------+
+| microcode | CPU microcode | Required |
++-----------------+---------------------------------+---------------------+
+| vgabios | VGA Option ROM | Optional |
++-----------------+---------------------------------+---------------------+
+```
+
+FSP-M and FSP-S are obtained after splitting the FSP binary (done automatically
+by the coreboot build system and included into the image; Coffee Lake for v1,
+Comet Lake for v2) from the `3rdparty/fsp` submodule.
+
+Microcode updates are automatically included into the coreboot image by the build
+system from the `3rdparty/intel-microcode` submodule. Official Purism release
+images may include newer microcode, which is instead pulled from Purism's
+[purism-blobs] repository.
+
+VGA Option ROM is not required to boot, but if one needs graphics in pre-OS
+stage, it should be included (if not using FSP/GOP display init). It can
+be extracted via cbfstool from the existing board firmware or pulled from
+the [purism-blobs] repository.
+
+## Intel Management Engine
+
+The Librem Mini uses version 12.x (v1) or 14.x (v2) of the Intel Management
+Engine (ME) / Converged Security Engine (CSE). The ME/CSE is disabled using
+the High Assurance Platform (HAP) bit, which puts the ME into a disabled state
+after platform bring-up (BUP) and disables all PCI/HECI interfaces.
+This can be verified via the coreboot cbmem utility:
+
+ `sudo ./cbmem -1 | grep 'ME:'`
+
+provided coreboot has been modified to output the ME status even when
+the PCI device is not visible/active (as it is in Purism's release builds).
+
+## Flashing coreboot
+
+### Internal programming
+
+The main SPI flash can be accessed using [flashrom]. The first version
+supporting the chipset is flashrom v1.2 (v1.2-107-gb1f858f or later needed
+for the Mini v2). Firmware an be easily flashed with internal programmer
+(either BIOS region or full image).
+
+### External programming
+
+The system has an internal flash chip which is a 8 MiB soldered SOIC-8 chip,
+and has a diode attached to the VCC line for in-system programming.
+This chip is located on the bottom side of the board under the CPU heatsink,
+in line with the front USB 2.0 ports.
+
+One has to remove all screws (in order):
+
+ * 2 top cover screws
+ * 4 screws securing the mainboard to the chassis
+ * 4 screws securing the heatsink/fan assembly to the mainboard (under the SODIMMs)
+
+The m.2 SSD will need to be removed if the Wi-Fi antenna are connected to
+an internal Wi-Fi/BT module. Use a SOIC-8 chip clip to program the chip.
+Specifically, it's a Winbond W25Q128JV (3.3V) - [datasheet][W25Q128JV].
+
+The EC firmware is stored on a separate SOIC-8 chip (a Winbond W25Q80DV),
+but is not protected by a diode and therefore cannot be read/written to without
+desoldering it from the mainboard.
+
+## Known issues
+
+ * SeaBIOS can be finicky with detecting USB devices
+ * Mode switching with VGA option ROM display init can be slow and sometimes hangs
+ * Some SATA devices on the 2.5" interface can have issues operating at 6 Gbps,
+ despite the HSIO PHY settings being set optimally via experimentation. These devices
+ may show errors in dmesg and drop down to 3 Gbps, but should not fail to boot.
+ The same issue is present on the AMI vendor firmware.
+
+## Working
+
+ * External displays via HDMI/DisplayPort with VGA option ROM or FSP/GOP init
+ (no libgfxinit support yet)
+ * SeaBIOS (1.14), Tianocore (CorebootPayloadPkg), Heads (Purism downstream) payloads
+ * Ethernet, m.2 2230 Wi-Fi
+ * System firmware updates via flashrom
+ * PCIe NVMe
+ * m.2 and SATA III
+ * Audio via front 3.5mm jack, HDMI, and DisplayPort
+ * SMBus (reading SPD from DIMMs)
+ * Initialization with FSP 2.0 (CFL for v1, CML for v2)
+ * S3 Suspend/Resume
+ * Booting PureOS 10.x, Debian 11.x, Qubes 4.1.0-alpha1, Linux Mint 20, Windows 10 2004
+
+## Not working / untested
+
+ * ITE IT8528E Super IO functions
+
+
+[Purism Librem Mini]: https://puri.sm/products/librem-mini/
+[purism-blobs]: https://source.puri.sm/coreboot/purism-blobs
+[W25Q128JV]: https://www.winbond.com/resource-files/w25q128jv%20revf%2003272018%20plus.pdf
+[flashrom]: https://flashrom.org/Flashrom
diff --git a/Documentation/mainboard/purism/librem_mini_flash.jpg b/Documentation/mainboard/purism/librem_mini_flash.jpg
new file mode 100644
index 0000000000..d1c6071f25
Binary files /dev/null and b/Documentation/mainboard/purism/librem_mini_flash.jpg differ
diff --git a/Documentation/mainboard/supermicro/x11-lga1151-series/x11-lga1151-series.md b/Documentation/mainboard/supermicro/x11-lga1151-series/x11-lga1151-series.md
index 2cb945ae14..03bebad0ed 100644
--- a/Documentation/mainboard/supermicro/x11-lga1151-series/x11-lga1151-series.md
+++ b/Documentation/mainboard/supermicro/x11-lga1151-series/x11-lga1151-series.md
@@ -7,6 +7,7 @@ Controller etc.
## Supported boards
- [X11SSH-TF](x11ssh-tf/x11ssh-tf.md)
+- [X11SSH-F](x11ssh-f/x11ssh-f.md)
- [X11SSM-F](x11ssm-f/x11ssm-f.md)
## Required proprietary blobs
@@ -30,14 +31,12 @@ Look at the [flashing tutorial] and the board-specific section.
These issues apply to all boards. Have a look at the board-specific issues, too.
-- TianoCore doesn't work with Aspeed NGI, as it's text mode only (Fix is WIP CB:35726)
- MRC caching does not work on cold boot with Intel SPS (see [Intel FSP2.0])
## ToDo
- Fix issues above
- Fix issues in board specific sections
-- Fix TODOs mentioned in code
- Add more boards! :-)
## Technology
diff --git a/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-f/x11ssh-f.md b/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-f/x11ssh-f.md
new file mode 100644
index 0000000000..f009bbe2ae
--- /dev/null
+++ b/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-f/x11ssh-f.md
@@ -0,0 +1,103 @@
+# Supermicro X11SSH-F
+
+This section details how to run coreboot on the [Supermicro X11SSH-F].
+
+## Flashing coreboot
+
+The board can be flashed externally. [STM32-based programmers] worked.
+
+The flash IC "W25Q128.V" (detected by flashrom) can be found near PCH PCIe Slot 4. It is sometime
+socketed, and covered by a sticker, hindering the observation of its precise model.
+
+It can be programmed in-system with a clip like pomona 5250.
+
+## BMC (IPMI)
+
+This board has an ASPEED [AST2400], which has BMC/[IPMI] functionality. The BMC firmware resides in a
+32 MiB SOIC-16 chip in the corner of the mainboard near the PCH PCIe Slot 4. This chip is a
+[MX25L25635F].
+
+## IGD
+
+If an IGD is integrated with CPU, it will be enabled on this board. Though there is no video output
+for it (The onboard VGA port is connected to BMC), it is said to be capable of being used for compute
+tasks, or for offloading graphics rendering via "muxless" [vga_witcheroo].
+
+## Tested and working
+
+- SeaBIOS payload to boot Kali Linux live USB
+- ECC ram (Linux' ie31200 driver works)
+- Integrated graphics device available without output
+- USB ports
+- Ethernet
+- SATA ports
+- RS232 external
+- PCIe slots
+- BMC (IPMI)
+- VGA on Aspeed
+- TPM on TPM expansion header
+
+## Known issues
+
+- See general issue section
+- S3 resume not working (vendor and coreboot)
+- SeaBIOS cannot make use of VGA on Aspeed (even if IGD is disabled)
+
+## ToDo
+
+- Fix known issues
+- Testing other payloads
+
+## Technology
+
+```eval_rst
++------------------+--------------------------------------------------+
+| CPU | Intel Kaby Lake |
++------------------+--------------------------------------------------+
+| PCH | Intel C236 |
++------------------+--------------------------------------------------+
+| Coprocessor | Intel SPS (server version of the ME) |
++------------------+--------------------------------------------------+
+| Super I/O | ASPEED AST2400 |
++------------------+--------------------------------------------------+
+| Ethernet | 2x Intel I210-AT 1 GbE |
+| | 1x dedicated BMC |
++------------------+--------------------------------------------------+
+| PCIe slots | 1x 3.0 x8 |
+| | 1x 3.0 x8 (in x16) |
+| | 1x 3.0 x4 (in x8) |
+| | 1x 3.0 x2 (in M.2 slot with key M) |
++------------------+--------------------------------------------------+
+| USB slots | 2x USB 2.0 (ext) |
+| | 2x USB 3.0 (ext) |
+| | 1x USB 3.0 (int) |
+| | 1x dual USB 3.0 header |
+| | 2x dual USB 2.0 header |
++------------------+--------------------------------------------------+
+| SATA slots | 8x S-ATA III |
++------------------+--------------------------------------------------+
+| Other slots | 1x RS232 (ext) |
+| | 1x RS232 header |
+| | 1x TPM header |
+| | 1x Power SMB header |
+| | 5x PWM Fan connector |
+| | 2x I-SGPIO |
+| | 2x S-ATA DOM Power connector |
+| | 1x XDP Port (connector may absent) |
+| | 1x External BMC I2C Header (for IPMI card) |
+| | 1x Chassis Intrusion Header |
++------------------+--------------------------------------------------+
+```
+
+## Extra links
+
+- [Supermicro X11SSH-F]
+- [Board manual]
+
+[Supermicro X11SSH-F]: https://www.supermicro.com/en/products/motherboard/X11SSH-F
+[Board manual]: https://www.supermicro.com/manuals/motherboard/C236/MNL-1778.pdf
+[AST2400]: https://www.aspeedtech.com/products.php?fPath=20&rId=376
+[IPMI]: ../../../../drivers/ipmi_kcs.md
+[MX25L25635F]: https://media.digikey.com/pdf/Data%20Sheets/Macronix/MX25L25635F.pdf
+[STM32-based programmers]: https://github.com/dword1511/stm32-vserprog
+[vga_switcheroo]: https://01.org/linuxgraphics/gfx-docs/drm/gpu/vga-switcheroo.html
diff --git a/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-tf/x11ssh-tf.md b/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-tf/x11ssh-tf.md
index 1caa34b3f7..1616676453 100644
--- a/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-tf/x11ssh-tf.md
+++ b/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssh-tf/x11ssh-tf.md
@@ -33,10 +33,6 @@ in a 32 MiB SOIC-16 chip in the corner of the mainboard near the [AST2400]. This
See general issue section.
-## ToDo
-
-- Fix TODOs mentioned in code
-
## Technology
```eval_rst
diff --git a/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssm-f/x11ssm-f.md b/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssm-f/x11ssm-f.md
index 5213bce6de..9f18b79cd8 100644
--- a/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssm-f/x11ssm-f.md
+++ b/Documentation/mainboard/supermicro/x11-lga1151-series/x11ssm-f/x11ssm-f.md
@@ -4,11 +4,11 @@ This section details how to run coreboot on the [Supermicro X11SSM-F].
## Flashing coreboot
-The board can be flashed externally. FTDI FT2232H and FT232H based programmers worked.
+The board can be flashed externally. FTDI FT2232H and FT232H based programmers worked. For this,
+one needs to add a diode between VCC and the flash chip. The flash IC [MX25L12873F] can be found
+near PCH PCIe Slot 4.
-The flash IC [MX25L12873F] can be found near PCH PCIe Slot 4. It is socketed on retail boards.
-
-For doing ISP (In-System-Programming) one needs to add a diode between VCC and the flash chip.
+Flashing is also possible through the BMC web interface, when a valid license was entered.
## BMC (IPMI)
@@ -16,6 +16,10 @@ This board has an ASPEED [AST2400], which has BMC/[IPMI] functionality. The BMC
32 MiB SOIC-16 chip in the corner of the mainboard near the PCH PCIe Slot 4. This chip is a
[MX25L25635F].
+## Disabling LAN firmware
+
+To disable the proprietary LAN firmware, the undocumented jumper J6 can be set to 2-3.
+
## Tested and working
- GRUB2 payload with Debian testing and kernel 5.2
@@ -32,14 +36,9 @@ This board has an ASPEED [AST2400], which has BMC/[IPMI] functionality. The BMC
## Known issues
- See general issue section
-- "only partially covers this bridge" info from Linux kernel (what does that mean?)
- LNXTHERM missing
- S3 resume not working
-## ToDo
-
-- Fix TODOs mentioned in code
-
## Technology
```eval_rst
diff --git a/Documentation/mainboard/ti/beaglebone-black.md b/Documentation/mainboard/ti/beaglebone-black.md
new file mode 100644
index 0000000000..db37e28099
--- /dev/null
+++ b/Documentation/mainboard/ti/beaglebone-black.md
@@ -0,0 +1,131 @@
+# Beaglebone Black
+This page gives some details about the [BeagleBone Black] coreboot port and
+describes how to build and run it.
+
+The port currently only supports booting coreboot from a micro SD card and has
+some other limitations listed below.
+
+## Supported Boards
+The Beaglebone port supports the following boards:
+
+- Beaglebone Black
+- Beaglebone Black Wireless
+- Beaglebone Pocket (untested, may need tweaking)
+- Beaglebone Blue (untested, may need tweaking)
+- Beaglebone Original (untested, may need tweaking)
+
+## Use Cases
+This port was primarily developed as a learning exercise and there is
+potentially little reason to use it compared to the defacto bootloader choice of
+U-Boot. However, it does have some interesting practical use cases compared to
+U-Boot:
+
+1. Choosing coreboot as a lightweight alternative to U-Boot. In this case,
+ coreboot is used to do the absolute minimum necessary to boot Linux, forgoing
+ some U-Boot features and functionality. Complex boot logic can then instead
+ be moved into Linux where it can be more flexibly and safely executed. This
+ is essentially the LinuxBoot philosophy. [U-Boot Falcon mode] has similar
+ goals to this as well.
+2. Facilitating experimenting with coreboot on real hardware. The Beaglebone
+ Black is widely available at a low pricepoint (~$65) making it a great way to
+ experiment with coreboot on real ARMv7 hardware. It also works well as a
+ development platform as it has exposed pads for JTAG and, due to the way it
+ boots, is effectively impossible to brick.
+3. The Beaglebone Black is often used as a external flasher and EHCI debug
+ gadget in the coreboot community, so many members have access to it and can
+ use it as a reference platform.
+
+## Quickstart
+1. Run `make menuconfig` and select _TI_/_Beaglebone_ in the _Mainboard_ menu.
+2. Add a payload as normal.
+3. Run `make`.
+4. Copy the resulting `build/MLO` file to the micro SD card at offset 128k - ie
+ `dd if=build/MLO of=/dev/sdcard seek=1 bs=128k`.
+
+**NOTE**: By default, the Beaglebone is configured to try to boot first from
+eMMC before booting from SD card. To ensure that the Beaglebone boots from SD,
+either erase the internal eMMC or hold the _S2_ button while powering on (note
+that this has to be while powering on - ie when plugging in the USB or DC barrel
+jack - the boot order doesn't change on reset) to prioritize SD in the boot
+order.
+
+## Serial Console
+By default, coreboot uses UART0 as the serial console. UART0 is available
+through the J1 header on both the Beaglebone Black and Beaglebone Black
+Wireless. The serial runs at 3.3V and 115200 8n1.
+
+The pin mapping is shown below for J1.
+
+ ```eval_rst
+ +----------------------------+------------+
+ | Pin number | Function |
+ +============================+============+
+ | 1 (Closest to barrel jack) | GND |
+ +----------------------------+------------+
+ | 4 | RX |
+ +----------------------------+------------+
+ | 5 | TX |
+ +----------------------------+------------+
+ ```
+
+## Boot Process
+The AM335x contains ROM code to allow booting in a number of different
+configurations. More information about the boot ROM code can be found in the
+AM335x technical reference manual (_SPRUH73Q_) in the _Initialization_ section.
+
+This coreboot port is currently configured to boot in "SD Raw Mode" where the
+boot binary, with header ("Table of Contents" in TI's nomenclature), is placed
+at the offset of 0x20000 (128KB) on the SD card. The boot ROM loads the coreboot
+bootblock stage into SRAM and executes it.
+
+The bootblock and subsequent romstage and ramstage coreboot stages expect that
+the coreboot image, containing the CBFS, is located at 0x20000 on the SD card.
+All stages directly read from the SD card in order to load the next stage in
+sequence.
+
+## Clock Initialization and PMIC
+To simplify the port, the TPS65217C Power Management IC (PMIC) on the Beaglebone
+Black is not configured by coreboot. By default, the PMIC reset values for
+VDD_MPU (1.1V) and VDD_CORE (1.8V) are within the Operating Performance Point
+(OPP) for the MPU PLL configuration set by the boot ROM of 500 MHz.
+
+When using Linux as a payload, the kernel will appropriately scale the core
+voltages for the desired MPU clock frequency as defined in the device tree.
+
+One significant difference because of this to the U-Boot port is that the DCDC1
+rail that powers the DDR3 RAM will be 1.5V by default. The Micron DDR3 supports
+both 1.35V and 1.5V and U-Boot makes use of this by setting it to 1.35V to
+conserve power. Fortunately, Linux is again able to configure this rail but it
+involves adding an entry to the device tree:
+
+ &dcdc1_reg {
+ regulator-name = "vdd_ddr3";
+ regulator-min-microvolt = <1350000>;
+ regulator-max-microvolt = <1350000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+If this port was to be extended to work with boards or SoCs with different
+requirements for the MPU clock frequency or different Operating Performance
+Points, then the port may need to be extended to set the core voltages and MPU
+PLL within coreboot, prior to loading a payload. Extending coreboot so that it
+can configure the PMIC would also be necessary if there was a requirement for
+coreboot to run at a different MPU frequency than the 500 MHz set by the boot
+ROM.
+
+# Todo
+- Allow coreboot to run from the Beaglebone Black's internal eMMC. This would
+ require updating the `mmc.c` driver to support running from both SD and eMMC.
+- Support the boot ROMs *FAT mode* so that the coreboot binary can be placed on
+ a FAT partition.
+- Increase the MMC read speed, it currently takes ~15s to read ~20MB which is a
+ bit slow. To do this, it should be possible to update the MMC driver to:
+ - Increase the supported blocksize (currently is always set to 1)
+ - Support 4-bit data width (currently only supports 1-bit data width)
+- Convert the while loops in the MMC driver to timeout so that coreboot does not
+ hang on a bad SD card or when the SD card is removed during boot.
+
+
+[Beaglebone Black]: https://beagleboard.org/black [U-Boot Falcon mode]:
+https://elixir.bootlin.com/u-boot/v2020.07/source/doc/README.falcon
\ No newline at end of file
diff --git a/Documentation/releases/checklist.md b/Documentation/releases/checklist.md
index a80fd85804..d777f0e38b 100644
--- a/Documentation/releases/checklist.md
+++ b/Documentation/releases/checklist.md
@@ -75,7 +75,8 @@ be more frequent than was needed, so we scaled it back to twice a year.
- [ ] Test the release from the actual release tarballs.
- [ ] Push signed Tag to repo.
- [ ] Announce that the release tag is done on IRC.
-- [ ] Upload release files to web server
+- [ ] Upload release files to web server.
+- [ ] Also extract the release notes and place them on the web server.
- [ ] Upload crossgcc sources to web server.
- [ ] Update download page to point to files, push to repo.
- [ ] Write and publish blog post with release notes.
@@ -197,16 +198,16 @@ the coreboot server, and put them in the release directory at
````
People can now see the release tarballs on the website at
-https://www.coreboot.org/releases/
+
-The downloads page is the official place to download the releases from, and it needs to be updated with links to the new release tarballs and .sig files. It can be found at https://review.coreboot.org/cgit/homepage.git/tree/downloads.html
+The downloads page is the official place to download the releases from, and it needs to be updated with links to the new release tarballs and .sig files. It can be found at
-Here is an example commit to change it: https://review.coreboot.org/#/c/19515/
+Here is an example commit to change it:
## Upload crossgcc sources
Sometimes the source files for older revisions of
crossgcc disappear. To deal with that we maintain a mirror at
-https://www.coreboot.org/releases/crossgcc-sources/ where we host the
+ where we host the
sources used by the crossgcc scripts that are part of coreboot releases.
Run
@@ -220,7 +221,7 @@ sources. Download them yourself and copy them into the crossgcc-sources
directory on the server.
## After the release is complete
-Post the release notes on https://blogs.coreboot.org
+Post the release notes on
## Making a branch
At times we will need to create a branch, generally for patch fixes.
diff --git a/Documentation/releases/coreboot-4.13-relnotes.md b/Documentation/releases/coreboot-4.13-relnotes.md
index 2910867f78..971d438ee0 100644
--- a/Documentation/releases/coreboot-4.13-relnotes.md
+++ b/Documentation/releases/coreboot-4.13-relnotes.md
@@ -1,18 +1,114 @@
-Upcoming release - coreboot 4.13
+coreboot 4.13
================================
-The 4.13 release is planned for November 2020.
+coreboot 4.13 was released on November 20th, 2020.
-Update this document with changes that should be in the release notes.
+Since 4.12 there were 4200 new commits by over 234 developers.
+Of these, about 72 contributed to coreboot for the first time.
-* Please use Markdown.
-* See the past few release notes for the general format.
-* The chip and board additions and removals will be updated right
- before the release, so those do not need to be added.
+Thank you to all developers who again helped made coreboot better
+than ever, and a big welcome to our new contributors!
+
+New mainboards
+--------------
+
+- Acer G43T-AM3
+- AMD Cereme
+- Asus A88XM-E FM2+
+- Biostar TH61-ITX
+- BostenTech GBYT4
+- Clevo L140CU/L141CU
+- Dell OptiPlex 9010
+- Example Min86 (fake board)
+- Google Ambassador
+- Google Asurada
+- Google Berknip
+- Google Boldar
+- Google Boten
+- Google Burnet
+- Google Cerise
+- Google Coachz
+- Google Dalboz
+- Google Dauntless
+- Google Delbin
+- Google Dirinboz
+- Google Dooly
+- Google Drawcia
+- Google Eldrid
+- Google Elemi
+- Google Esche
+- Google Ezkinil
+- Google Faffy
+- Google Fennel
+- Google Genesis
+- Google Hayato
+- Google Lantis
+- Google Lindar
+- Google Madoo
+- Google Magolor
+- Google Metaknight
+- Google Morphius
+- Google Noibat
+- Google Pompom
+- Google Shuboz
+- Google Stern
+- Google Terrador
+- Google Todor
+- Google Trembyle
+- Google Vilboz
+- Google Voema
+- Google Volteer2
+- Google Voxel
+- Google Willow
+- Google Woomax
+- Google Wyvern
+- HP EliteBook 2560p
+- HP EliteBook Folio 9480m
+- HP ProBook 6360b
+- Intel Alderlake-P RVP
+- Kontron COMe-bSL6
+- Lenovo ThinkPad X230s
+- Open Compute Project DeltaLake
+- Prodrive Hermes
+- Purism Librem Mini
+- Purism Librem Mini v2
+- Siemens Chili
+- Supermicro X11SSH-F
+- System76 lemp9
+
+Removed mainboards
+------------------
+
+- Google Cheza
+- Google DragonEgg
+- Google Ripto
+- Google Sushi
+- Open Compute Project SonoraPass
Significant changes
-------------------
+### Native refcode implementation for Bay Trail
+
+Bay Trail no longer needs a refcode binary to function properly. The refcode
+was reimplemented as coreboot code, which should be functionally equivalent.
+Thus, coreboot only needs to run the MRC.bin to successfully boot Bay Trail.
+
+### Unusual config files to build test more code
+
+There's some new highly-unusual config files, whose only purpose is to coerce
+Jenkins into build-testing several disabled-by-default coreboot config options.
+This prevents them from silently decaying over time because of build failures.
+
+### Initial support for Intel Trusted eXecution Technology
+
+coreboot now supports enabling Intel TXT. Though it's not feature-complete yet,
+the code allows successfully launching tboot, a Measured Launch Environment. It
+was tested on Haswell using an Asrock B85M Pro4 mainboard with TPM 2.0 on LPC.
+Though support for other platforms is still not ready, it is being worked on.
+The Haswell MRC.bin needs to be patched so as to enable DPR. Given that the MRC
+binary cannot be redistributed, the best long-term solution is to replace it.
+
### Hidden PCI devices
This new functionality takes advantage of the existing 'hidden' keyword in the
@@ -39,4 +135,126 @@ attributes as per their datasheet and convert those attributes into SPD files fo
the platforms. More details about the tools are added in
[README.md](https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/util/spd_tools/intel/lp4x/README.md).
-### Add significant changes here
+### New version of SMM loader
+
+A new version of the SMM loader which accommodates platforms with over 32
+CPU threads. The existing version of SMM loader uses a 64K code/data
+segment and only a limited number of CPU threads can fit into one segment
+(because of save state, STM, other features, etc). This loader extends beyond
+the 64K segment to accommodate additional CPUs and in theory allows as many
+CPU threads as possible limited only by SMRAM space and not by 64K. By default
+this loader version is disabled. Please see cpu/x86/Kconfig for more info.
+
+### Address Sanitizer
+
+coreboot now has an in-built Address Sanitizer, a runtime memory debugger
+designed to find out-of-bounds access and use-after-scope bugs. It is made
+available on all x86 platforms in ramstage and on QEMU i440fx, Intel Apollo
+Lake, and Haswell in romstage. Further, it can be enabled in romstage on other
+x86 platforms as well. Refer [ASan documentation](../technotes/asan.md) for
+more info.
+
+### Initial support for x86_64
+
+The x86_64 code support has been revived and enabled for QEMU. While it started
+as PoC and the only supported platform is an emulator, there's interest in
+enabling additional platforms. It would allow to access more than 4GiB of memory
+at runtime and possibly brings optimised code for faster execution times.
+It still needs changes in assembly, fixed integer to pointer conversions in C,
+wrappers for blobs, support for running Option ROMs, among other things.
+
+### Preparations to minimize enabling PCI bus mastering
+
+For security reasons, bus mastering should be enabled as late as possible. In
+coreboot, it's usually not necessary and payloads should only enable it for
+devices they use. Since not all payloads enable bus mastering properly yet,
+some Kconfig options were added as an intermediate step to give some sort of
+"backwards compatibility", which allow enabling or disabling bus mastering by
+groups.
+
+Currently available groups are:
+
+* PCI bridges
+* Any devices
+
+For now, "Any devices" is enabled by default to keep the traditional behaviour,
+which also includes all other options. This is currently necessary, for instance,
+for libpayload-based payloads as the drivers don't enable bus mastering for PCI
+bridges.
+
+Exceptional cases, that may still need early bus master enabling in the future,
+should get their own per-reason Kconfig option. Ideally before the next release.
+
+### Early runtime configurability of the console log level
+
+Traditionally, we didn't allow the log level of the `romstage` console
+to be changed at runtime (e.g. via `get_option()`). It turned out that
+the technical constraints for this (no global variables in `romstage`)
+vanished long ago, though. The new behaviour is to query `get_option()`
+now from the second stage that uses the console on. In other words, if
+the `bootblock` already enables the console, the `romstage` log level
+can be changed via `get_option()`. Keeping the log level of the first
+console static ensures that we can see console output even if there's
+a bug in the more involved code to query options.
+
+### Resource allocator v4
+
+A new revision of resource allocator v4 is now added to coreboot that supports
+mutiple ranges for allocating resources. Unlike the previous allocator (v3), it does
+not use the topmost available window for allocation. Instead, it uses the first
+window within the address space that is available and satisfies the resource request.
+This allows utilization of the entire available address space and also allows
+allocation above the 4G boundary. The old resource allocator v3 is still retained for
+some AMD platforms that do not conform to the requirements of the allocator.
+
+Deprecations
+------------
+
+### PCI bus master configuration options
+
+In order to minimize the usage of PCI bus mastering, the options we introduced in
+this release will be dropped in a future release again. For more details, please
+see [Preparations to minimize enabling PCI bus mastering](#preparations-to-minimize-enabling-pci-bus-mastering-in-coreboot).
+
+### Resource allocator v3
+
+Resource allocator v3 is retained in coreboot tree because the following platforms
+do not conform to the requirements of the resource allocation i.e. not all the fixed
+resources of the platform are provided during the `read_resources()` operation:
+
+* northbridge/amd/pi/00630F01
+* northbridge/amd/pi/00730F01
+* northbridge/amd/pi/00660F01
+* northbridge/amd/agesa/family14
+* northbridge/amd/agesa/family15tn
+* northbridge/amd/agesa/family16kb
+
+In order to have a single unified allocator in coreboot, this notice is being added
+to ensure that the platforms listed above are fixed before the next release. If there
+is interest in maintaining support for these platforms beyond the next release,
+please ensure that the platforms are fixed to conform to the expectations of resource
+allocation.
+
+Notes
+-----
+
+### Intel microcode updates
+
+Intel microcode updates tagged *microcode-20200616* are still included in our
+builds. Note, [Intel released new microcode updates]
+(https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/blob/main/releasenote.md)
+tagged
+
+1. *microcode-20201110*
+2. *microcode-20201112*
+3. *microcode-20201118*
+
+with security updates for [INTEL-SA-00381]
+(https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00381.html)
+and [INTEL-SA-00389]
+(https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00389.html).
+
+Due to too short time for rigorous testing and bad experience with botched
+microcode updates in the past, these new updates are not included. Users wanting
+to use those, can apply them in the operating system, or update the submodule
+pointer themselves.
diff --git a/Documentation/releases/coreboot-4.14-relnotes.md b/Documentation/releases/coreboot-4.14-relnotes.md
new file mode 100644
index 0000000000..43a8d0dc0b
--- /dev/null
+++ b/Documentation/releases/coreboot-4.14-relnotes.md
@@ -0,0 +1,16 @@
+Upcoming release - coreboot 4.14
+================================
+
+The 4.14 release is planned for May 2021.
+
+Update this document with changes that should be in the release notes.
+
+* Please use Markdown.
+* See the past few release notes for the general format.
+* The chip and board additions and removals will be updated right
+ before the release, so those do not need to be added.
+
+Significant changes
+-------------------
+
+### Add significant changes here
diff --git a/Documentation/releases/index.md b/Documentation/releases/index.md
index 0575e93f3b..081d1fc89c 100644
--- a/Documentation/releases/index.md
+++ b/Documentation/releases/index.md
@@ -13,6 +13,7 @@ Release notes for previous releases
* [4.10 - July 2019](coreboot-4.10-relnotes.md)
* [4.11 - November 2019](coreboot-4.11-relnotes.md)
* [4.12 - May 2020](coreboot-4.12-relnotes.md)
+* [4.13 - November 2020](coreboot-4.13-relnotes.md)
The checklist contains instructions to ensure that a release covers all
important things and provides a reliable format for tarballs, branch
@@ -24,4 +25,4 @@ Upcoming release
----------------
Please add to the release notes as changes are added:
-* [4.13 - November 2020](coreboot-4.13-relnotes.md)
+* [4.14 - May 2021](coreboot-4.14-relnotes.md)
diff --git a/Documentation/security/vboot/list_vboot.md b/Documentation/security/vboot/list_vboot.md
index 845c0e7109..b94901b55c 100644
--- a/Documentation/security/vboot/list_vboot.md
+++ b/Documentation/security/vboot/list_vboot.md
@@ -8,6 +8,8 @@
- Facebook Monolith
## Google
+- Asurada
+- Hayato
- Auron_Paine (Acer C740 Chromebook)
- Auron_Yuna (Acer Chromebook 15 (C910/CB5-531))
- Buddy (Acer Chromebase 24)
@@ -20,7 +22,6 @@
- Tricky (Dell Chromebox 3010)
- Zako (HP Chromebox G1)
- Butterfly (HP Pavilion Chromebook 14)
-- Cheza
- Banon (Acer Chromebook 15 (CB3-532))
- Celes (Samsung Chromebook 3)
- Cyan (Acer Chromebook R11 (C738T))
@@ -35,7 +36,6 @@
- Daisy (Samsung Chromebook (2012))
- Deltan
- Deltaur
-- DragonEgg
- Drallion
- Eve (Google Pixelbook)
- Fizz
@@ -58,9 +58,12 @@
- Rainier
- Akemi
- Dratini
+- Duffy Legacy (32MB)
- Duffy
+- Faffy
- Hatch
- Jinlon
+- Kaisa Legacy (32MB)
- Kaisa
- Kohaku
- Kindred
@@ -68,10 +71,14 @@
- Mushu
- Palkia
- Nightfury
+- Noibat
- Puff
- Helios_Diskswap
- Stryke
-- Sushi
+- Wyvern
+- Dooly
+- Ambassador
+- Genesis
- Guado (ASUS Chromebox CN62)
- Jecht
- Rikku (Acer Chromebox CXI2)
@@ -91,6 +98,12 @@
- Juniper
- Kappa
- Damu
+- Cerise
+- Stern
+- Willow
+- Esche
+- Burnet
+- Fennel
- Link (Google Chromebook Pixel (2013))
- Mistral
- Nyan
@@ -101,13 +114,13 @@
- Hana (Lenovo N23 Yoga Chromebook)
- Parrot (Acer C7/C710 Chromebook)
- Peach Pit (Samsung Chromebook 2 11\")
-- Atlas
+- Atlas (Google Pixelbook Go)
- Poppy
- Nami
-- Nautilus
-- Nocturne
-- Rammus
-- Soraka
+- Nautilus (Samsung Chromebook Plus (V2 / LTE))
+- Nocturne (Google Pixel Slate)
+- Rammus (Asus Chromebook C425, Flip C433, Flip C434)
+- Soraka (HP Chromebook x2)
- Banjo (Acer Chromebook 15 (CB3-531))
- Candy (Dell Chromebook 11 3120)
- Clapper (Lenovo N20 Chromebook)
@@ -139,9 +152,11 @@
- Smaug (Google Pixel C)
- Storm (OnHub Router TGR1900)
- Stout (Lenovo Thinkpad X131e Chromebook)
-- Trogdor
-- Lazor
- Bubs
+- Coachz
+- Lazor
+- Pompom
+- Trogdor
- Veyron_Jaq (Haier Chromebook 11)
- Veyron_Jerry (Hisense Chromebook 11)
- Veyron_Mighty (Haier Chromebook 11(edu))
@@ -149,11 +164,22 @@
- Veyron_Speedy (ASUS C201 Chromebook)
- Veyron_Mickey (Asus Chromebit CS10)
- Veyron_Rialto
+- Dalboz
+- Vilboz
+- Ezkinil
+- Morphius
+- Trembyle
+- Berknip
+- Woomax
+- Dirinboz
+- Shuboz
## HP
- Z220 SFF Workstation
## Intel
+- Alderlake-P RVP
+- Alderlake-P RVP with Chrome EC
- Basking Ridge CRB
- Cannonlake U LPDDR4 RVP
- Cannonlake Y LPDDR4 RVP
@@ -206,6 +232,7 @@
- ThinkPad X1
- ThinkPad X230
- ThinkPad X230t
+- ThinkPad X230s
- ThinkPad X60 / X60s / X60t
## OpenCellular
@@ -226,6 +253,7 @@
## Supermicro
- X11SSH-TF
- X11SSM-F
+- X11SSH-F
## UP
- Squared
diff --git a/Documentation/soc/amd/family17h.md b/Documentation/soc/amd/family17h.md
index 23088cd12b..fffe25b023 100755
--- a/Documentation/soc/amd/family17h.md
+++ b/Documentation/soc/amd/family17h.md
@@ -240,47 +240,12 @@ in an Integration Guide.
## APCB setup
APCBs are used to provide the PSP with SPD information and optionally a set of
-GPIOs to use for selecting which SPD to load.
-
-### Prebuilt
-The picasso `Makefile` expects APCBs to be located in
-`3rdparty/blobs/mainboard/$(MAINBOARDDIR)`. If you have a pre-built binary just
-add the following to your mainboard's Makefile.
-
-```
-# i.e., 3rdparty/blobs/mainboard/amd/mandolin/APCB_mandolin.bin
-APCB_SOURCES = mandolin
-```
+GPIOs to use for selecting which SPD to load. A list of APCB files should be
+specified in `APCB_SOURCES`.
### Generating APCBs
If you have a template APCB file, the `apcb_edit` tool can be used to inject the
-SPD and GPIOs used to select the correct slot. Entries should match this
-pattern `{NAME}_x{1,2}`. There should be a matching SPD hex file in
-`SPD_SOURCES_DIR` matching the pattern `{NAME}.spd.hex`.
-The `_x{1,2}` suffix denotes single or dual channel. Up to 16 slots can be used.
-If a slot is empty, the special empty keyword can be used. This will generate
-an APCB with an empty SPD.
-
-```
-APCB_SOURCES = hynix-HMA851S6CJR6N-VK_x1 # 0b0000
-APCB_SOURCES += hynix-HMAA1GS6CMR6N-VK_x2 # 0b0001
-APCB_SOURCES += empty # 0b0010
-APCB_SOURCES += samsung-K4A8G165WC-BCWE_x1 # 0b0011
-```
-
-#### APCB Board ID GPIO configuration.
-The GPIOs determine which memory SPD will be used during boot.
-```
-# APCB_BOARD_ID_GPIO[0-3] = GPIO_NUMBER GPIO_IO_MUX GPIO_BANK_CTL
-# GPIO_NUMBER: FCH GPIO number
-# GPIO_IO_MUX: Value write to IOMUX to configure this GPIO
-# GPIO_BANK_CTL: Value write to GPIOBankCtl[23:16] to configure this GPIO
-
-APCB_BOARD_ID_GPIO0 = 121 1 0
-APCB_BOARD_ID_GPIO1 = 120 1 0
-APCB_BOARD_ID_GPIO2 = 131 3 0
-APCB_BOARD_ID_GPIO3 = 116 1 0
-```
+SPD and GPIOs used to select the correct slot.
## Footnotes
diff --git a/Documentation/soc/intel/cse_fw_update/Layout_after.svg b/Documentation/soc/intel/cse_fw_update/Layout_after.svg
new file mode 100644
index 0000000000..95720db6b5
--- /dev/null
+++ b/Documentation/soc/intel/cse_fw_update/Layout_after.svg
@@ -0,0 +1,150 @@
+
+
+
+
diff --git a/Documentation/soc/intel/cse_fw_update/Layout_before.svg b/Documentation/soc/intel/cse_fw_update/Layout_before.svg
new file mode 100644
index 0000000000..d03754880e
--- /dev/null
+++ b/Documentation/soc/intel/cse_fw_update/Layout_before.svg
@@ -0,0 +1,95 @@
+
+
+
+
diff --git a/Documentation/soc/intel/cse_fw_update/cse_fw_update.md b/Documentation/soc/intel/cse_fw_update/cse_fw_update.md
new file mode 100644
index 0000000000..98fe310113
--- /dev/null
+++ b/Documentation/soc/intel/cse_fw_update/cse_fw_update.md
@@ -0,0 +1,127 @@
+CSE FW update mechanism for devices in field
+
+## Introduction
+
+CSE Firmware and PMC Firmware are critical components of Intel SoCs.
+CSE and PMC cooperate by providing platform services during boot and other
+power transition flows.
+
+## Problem Statement
+
+Currently, on Chromium OS Systems, CSE region is not updatable. So, new CSE FW
+versions that are released by Intel to address important functional and security
+bugs post-product launch will not be available to the end-user. Hence, the proposed
+solution allows in-field CSE FW update to propagate those bug fixes
+to end user platforms.
+
+## Design Proposal
+
+### CSE FW design Proposal:
+
+Key Elements:
+
+- CSE FW layout is composed of two bootable partitions (RO Recovery Partition
+ and RW Normal Partition).
+
+- Boot partition selection: An API-based mechanism is used to decide from which partition
+ CSE will boot.
+
+- The HECI APIs below will be supported in this CSE FW:
+
+ - HMRFPO_ENABLE: This command requests the CSE enter a mode in which writes to
+ the CSE region from the CSE are disabled. It also grants temporary write access
+ to the RW partition from the host (RO is still protected by GPR0).
+
+ - GET_PARTITION_INFO: The command retrieves information for each boot partition from CSE
+ like version, start/end offsets of a partition within CSE region, and boot
+ partition status. Also, it provides below information:
+ - The current boot partition which was used during this boot,
+ - The boot partition that will be used on the next CSE reset
+ - The number of boot partitions available in the CSE region
+
+ - SET_BOOT_PARTITION_INFO: This command allows the firmware to request the
+ CSE to boot from either its RO or RW partition at its next reset.
+
+ - DATA_CLEAR: This command requests the CSE to reset its data partition back
+ to manufacturing defaults
+
+FW Layout, RW/RO Partitions:
+
+The CSE RO partition is the first in the CSE boot order, hence it will be used
+out of G3. RO partition contains minimum CSE code capable to boot platform and
+execute FW update of RW partition. In addition to CSE code, the RO partition also
+contains PMC FW patch and other CSE-loadable platform FW components.
+
+RW partition contains fully operational CSE FW, PMC FW, other CSE loadable
+platform FW components.
+
+Boot partition selection:
+
+CSE FW shall support 2 APIs to get boot partition info, and set boot partition
+info to notify CSE to select the partition on the next boot.
+
+### HOST FW Design proposal:
+
+Key Elements:
+
+- Build time artifacts:
+
+ CSE RW Version update binary - The FW shall pack CSE RW update blob and
+ corresponding version binary which contains version of the CSE RW blob.
+
+- FW Update:
+
+ coreboot will implement the logic to compare the CSE's FW version with CBFS
+ CSE RW binary's version in the firmware slot (FW_MAIN_A/FW_MAIN_B) and update
+ the CSE RW region if there is a version mismatch. If there is no version
+ mismatch, firmware skips CSE FW update.
+
+- Handling of CSE FW Downgrade:
+
+ coreboot will send DATA_CLEAR HECI command when there is a CSE FW downgrade.
+ This must be done to avoid data mismatch due to CSE FW downgrade. Further,
+ CSE will restore the data back to manufacturing defaults after data reset.
+
+
+## Implementation Details
+
+
+To enable CSE FW update flow the following changes are required in coreboot:
+
+* Descriptor change may be required to accommodate CSE binary. The CSE binary is tied with
+a platform. So CSE size may vary from one platform to another.
+* FMAP changes may be required to accommodate CSE binary and CSE RW blob in the RW CBFS region.
+Please check platform specific CSE kit for CSE binary information.
+* CSE Lite SKU binary and CSE RW blob
+* Makefile change to pack CSE RW binaries in the CBFS
+* Implementation of update flow:
+ - Get CSE boot partition info using GET_BOOT_PARTITION_INFO HECI command.
+ - Get the cbfs_me_rw.version from the currently selected RW slot.
+ - If the version from the above 2 locations don't match, then start CSE FW update.
+ - If CSE is not booting from RO, then
+ - Set the CSE's next boot partition to RO using SET_BOOT_PARTITION_INFO
+ HECI command.
+ - Send GLOBAL_RESET HECI command to reset the system.
+ - If RW update is a CSE FW downgrade, then coreboot has to send
+ DATA_CLEAR command to clear run time data of CSE.
+ - Enable HMRFPO Mode (Host ME Region Flash Protection Override) by
+ sending HMRFPO_ENABLE HECI command to CSE.
+ - Erase and Copy the CBFS CSE RW to CSE RW partition
+ - Set CSE's next boot partition to RW.
+ - Trigger Global Reset which resets both CSE and Host.
+ Then system should boot with the updated CSE.
+
+* The resulting flash layout is shown below:
+
+ 
+
+
+ - Typical boot flow
+
+ - Vboot selects the RW FW (FW_MAIN_A or FW_MAIN_B) to boot.
+ - coreboot skips CSE FW update flow if boot mode is recovery.
+ - If CSE RW blob is not locatable in the CBFS, then RW Firmware skips update flow
+ and sends SET_BOOT_PARTITION_INFO command to switch CSE to boot from RW
+ and issues Global Reset if CSE is already not booting from RW partition.
+ - The RW firmware will compare the CSE RW version with CSE RW blob in the slot.
+ - If there is a mismatch, then firmware will carry out update flow as explained before.
diff --git a/Documentation/soc/intel/icelake/iceLake_coreboot_development.md b/Documentation/soc/intel/icelake/iceLake_coreboot_development.md
index 5f8e279841..214733140b 100644
--- a/Documentation/soc/intel/icelake/iceLake_coreboot_development.md
+++ b/Documentation/soc/intel/icelake/iceLake_coreboot_development.md
@@ -20,11 +20,6 @@ Like any other Intel SoC, Ice Lake coreboot development is also based on "Intel
:doc:`../../../mainboard/intel/icelake_rvp`
```
-3. OEMs to design based on reference platform and make use of mainboard sample code. Dragonegg is Ice Lake based mainboard developed by Google
- ```eval_rst
- :doc:`../../../mainboard/google/dragonegg`
- ```
-
### Summary:
* SoC is Ice Lake.
* Reference platform is icelake_rvp.
diff --git a/Documentation/soc/intel/index.md b/Documentation/soc/intel/index.md
index f30ff9a1d6..71e427ebef 100644
--- a/Documentation/soc/intel/index.md
+++ b/Documentation/soc/intel/index.md
@@ -8,5 +8,7 @@ This section contains documentation about coreboot on specific Intel SOCs.
- [FSP](fsp/index.md)
- [Ice Lake/9th Gen Core-i series](icelake/index.md)
- [MP Initialization](mp_init/mp_init.md)
+- [Microcode Updates](microcode.md)
- [Firmware Interface Table](fit.md)
- [Apollolake](apollolake/index.md)
+- [CSE FW Update](cse_fw_update/cse_fw_update.md)
diff --git a/Documentation/soc/intel/microcode.md b/Documentation/soc/intel/microcode.md
new file mode 100644
index 0000000000..0d65b74b11
--- /dev/null
+++ b/Documentation/soc/intel/microcode.md
@@ -0,0 +1,136 @@
+# Microcode updates
+
+When booting a modern x86 platform, one task of the firmware is to update
+[microcode] to correct hardware bugs and mitigate security issues found
+after silicon has been shipped. The [Pentium FDIV bug] could have been
+fixed with a microcode update, had the Pentium used updateable microcode.
+Starting with the Pentium Pro, CPU microcode can be updated by software.
+
+As per BIOS Writer's Guides, Intel defines a processor as the silicon and
+the accompanying microcode update, and considers any processor that does
+not have its microcode updated to be running out of specification. This
+suggests that microcode is a crucial ingredient for correct operation.
+
+On multi-processor or Hyper-Threading-enabled systems, each thread has
+its own microcode. Therefore, microcode must be updated on every thread.
+
+## When to update microcode
+
+When a CPU core comes out of reset, it uses microcode from an internal
+ROM. This “default” microcode often contains bugs, so it needs to be
+updated as soon as possible. For example, Core 2 CPUs can boot without
+microcode updates, but have stability problems. On newer platforms,
+it is nearly impossible to boot without having updated the microcode.
+On some platforms, an updated microcode is required in order to enable
+Cache-As-RAM or to be able to successfully initialize the DRAM.
+
+Plus, microcode needs to be loaded multiple times. Intel Document 504790
+explains that this is because of so-called *enhanced microcode updates*,
+which are large updates with errata workarounds for both core and uncore.
+In order to correctly apply enhanced microcode updates, the [MP-Init]
+algorithm must be decomposed into multiple initialization phases.
+
+### Firmware Interface Table
+
+Beginning with 4th generation Intel Core processors, it is possible for
+microcode to be updated before the CPU is taken out of reset. This is
+accomplished by means of [FIT], a data structure which contains pointers
+to various firmware ingredients in the BIOS flash.
+
+In rare cases, FIT microcode updates may not be successful. Therefore,
+it is important to check that the microcode is up-to-date and, if not,
+update it. This needs to be done as early as possible, like on older
+processor generations without FIT support.
+
+Whether all threads on a processor get their microcode updated through
+FIT is not clear. According to Intel Documents 493770 and 535094, FIT
+microcode updates are applied to all cores within the package. However,
+Intel Document 550049 states that FIT microcode updates are applied to
+all threads within the package.
+
+## SMM bring-up
+
+Prior to SMM relocation, microcode must have been updated at least once.
+
+## Multi-Processor bring-up
+
+The BWG briefly describes microcode updates as part of the *MP-Init*.
+
+### MP-Init
+
+As part of the [MP-Init] sequence, two microcode updates are required.
+
+* The first update must happen as soon as one AP comes out of reset.
+* The second update must happen after the MP-Init sequence has written MTRRs,
+ PRMRR, DCU mode and prefetcher configuration, SMM has been relocated, but
+ before clearing the MCE banks.
+
+## Recommendations
+
+The Linux kernel developer's recommendations are:
+* Serialize microcode updates if possible.
+* Idle as many APs as possible while updating.
+* Idle the sibling thread on a Hyper-Threading enabled CPU while updating.
+
+## Platform BWGs
+
+The requirements specified in BWGs differ between platforms:
+
+### Sandy Bridge
+
+* Before setting up Cache-As-RAM, load microcode update into the SBSP.
+* Losing (non-SBSP) NBSPs must load their microcode update before being placed
+ back in the wait-for-SIPI state.
+* Sibling threads on HT must use a semaphore.
+* Microcode update loading has been done prior to SMM relocation.
+* In MP-Init the microcode update on an AP must be done before initializing the
+ cache, MTRRs, SMRRs and PRMRRs.
+* In MP-Init a second update must happen on all threads after initializing the
+ cache, MTRRs, SMRRs and PRMRRs.
+
+Refer to Intel Document 504790 for details.
+
+### Haswell/Broadwell Client
+
+* A microcode update must exist in FIT.
+* During the race to the BSP semaphore, each NBSP must load its microcode update.
+* All HT enabled threads can load microcode in parallel. However, the
+ IA32_BIOS_UPDT_TRIG MSR is core-scoped, just like on other platforms.
+* Microcode update loading has been done prior to SMM relocation.
+* In MP-Init the microcode update on an AP must be done before initializing the
+ cache, MTRRs, SMRRs and EMRR.
+* In MP-Init a second update must happen on all threads after initializing the
+ cache, MTRRs, SMRRs and EMRR and after SMM initialization.
+
+Refer to Intel Document 493770 and 535094 for details.
+
+### Broadwell Server
+
+* A microcode update must exist in FIT.
+* Before setting up Cache-As-RAM, load microcode update into each BSP.
+* In MP-Init the microcode update on an AP must be done before initializing the
+ cache, MTRRs, SMRRs and EMRR.
+* In MP-Init a second update must happen on all threads after initializing the
+ cache, MTRRs, SMRRs and EMRR and after SMM initialization.
+
+Refer to Intel Document 546625 for details.
+
+### Skylake/Kaby Lake/Coffee Lake/Whiskey Lake/Comet Lake
+
+* A microcode update must exist in FIT.
+* Before setting up Cache-As-RAM, load microcode update into the BSP.
+* Microcode update loading has been done prior to SMM relocation.
+* In MP-Init the first update must happen as soon as one AP comes out of reset.
+* In MP-Init the second update must happen after the MP-Init sequence has
+ written MTRRs, PRMRR, DCU mode and prefetcher configuration, but before
+ clearing the MCE banks.
+* Microcode updates must happen on all threads.
+* Sibling threads on HT should use a semaphore.
+
+Refer to Intel Document 550049 for details.
+
+[microcode]: https://en.wikipedia.org/wiki/Microcode
+[Pentium FDIV bug]: https://en.wikipedia.org/wiki/Pentium_FDIV_bug
+[FIT]: fit.md
+[SDM]: https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf
+[MP-Init]: mp_init/mp_init.md
diff --git a/Documentation/technotes/asan.md b/Documentation/technotes/asan.md
new file mode 100644
index 0000000000..e0d503a2a2
--- /dev/null
+++ b/Documentation/technotes/asan.md
@@ -0,0 +1,302 @@
+# Address Sanitizer
+
+Memory safety is hard to achieve. We, as humans, are bound to make mistakes in
+our code. While it may be straightforward to detect memory corruption bugs in
+few lines of code, it becomes quite challenging to find those bugs in a massive
+code. In such cases, 'Address Sanitizer' may prove to be useful and could help
+save time.
+
+[Address Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer)
+, also known as ASan, is a runtime memory debugger designed to find
+out-of-bounds accesses and use-after-scope bugs. coreboot has an in-built
+Address Sanitizer. Therefore, it is advised to take advantage of this debugging
+tool while working on large patches. This would further help to ensure code
+quality and make runtime code more robust.
+
+## Types of errors detected
+ASan in coreboot catches the following types of memory bugs:
+
+### Stack buffer overflow
+Example stack-out-of-bounds:
+```c
+void foo()
+{
+ int stack_array[5] = {0};
+ int i, out;
+ for (i = 0; i < 10; i++)
+ out = stack_array[i];
+}
+```
+In this example, the array is of length 5 but it is being read even beyond the
+index 4.
+
+### Global buffer overflow
+Example global-out-of-bounds:
+```c
+char a[] = "I use coreboot";
+
+void foo()
+{
+ char b[] = "proprietary BIOS";
+ strcpy(a + 6, b);
+}
+```
+In this example,
+> well, you are replacing coreboot with proprietary BIOS. In any case, that's
+an "error".
+
+Let's come to the memory bug. The string 'a' is of length 14 but it is being
+written to even beyond that.
+
+### Use after scope
+Example use-after-scope:
+```c
+volatile int *p = 0;
+
+void foo() {
+ {
+ int x = 0;
+ p = &x;
+ }
+ *p = 5;
+}
+```
+In this example, the value 5 is written to an undefined address instead of the
+variable 'x'. This happens because 'x' can't be accessed outside its scope.
+
+## Using ASan
+
+In order to enable ASan on a supported platform,
+select `Address sanitizer support` from `General setup` menu while configuring
+coreboot.
+
+Then build coreboot and run the image as usual. If your code contains any of the
+above-mentioned memory bugs, ASan will report them in the console log as shown
+below:
+```text
+ASan: in
+ of bytes at addr
+```
+where,
+
+`bug type` is either `stack-out-of-bounds`, `global-out-of-bounds` or
+`use-after-scope`,
+
+`ip` is the address of the last good instruction before the bad access,
+
+`access type` is either `Read` or `Write`,
+
+`access size` is the number of bytes read or written, and
+
+`access address` is the memory location which is accessed while the error
+occurs.
+
+Next, you have to use `ip` to retrieve the instruction which causes the error.
+Since stages in coreboot are relocated, you need to normalize `ip`. For this,
+first subtract the start address of the stage from `ip`. Then, read the section
+headers from `.debug` file to determine the offset of the text segment.
+Add this offset to the difference you calculated earlier. Let's call the
+resultant address `ip'`.
+
+Next, read the contents of the symbol table and search for a function having
+an address closest to `ip'`. This is the function in which our memory bug is
+present. Let's denote the address of this function by `ip''`.
+
+Finally, read the assembly contents of the object file where this function is
+present. Look for the affected function. Here, the instruction which exists at
+the offset `ip' - ip''` corresponds to the address `ip`. Therefore, the very
+next instruction is the one which causes the error.
+
+To see ASan in action, let's take an example. Suppose, there is a
+stack-out-of-bounds error in cbfs.c that we aren’t aware of and we want ASan
+to help us detect it.
+```c
+int cbfs_boot_region_device(struct region_device *rdev)
+{
+ int array[5], i;
+ boot_device_init();
+
+ for (i = 10; i > 0; i--)
+ array[i] = i;
+
+ return vboot_locate_cbfs(rdev) &&
+ fmap_locate_area_as_rdev("COREBOOT", rdev);
+}
+```
+First, we enable ASan from the configuration menu as shown above. Then, we
+build coreboot and run the image.
+
+ASan reports the following error in the console log:
+```text
+ASan: stack-out-of-bounds in 0x7f7432fd
+Write of 4 bytes at addr 0x7f7c2ac8
+```
+Here 0x7f7432fd is `ip` i.e. the address of the last good instruction before
+the bad access. First we have to normalize this address as stated above.
+As per the console log, this error happened in ramstage and the stage starts
+from 0x7f72c000. So, let’s look at the sections headers of ramstage from
+`ramstage.debug`.
+```text
+$ objdump -h build/cbfs/fallback/ramstage.debug
+
+build/cbfs/fallback/ramstage.debug: file format elf32-i386
+
+Sections:
+Idx Name Size VMA LMA File off Algn
+ 0 .text 00070b20 00e00000 00e00000 00001000 2**12
+ CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
+ 1 .ctors 0000036c 00e70b20 00e70b20 00071b20 2**2
+ CONTENTS, ALLOC, LOAD, RELOC, DATA
+ 2 .data 0001c8f4 00e70e8c 00e70e8c 00071e8c 2**2
+ CONTENTS, ALLOC, LOAD, RELOC, DATA
+ 3 .bss 00012940 00e8d780 00e8d780 0008e780 2**7
+ ALLOC
+ 4 .heap 00004000 00ea00c0 00ea00c0 0008e780 2**0
+ ALLOC
+```
+As you can see, the offset of the text segment is 0x00e00000. Let's subtract the
+start address of the stage from `ip` and add this offset to the difference. The
+resultant address i.e. `ip'` is 0x00e172fd.
+
+Next, we read the contents of the symbol table and search for a function having
+an address closest to 0x00e172fd.
+```text
+$ nm -n build/cbfs/fallback/ramstage.debug
+........
+........
+00e17116 t _GLOBAL__sub_I_65535_1_gfx_get_init_done
+00e17129 t tohex16
+00e171db T cbfs_load_and_decompress
+00e1729b T cbfs_boot_region_device
+00e17387 T cbfs_boot_locate
+00e1740d T cbfs_boot_map_with_leak
+00e174ef T cbfs_boot_map_optionrom
+........
+........
+```
+The symbol having an address closest to 0x00e172fd is `cbfs_boot_region_device` and
+its address i.e. `ip''` is 0x00e1729b.
+
+Now, as we know the affected function, let's read the assembly contents of
+`cbfs_boot_region_device()` which is present in `cbfs.o` to find the faulty
+instruction.
+```text
+$ objdump -d build/ramstage/lib/cbfs.o
+........
+........
+ 51: e8 fc ff ff ff call 52
+ 56: 83 ec 0c sub $0xc,%esp
+ 59: 57 push %edi
+ 5a: 83 ef 04 sub $0x4,%edi
+ 5d: e8 fc ff ff ff call 5e
+ 62: 83 c4 10 add $0x10,%esp
+ 65: 89 5f 04 mov %ebx,0x4(%edi)
+ 68: 4b dec %ebx
+ 69: 75 eb jne 56
+........
+........
+```
+Here, we look for the instruction present at the offset 62 i.e. `ip' - ip''`.
+The instruction is `add $0x10,%esp` and it corresponds to
+`for (i = 10; i > 0; i--)` in our code. It means the very next instruction
+i.e. `mov %ebx,0x4(%edi)` is the one that causes the error. Now, as we look at
+C code of `cbfs_boot_region_device()` again, we find that this instruction
+corresponds to `array[i] = i`.
+
+Voilà! We just caught the memory bug using ASan.
+
+## Supported platforms
+Presently, the following architectures support ASan in ramstage:
+```eval_rst
++------------------+--------------------------------+
+| Architecture | Notes |
++==================+================================+
+| x86 | Support for all x86 platforms |
++------------------+--------------------------------+
+```
+
+And in romstage ASan is available on the following platforms:
+```eval_rst
++---------------------+-----------------------------+
+| Platform | Notes |
++=====================+=============================+
+| QEMU i440-fx | |
++---------------------+-----------------------------+
+| Intel Apollo Lake | |
++---------------------+-----------------------------+
+| Intel Haswell | |
++---------------------+-----------------------------+
+```
+Alternatively, you can use `grep` to view the list of platforms that support
+ASan in romstage:
+
+ $ git grep "select HAVE_ASAN_IN_ROMSTAGE"
+
+If the x86 platform you are using is not listed here, there is
+still a chance that it supports ASan in romstage.
+
+To test it, select `HAVE_ASAN_IN_ROMSTAGE` from the Kconfig file in the
+platform's dedicated directory. Then, enable ASan from the config menu as
+indicated in the previous section.
+
+If you are able to build coreboot without any errors and boot cleanly, that
+means the platform supports ASan in romstage. In that case, please upload a
+patch on Gerrit selecting this config option using 'ASan' topic. Also, update
+the platform name in the table.
+
+However, if you end up in compilation errors or the linker error saying that
+the cache got full, additional steps need to be taken to enable ASan in
+romstage on the platform. While compile errors could be resolved easily and
+therefore ASan in romstage has a good chance to be supported, a full cache is
+an indication that it is way more work or even likely impossible to enable
+ASan in romstage.
+
+## Future work
+### Heap buffer overflow
+Presently, ASan doesn't detect out-of-bounds accesses for the objects defined
+in heap.
+
+To add support for these type of memory bugs, you have to make sure that
+whenever some block of memory is allocated in the heap, the surrounding areas
+(redzones) are poisoned. Correspondingly, these redzones should be unpoisoned
+when the memory block is de-allocated.
+
+### ASan on other architectures
+The following points should help when adding support for ASan to other
+architectures like ARM or RISC-V:
+
+* Enabling ASan in ramstage on other architectures should be easy. You just
+have to make sure the shadow memory is initialized as early as possible when
+ramstage is loaded. This can be done by making a function call to `asan_init()`
+at the appropriate place.
+
+* For romstage, you have to find out if there is enough room in the cache to fit
+the shadow memory region. For this, find the boundary linker symbols for the
+region you'd want to run ASan on, excluding the hardware mapped addresses.
+Then define a new linker section named `asan_shadow` of size
+`(_end - _start) >> 3`, where `_start` and `_end` are the linker symbols you
+found earlier. This section should be appended to the region already occupied
+by the coreboot program. Now build coreboot. If you don't see any errors while
+building with the current translation function, ASan can be enabled on that
+platform.
+
+* The shadow region we currently use consumes memory equal to 1/8th of the
+program memory. So, if you end up in a linker error saying that the memory got
+full, you'll have to use a more compact shadow region. In that case, the
+translation function could be something like
+`shadow = (mem >> 7) | shadow_offset`. Since the stack buffers are protected by
+the compiler, you'll also have to create a GCC patch forcing it to use the new
+translation function for this particular architecture.
+
+* Once you are sure that the architecture supports ASan in ramstage, select
+`HAVE_ASAN_IN_RAMSTAGE` from the Kconfig file of that architecture. Similarly,
+if the platform supports ASan in romstage, select `HAVE_ASAN_IN_ROMSTAGE` from
+the platform's dedicated Kconfig file.
+
+### Post-processing script
+Unlike Linux, coreboot doesn't have `%pS` printk format to dereference pointer
+to its symbolic name. Therefore, we normalise the pointer address manually to
+determine the name of the affected function and further use it to find the
+instruction which causes the error.
+
+A custom script can be written to automate this process.
diff --git a/Documentation/technotes/index.md b/Documentation/technotes/index.md
index 5367e69aa2..a9320fb782 100644
--- a/Documentation/technotes/index.md
+++ b/Documentation/technotes/index.md
@@ -3,3 +3,4 @@
* [Dealing with Untrusted Input in SMM](2017-02-dealing-with-untrusted-input-in-smm.md)
* [Rebuilding coreboot image generation](2015-11-rebuilding-coreboot-image-generation.md)
* [Unit testing coreboot](2020-03-unit-testing-coreboot.md)
+* [Address Sanitizer](asan.md)
diff --git a/Documentation/tutorial/part1.md b/Documentation/tutorial/part1.md
index 7e3da01572..e02812b68f 100644
--- a/Documentation/tutorial/part1.md
+++ b/Documentation/tutorial/part1.md
@@ -19,9 +19,21 @@ Download, configure, and build coreboot
$ cd coreboot
### Step 3 - Build the coreboot toolchain
-Please note that this can take a significant amount of time.
+Please note that this can take a significant amount of time. Use `CPUS=` to
+specify number of `make` jobs to run in parallel.
- $ make crossgcc-i386 CPUS=$(nproc)
+This will list toolchain options and supported architectures:
+
+ $ make help_toolchain
+
+Here are some examples:
+
+ $ make crossgcc-i386 CPUS=$(nproc) # build i386 toolchain
+ $ make crossgcc-aarch64 CPUS=$(nproc) # build Aarch64 toolchain
+ $ make crossgcc-riscv CPUS=$(nproc) # build RISC-V toolchain
+
+Note that the i386 toolchain is currently used for all x86 platforms, including
+x86_64.
Also note that you can possibly use your system toolchain, but the results are
not reproducible, and may have issues, so this is not recommended. See step 5
diff --git a/Documentation/util.md b/Documentation/util.md
index 27a7c9cab9..8e03333194 100644
--- a/Documentation/util.md
+++ b/Documentation/util.md
@@ -20,7 +20,7 @@ status repository `Bash` `Go`
* __cavium__ - Devicetree_convert Tool to convert a DTB to a static C
file `Python`
* __cbfstool__
- * _cbfstool_ - For manipulating CBFS file `C`
+ * [_cbfstool_](cbfstool/index.md) - For manipulating CBFS file `C`
* _fmaptool_ - Converts plaintext fmd files into fmap blobs `C`
* _rmodtool_ - Creates rmodules `C`
* _ifwitool_ - For manipulating IFWI `C`
diff --git a/MAINTAINERS b/MAINTAINERS
index 924247edaf..7a82159919 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -137,6 +137,14 @@ Maintainers List (try to look for most precise areas first)
# Mainboards
################################################################################
+AMD family 17h and 19h reference boards
+M: Marshall Dawson
+M: Felix Held
+M: Jason Glenesk
+S: Maintained
+F: src/mainboard/amd/majolica/
+F: src/mainboard/amd/mandolin/
+
APPLE MAINBOARDS
M: Evgeny Zinoviev
S: Maintained
@@ -208,6 +216,14 @@ F: src/mainboard/asus/p8z77-v_lx2/
+CLEVO MAINBOARDS
+M: Felix Singer
+M: Michael Niewöhner
+S: Supported
+F: src/mainboard/clevo/
+
+
+
FACEBOOK FBG1701 MAINBOARD
M: Frans Hendriks
M: Wim Vervoorn
@@ -225,19 +241,19 @@ F: src/mainboard/facebook/monolith/
GETAC P470 MAINBOARD
M: Patrick Georgi
S: Maintained
-F: src/mainboard/getac/p470
+F: src/mainboard/getac/p470/
GIGABYTE GA-G41M-ES2L MAINBOARD
M: Damien Zammit
S: Odd Fixes
-F: src/mainboard/gigabyte/ga-g41m-es2l
+F: src/mainboard/gigabyte/ga-g41m-es2l/
GIGABYTE GA-H61M SERIES MAINBOARDS
M: Angel Pons
S: Maintained
-F: src/mainboard/gigabyte/ga-h61m-series
+F: src/mainboard/gigabyte/ga-h61m-series/
@@ -265,7 +281,7 @@ F: src/mainboard/google/stout/
INTEL D510MO MAINBOARD
M: Damien Zammit
S: Odd Fixes
-F: src/mainboard/intel/d510mo
+F: src/mainboard/intel/d510mo/
INTEL STRAGO MAINBOARD
M: Hannah Williams
@@ -274,6 +290,21 @@ F: /src/mainboard/intel/strago/
+KONTRON BSL6 MAINBOARD
+M: Felix Singer
+M: Nico Huber
+S: Supported
+F: src/mainboard/kontron/bsl6/
+
+KONTRON MAL10 MAINBOARD
+M: Maxim Polyakov
+M: Nico Huber
+M: Felix Singer
+S: Supported
+F: src/mainboard/kontron/mal10/
+
+
+
LENOVO MAINBOARDS
M: Alexander Couzens
M: Patrick Rudolph
@@ -291,7 +322,7 @@ LIBRETREND LT1000 MAINBOARD
M: Piotr Król
M: Michał Żygowski
S: Maintained
-F: src/mainboard/libretrend/lt1000
+F: src/mainboard/libretrend/lt1000/
OCP DELTALAKE MAINBOARD
@@ -302,7 +333,7 @@ M: Morgan Jang
M: Ryback Hung <
M: Bryant Ou
S: Supported
-F: src/mainboard/ocp/deltalake
+F: src/mainboard/ocp/deltalake/
OCP TIOGAPASS MAINBOARD
M: Jonathan Zhang
@@ -312,7 +343,7 @@ M: Morgan Jang
M: Ryback Hung <
M: Bryant Ou
S: Maintained
-F: src/mainboard/ocp/tiogapass
+F: src/mainboard/ocp/tiogapass/
@@ -352,14 +383,14 @@ PRODRIVE HERMES MAINBOARD
M: Christian Walter
M: Patrick Rudolph
S: Maintained
-F: src/mainboard/prodrive/hermes
+F: src/mainboard/prodrive/hermes/
PURISM MAINBOARDS
M: Matt DeVillier
S: Supported
-F: src/mainboard/purism
+F: src/mainboard/purism/
@@ -371,6 +402,12 @@ F: src/mainboard/samsung/stumpy/
+SIEMENS CHILI MAINBAORD
+M: Felix Singer
+M: Nico Huber
+S: Supported
+F: src/mainboard/siemens/chili/
+
SIEMENS MC_xxxx MAINBOARDS
M: Werner Zeh
S: Maintained
@@ -393,7 +430,7 @@ F: src/mainboard/supermicro/x10slm-f/
SUPERMICRO X11-LGA1151-SERIES
M: Michael Niewöhner
S: Maintained
-F: src/mainboard/supermicro/x11-lga1151-series
+F: src/mainboard/supermicro/x11-lga1151-series/
################################################################################
# Architectures
@@ -404,7 +441,6 @@ M: Julius Werner
S: Supported
F: src/arch/arm/
F: src/arch/arm64/
-F: src/soc/mediatek/
F: src/soc/nvidia/
F: src/soc/rockchip/
F: util/nvidia/
@@ -499,12 +535,13 @@ F: src/drivers/intel/
F: src/include/cpu/intel/
INTEL FSP DENVERTON-NS SOC & HARCUVAR CRB
+M: Suresh Bellampalli
M: Vanessa Eusebio
-M: David Guckian
-S: Odd Fixes
+M: Michal Motyl
+M: Mariusz Szafranski
+S: Maintained
F: src/mainboard/intel/harcuvar/
F: src/soc/intel/denverton_ns/
-F: src/vendorcode/intel/fsp/fsp2_0/denverton_ns/
INTEL FSP 1.1
M: Lee Leahy
@@ -522,6 +559,28 @@ F: src/drivers/intel/fsp2_0/
# Systems on a Chip
################################################################################
+AMD Cezanne
+M: Marshall Dawson
+M: Felix Held
+M: Jason Glenesk
+S: Maintained
+F: src/soc/amd/cezanne/
+
+AMD common SoC code
+M: Marshall Dawson
+M: Felix Held
+M: Jason Glenesk
+S: Maintained
+F: src/soc/amd/common/
+
+AMD Picasso
+M: Marshall Dawson
+M: Felix Held
+M: Jason Glenesk
+S: Maintained
+F: src/soc/amd/picasso/
+F: src/vendorcode/amd/fsp/picasso/
+
INTEL APOLLOLAKE_SOC
M: Andrey Petrov
S: Maintained
@@ -532,8 +591,8 @@ M: Piotr Król
M: Michał Żygowski
M: Frans Hendriks
S: Maintained
-F: /src/soc/intel/braswell
-F: /src/vendorcode/intel/fsp/fsp1_1/braswell
+F: /src/soc/intel/braswell/
+F: /src/vendorcode/intel/fsp/fsp1_1/braswell/
INTEL Xeon Sacalable Processor Family
M: Jonathan Zhang
@@ -544,13 +603,18 @@ M: Ryback Hung <
M: Bryant Ou
S: Supported
F: src/soc/intel/xeon_sp
-F: src/vendorcode/intel/fsp/fsp2_0/skylake_sp
-F: src/vendorcode/intel/fsp/fsp2_0/copperlake_sp
+F: src/vendorcode/intel/fsp/fsp2_0/skylake_sp/
+F: src/vendorcode/intel/fsp/fsp2_0/copperlake_sp/
+
+MEDIATEK SOCS
+M: Hung-Te Lin
+S: Supported
+F: src/soc/mediatek/
ORPHANED ARM SOCS
S: Orphaned
F: src/cpu/armltd/
-F: src/cpu/ti/
+F: src/soc/ti/
F: src/soc/qualcomm/
F: src/soc/samsung/
F: util/exynos/
@@ -573,13 +637,13 @@ F: payloads/coreinfo/
EXTERNAL PAYLOADS INTEGRATION
M: Stefan Reinauer
M: Martin Roth
-F: payloads/external
+F: payloads/external/
LINUXBOOT PAYLOAD INTEGRATION
M: Christian Walter
M: Marcello Sylvester Bauer
S: Supported
-F: payloads/external/LinuxBoot
+F: payloads/external/LinuxBoot/
################################################################################
# Utilities
@@ -653,6 +717,8 @@ F: src/drivers/aspeed/common/
F: src/drivers/aspeed/ast2050/
ACPI
+M: Lance Zhao
+S: Supported
F: src/acpi/
F: src/arch/x86/acpi/
F: util/acpi/
@@ -682,8 +748,13 @@ OPTION ROM EXECUTION & X86EMU
F: src/device/oprom/
CBFS
-F: src/include/cbfs.h
-F: src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h
+M: Julius Werner
+F: src/include/cbfs*
+F: src/commonlib/bsd/include/commonlib/bsd/cbfs*
+F: src/commonlib/bsd/cbfs*
+F: src/lib/cbfs.c
+
+CBFSTOOL
F: util/cbfstool/
CBMEM
@@ -704,7 +775,7 @@ TPM SUPPORT
M: Christian Walter
S: Supported
F: src/drivers/*/tpm/
-F: src/security/tpm
+F: src/security/tpm/
SUPERIOS & SUPERIOTOOL
M: Felix Held
@@ -722,7 +793,7 @@ ELTAN VENDORCODE
M: Frans Hendriks
M: Wim Vervoorn
S: Maintained
-F: src/vendorcode/eltan
+F: src/vendorcode/eltan/
MISSING: TIMERS / DELAYS
diff --git a/Makefile b/Makefile
index 2705c66b51..ec0f95b595 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@ src := src
srck := $(top)/util/kconfig
obj ?= build
override obj := $(subst $(top)/,,$(abspath $(obj)))
+xcompile ?= $(obj)/xcompile
objutil ?= $(obj)/util
objk := $(objutil)/kconfig
absobj := $(abspath $(obj))
@@ -119,7 +120,7 @@ UNIT_TEST:=1
NOCOMPILE:=
endif
-.xcompile: util/xcompile/xcompile
+$(xcompile): util/xcompile/xcompile
rm -f $@
$< $(XGCCPATH) > $@.tmp
\mv -f $@.tmp $@ 2> /dev/null
@@ -146,15 +147,17 @@ ifneq ($(UNIT_TEST),1)
include $(DOTCONFIG)
endif
-# in addition to the dependency below, create the file if it doesn't exist
-# to silence stupid warnings about a file that would be generated anyway.
-$(if $(wildcard .xcompile)$(NOCOMPILE),,$(eval $(shell util/xcompile/xcompile $(XGCCPATH) > .xcompile || rm -f .xcompile)))
+# The toolchain requires xcompile to determine the ARCH_SUPPORTED, so we can't
+# wait for make to generate the file.
+$(if $(wildcard $(xcompile)),, $(shell \
+ mkdir -p $(dir $(xcompile)) && \
+ util/xcompile/xcompile $(XGCCPATH) > $(xcompile) || rm -f $(xcompile)))
--include .xcompile
+include $(xcompile)
ifneq ($(XCOMPILE_COMPLETE),1)
-$(shell rm -f .xcompile)
-$(error .xcompile deleted because it's invalid. \
+$(shell rm -f $(xcompile))
+$(error $(xcompile) deleted because it's invalid. \
Restarting the build should fix that, or explain the problem)
endif
@@ -440,10 +443,10 @@ doxygen_simple:
doxyplatform doxygen_platform: $(obj)/project_filelist.txt
echo
echo "Building doxygen documentation for $(CONFIG_MAINBOARD_PART_NUMBER)"
- export DOXYGEN_OUTPUT_DIR="$(DOXYGEN_OUTPUT_DIR)/$(CONFIG_MAINBOARD_VENDOR)/$(CONFIG_MAINBOARD_PART_NUMBER)"; \
+ export DOXYGEN_OUTPUT_DIR="$$( echo $(DOXYGEN_OUTPUT_DIR)/$(call strip_quotes, $(CONFIG_MAINBOARD_VENDOR))_$(call strip_quotes, $(CONFIG_MAINBOARD_PART_NUMBER)) | sed 's|[^A-Za-z0-9/]|_|g' )"; \
mkdir -p "$$DOXYGEN_OUTPUT_DIR"; \
export DOXYFILES="$$(cat $(obj)/project_filelist.txt | grep -v '\.ld$$' | sed 's/\.aml/\.dsl/' | tr '\n' ' ')"; \
- export DOXYGEN_PLATFORM="$(CONFIG_MAINBOARD_DIR) ($(CONFIG_MAINBOARD_PART_NUMBER)) version $(KERNELVERSION)"; \
+ export DOXYGEN_PLATFORM="$(call strip_quotes, $(CONFIG_MAINBOARD_DIR)) \($(call strip_quotes, $(CONFIG_MAINBOARD_PART_NUMBER))\) version $(KERNELVERSION)"; \
$(DOXYGEN) Documentation/doxygen/Doxyfile.coreboot_platform
doxyclean: doxygen-clean
diff --git a/Makefile.inc b/Makefile.inc
index 89bb3e4239..a67b22c84d 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -13,6 +13,7 @@ CONFIG_CBFS_PREFIX:=$(call strip_quotes,$(CONFIG_CBFS_PREFIX))
CONFIG_FMDFILE:=$(call strip_quotes,$(CONFIG_FMDFILE))
CONFIG_DEVICETREE:=$(call strip_quotes, $(CONFIG_DEVICETREE))
CONFIG_OVERRIDE_DEVICETREE:=$(call strip_quotes, $(CONFIG_OVERRIDE_DEVICETREE))
+CONFIG_CHIPSET_DEVICETREE:=$(call strip_quotes, $(CONFIG_CHIPSET_DEVICETREE))
CONFIG_MEMLAYOUT_LD_FILE:=$(call strip_quotes, $(CONFIG_MEMLAYOUT_LD_FILE))
#######################################################################
@@ -34,7 +35,8 @@ COREBOOT_EXPORTS += KERNELVERSION
# Basic component discovery
MAINBOARDDIR=$(call strip_quotes,$(CONFIG_MAINBOARD_DIR))
VARIANT_DIR:=$(call strip_quotes,$(CONFIG_VARIANT_DIR))
-COREBOOT_EXPORTS += MAINBOARDDIR VARIANT_DIR
+CARRIER_DIR:=$(call strip_quotes,$(CONFIG_CARRIER_DIR))
+COREBOOT_EXPORTS += MAINBOARDDIR VARIANT_DIR CARRIER_DIR
## Final build results, which CBFSTOOL uses to create the final
## rom image file, are placed under $(objcbfs).
@@ -75,14 +77,15 @@ PHONY+= clean-abuild coreboot check-style build-dirs build_complete
#######################################################################
# root source directories of coreboot
-subdirs-y := src/lib src/commonlib/ src/console src/device src/acpi
+subdirs-y := src/lib src/commonlib/ src/console src/device src/acpi src/superio/common
subdirs-y += src/ec/acpi $(wildcard src/ec/*/*) $(wildcard src/southbridge/*/*)
subdirs-y += $(wildcard src/soc/*/*) $(wildcard src/northbridge/*/*)
-subdirs-y += src/superio
-subdirs-y += $(wildcard src/drivers/*) $(wildcard src/drivers/*/*)
+subdirs-y += $(wildcard src/superio/*) $(wildcard src/superio/*/*)
+subdirs-y += $(wildcard src/drivers/*) $(wildcard src/drivers/*/*) $(wildcard src/drivers/*/*/*)
subdirs-y += src/cpu src/vendorcode
-subdirs-y += util/cbfstool util/sconfig util/nvramtool util/pgtblgen
-subdirs-y += util/futility util/marvell util/bincfg util/supermicro
+subdirs-y += util/cbfstool util/sconfig util/nvramtool util/pgtblgen util/amdfwtool
+subdirs-y += util/futility util/marvell util/bincfg util/supermicro util/qemu
+subdirs-y += util/ifdtool
subdirs-y += $(wildcard src/arch/*)
subdirs-y += src/mainboard/$(MAINBOARDDIR)
subdirs-y += src/security
@@ -181,9 +184,6 @@ decompressor-generic-ccopts += -D__DECOMPRESSOR__
bootblock-generic-ccopts += -D__BOOTBLOCK__
romstage-generic-ccopts += -D__ROMSTAGE__
ramstage-generic-ccopts += -D__RAMSTAGE__
-ifeq ($(CONFIG_TRACE),y)
-ramstage-c-ccopts += -finstrument-functions
-endif
ifeq ($(CONFIG_COVERAGE),y)
ramstage-c-ccopts += -fprofile-arcs -ftest-coverage
endif
@@ -264,12 +264,14 @@ REDUNDANT_OFFSET_REMARK = 2158
# "Multiple types (Device object requires either a _HID or _ADR, but not both)"
MULTIPLE_TYPES_WARNING = 3073
+IASL_WARNINGS_LIST = $(EMPTY_RESOURCE_TEMPLATE_WARNING) $(REDUNDANT_OFFSET_REMARK)
+
ifeq ($(CONFIG_SOUTHBRIDGE_INTEL_LYNXPOINT)$(CONFIG_SOC_INTEL_BROADWELL),y)
-IGNORED_IASL_WARNINGS = -vw $(EMPTY_RESOURCE_TEMPLATE_WARNING) -vw $(REDUNDANT_OFFSET_REMARK) -vw $(MULTIPLE_TYPES_WARNING)
-else
-IGNORED_IASL_WARNINGS = -vw $(EMPTY_RESOURCE_TEMPLATE_WARNING) -vw $(REDUNDANT_OFFSET_REMARK)
+IASL_WARNINGS_LIST += $(MULTIPLE_TYPES_WARNING)
endif
+IGNORED_IASL_WARNINGS = $(addprefix -vw , $(IASL_WARNINGS_LIST))
+
define asl_template
$(CONFIG_CBFS_PREFIX)/$(1).aml-file = $(obj)/$(1).aml
$(CONFIG_CBFS_PREFIX)/$(1).aml-type = raw
@@ -280,6 +282,7 @@ $(obj)/$(1).aml: $(src)/mainboard/$(MAINBOARDDIR)/$(1).asl $(obj)/config.h
@printf " IASL $$(subst $(top)/,,$$(@))\n"
$(CC_ramstage) -x assembler-with-cpp -E -MMD -MT $$(@) $$(CPPFLAGS_ramstage) -D__ACPI__ -P -include $(src)/include/kconfig.h -I$(obj) -I$(src) -I$(src)/include -I$(src)/arch/$(ARCHDIR-$(ARCH-ramstage-y))/include -I$(src)/mainboard/$(MAINBOARDDIR) $$< -o $(obj)/$(1).asl
cd $$(dir $$@); $(IASL) $(IGNORED_IASL_WARNINGS) -we -p $$(notdir $$@) $(1).asl
+ echo " IASL "$(IASL_WARNINGS_LIST)" warning types were ignored!"
if ! $(IASL) -d $$@ 2>&1 | grep -Eq 'ACPI (Warning|Error)'; then \
echo " IASL $$@ disassembled correctly."; \
true; \
@@ -331,9 +334,9 @@ endef
# arg2: binary file
cbfs-files-processor-struct= \
$(eval $(2): $(1) $(obj)/build.h $(KCONFIG_AUTOHEADER); \
- printf " CC+STRIP $(@)\n"; \
+ printf " CC+STRIP $(1)\n"; \
$(CC_ramstage) -MMD $(CPPFLAGS_ramstage) $(CFLAGS_ramstage) $$(ramstage-c-ccopts) -include $(KCONFIG_AUTOHEADER) -MT $(2) -o $(2).tmp -c $(1) && \
- $(OBJCOPY_ramstage) -O binary $(2).tmp $(2); \
+ $(OBJCOPY_ramstage) -O binary --set-section-flags .bss*=alloc,contents,load $(2).tmp $(2); \
rm -f $(2).tmp) \
$(eval DEPENDENCIES += $(2).d)
@@ -411,6 +414,10 @@ CPPFLAGS_common += -include $(src)/commonlib/bsd/include/commonlib/bsd/compiler.
CPPFLAGS_common += -I3rdparty
CPPFLAGS_common += -D__BUILD_DIR__=\"$(obj)\"
+ifeq ($(BUILD_TIMELESS),1)
+CPPFLAGS_common += -D__TIMELESS__
+endif
+
ifeq ($(CONFIG_PCI_OPTION_ROM_RUN_YABEL)$(CONFIG_PCI_OPTION_ROM_RUN_REALMODE),y)
CPPFLAGS_ramstage += -Isrc/device/oprom/include
endif
@@ -418,10 +425,10 @@ endif
CFLAGS_common += -pipe -g -nostdinc -std=gnu11
CFLAGS_common += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
CFLAGS_common += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough
-CFLAGS_common += -Wstrict-aliasing -Wshadow -Wdate-time -Wtype-limits -Wvla
+CFLAGS_common += -Wshadow -Wdate-time -Wtype-limits -Wvla
CFLAGS_common += -Wlogical-op -Wduplicated-cond -Wdangling-else
CFLAGS_common += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
-CFLAGS_common += -ffunction-sections -fdata-sections -fno-pie
+CFLAGS_common += -fstrict-aliasing -ffunction-sections -fdata-sections -fno-pie
ifeq ($(CONFIG_COMPILER_GCC),y)
# Don't add these GCC specific flags when running scan-build
ifeq ($(CCC_ANALYZER_OUTPUT_FORMAT),)
@@ -514,7 +521,8 @@ build_h_exports := BUILD_TIMELESS KERNELVERSION COREBOOT_EXTRA_VERSION
# Report new `build.ht` as dependency if `build.h` differs.
build_h_check := \
export $(foreach exp,$(build_h_exports),$(exp)="$($(exp))"); \
- util/genbuild_h/genbuild_h.sh .xcompile >$(build_h)t 2>/dev/null; \
+ util/genbuild_h/genbuild_h.sh $(xcompile) \
+ >$(build_h)t 2>/dev/null; \
cmp -s $(build_h)t $(build_h) >/dev/null 2>&1 || echo $(build_h)t
$(build_h): $$(shell $$(build_h_check))
@@ -524,6 +532,12 @@ $(build_h): $$(shell $$(build_h_check))
build-dirs $(objcbfs) $(objgenerated):
mkdir -p $(objcbfs) $(objgenerated)
+$(obj)/build_info:
+ @echo 'COREBOOT_VERSION: $(call strip_quotes,$(KERNELVERSION))' > $@.tmp
+ @echo 'MAINBOARD_VENDOR: $(call strip_quotes,$(CONFIG_MAINBOARD_VENDOR))' >> $@.tmp
+ @echo 'MAINBOARD_PART_NUMBER: $(call strip_quotes,$(CONFIG_MAINBOARD_PART_NUMBER))' >> $@.tmp
+ mv $@.tmp $@
+
#######################################################################
# Build the tools
CBFSTOOL:=$(objutil)/cbfstool/cbfstool
@@ -563,15 +577,8 @@ endif
BINCFG:=$(objutil)/bincfg/bincfg
IFDTOOL:=$(objutil)/ifdtool/ifdtool
-$(IFDTOOL):
- @printf " Compile IFDTOOL\n"
- +$(MAKE) -C $(top)/util/ifdtool
- cp -a $(top)/util/ifdtool/ifdtool $@
AMDFWTOOL:=$(objutil)/amdfwtool/amdfwtool
-$(AMDFWTOOL): $(top)/util/amdfwtool/amdfwtool.c
- @printf " HOSTCC $(subst $(obj)/,,$(@))\n"
- $(HOSTCC) $(HOSTCFLAGS) -DCONFIG_ROM_SIZE=$(CONFIG_ROM_SIZE) -o $@ $<
APCB_EDIT_TOOL:=$(top)/util/apcb/apcb_edit.py
@@ -588,19 +595,34 @@ $(obj)/config.h: $(objutil)/kconfig/conf
# Creation of these is architecture and mainboard independent
DEVICETREE_FILE := $(src)/mainboard/$(MAINBOARDDIR)/$(CONFIG_DEVICETREE)
+SCONFIG_OPTIONS := --mainboard_devtree=$(DEVICETREE_FILE)
+
ifneq ($(CONFIG_OVERRIDE_DEVICETREE),)
-
OVERRIDE_DEVICETREE_FILE := $(src)/mainboard/$(MAINBOARDDIR)/$(CONFIG_OVERRIDE_DEVICETREE)
+SCONFIG_OPTIONS += --override_devtree=$(OVERRIDE_DEVICETREE_FILE)
+endif
+ifneq ($(CONFIG_CHIPSET_DEVICETREE),)
+CHIPSET_DEVICETREE_FILE := $(src)/$(CONFIG_CHIPSET_DEVICETREE)
+SCONFIG_OPTIONS += --chipset_devtree=$(CHIPSET_DEVICETREE_FILE)
endif
DEVICETREE_STATIC_C := $(obj)/mainboard/$(MAINBOARDDIR)/static.c
-DEVICETREE_STATIC_H := $(obj)/static.h
+SCONFIG_OPTIONS += --output_c=$(DEVICETREE_STATIC_C)
-$(DEVICETREE_STATIC_C): $(DEVICETREE_FILE) $(OVERRIDE_DEVICETREE_FILE) $(objutil)/sconfig/sconfig
+DEVICETREE_STATIC_H := $(obj)/static.h
+SCONFIG_OPTIONS += --output_h=$(DEVICETREE_STATIC_H)
+
+DEVICETREE_DEVICENAMES_H := $(obj)/static_devices.h
+SCONFIG_OPTIONS += --output_d=$(DEVICETREE_DEVICENAMES_H)
+
+DEVICETREE_FWCONFIG_H := $(obj)/static_fw_config.h
+SCONFIG_OPTIONS += --output_f=$(DEVICETREE_FWCONFIG_H)
+
+$(DEVICETREE_STATIC_C): $(DEVICETREE_FILE) $(OVERRIDE_DEVICETREE_FILE) $(CHIPSET_DEVICETREE_FILE) $(objutil)/sconfig/sconfig
@printf " SCONFIG $(subst $(src)/,,$(<))\n"
mkdir -p $(dir $(DEVICETREE_STATIC_C))
- $(objutil)/sconfig/sconfig $(DEVICETREE_FILE) $(DEVICETREE_STATIC_C) $(DEVICETREE_STATIC_H) $(OVERRIDE_DEVICETREE_FILE)
+ $(objutil)/sconfig/sconfig $(SCONFIG_OPTIONS)
ramstage-y+=$(DEVICETREE_STATIC_C)
romstage-y+=$(DEVICETREE_STATIC_C)
@@ -805,6 +827,10 @@ endif
# cbfs-add-cmd-for-region
# $(call cbfs-add-cmd-for-region,file in extract_nth format,region name)
+#
+# CBFSTOOL_ADD_CMD_OPTIONS can be used by arch/SoC/mainboard to supply
+# add commands with any additional arguments for cbfstool.
+# Example: --ext-win-base --ext-win-size
define cbfs-add-cmd-for-region
$(CBFSTOOL) $@.tmp \
add$(if $(filter stage,$(call extract_nth,3,$(1))),-stage)$(if \
@@ -819,8 +845,8 @@ define cbfs-add-cmd-for-region
-r $(2) \
$(if $(call extract_nth,6,$(1)),-a $(call extract_nth,6,$(file)), \
$(if $(call extract_nth,5,$(file)),-b $(call extract_nth,5,$(file)))) \
- $(call extract_nth,7,$(1))
-
+ $(call extract_nth,7,$(1)) \
+ $(CBFSTOOL_ADD_CMD_OPTIONS)
endef
# Empty line before endef is necessary so cbfs-add-cmd-for-region ends in a
@@ -944,6 +970,25 @@ else
FMAP_SMMSTORE_ENTRY :=
endif
+ifeq ($(CONFIG_SPD_CACHE_IN_FMAP),y)
+FMAP_SPD_CACHE_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x4000)
+FMAP_SPD_CACHE_SIZE := $(call int-multiply, $(CONFIG_DIMM_MAX) $(CONFIG_DIMM_SPD_SIZE))
+FMAP_SPD_CACHE_SIZE := $(call int-align, $(FMAP_SPD_CACHE_SIZE), 0x1000)
+FMAP_SPD_CACHE_ENTRY := $(CONFIG_SPD_CACHE_FMAP_NAME)@$(FMAP_SPD_CACHE_BASE) $(FMAP_SPD_CACHE_SIZE)
+FMAP_CURRENT_BASE := $(call int-add, $(FMAP_SPD_CACHE_BASE) $(FMAP_SPD_CACHE_SIZE))
+else
+FMAP_SPD_CACHE_ENTRY :=
+endif
+
+ifeq ($(CONFIG_VPD),y)
+FMAP_VPD_BASE := $(call int-align, $(FMAP_CURRENT_BASE), 0x4000)
+FMAP_VPD_SIZE := $(CONFIG_VPD_FMAP_SIZE)
+FMAP_VPD_ENTRY := $(CONFIG_VPD_FMAP_NAME)@$(FMAP_VPD_BASE) $(FMAP_VPD_SIZE)
+FMAP_CURRENT_BASE := $(call int-add, $(FMAP_VPD_BASE) $(FMAP_VPD_SIZE))
+else
+FMAP_VPD_ENTRY :=
+endif
+
#
# X86 FMAP region
#
@@ -1020,6 +1065,8 @@ $(obj)/fmap.fmd: $(top)/Makefile.inc $(DEFAULT_FLASHMAP) $(obj)/config.h
-e "s,##CONSOLE_ENTRY##,$(FMAP_CONSOLE_ENTRY)," \
-e "s,##MRC_CACHE_ENTRY##,$(FMAP_MRC_CACHE_ENTRY)," \
-e "s,##SMMSTORE_ENTRY##,$(FMAP_SMMSTORE_ENTRY)," \
+ -e "s,##SPD_CACHE_ENTRY##,$(FMAP_SPD_CACHE_ENTRY)," \
+ -e "s,##VPD_ENTRY##,$(FMAP_VPD_ENTRY)," \
-e "s,##CBFS_BASE##,$(FMAP_CBFS_BASE)," \
-e "s,##CBFS_SIZE##,$(FMAP_CBFS_SIZE)," \
$(DEFAULT_FLASHMAP) > $@.tmp
@@ -1043,6 +1090,7 @@ $(obj)/fmap.fmap: $(obj)/fmap.fmd $(FMAPTOOL)
ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y)
TS_OPTIONS := -j $(CONFIG_INTEL_TOP_SWAP_BOOTBLOCK_SIZE)
endif
+
ifneq ($(CONFIG_UPDATE_IMAGE),y)
$(obj)/coreboot.pre: $(objcbfs)/bootblock.bin $$(prebuilt-files) $(CBFSTOOL) $(IFITTOOL) $$(cpu_ucode_cbfs_file) $(obj)/fmap.fmap $(obj)/fmap.desc
$(CBFSTOOL) $@.tmp create -M $(obj)/fmap.fmap -r $(shell cat $(obj)/fmap.desc)
@@ -1053,7 +1101,8 @@ ifeq ($(CONFIG_ARCH_X86),y)
-t bootblock \
$(TXTIBB) \
-b -$(call file-size,$(objcbfs)/bootblock.bin) $(cbfs-autogen-attributes) \
- $(TS_OPTIONS)
+ $(TS_OPTIONS) \
+ $(CBFSTOOL_ADD_CMD_OPTIONS)
else # ifeq ($(CONFIG_ARCH_X86),y)
$(CBFSTOOL) $@.tmp write -u \
-r BOOTBLOCK \
@@ -1065,10 +1114,11 @@ else # ifeq ($(CONFIG_ARCH_X86),y)
-f $@.tmp.2 \
-n "header pointer" \
-t "cbfs header" \
- -b -4
+ -b -4 \
+ $(CBFSTOOL_ADD_CMD_OPTIONS)
rm -f $@.tmp.2
endif # ifeq ($(CONFIG_ARCH_X86),y)
- $(CBFSTOOL) $@.tmp add-master-header $(TS_OPTIONS)
+ $(CBFSTOOL) $@.tmp add-master-header $(TS_OPTIONS) $(CBFSTOOL_ADD_CMD_OPTIONS)
$(prebuild-files) true
mv $@.tmp $@
else # ifneq ($(CONFIG_UPDATE_IMAGE),y)
@@ -1088,74 +1138,30 @@ $(REFCODE_BLOB): $(RMODTOOL)
$(RMODTOOL) -i $(CONFIG_REFCODE_BLOB_FILE) -o $@
endif
-FIT_ENTRY=$(call strip_quotes, $(CONFIG_INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG))
-
ifeq ($(CONFIG_HAVE_RAMSTAGE),y)
RAMSTAGE=$(objcbfs)/ramstage.elf
else
RAMSTAGE=
endif
-$(obj)/coreboot.rom: $(obj)/coreboot.pre $(RAMSTAGE) $(CBFSTOOL) $$(INTERMEDIATE)
+add_intermediate = \
+ $(1): $(2) | $(INTERMEDIATE) \
+ $(eval INTERMEDIATE+=$(1)) $(eval PHONY+=$(1))
+$(obj)/coreboot.rom: $(obj)/coreboot.pre $(RAMSTAGE) $(CBFSTOOL) $$(INTERMEDIATE)
@printf " CBFS $(subst $(obj)/,,$(@))\n"
# The full ROM may be larger than the CBFS part, so create an empty
# file (filled with \377 = 0xff) and copy the CBFS image over it.
dd if=/dev/zero bs=$(call _toint,$(CONFIG_ROM_SIZE)) count=1 2> /dev/null | tr '\000' '\377' > $@.tmp
dd if=$(obj)/coreboot.pre of=$@.tmp bs=8192 conv=notrunc 2> /dev/null
-ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),)
-ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),0)
-ifneq ($(CONFIG_UPDATE_IMAGE),y)
- @printf " SeaBIOS Wait up to $(CONFIG_SEABIOS_PS2_TIMEOUT) ms for PS/2 keyboard controller initialization\n"
- $(CBFSTOOL) $@.tmp add-int -i $(CONFIG_SEABIOS_PS2_TIMEOUT) -n etc/ps2-keyboard-spinup
-endif
-endif
-endif
-ifeq ($(CONFIG_SEABIOS_ADD_SERCON_PORT_FILE),y)
- @printf " SeaBIOS Add sercon-port file\n"
- $(CBFSTOOL) $@.tmp add-int -i $(CONFIG_SEABIOS_SERCON_PORT_ADDR) -n etc/sercon-port
-endif
-ifeq ($(CONFIG_SEABIOS_THREAD_OPTIONROMS),y)
- @printf " SeaBIOS Thread optionroms\n"
- $(CBFSTOOL) $@.tmp add-int -i 2 -n etc/threads
-endif
ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y)
-ifneq ($(CONFIG_UPDATE_IMAGE),y) # never update the bootblock
-ifeq ($(CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_HEADER),y)
- @printf " UPDATE-FIT\n"
- $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \
- -r COREBOOT
-endif
-ifeq ($(CONFIG_USE_CPU_MICROCODE_CBFS_BINS),y)
- @printf " UPDATE-FIT\n"
- $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \
- -r COREBOOT
-endif
+# Print final FIT table
$(IFITTOOL) -f $@.tmp -D -r COREBOOT
-
-# Second FIT in TOP_SWAP bootblock
+# Print final TS BOOTBLOCK FIT table
ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y)
-# INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG adds a region as first ucode into the seconds bootblock
-ifneq ($(FIT_ENTRY),)
- @printf " UPDATE-FIT2\n"
- $(IFITTOOL) -f $@.tmp -A -n $(FIT_ENTRY) -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \
- $(TS_OPTIONS) -r COREBOOT
-endif
-ifeq ($(CONFIG_CPU_MICROCODE_CBFS_EXTERNAL_HEADER),y)
- @printf " UPDATE-FIT2\n"
- $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \
- $(TS_OPTIONS) -r COREBOOT
-endif
-ifeq ($(CONFIG_USE_CPU_MICROCODE_CBFS_BINS),y)
- @printf " UPDATE-FIT2\n"
- $(IFITTOOL) -f $@.tmp -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) \
- $(TS_OPTIONS) -r COREBOOT
-endif
+ @printf " TOP SWAP FIT table\n"
$(IFITTOOL) -f $@.tmp -D $(TS_OPTIONS) -r COREBOOT
-
-endif
-
-endif # !CONFIG_UPDATE_IMAGE
+endif # CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK
endif # CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE
mv $@.tmp $@
@printf " CBFSLAYOUT $(subst $(obj)/,,$(@))\n\n"
@@ -1220,6 +1226,10 @@ cbfs-files-$(CONFIG_INCLUDE_CONFIG_FILE) += revision
revision-file := $(obj)/build.h
revision-type := raw
+cbfs-files-y += build_info
+build_info-file := $(obj)/build_info
+build_info-type := raw
+
BOOTSPLASH_SUFFIX=$(suffix $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE)))
cbfs-files-$(CONFIG_BOOTSPLASH_IMAGE) += bootsplash$(BOOTSPLASH_SUFFIX)
bootsplash$(BOOTSPLASH_SUFFIX)-file := $(call strip_quotes,$(CONFIG_BOOTSPLASH_FILE))
@@ -1241,7 +1251,7 @@ cbfs-get-segments-cmd = $(CBFSTOOL) $(obj)/coreboot.pre print -v | sed -n \
ramstage-symbol-addr-cmd = $(OBJDUMP_ramstage) -t $(objcbfs)/ramstage.elf | \
sed -n '/ $(1)$$/s/^\([0-9a-fA-F]*\) .*/0x\1/p'
-check-ramstage-overlaps: $(obj)/coreboot.pre
+$(call add_intermediate, check-ramstage-overlaps, $(obj)/coreboot.pre)
programs=$$($(foreach file,$(check-ramstage-overlap-files), \
$(call cbfs-get-segments-cmd,$(file)) ; )) ; \
regions=$$($(foreach region,$(check-ramstage-overlap-regions), \
@@ -1267,6 +1277,4 @@ check-ramstage-overlaps: $(obj)/coreboot.pre
pstart= ; pend= ; \
done
-INTERMEDIATE+=check-ramstage-overlaps
-PHONY+=check-ramstage-overlaps
endif
diff --git a/configs/config.asrock_b85m_pro4.debug_smmstore_hotplug_gcov_ubsan_em100 b/configs/config.asrock_b85m_pro4.debug_smmstore_hotplug_gcov_ubsan_em100
new file mode 100644
index 0000000000..563f83ac5e
--- /dev/null
+++ b/configs/config.asrock_b85m_pro4.debug_smmstore_hotplug_gcov_ubsan_em100
@@ -0,0 +1,49 @@
+# Not meant for actual use, but rather to build-test individual options.
+# If keeping this combination of options buildable becomes too hard in
+# the future, then this config can be split into several smaller chunks.
+# Exercises, among other things:
+# + Code coverage
+# + UBSAN
+# + Debug options
+# + SMMSTORE
+# + Silicon Image SIL3114 driver
+# + Genesys Logic GL9763E driver
+# + EM100 support
+# + SMM module loader V2
+CONFIG_COVERAGE=y
+CONFIG_UBSAN=y
+CONFIG_VENDOR_ASROCK=y
+CONFIG_ONBOARD_VGA_IS_PRIMARY=y
+CONFIG_CBFS_SIZE=0x200000
+CONFIG_BOARD_ASROCK_B85M_PRO4=y
+CONFIG_PCIEXP_L1_SUB_STATE=y
+CONFIG_PCIEXP_CLK_PM=y
+CONFIG_CONSOLE_POST=y
+# CONFIG_INTEL_CHIPSET_LOCKDOWN is not set
+# CONFIG_FINALIZE_USB_ROUTE_XHCI is not set
+CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
+CONFIG_PCIEXP_HOTPLUG=y
+CONFIG_SMMSTORE=y
+CONFIG_SMMSTORE_SIZE=0x30000
+CONFIG_SPI_FLASH_NO_FAST_READ=y
+CONFIG_USBDEBUG=y
+CONFIG_USBDEBUG_DONGLE_FTDI_FT232H=y
+CONFIG_DRIVERS_SIL_3114=y
+CONFIG_DRIVERS_GENESYSLOGIC_GL9763E=y
+# CONFIG_SQUELCH_EARLY_SMP is not set
+CONFIG_CONSOLE_SPI_FLASH=y
+CONFIG_POST_DEVICE_PCI_PCIE=y
+CONFIG_FATAL_ASSERTS=y
+CONFIG_DEBUG_CBFS=y
+CONFIG_DEBUG_SMBUS=y
+CONFIG_DEBUG_SMI=y
+CONFIG_DEBUG_PERIODIC_SMI=y
+CONFIG_DEBUG_MALLOC=y
+CONFIG_DEBUG_CONSOLE_INIT=y
+CONFIG_DEBUG_SPI_FLASH=y
+CONFIG_DEBUG_COVERAGE=y
+CONFIG_DEBUG_BOOT_STATE=y
+CONFIG_DEBUG_ADA_CODE=y
+CONFIG_HAVE_EM100_SUPPORT=y
+CONFIG_X86_SMM_LOADER_VERSION2=y
+CONFIG_EM100=y
diff --git a/configs/config.asrock_b85m_pro4.tpm2_txt_placeholder_acms b/configs/config.asrock_b85m_pro4.tpm2_txt_placeholder_acms
new file mode 100644
index 0000000000..856701fee8
--- /dev/null
+++ b/configs/config.asrock_b85m_pro4.tpm2_txt_placeholder_acms
@@ -0,0 +1,10 @@
+# Known-working configuration to boot with TXT enabled. Since BIOS
+# and SINIT ACM blobs are missing, use something else as placeholder.
+# Used ACMs were extracted from a Supermicro X10SLH firmware update.
+CONFIG_VENDOR_ASROCK=y
+CONFIG_BOARD_ASROCK_B85M_PRO4=y
+CONFIG_USER_TPM2=y
+CONFIG_INTEL_TXT=y
+CONFIG_INTEL_TXT_BIOSACM_FILE="3rdparty/blobs/cpu/intel/stm/stm.bin"
+CONFIG_INTEL_TXT_SINITACM_FILE="3rdparty/blobs/cpu/intel/stm/stm.bin"
+CONFIG_INTEL_TXT_LOGGING=y
diff --git a/configs/config.asus_p8z77-v_lx2.debug_smmstore_hotplug_yabel_em100 b/configs/config.asus_p8z77-v_lx2.debug_smmstore_hotplug_yabel_em100
new file mode 100644
index 0000000000..167909da0d
--- /dev/null
+++ b/configs/config.asus_p8z77-v_lx2.debug_smmstore_hotplug_yabel_em100
@@ -0,0 +1,38 @@
+# Not meant for actual use, but rather to build-test individual options.
+# If keeping this combination of options buildable becomes too hard in
+# the future, then this config can be split into several smaller chunks.
+# Exercises, among other things:
+# + PCIe hotplug
+# + Fatal assertions
+# + Debug options
+# + SMMSTORE
+# + YABEL
+# + VESA framebuffer
+# + EM100 support
+CONFIG_VENDOR_ASUS=y
+CONFIG_CBFS_SIZE=0x200000
+CONFIG_BOARD_ASUS_P8Z77_V_LX2=y
+CONFIG_PCIEXP_L1_SUB_STATE=y
+CONFIG_PCIEXP_CLK_PM=y
+# CONFIG_S3_VGA_ROM_RUN is not set
+CONFIG_NATIVE_RAMINIT_IGNORE_MAX_MEM_FUSES=y
+CONFIG_NATIVE_RAMINIT_IGNORE_XMP_MAX_DIMMS=y
+CONFIG_RAMINIT_ALWAYS_ALLOW_DLL_OFF=y
+CONFIG_VGA_ROM_RUN=y
+CONFIG_PCI_OPTION_ROM_RUN_YABEL=y
+CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
+CONFIG_VBE_LINEAR_FRAMEBUFFER=y
+CONFIG_PCIEXP_HOTPLUG=y
+CONFIG_SMMSTORE=y
+CONFIG_FATAL_ASSERTS=y
+CONFIG_DEBUG_CBFS=y
+CONFIG_DEBUG_RAM_SETUP=y
+CONFIG_DEBUG_SMBUS=y
+CONFIG_DEBUG_SMI=y
+CONFIG_DEBUG_MALLOC=y
+CONFIG_DEBUG_CONSOLE_INIT=y
+CONFIG_DEBUG_SPI_FLASH=y
+CONFIG_DEBUG_BOOT_STATE=y
+CONFIG_DEBUG_ADA_CODE=y
+CONFIG_HAVE_EM100_SUPPORT=y
+CONFIG_EM100=y
diff --git a/configs/config.emulation_qemu_x86_i440fx_debug b/configs/config.emulation_qemu_x86_i440fx_debug
index 011f16356c..e39ff590fd 100644
--- a/configs/config.emulation_qemu_x86_i440fx_debug
+++ b/configs/config.emulation_qemu_x86_i440fx_debug
@@ -4,6 +4,5 @@ CONFIG_FATAL_ASSERTS=y
CONFIG_DEBUG_CBFS=y
CONFIG_DEBUG_PIRQ=y
CONFIG_DEBUG_MALLOC=y
-CONFIG_TRACE=y
CONFIG_DEBUG_BOOT_STATE=y
CONFIG_DEBUG_ADA_CODE=y
diff --git a/configs/config.emulation_qemu_x86_i440fx_x86_64 b/configs/config.emulation_qemu_x86_i440fx_x86_64
new file mode 100644
index 0000000000..0ddb3f1339
--- /dev/null
+++ b/configs/config.emulation_qemu_x86_i440fx_x86_64
@@ -0,0 +1 @@
+CONFIG_CPU_QEMU_X86_64=y
diff --git a/configs/config.portwell_m107.debug_smmstore_oxpcie_em100spi b/configs/config.portwell_m107.debug_smmstore_oxpcie_em100spi
new file mode 100644
index 0000000000..09dfbe35cf
--- /dev/null
+++ b/configs/config.portwell_m107.debug_smmstore_oxpcie_em100spi
@@ -0,0 +1,41 @@
+# Not meant for actual use, but rather to build-test individual options.
+# If keeping this combination of options buildable becomes too hard in
+# the future, then this config can be split into several smaller chunks.
+# Exercises, among other things:
+# + SMMSTORE
+# + OXPCIE support
+# + FSP MP init
+# + EM100Pro SPI console
+# + Debug options
+CONFIG_VENDOR_PORTWELL=y
+CONFIG_CONSOLE_POST=y
+# CONFIG_CONSOLE_SERIAL is not set
+CONFIG_ENABLE_BUILTIN_COM1=y
+CONFIG_ONBOARD_MEM_KINGSTON=y
+CONFIG_USE_INTEL_FSP_MP_INIT=y
+CONFIG_SOC_INTEL_COMMON_BLOCK_SMM_TCO_ENABLE=y
+CONFIG_SOC_INTEL_DEBUG_CONSENT=y
+CONFIG_PCIEXP_HOTPLUG=y
+CONFIG_PCIEXP_HOTPLUG_PREFETCH_MEM_BELOW_4G=y
+CONFIG_SOFTWARE_I2C=y
+CONFIG_SMMSTORE=y
+CONFIG_SPI_FLASH_NO_FAST_READ=y
+CONFIG_DRIVERS_UART_OXPCIE=y
+CONFIG_DRIVERS_GENESYSLOGIC_GL9755=y
+CONFIG_DISPLAY_HOBS=y
+CONFIG_DISPLAY_VBT=y
+CONFIG_DISPLAY_FSP_ENTRY_POINTS=y
+CONFIG_DISPLAY_UPD_DATA=y
+CONFIG_EM100PRO_SPI_CONSOLE=y
+CONFIG_DISPLAY_MTRRS=y
+CONFIG_GDB_STUB=y
+CONFIG_GDB_WAIT=y
+CONFIG_FATAL_ASSERTS=y
+CONFIG_DEBUG_CBFS=y
+CONFIG_DEBUG_SMBUS=y
+CONFIG_DEBUG_SMI=y
+CONFIG_DEBUG_PERIODIC_SMI=y
+CONFIG_DEBUG_MALLOC=y
+CONFIG_DEBUG_CONSOLE_INIT=y
+CONFIG_REALMODE_DEBUG=y
+CONFIG_DEBUG_BOOT_STATE=y
diff --git a/configs/config.purism_librem15_v4.txt_build_test b/configs/config.purism_librem15_v4.txt_build_test
new file mode 100644
index 0000000000..f2de8bc59f
--- /dev/null
+++ b/configs/config.purism_librem15_v4.txt_build_test
@@ -0,0 +1,8 @@
+# Not meant for actual use. Exercises Intel TXT code. Since BIOS
+# and SINIT ACM blobs are missing, use something else as placeholder.
+CONFIG_VENDOR_PURISM=y
+CONFIG_BOARD_PURISM_LIBREM15_V4=y
+CONFIG_INTEL_TXT=y
+CONFIG_INTEL_TXT_BIOSACM_FILE="3rdparty/blobs/cpu/intel/stm/stm.bin"
+CONFIG_INTEL_TXT_SINITACM_FILE="3rdparty/blobs/cpu/intel/stm/stm.bin"
+CONFIG_INTEL_TXT_LOGGING=y
diff --git a/configs/config.stm b/configs/config.purism_librem15_v4_stm
similarity index 100%
rename from configs/config.stm
rename to configs/config.purism_librem15_v4_stm
diff --git a/configs/config.scaleway_tagada b/configs/config.scaleway_tagada
new file mode 100644
index 0000000000..eaa428831b
--- /dev/null
+++ b/configs/config.scaleway_tagada
@@ -0,0 +1,15 @@
+CONFIG_VENDOR_SCALEWAY=y
+CONFIG_BOARD_SCALEWAY_TAGADA=y
+CONFIG_CBFS_SIZE=0x400000
+CONFIG_CONSOLE_POST=y
+# CONFIG_DRIVERS_INTEL_WIFI is not set
+# CONFIG_IQAT_ENABLE is not set
+CONFIG_LEGACY_UART_MODE=y
+CONFIG_USE_DENVERTON_NS_FSP_CAR=y
+CONFIG_SPI_FLASH_NO_FAST_READ=y
+CONFIG_PAYLOAD_ELF=y
+CONFIG_PAYLOAD_FILE="UEFIPAYLOAD.fd"
+CONFIG_DISPLAY_FSP_CALLS_AND_STATUS=y
+CONFIG_DISPLAY_FSP_HEADER=y
+CONFIG_DEBUG_CBFS=y
+CONFIG_DEBUG_BOOT_STATE=y
diff --git a/payloads/Kconfig b/payloads/Kconfig
index cfb28d6e81..627bb95c9c 100644
--- a/payloads/Kconfig
+++ b/payloads/Kconfig
@@ -30,7 +30,7 @@ config PAYLOAD_ELF
config PAYLOAD_FIT
bool "A FIT payload"
- depends on ARCH_ARM64 || ARCH_RISCV
+ depends on ARCH_ARM64 || ARCH_RISCV || ARCH_ARM
select PAYLOAD_FIT_SUPPORT
help
Select this option if you have a payload image (a FIT file) which
@@ -97,7 +97,7 @@ config PAYLOAD_FIT_SUPPORT
bool "FIT support"
default n
default y if PAYLOAD_LINUX && (ARCH_ARM || ARCH_ARM64 || ARCH_RISCV)
- depends on ARCH_ARM64 || ARCH_RISCV
+ depends on ARCH_ARM64 || ARCH_RISCV || ARCH_ARM
select FLATTENED_DEVICE_TREE
help
Select this option if your payload is of type FIT.
diff --git a/payloads/coreinfo/.gitignore b/payloads/coreinfo/.gitignore
new file mode 100644
index 0000000000..101045e012
--- /dev/null
+++ b/payloads/coreinfo/.gitignore
@@ -0,0 +1,2 @@
+lpbuild/
+lp.config*
diff --git a/payloads/coreinfo/AUTHORS b/payloads/coreinfo/AUTHORS
new file mode 100644
index 0000000000..772018081d
--- /dev/null
+++ b/payloads/coreinfo/AUTHORS
@@ -0,0 +1,14 @@
+# This is the list of coreinfo authors for copyright purposes.
+#
+# This does not necessarily list everyone who has contributed code, since in
+# some cases, their employer may be the copyright holder. To see the full list
+# of contributors, and their email addresses, see the revision history in source
+# control.
+# Run the below commands in the coreinfo repo for additional information.
+# To see a list of contributors: git log --pretty=format:%an | sort | uniq
+# For patches adding or removing a name: git log -i -S "NAME" --source --all
+
+Advanced Micro Devices, Inc.
+Dave Jones
+Jordan Crouse
+Uwe Hermann
diff --git a/payloads/coreinfo/Kconfig b/payloads/coreinfo/Kconfig
index 3b69c0c559..2c1f91c874 100644
--- a/payloads/coreinfo/Kconfig
+++ b/payloads/coreinfo/Kconfig
@@ -1,7 +1,3 @@
-##
-##
-## Copyright (C) 2008 Uwe Hermann
-##
## SPDX-License-Identifier: GPL-2.0-only
# For a description of the syntax of this configuration file,
@@ -46,6 +42,15 @@ config PAYLOAD_INFO_VERSION
help
The version number of this payload.
+config LTO
+ bool "Use link time optimization (LTO)"
+ default n
+ help
+ Compile with link time optimization. This can often decrease the
+ final binary size, but may increase compilation time. This option
+ is most effective when LTO is also enabled in libpayload, which
+ is done separately.
+
endmenu
menu "Modules"
diff --git a/payloads/coreinfo/Makefile b/payloads/coreinfo/Makefile
index 4171796350..cd58f392dd 100644
--- a/payloads/coreinfo/Makefile
+++ b/payloads/coreinfo/Makefile
@@ -1,8 +1,3 @@
-##
-##
-## Copyright (C) 2008 Advanced Micro Devices, Inc.
-## Copyright (C) 2008 Uwe Hermann
-##
## SPDX-License-Identifier: GPL-2.0-only
src := $(CURDIR)
@@ -81,9 +76,13 @@ ifneq ($(strip $(HAVE_DOTCONFIG)),)
include $(src)/.config
real-all: $(TARGET)
+ifeq ($(CONFIG_LTO),y)
+CFLAGS += -flto
+endif
+
$(TARGET): $(src)/.config $(coreinfo_obj)/config.h $(OBJS) libpayload
printf " LPCC $(subst $(CURDIR)/,,$(@)) (LINK)\n"
- $(LPCC) -o $@ $(OBJS)
+ $(LPCC) $(CFLAGS) -o $@ $(OBJS)
$(OBJCOPY) --only-keep-debug $@ $(TARGET).debug
$(OBJCOPY) --strip-debug $@
$(OBJCOPY) --add-gnu-debuglink=$(TARGET).debug $@
@@ -128,10 +127,9 @@ include $(srck)/Makefile
else
clean:
- rm -rf build/*.elf build/*.o .xcompile
+ rm -rf build lpbuild .xcompile
distclean: clean
- rm -rf build lpbuild
rm -f .config* lp.config*
.PHONY: clean distclean
diff --git a/payloads/coreinfo/bootlog_module.c b/payloads/coreinfo/bootlog_module.c
index 1502a559dd..5a87f28340 100644
--- a/payloads/coreinfo/bootlog_module.c
+++ b/payloads/coreinfo/bootlog_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Uwe Hermann
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
@@ -19,14 +7,12 @@
#define LINES_SHOWN 19
#define TAB_WIDTH 2
-
/* Globals that are used for tracking screen state */
static char *g_buf = NULL;
static s32 g_line = 0;
static s32 g_lines_count = 0;
static s32 g_max_cursor_line = 0;
-
/* Copied from libpayload/drivers/cbmem_console.c */
struct cbmem_console {
u32 size;
@@ -37,7 +23,6 @@ struct cbmem_console {
#define CURSOR_MASK ((1 << 28) - 1)
#define OVERFLOW (1 << 31)
-
static u32 char_width(char c, u32 cursor, u32 screen_width)
{
if (c == '\n') {
@@ -110,7 +95,7 @@ static int bootlog_module_init(void)
return -1;
}
- struct cbmem_console *console = lib_sysinfo.cbmem_cons;
+ struct cbmem_console *console = phys_to_virt(lib_sysinfo.cbmem_cons);
if (console == NULL) {
return -1;
}
diff --git a/payloads/coreinfo/cbfs_module.c b/payloads/coreinfo/cbfs_module.c
index f22453e4e8..adbe2778aa 100644
--- a/payloads/coreinfo/cbfs_module.c
+++ b/payloads/coreinfo/cbfs_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2009 Uwe Hermann
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
#include "endian.h"
diff --git a/payloads/coreinfo/coreboot_module.c b/payloads/coreinfo/coreboot_module.c
index 074d73a475..87032d5990 100644
--- a/payloads/coreinfo/coreboot_module.c
+++ b/payloads/coreinfo/coreboot_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
#include
diff --git a/payloads/coreinfo/coreinfo.c b/payloads/coreinfo/coreinfo.c
index 35e5016ae6..b357f97988 100644
--- a/payloads/coreinfo/coreinfo.c
+++ b/payloads/coreinfo/coreinfo.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
diff --git a/payloads/coreinfo/coreinfo.h b/payloads/coreinfo/coreinfo.h
index 004a5e9663..b96af89efd 100644
--- a/payloads/coreinfo/coreinfo.h
+++ b/payloads/coreinfo/coreinfo.h
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef COREINFO_H_
#define COREINFO_H_
diff --git a/payloads/coreinfo/cpuid.S b/payloads/coreinfo/cpuid.S
index b004052080..84cdc77874 100644
--- a/payloads/coreinfo/cpuid.S
+++ b/payloads/coreinfo/cpuid.S
@@ -1,18 +1,6 @@
-/*
- *
- * It is derived from the x86info project, which is GPLv2-licensed.
- *
- * Copyright (C) 2001-2007 Dave Jones
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/* It is derived from the x86info project, which is GPLv2-licensed. */
/* calling syntax: docpuid(idx,eax,ebx,ecx,edx) */
diff --git a/payloads/coreinfo/cpuinfo_module.c b/payloads/coreinfo/cpuinfo_module.c
index 96c495a170..b937e4c1d4 100644
--- a/payloads/coreinfo/cpuinfo_module.c
+++ b/payloads/coreinfo/cpuinfo_module.c
@@ -1,19 +1,6 @@
-/*
- *
- * It is derived from the x86info project, which is GPLv2-licensed.
- *
- * Copyright (C) 2001-2007 Dave Jones
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/* It is derived from the x86info project, which is GPLv2-licensed. */
#include "coreinfo.h"
diff --git a/payloads/coreinfo/multiboot_module.c b/payloads/coreinfo/multiboot_module.c
index dd5ce366fb..2ec9929b60 100644
--- a/payloads/coreinfo/multiboot_module.c
+++ b/payloads/coreinfo/multiboot_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Jordan Crouse
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include
#include "coreinfo.h"
diff --git a/payloads/coreinfo/nvram_module.c b/payloads/coreinfo/nvram_module.c
index 9ac734a76c..99c6e9b69f 100644
--- a/payloads/coreinfo/nvram_module.c
+++ b/payloads/coreinfo/nvram_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Uwe Hermann
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
diff --git a/payloads/coreinfo/pci_module.c b/payloads/coreinfo/pci_module.c
index 019f8d05a4..ff01770868 100644
--- a/payloads/coreinfo/pci_module.c
+++ b/payloads/coreinfo/pci_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include
#include
@@ -163,7 +151,7 @@ static int pci_module_redraw(WINDOW *win)
return 0;
}
-static void pci_scan_bus(int bus)
+static void ci_pci_scan_bus(int bus)
{
int slot, func;
unsigned int val;
@@ -208,7 +196,7 @@ static void pci_scan_bus(int bus)
busses = pci_read_config32(dev, REG_PRIMARY_BUS);
- pci_scan_bus((busses >> 8) & 0xff);
+ ci_pci_scan_bus((busses >> 8) & 0xff);
}
}
@@ -252,7 +240,7 @@ static int pci_module_handle(int key)
static int pci_module_init(void)
{
- pci_scan_bus(0);
+ ci_pci_scan_bus(0);
return 0;
}
diff --git a/payloads/coreinfo/ramdump_module.c b/payloads/coreinfo/ramdump_module.c
index abb8472ff5..762707f5e5 100644
--- a/payloads/coreinfo/ramdump_module.c
+++ b/payloads/coreinfo/ramdump_module.c
@@ -1,16 +1,4 @@
-/*
- *
- * Copyright (C) 2008 Uwe Hermann
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
diff --git a/payloads/coreinfo/timestamps_module.c b/payloads/coreinfo/timestamps_module.c
index 32f1866693..3a24930748 100644
--- a/payloads/coreinfo/timestamps_module.c
+++ b/payloads/coreinfo/timestamps_module.c
@@ -1,14 +1,4 @@
-/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "coreinfo.h"
#include
@@ -147,7 +137,7 @@ static int timestamps_module_init(void)
if (ret)
return -1;
- struct timestamp_table *timestamps = lib_sysinfo.tstamp_table;
+ struct timestamp_table *timestamps = phys_to_virt(lib_sysinfo.tstamp_table);
if (timestamps == NULL)
return -1;
diff --git a/payloads/external/.gitignore b/payloads/external/.gitignore
new file mode 100644
index 0000000000..ebca42908b
--- /dev/null
+++ b/payloads/external/.gitignore
@@ -0,0 +1,10 @@
+depthcharge/depthcharge/
+FILO/filo/
+GRUB2/grub2/
+LinuxBoot/linuxboot/
+SeaBIOS/seabios/
+tianocore/tianocore/
+tint/tint/
+U-Boot/u-boot/
+Memtest86Plus/memtest86plus/
+iPXE/ipxe/
diff --git a/payloads/external/BOOTBOOT/Kconfig b/payloads/external/BOOTBOOT/Kconfig
new file mode 100644
index 0000000000..c9d7133b71
--- /dev/null
+++ b/payloads/external/BOOTBOOT/Kconfig
@@ -0,0 +1,6 @@
+if PAYLOAD_BOOTBOOT
+
+config PAYLOAD_FILE
+ default "payloads/external/BOOTBOOT/bootboot/dist/bootbootcb.elf"
+
+endif
diff --git a/payloads/external/BOOTBOOT/Kconfig.name b/payloads/external/BOOTBOOT/Kconfig.name
new file mode 100644
index 0000000000..082a9b1ec2
--- /dev/null
+++ b/payloads/external/BOOTBOOT/Kconfig.name
@@ -0,0 +1,8 @@
+config PAYLOAD_BOOTBOOT
+ bool "BOOTBOOT"
+ depends on ARCH_X86 || ARCH_ARM64
+ help
+ Select this option if you want to build a coreboot image
+ with a BOOTBOOT Protocol payload.
+
+ See https://gitlab.com/bztsrc/bootboot for more information.
diff --git a/payloads/external/BOOTBOOT/Makefile b/payloads/external/BOOTBOOT/Makefile
new file mode 100644
index 0000000000..2460c183bb
--- /dev/null
+++ b/payloads/external/BOOTBOOT/Makefile
@@ -0,0 +1,44 @@
+project_git_repo=https://gitlab.com/bztsrc/bootboot.git
+project_dir=bootboot
+ifeq ($(CONFIG_COREBOOT_BUILD),)
+include ../../../.config
+endif
+ifeq ($(CONFIG_ARCH_ARM64),y)
+loader_dir=$(project_dir)/aarch64-cb
+else
+loader_dir=$(project_dir)/x86_64-cb
+endif
+
+unexport KCONFIG_AUTOHEADER
+unexport KCONFIG_AUTOCONFIG
+unexport KCONFIG_DEPENDENCIES
+unexport KCONFIG_SPLITCONFIG
+unexport KCONFIG_TRISTATE
+unexport KCONFIG_NEGATIVES
+
+all: bootboot
+
+checkout:
+ echo " GIT BOOTBOOT $(loader_dir)"
+ test -L $(project_dir) || test -d $(project_dir) || \
+ git clone $(project_git_repo) $(project_dir)
+
+bootboot: libpayload
+ echo " MAKE $(loader_dir)"
+ $(MAKE) -C $(loader_dir) LIBCONFIG_PATH=../../../libpayload
+
+libpayload: checkout
+ cp $(loader_dir)/lib.config ../../libpayload/.config
+ cd ../../libpayload && $(MAKE) oldconfig && \
+ $(MAKE) && $(MAKE) DESTDIR=../external/BOOTBOOT/$(loader_dir) install
+
+clean:
+ test -d $(loader_dir) && $(MAKE) -C $(loader_dir) clean || exit 0
+
+distclean:
+ rm -rf $(project_dir)
+
+print-repo-info:
+ echo "$(project_git_repo) $(project_dir)"
+
+.PHONY: checkout bootboot libpayload clean distclean print-repo-info
diff --git a/payloads/external/FILO/Kconfig b/payloads/external/FILO/Kconfig
index 94d5e18df0..1cf171d2cf 100644
--- a/payloads/external/FILO/Kconfig
+++ b/payloads/external/FILO/Kconfig
@@ -5,9 +5,9 @@ choice
default FILO_STABLE
config FILO_STABLE
- bool "0.6.0"
+ bool "tested"
help
- Stable FILO version
+ Tested FILO version
config FILO_MASTER
bool "HEAD"
diff --git a/payloads/external/FILO/Makefile b/payloads/external/FILO/Makefile
index a89ea2af59..6175cfe62c 100644
--- a/payloads/external/FILO/Makefile
+++ b/payloads/external/FILO/Makefile
@@ -1,6 +1,6 @@
TAG-$(CONFIG_FILO_MASTER)=origin/master
NAME-$(CONFIG_FILO_MASTER)=MASTER
-TAG-$(CONFIG_FILO_STABLE)=22baa6bde9339029edfafa421b3d4a7be159edad
+TAG-$(CONFIG_FILO_STABLE)=c2fa1ea6125c63e84cdf7779c37d76da8c5bc412
NAME-$(CONFIG_FILO_STABLE)=STABLE
project_git_repo=https://review.coreboot.org/filo.git
diff --git a/payloads/external/LinuxBoot/Kconfig b/payloads/external/LinuxBoot/Kconfig
index 591d649d8f..c2689e1871 100644
--- a/payloads/external/LinuxBoot/Kconfig
+++ b/payloads/external/LinuxBoot/Kconfig
@@ -1,7 +1,3 @@
-##
-## Copyright (C) 2017 Facebook Inc.
-## Copyright (C) 2018 9elements Cyber Security
-##
## SPDX-License-Identifier: GPL-2.0-only
if PAYLOAD_LINUXBOOT
@@ -135,7 +131,6 @@ config LINUXBOOT_KERNEL_UIMAGE
endchoice
-
config LINUXBOOT_DTB_FILE
string "Compiled devicetree file"
depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV
diff --git a/payloads/external/LinuxBoot/Kconfig.name b/payloads/external/LinuxBoot/Kconfig.name
index 013873269f..4d3decd923 100644
--- a/payloads/external/LinuxBoot/Kconfig.name
+++ b/payloads/external/LinuxBoot/Kconfig.name
@@ -1,6 +1,3 @@
-##
-## Copyright (C) 2017 Facebook Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
config PAYLOAD_LINUXBOOT
diff --git a/payloads/external/LinuxBoot/Makefile b/payloads/external/LinuxBoot/Makefile
index 45b1764932..c91b1d43da 100644
--- a/payloads/external/LinuxBoot/Makefile
+++ b/payloads/external/LinuxBoot/Makefile
@@ -1,7 +1,3 @@
-##
-## Copyright (C) 2017 Facebook Inc.
-## Copyright (C) 2018 9elements Cyber Security
-##
## SPDX-License-Identifier: GPL-2.0-only
project_dir=linuxboot
diff --git a/payloads/external/LinuxBoot/targets/linux.mk b/payloads/external/LinuxBoot/targets/linux.mk
index 5dec401e1a..990672936d 100644
--- a/payloads/external/LinuxBoot/targets/linux.mk
+++ b/payloads/external/LinuxBoot/targets/linux.mk
@@ -1,7 +1,3 @@
-##
-## Copyright (C) 2017 Facebook Inc.
-## Copyright (C) 2018 9elements Cyber Security
-##
## SPDX-License-Identifier: GPL-2.0-only
SHELL := /bin/bash
diff --git a/payloads/external/LinuxBoot/targets/u-root.mk b/payloads/external/LinuxBoot/targets/u-root.mk
index 07c453d65b..0cf91fec5b 100644
--- a/payloads/external/LinuxBoot/targets/u-root.mk
+++ b/payloads/external/LinuxBoot/targets/u-root.mk
@@ -1,7 +1,3 @@
-##
-## Copyright (C) 2017 Facebook Inc.
-## Copyright (C) 2018 9elements Cyber Security
-##
## SPDX-License-Identifier: GPL-2.0-only
project_dir=$(shell pwd)/linuxboot
diff --git a/payloads/external/Makefile.inc b/payloads/external/Makefile.inc
index ef0990c9b7..9c1a569c09 100644
--- a/payloads/external/Makefile.inc
+++ b/payloads/external/Makefile.inc
@@ -1,10 +1,3 @@
-################################################################################
-##
-##
-## Copyright (C) 2009-2010 coresystems GmbH
-## Copyright (C) 2015 Google Inc.
-## Copyright (C) 2017 Facebook Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
# set up payload config and version files for later inclusion
@@ -106,6 +99,29 @@ bootorder-file := $(strip $(CONFIG_SEABIOS_BOOTORDER_FILE))
bootorder-type := raw
endif
+ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),)
+ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),0)
+$(call add_intermediate, seabios_ps2_timeout, $(obj)/coreboot.pre $(CBFSTOOL))
+ @printf " SeaBIOS Wait up to $(CONFIG_SEABIOS_PS2_TIMEOUT) ms for PS/2 keyboard controller initialization\n"
+ $(if $(CONFIG_UPDATE_IMAGE),-$(CBFSTOOL) $< remove -n etc/ps2-keyboard-spinup 2>/dev/null)
+ $(CBFSTOOL) $< add-int -i $(CONFIG_SEABIOS_PS2_TIMEOUT) -n etc/ps2-keyboard-spinup
+endif
+endif
+
+ifeq ($(CONFIG_SEABIOS_ADD_SERCON_PORT_FILE),y)
+$(call add_intermediate, seabios_sercon, $(obj)/coreboot.pre $(CBFSTOOL))
+ @printf " SeaBIOS Add sercon-port file\n"
+ $(if $(CONFIG_UPDATE_IMAGE),-$(CBFSTOOL) $< remove -n etc/sercon-port 2>/dev/null)
+ $(CBFSTOOL) $< add-int -i $(CONFIG_SEABIOS_SERCON_PORT_ADDR) -n etc/sercon-port
+endif
+
+ifeq ($(CONFIG_SEABIOS_THREAD_OPTIONROMS),y)
+$(call add_intermediate, seabios_thread_optionroms, $(obj)/coreboot.pre $(CBFSTOOL))
+ @printf " SeaBIOS Thread optionroms\n"
+ $(if $(CONFIG_UPDATE_IMAGE),-$(CBFSTOOL) $< remove -n etc/threads 2>/dev/null)
+ $(CBFSTOOL) $< add-int -i 2 -n etc/threads
+endif
+
# Depthcharge
payloads/external/depthcharge/depthcharge/build/depthcharge.elf depthcharge: $(DOTCONFIG) $(CBFSTOOL)
@@ -132,6 +148,7 @@ payloads/external/tianocore/tianocore/Build/UEFIPAYLOAD.fd tianocore: $(DOTCONFI
CONFIG_TIANOCORE_UEFIPAYLOAD=$(CONFIG_TIANOCORE_UEFIPAYLOAD) \
CONFIG_TIANOCORE_COREBOOTPAYLOAD=$(CONFIG_TIANOCORE_COREBOOTPAYLOAD) \
CONFIG_MMCONF_BASE_ADDRESS=$(CONFIG_MMCONF_BASE_ADDRESS) \
+ CONFIG_TIANOCORE_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT) \
GCC_CC_x86_32=$(GCC_CC_x86_32) \
GCC_CC_x86_64=$(GCC_CC_x86_64) \
GCC_CC_arm=$(GCC_CC_arm) \
@@ -303,3 +320,8 @@ payloads/external/Yabits/uefi/build/uefi.elf yabits:
CONFIG_YABITS_MASTER=$(CONFIG_YABITS_MASTER) \
CONFIG_YABITS_STABLE=$(CONFIG_YABITS_STABLE) \
MFLAGS= MAKEFLAGS=
+
+# BOOTBOOT
+
+payloads/external/BOOTBOOT/bootboot/dist/bootbootcb.elf:
+ $(MAKE) -C payloads/external/BOOTBOOT all
diff --git a/payloads/external/Memtest86Plus/Makefile b/payloads/external/Memtest86Plus/Makefile
index 5aec5c8156..3853cb9586 100644
--- a/payloads/external/Memtest86Plus/Makefile
+++ b/payloads/external/Memtest86Plus/Makefile
@@ -1,7 +1,3 @@
-##
-##
-## Copyright (C) 2016 Google Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
TAG-$(CONFIG_MEMTEST_MASTER)=origin/master
diff --git a/payloads/external/SeaBIOS/Kconfig b/payloads/external/SeaBIOS/Kconfig
index 21e47206f4..9aea2d012b 100644
--- a/payloads/external/SeaBIOS/Kconfig
+++ b/payloads/external/SeaBIOS/Kconfig
@@ -5,7 +5,7 @@ choice
default SEABIOS_STABLE
config SEABIOS_STABLE
- bool "1.13.0"
+ bool "1.14.0"
help
Stable SeaBIOS version
config SEABIOS_MASTER
diff --git a/payloads/external/SeaBIOS/Makefile b/payloads/external/SeaBIOS/Makefile
index cd646d9d73..cdcd426770 100644
--- a/payloads/external/SeaBIOS/Makefile
+++ b/payloads/external/SeaBIOS/Makefile
@@ -1,5 +1,5 @@
TAG-$(CONFIG_SEABIOS_MASTER)=origin/master
-TAG-$(CONFIG_SEABIOS_STABLE)=f21b5a4aeb020f2a5e2c6503f906a9349dd2f069
+TAG-$(CONFIG_SEABIOS_STABLE)=155821a1990b6de78dde5f98fa5ab90e802021e0
TAG-$(CONFIG_SEABIOS_REVISION)=$(CONFIG_SEABIOS_REVISION_ID)
project_git_repo=https://review.coreboot.org/seabios.git
diff --git a/payloads/external/U-Boot/Makefile b/payloads/external/U-Boot/Makefile
index 6d186ad1c9..38dfe99a0e 100644
--- a/payloads/external/U-Boot/Makefile
+++ b/payloads/external/U-Boot/Makefile
@@ -1,7 +1,3 @@
-##
-##
-## Copyright (C) 2015 Google Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
# 2019-4 tag
diff --git a/payloads/external/Yabits/Makefile b/payloads/external/Yabits/Makefile
index 74f00efa65..adac77e810 100644
--- a/payloads/external/Yabits/Makefile
+++ b/payloads/external/Yabits/Makefile
@@ -1,7 +1,3 @@
-##
-##
-## Copyright (C) 2016 Google Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
TAG-$(CONFIG_YABITS_MASTER)=origin/master
diff --git a/payloads/external/iPXE/Kconfig b/payloads/external/iPXE/Kconfig
index 0b81d183e9..6c8049a3d7 100644
--- a/payloads/external/iPXE/Kconfig
+++ b/payloads/external/iPXE/Kconfig
@@ -1,5 +1,3 @@
-##
-##
## SPDX-License-Identifier: GPL-2.0-only
config PXE
diff --git a/payloads/external/iPXE/Makefile b/payloads/external/iPXE/Makefile
index 2a9e8c9b64..3e12f611a1 100644
--- a/payloads/external/iPXE/Makefile
+++ b/payloads/external/iPXE/Makefile
@@ -1,7 +1,3 @@
-##
-##
-## Copyright (C) 2016 Google Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
# 2019.3 - Last commit of March 2019
diff --git a/payloads/external/tianocore/Kconfig b/payloads/external/tianocore/Kconfig
index 7d5f038ebd..87b6e15582 100644
--- a/payloads/external/tianocore/Kconfig
+++ b/payloads/external/tianocore/Kconfig
@@ -100,4 +100,12 @@ config TIANOCORE_BOOTSPLASH_FILE
If an absolute path is not given, the path will assumed to be
relative to the coreboot root directory.
+config TIANOCORE_BOOT_TIMEOUT
+ int
+ default 2
+ help
+ The length of time in seconds for which the boot splash/menu prompt will be displayed.
+ For boards with an internal display, the default value of 2s is generally sufficient.
+ For boards without an internal display, a value of 5s is generally sufficient.
+
endif
diff --git a/payloads/external/tianocore/Makefile b/payloads/external/tianocore/Makefile
index 9945411880..198c17f6fe 100644
--- a/payloads/external/tianocore/Makefile
+++ b/payloads/external/tianocore/Makefile
@@ -1,7 +1,3 @@
-##
-##
-## Copyright (C) 2017 Google Inc.
-##
## SPDX-License-Identifier: GPL-2.0-only
# force the shell to bash - the edksetup.sh script doesn't work with dash
@@ -41,12 +37,16 @@ ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y)
TIMER=-DUSE_HPET_TIMER
endif
+TIMEOUT=-D PLATFORM_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT)
+
ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y)
- BUILD_STR=-q -a IA32 -t COREBOOT -p $(bootloader)/$(bootloader)Ia32.dsc -b $(BUILD_TYPE) $(TIMER) $(build_flavor)
+ARCH=-a IA32 -p $(bootloader)/$(bootloader)Ia32.dsc
else
- BUILD_STR=-q -a IA32 -a X64 -t COREBOOT -p $(bootloader)/$(bootloader)Ia32X64.dsc -b $(BUILD_TYPE) $(TIMER) $(build_flavor)
+ARCH=-a IA32 -a X64 -p $(bootloader)/$(bootloader)Ia32X64.dsc
endif
+BUILD_STR=-q $(ARCH) -t COREBOOT -b $(BUILD_TYPE) $(TIMER) $(TIMEOUT) $(build_flavor)
+
all: clean build
$(project_dir):
diff --git a/payloads/external/tint/Makefile b/payloads/external/tint/Makefile
index 253bfea9dd..9473c02c57 100644
--- a/payloads/external/tint/Makefile
+++ b/payloads/external/tint/Makefile
@@ -18,9 +18,9 @@ patch: download
cd tint; \
if [ -e debian ]; then \
rm -rf debian typedefs.h Makefile; \
- touch Makefile; \
- patch -l -p1 < ../libpayload_tint.patch; \
- fi
+ touch Makefile; \
+ patch -l -p1 < ../libpayload_tint.patch; \
+ fi
download:
test -d tint || { wget $(project_url); \
diff --git a/payloads/libpayload/.gitignore b/payloads/libpayload/.gitignore
new file mode 100644
index 0000000000..c7b20fc357
--- /dev/null
+++ b/payloads/libpayload/.gitignore
@@ -0,0 +1 @@
+install/
diff --git a/payloads/libpayload/Kconfig b/payloads/libpayload/Kconfig
index b5dc9a3c8b..7a502b5853 100644
--- a/payloads/libpayload/Kconfig
+++ b/payloads/libpayload/Kconfig
@@ -79,6 +79,14 @@ config COMPILER_LLVM_CLANG
endchoice
+config LTO
+ bool "Use link time optimization (LTO)"
+ default n
+ depends on COMPILER_GCC
+ help
+ Compile with link time optimization. This can often decrease the
+ final binary size, but may increase compilation time.
+
config REMOTEGDB
bool "Remote GDB stub"
default n
@@ -367,10 +375,6 @@ config PC_KEYBOARD
default y if ARCH_X86 # uses IO
default n
-config PC_KEYBOARD_AT_TRANSLATED
- bool "AT Translation keyboard device"
- default n
-
config PC_KEYBOARD_LAYOUT_US
bool "English (US) keyboard layout"
depends on PC_KEYBOARD
diff --git a/payloads/libpayload/Makefile b/payloads/libpayload/Makefile
index b5687c3859..0b08c70af7 100644
--- a/payloads/libpayload/Makefile
+++ b/payloads/libpayload/Makefile
@@ -118,6 +118,11 @@ NOCOMPILE:=1
endif
endif
+xcompile ?= $(obj)/xcompile
+$(xcompile): $(top)/../../util/xcompile/xcompile
+ $< $(XGCCPATH) > $@.tmp
+ \mv -f $@.tmp $@ 2> /dev/null
+
ifeq ($(NOCOMPILE),1)
include $(TOPLEVEL)/Makefile.inc
real-all: config
@@ -126,13 +131,17 @@ else
# in addition to the dependency below, create the file if it doesn't exist
# to silence stupid warnings about a file that would be generated anyway.
-$(if $(wildcard .xcompile)$(NOCOMPILE),,$(eval $(shell $(top)/../../util/xcompile/xcompile $(XGCCPATH) > .xcompile)))
+$(if $(wildcard $(xcompile)),,$(shell \
+ mkdir -p $(dir $(xcompile)) && \
+ $(top)/../../util/xcompile/xcompile $(XGCCPATH) > $(xcompile) || rm -f $(xcompile)))
-.xcompile: $(top)/../../util/xcompile/xcompile
- $< $(XGCCPATH) > $@.tmp
- \mv -f $@.tmp $@ 2> /dev/null
+include $(xcompile)
--include .xcompile
+ifneq ($(XCOMPILE_COMPLETE),1)
+$(shell rm -f $(xcompile))
+$(error $(xcompile) deleted because it's invalid. \
+ Restarting the build should fix that, or explain the problem)
+endif
CC := $(CC_$(ARCH-y))
AS := $(AS_$(ARCH-y))
@@ -294,7 +303,7 @@ doxygen-clean:
rm -rf $(DOXYGEN_OUTPUT_DIR)
clean-for-update: doxygen-clean clean-for-update-target
- rm -f $(allobjs) .xcompile
+ rm -f $(allobjs) $(xcompile)
rm -f $(DEPENDENCIES)
rmdir -p $(alldirs) 2>/dev/null >/dev/null || true
diff --git a/payloads/libpayload/Makefile.inc b/payloads/libpayload/Makefile.inc
index 2acf2266da..fc679dd27e 100644
--- a/payloads/libpayload/Makefile.inc
+++ b/payloads/libpayload/Makefile.inc
@@ -55,7 +55,8 @@ subdirs-$(CONFIG_LP_CBFS) += libcbfs
subdirs-$(CONFIG_LP_LZMA) += liblzma
subdirs-$(CONFIG_LP_LZ4) += liblz4
-INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj) -include include/kconfig.h
+INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
+INCLUDES += -include include/kconfig.h -include include/compiler.h
CFLAGS += $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc -ggdb3
CFLAGS += -nostdlib -fno-builtin -ffreestanding -fomit-frame-pointer
@@ -64,7 +65,14 @@ CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wvla
CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wimplicit-fallthrough
CFLAGS += -Wstrict-aliasing -Wshadow -Werror
-$(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
+ifeq ($(CONFIG_LP_LTO),y)
+CFLAGS += -flto
+endif
+
+$(obj)/libpayload.config: $(DOTCONFIG)
+ cp $< $@
+
+$(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER) $(obj)/libpayload.config
cmp $@ $< 2>/dev/null || cp $< $@
library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
@@ -116,7 +124,7 @@ install: real-target
install -m 755 bin/lpas $(DESTDIR)/libpayload/bin
install -m 644 bin/lp.functions $(DESTDIR)/libpayload/bin
install -m 644 $(DOTCONFIG) $(DESTDIR)/libpayload/libpayload.config
- install -m 755 .xcompile $(DESTDIR)/libpayload/libpayload.xcompile
+ install -m 755 $(xcompile) $(DESTDIR)/libpayload/libpayload.xcompile
clean-for-update-target:
rm -f $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
diff --git a/payloads/libpayload/arch/arm/cpu.S b/payloads/libpayload/arch/arm/cpu.S
index 4a1d41dc4d..a5ff12dc3d 100644
--- a/payloads/libpayload/arch/arm/cpu.S
+++ b/payloads/libpayload/arch/arm/cpu.S
@@ -81,7 +81,7 @@
lsl ip, ip, r2 @ shift by that into way position
mov r0, #1
lsl r2, r0, r2 @ r2 now contains the way decr
- mov r0, r3 @ get sets/level (no way yet)
+ mov r0, r3 @ get sets/level (no way yet)
orr r3, r3, ip @ merge way into way/set/level
bfc r0, #0, #4 @ clear low 4 bits (level) to get numset - 1
sub r2, r2, r0 @ subtract from way decr
diff --git a/payloads/libpayload/arch/arm64/mmu.c b/payloads/libpayload/arch/arm64/mmu.c
index 1fa9ced1be..bc4c233479 100644
--- a/payloads/libpayload/arch/arm64/mmu.c
+++ b/payloads/libpayload/arch/arm64/mmu.c
@@ -625,14 +625,10 @@ static void mmu_extract_ranges(struct memrange *cb_ranges,
static void mmu_add_fb_range(struct mmu_ranges *mmu_ranges)
{
struct mmu_memrange *fb_range;
- static struct cb_framebuffer modified_fb;
- struct cb_framebuffer *framebuffer = lib_sysinfo.framebuffer;
+ struct cb_framebuffer *framebuffer = &lib_sysinfo.framebuffer;
uint32_t fb_size;
/* Check whether framebuffer is needed */
- if (framebuffer == NULL)
- return;
-
fb_size = framebuffer->bytes_per_line * framebuffer->y_resolution;
if (!fb_size)
return;
@@ -652,16 +648,7 @@ static void mmu_add_fb_range(struct mmu_ranges *mmu_ranges)
if (fb_range == NULL)
mmu_error();
- /*
- * Set framebuffer address. However, one needs to use a freshly
- * allocated framebuffer structure because the one in the coreboot
- * table is part of a checksum calculation. Therefore, one cannot
- * modify a field without recomputing the necessary checksum
- * calcuation.
- */
- modified_fb = *framebuffer;
- modified_fb.physical_address = fb_range->base;
- lib_sysinfo.framebuffer = &modified_fb;
+ framebuffer->physical_address = fb_range->base;
}
/*
@@ -718,3 +705,8 @@ void mmu_presysinfo_enable(void)
mmu_init(&usedmem_ranges);
mmu_enable();
}
+
+const struct mmu_ranges *mmu_get_used_ranges(void)
+{
+ return &usedmem_ranges;
+}
diff --git a/payloads/libpayload/arch/arm64/virtual.c b/payloads/libpayload/arch/arm64/virtual.c
index 2d336e301e..9450ac0d86 100644
--- a/payloads/libpayload/arch/arm64/virtual.c
+++ b/payloads/libpayload/arch/arm64/virtual.c
@@ -30,7 +30,6 @@
unsigned long virtual_offset = 0;
-
int getpagesize(void)
{
return 4096;
diff --git a/payloads/libpayload/arch/x86/Kconfig b/payloads/libpayload/arch/x86/Kconfig
index 2be47bc0ce..05cf58b446 100644
--- a/payloads/libpayload/arch/x86/Kconfig
+++ b/payloads/libpayload/arch/x86/Kconfig
@@ -52,5 +52,4 @@ config DIE_ON_UNKNOWN_INTERRUPT
endchoice
-
endif
diff --git a/payloads/libpayload/arch/x86/apic.c b/payloads/libpayload/arch/x86/apic.c
index 62011612a5..e0671064c8 100644
--- a/payloads/libpayload/arch/x86/apic.c
+++ b/payloads/libpayload/arch/x86/apic.c
@@ -127,7 +127,6 @@ void apic_start_delay(unsigned int usec)
enable_interrupts();
}
-
void apic_wait_delay(void)
{
/* Loop in case another interrupt has fired and resumed execution. */
diff --git a/payloads/libpayload/arch/x86/coreboot.c b/payloads/libpayload/arch/x86/coreboot.c
index bf16b71f97..38ede875c7 100644
--- a/payloads/libpayload/arch/x86/coreboot.c
+++ b/payloads/libpayload/arch/x86/coreboot.c
@@ -49,7 +49,7 @@ static void cb_parse_x86_rom_var_mtrr(void *ptr, struct sysinfo_t *info)
static void cb_parse_mrc_cache(void *ptr, struct sysinfo_t *info)
{
- info->mrc_cache = get_cbmem_ptr(ptr);
+ info->mrc_cache = get_cbmem_addr(ptr);
}
int cb_parse_arch_specific(struct cb_record *rec, struct sysinfo_t *info)
diff --git a/payloads/libpayload/arch/x86/delay.c b/payloads/libpayload/arch/x86/delay.c
index df2c0ac9ba..373c8417b3 100644
--- a/payloads/libpayload/arch/x86/delay.c
+++ b/payloads/libpayload/arch/x86/delay.c
@@ -38,7 +38,6 @@
/* Let's assume APIC interrupts take at least 100us */
#define APIC_INTERRUPT_LATENCY_NS (100 * NSECS_PER_USEC)
-
void arch_ndelay(uint64_t ns)
{
uint64_t delta = ns * timer_hz() / NSECS_PER_SEC;
diff --git a/payloads/libpayload/arch/x86/sysinfo.c b/payloads/libpayload/arch/x86/sysinfo.c
index ffa57bb08f..5dd606746f 100644
--- a/payloads/libpayload/arch/x86/sysinfo.c
+++ b/payloads/libpayload/arch/x86/sysinfo.c
@@ -78,5 +78,10 @@ int lib_get_sysinfo(void)
lib_sysinfo.memrange[1].type = CB_MEM_RAM;
}
+#if CONFIG(LP_PCI)
+ pci_init(&lib_sysinfo.pacc);
+ pci_scan_bus(&lib_sysinfo.pacc);
+#endif
+
return ret;
}
diff --git a/payloads/libpayload/arch/x86/timer.c b/payloads/libpayload/arch/x86/timer.c
index 1ff2cd6d55..6dcfd5b27f 100644
--- a/payloads/libpayload/arch/x86/timer.c
+++ b/payloads/libpayload/arch/x86/timer.c
@@ -33,6 +33,10 @@
#include
#include
+#include
+#include
+
+#define MSR_PLATFORM_INFO 0xce
/**
* @ingroup arch
@@ -41,11 +45,11 @@
uint32_t cpu_khz;
/**
- * Calculate the speed of the processor for use in delays.
+ * @brief Measure the speed of the processor for use in delays
*
* @return The CPU speed in kHz.
*/
-unsigned int get_cpu_speed(void)
+static unsigned int calibrate_pit(void)
{
unsigned long long start, end;
const uint32_t clock_rate = 1193182; // 1.193182 MHz
@@ -71,7 +75,116 @@ unsigned int get_cpu_speed(void)
* clock_rate / (interval * 1000). Multiply that by the number of
* measured clocks to get the kHz value.
*/
- cpu_khz = (end - start) * clock_rate / (1000 * interval);
+ return (end - start) * clock_rate / (1000 * interval);
+}
+
+/**
+ * @brief Calculates the core clock frequency via CPUID 0x15
+ *
+ * Newer Intel CPUs report their core clock in CPUID leaf 0x15. Early models
+ * supporting this leaf didn't provide the nominal crystal frequency in ecx,
+ * hence we use hard coded values for them.
+ */
+static int get_cpu_khz_xtal(void)
+{
+ uint32_t ecx, edx, num, denom;
+ uint64_t nominal;
+
+ if (cpuid_max() < 0x15)
+ return -1;
+ cpuid(0x15, denom, num, ecx, edx);
+
+ if (denom == 0 || num == 0)
+ return -1;
+
+ if (ecx != 0) {
+ nominal = ecx;
+ } else {
+ if (cpuid_family() != 6)
+ return -1;
+
+ switch (cpuid_model()) {
+ case SKYLAKE_U_Y:
+ case SKYLAKE_S_H:
+ case KABYLAKE_U_Y:
+ case KABYLAKE_S_H:
+ nominal = 24000000;
+ break;
+ case APOLLOLAKE:
+ nominal = 19200000;
+ break;
+ default:
+ return -1;
+ }
+ }
+
+ return nominal * num / denom / 1000;
+}
+
+/**
+ * @brief Returns three times the bus clock in kHz
+ *
+ * The result of calculations with the returned value shall be divided by 3.
+ * This helps to avoid rounding errors.
+ */
+static int get_bus_khz_x3(void)
+{
+ if (cpuid_family() != 6)
+ return -1;
+
+ switch (cpuid_model()) {
+ case NEHALEM:
+ return 400 * 1000; /* 133 MHz */
+ case SANDYBRIDGE:
+ case IVYBRIDGE:
+ case HASWELL:
+ case HASWELL_U:
+ case HASWELL_GT3E:
+ case BROADWELL:
+ case BROADWELL_U:
+ return 300 * 1000; /* 100 MHz */
+ default:
+ return -1;
+ }
+}
+
+/**
+ * @brief Returns the calculated CPU frequency
+ *
+ * Over the years, multiple ways to discover the CPU frequency have been
+ * exposed through CPUID and MSRs. Try the most recent and accurate first
+ * (crystal information in CPUID leaf 0x15) and then fall back to older
+ * methods.
+ *
+ * This should cover all Intel Core i processors at least. For older
+ * processors we fall back to the PIT calibration.
+ */
+static int get_cpu_khz_fast(void)
+{
+ /* Try core crystal clock frequency first (supposed to be more accurate). */
+ const int cpu_khz_xtal = get_cpu_khz_xtal();
+ if (cpu_khz_xtal > 0)
+ return cpu_khz_xtal;
+
+ /* Try `bus clock * speedstep multiplier`. */
+ const int bus_x3 = get_bus_khz_x3();
+ if (bus_x3 <= 0)
+ return -1;
+ /*
+ * Systems with an invariant TSC report the multiplier (maximum
+ * non-turbo ratio) in MSR_PLATFORM_INFO[15:8].
+ */
+ const unsigned int mult = _rdmsr(MSR_PLATFORM_INFO) >> 8 & 0xff;
+ return bus_x3 * mult / 3;
+}
+
+unsigned int get_cpu_speed(void)
+{
+ const int cpu_khz_fast = get_cpu_khz_fast();
+ if (cpu_khz_fast > 0)
+ cpu_khz = (unsigned int)cpu_khz_fast;
+ else
+ cpu_khz = calibrate_pit();
return cpu_khz;
}
diff --git a/payloads/libpayload/arch/x86/virtual.c b/payloads/libpayload/arch/x86/virtual.c
index 2d336e301e..9450ac0d86 100644
--- a/payloads/libpayload/arch/x86/virtual.c
+++ b/payloads/libpayload/arch/x86/virtual.c
@@ -30,7 +30,6 @@
unsigned long virtual_offset = 0;
-
int getpagesize(void)
{
return 4096;
diff --git a/payloads/libpayload/bin/lp.functions b/payloads/libpayload/bin/lp.functions
index 3911c42a5b..fd26956243 100644
--- a/payloads/libpayload/bin/lp.functions
+++ b/payloads/libpayload/bin/lp.functions
@@ -35,6 +35,10 @@ warn() {
echo "Warning: $1"
}
+# For in-tree builds, allow to override the libpayload build dir.
+
+_OBJ=${_OBJ:-$BASE/../build}
+
# If the user didn't specify LIBPAYLOAD_PREFIX, then preload it
# with the default prefix value
@@ -48,8 +52,8 @@ fi
if [ -f $BASE/../lib/libpayload.a ]; then
_LIBDIR=$BASE/../lib
-elif [ -f $BASE/../build/libpayload.a ]; then
- _LIBDIR=$BASE/../build
+elif [ -f $_OBJ/libpayload.config ]; then
+ _LIBDIR=$_OBJ
else
_LIBDIR=$LIBPAYLOAD_PREFIX/lib
fi
diff --git a/payloads/libpayload/bin/lpgcc b/payloads/libpayload/bin/lpgcc
index 2657a1a1b1..c0fe56adf5 100755
--- a/payloads/libpayload/bin/lpgcc
+++ b/payloads/libpayload/bin/lpgcc
@@ -57,11 +57,17 @@ BASE=`dirname $0`
# This will set the _LIBDIR and _INCDIR variables used below
. $BASE/lp.functions
+if [ $_LIBDIR != $_OBJ ]; then
+ _DOTCONFIG=$BASE/../libpayload.config
+ _XCOMPILE=$BASE/../libpayload.xcompile
+else
+ _DOTCONFIG=$_OBJ/libpayload.config
+ _XCOMPILE=$_OBJ/xcompile
+fi
+
# include libpayload config
-if [ -f $BASE/../libpayload.config ]; then
- . $BASE/../libpayload.config
-elif [ -f $BASE/../.config ]; then
- . $BASE/../.config
+if [ -f $_DOTCONFIG ]; then
+ . $_DOTCONFIG
else
echo "Can't find config"
exit 1
@@ -137,14 +143,19 @@ while [ $# -gt 0 ]; do
shift
done
-_CFLAGS="$_ARCHEXTRA -nostdinc -nostdlib -I$BASE/../build -I$_INCDIR -I$_ARCHINCDIR -D__LIBPAYLOAD__=1"
+_CFLAGS="$_ARCHEXTRA -nostdinc -nostdlib -I$_INCDIR -I$_ARCHINCDIR -D__LIBPAYLOAD__=1"
-if [ "$CONFIG_LP_PDCURSES" = y ]; then
- _CFLAGS="$_CFLAGS -I$BASE/../curses/PDCurses"
-fi
+if [ $_LIBDIR = $_OBJ ]; then
+ _CFLAGS="$_CFLAGS -I$_OBJ"
-if [ "$CONFIG_LP_TINYCURSES" = y ]; then
- _CFLAGS="$_CFLAGS -I$BASE/../curses"
+ if [ "$CONFIG_LP_PDCURSES" = y ]; then
+ _CFLAGS="$_CFLAGS -I$BASE/../curses/PDCurses -I$BASE/../curses/pdcurses-backend"
+ _CFLAGS="$_CFLAGS -I$BASE/../curses/form -I$BASE/../curses/menu"
+ fi
+
+ if [ "$CONFIG_LP_TINYCURSES" = y ]; then
+ _CFLAGS="$_CFLAGS -I$BASE/../curses"
+ fi
fi
# Check for the -fno-stack-protector silliness
@@ -152,9 +163,10 @@ fi
trygccoption -fno-stack-protector
[ $? -eq 0 ] && _CFLAGS="$_CFLAGS -fno-stack-protector"
-_CFLAGS="$_CFLAGS -include $BASE/../include/kconfig.h -I`$DEFAULT_CC $_ARCHEXTRA -print-search-dirs | head -n 1 | cut -d' ' -f2`include"
+_CFLAGS="$_CFLAGS -include $BASE/../include/kconfig.h -include $BASE/../include/compiler.h"
+_CFLAGS="$_CFLAGS -I`$DEFAULT_CC $_ARCHEXTRA -print-search-dirs | head -n 1 | cut -d' ' -f2`include"
-_LDFLAGS="-L$BASE/../lib -L$_LIBDIR $_LDSCRIPT -static"
+_LDFLAGS="-L$_LIBDIR $_LDSCRIPT -static"
if [ $DOLINK -eq 0 ]; then
if [ $DEBUGME -eq 1 ]; then
@@ -166,15 +178,15 @@ else
_LIBGCC=`$DEFAULT_CC $_ARCHEXTRA -print-libgcc-file-name`
if [ -f $_ARCHLIBDIR/head.o ]; then
HEAD_O=$_ARCHLIBDIR/head.o
- elif [ -f $BASE/../build/head.o ]; then
- HEAD_O=$BASE/../build/head.o
+ elif [ -f $_OBJ/head.o ]; then
+ HEAD_O=$_OBJ/head.o
else
echo "Could not find head.o"
exit 1
fi
- if grep -q ARM64_A53_ERRATUM_843419=y $BASE/../libpayload.config &&
- grep -q fix-cortex-a53-843419 $BASE/../libpayload.xcompile; then
+ if [ "$CONFIG_LP_ARM64_A53_ERRATUM_843419" = y ] &&
+ grep -q fix-cortex-a53-843419 $_XCOMPILE; then
_LDFLAGS="$_LDFLAGS -Wl,--fix-cortex-a53-843419"
fi
diff --git a/payloads/libpayload/configs/config.cheza b/payloads/libpayload/configs/config.cheza
deleted file mode 100644
index 5f60392fdb..0000000000
--- a/payloads/libpayload/configs/config.cheza
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_LP_CHROMEOS=y
-CONFIG_LP_ARCH_ARM64=y
-CONFIG_LP_TIMER_ARM64_ARCH=y
diff --git a/payloads/libpayload/configs/defconfig b/payloads/libpayload/configs/defconfig
index 896039ea0b..4ef1ed15b7 100644
--- a/payloads/libpayload/configs/defconfig
+++ b/payloads/libpayload/configs/defconfig
@@ -5,4 +5,4 @@ CONFIG_LP_USB_UHCI=y
CONFIG_LP_USB_OHCI=y
CONFIG_LP_USB_EHCI=y
CONFIG_LP_USB_XHCI=y
-CONFIG_LP_HEAP_SIZE=262144
+CONFIG_LP_HEAP_SIZE=1048576
diff --git a/payloads/libpayload/crypto/sha1.c b/payloads/libpayload/crypto/sha1.c
index fce96a3463..5f54431a82 100644
--- a/payloads/libpayload/crypto/sha1.c
+++ b/payloads/libpayload/crypto/sha1.c
@@ -115,7 +115,6 @@ SHA1Transform(u_int32_t state[5], const u_int8_t buffer[SHA1_BLOCK_LENGTH])
a = b = c = d = e = 0;
}
-
/*
* SHA1Init - Initialize new context
*/
@@ -132,7 +131,6 @@ SHA1Init(SHA1_CTX *context)
context->state[4] = 0xC3D2E1F0;
}
-
/*
* Run your data through this.
*/
@@ -155,7 +153,6 @@ SHA1Update(SHA1_CTX *context, const u_int8_t *data, size_t len)
(void)memcpy(&context->buffer[j], &data[i], len - i);
}
-
/*
* Add padding and return the message digest.
*/
diff --git a/payloads/libpayload/curses/PDCurses/curses.h b/payloads/libpayload/curses/PDCurses/curses.h
index 5f651fef44..45245ae0b1 100644
--- a/payloads/libpayload/curses/PDCurses/curses.h
+++ b/payloads/libpayload/curses/PDCurses/curses.h
@@ -41,6 +41,7 @@ PDCurses portable platform definitions list:
/*----------------------------------------------------------------------*/
#include
+#include
#include
#include /* Required by X/Open usage below */
@@ -48,12 +49,6 @@ PDCurses portable platform definitions list:
# include
#endif
-#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
-extern "C"
-{
-# define bool _bool
-#endif
-
/*----------------------------------------------------------------------
*
* PDCurses Manifest Constants
@@ -82,8 +77,6 @@ extern "C"
*
*/
-typedef unsigned char bool; /* PDCurses Boolean type */
-
#ifdef CHTYPE_LONG
# if _LP64
typedef unsigned int chtype;
diff --git a/payloads/libpayload/curses/PDCurses/demos/tui.c b/payloads/libpayload/curses/PDCurses/demos/tui.c
index 62e0d53767..41f34ba410 100644
--- a/payloads/libpayload/curses/PDCurses/demos/tui.c
+++ b/payloads/libpayload/curses/PDCurses/demos/tui.c
@@ -46,14 +46,12 @@ void rmerror(void);
# define EDITBOXCOLOR (A_BOLD | A_REVERSE)
#endif
-
#define th 1 /* title window height */
#define mh 1 /* main menu height */
#define sh 2 /* status window height */
#define bh (LINES - th - mh - sh) /* body window height */
#define bw COLS /* body window width */
-
/******************************* STATIC ************************************/
static WINDOW *wtitl, *wmain, *wbody, *wstat; /* title, menu, body, status win*/
@@ -360,7 +358,6 @@ static void cleanup(void) /* cleanup curses settings */
}
}
-
/******************************* EXTERNAL **********************************/
void clsbody(void)
diff --git a/payloads/libpayload/curses/PDCurses/x11/ScrollBox.c b/payloads/libpayload/curses/PDCurses/x11/ScrollBox.c
index e77d2c78ce..b96a027282 100644
--- a/payloads/libpayload/curses/PDCurses/x11/ScrollBox.c
+++ b/payloads/libpayload/curses/PDCurses/x11/ScrollBox.c
@@ -116,7 +116,6 @@ ScrollBoxClassRec scrollBoxClassRec = {
WidgetClass scrollBoxWidgetClass = (WidgetClass)&scrollBoxClassRec;
-
/************************************************************************
* *
* Private Routines *
diff --git a/payloads/libpayload/curses/PDCurses/x11/ScrollBox.h b/payloads/libpayload/curses/PDCurses/x11/ScrollBox.h
index 5825862744..9ba7d67331 100644
--- a/payloads/libpayload/curses/PDCurses/x11/ScrollBox.h
+++ b/payloads/libpayload/curses/PDCurses/x11/ScrollBox.h
@@ -42,7 +42,6 @@
*/
-
/* Class record constants */
extern WidgetClass scrollBoxWidgetClass;
diff --git a/payloads/libpayload/curses/PDCurses/x11/ScrollBoxP.h b/payloads/libpayload/curses/PDCurses/x11/ScrollBoxP.h
index 44551386bc..902edeebb7 100644
--- a/payloads/libpayload/curses/PDCurses/x11/ScrollBoxP.h
+++ b/payloads/libpayload/curses/PDCurses/x11/ScrollBoxP.h
@@ -56,7 +56,6 @@ typedef struct {
XtGeometryMask last_query_mode;
} ScrollBoxPart;
-
/************************************************************************
* *
* Full instance record declaration *
diff --git a/payloads/libpayload/curses/PDCurses/x11/x11.c b/payloads/libpayload/curses/PDCurses/x11/x11.c
index 69c3199b54..46444d4471 100644
--- a/payloads/libpayload/curses/PDCurses/x11/x11.c
+++ b/payloads/libpayload/curses/PDCurses/x11/x11.c
@@ -276,7 +276,6 @@ static char *program_name;
#define RCOLOR(name, value) RPIXEL(color##name, Color##name, value)
-
#define RSTRINGP(name1, name2, param) { \
#name1, #name2, XtRString, \
MAX_PATH, APPDATAOFF(name1), XtRString, (XtPointer)param \
diff --git a/payloads/libpayload/curses/curses.h b/payloads/libpayload/curses/curses.h
index 1699250de6..b802adb3f4 100644
--- a/payloads/libpayload/curses/curses.h
+++ b/payloads/libpayload/curses/curses.h
@@ -87,7 +87,7 @@
* User-definable tweak to disable the include of .
*/
#ifndef NCURSES_ENABLE_STDBOOL_H
-#define NCURSES_ENABLE_STDBOOL_H 0 //// XXX
+#define NCURSES_ENABLE_STDBOOL_H 1
#endif
/*
diff --git a/payloads/libpayload/curses/curses.priv.h b/payloads/libpayload/curses/curses.priv.h
index 78b7ff3cc9..31ec80f1bb 100644
--- a/payloads/libpayload/curses/curses.priv.h
+++ b/payloads/libpayload/curses/curses.priv.h
@@ -32,7 +32,6 @@
* and: Thomas E. Dickey 1996-on *
****************************************************************************/
-
/*
* $Id: curses.priv.h,v 1.314 2006/12/10 00:55:14 tom Exp $
*
@@ -497,7 +496,6 @@ struct screen {
chtype * _acs_map; /* the real alternate-charset map */
bool * _screen_acs_map;
-
/* used in lib_vidattr.c */
bool _use_rmso; /* true if we may use 'rmso' */
bool _use_rmul; /* true if we may use 'rmul' */
@@ -980,7 +978,6 @@ extern NCURSES_EXPORT(void) name (void); \
}\
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
-
#define toggle_attr_off(S,at) {\
if (PAIR_NUMBER(at) > 0) {\
(S) &= ~(at|A_COLOR);\
diff --git a/payloads/libpayload/curses/form/form.h b/payloads/libpayload/curses/form/form.h
index d7bb85adf4..2f55e42591 100644
--- a/payloads/libpayload/curses/form/form.h
+++ b/payloads/libpayload/curses/form/form.h
@@ -106,7 +106,6 @@ typedef struct fieldnode {
NCURSES_FIELD_INTERNALS
} FIELD;
-
/*********
* FORM *
*********/
@@ -138,7 +137,6 @@ typedef struct formnode {
} FORM;
-
/**************
* FIELDTYPE *
**************/
diff --git a/payloads/libpayload/curses/menu/eti.h b/payloads/libpayload/curses/menu/eti.h
index baa6190d8f..152ada76ce 100644
--- a/payloads/libpayload/curses/menu/eti.h
+++ b/payloads/libpayload/curses/menu/eti.h
@@ -36,19 +36,19 @@
#define NCURSES_ETI_H_incl 1
#define E_OK (0)
-#define E_SYSTEM_ERROR (-1)
-#define E_BAD_ARGUMENT (-2)
-#define E_POSTED (-3)
-#define E_CONNECTED (-4)
-#define E_BAD_STATE (-5)
-#define E_NO_ROOM (-6)
+#define E_SYSTEM_ERROR (-1)
+#define E_BAD_ARGUMENT (-2)
+#define E_POSTED (-3)
+#define E_CONNECTED (-4)
+#define E_BAD_STATE (-5)
+#define E_NO_ROOM (-6)
#define E_NOT_POSTED (-7)
#define E_UNKNOWN_COMMAND (-8)
#define E_NO_MATCH (-9)
#define E_NOT_SELECTABLE (-10)
-#define E_NOT_CONNECTED (-11)
+#define E_NOT_CONNECTED (-11)
#define E_REQUEST_DENIED (-12)
-#define E_INVALID_FIELD (-13)
+#define E_INVALID_FIELD (-13)
#define E_CURRENT (-14)
#endif
diff --git a/payloads/libpayload/curses/menu/menu.h b/payloads/libpayload/curses/menu/menu.h
index 1fdd9e795d..1df980c551 100644
--- a/payloads/libpayload/curses/menu/menu.h
+++ b/payloads/libpayload/curses/menu/menu.h
@@ -132,7 +132,6 @@ typedef struct tagMENU
} MENU;
-
/* Define keys */
#define REQ_LEFT_ITEM (KEY_MAX + 1)
@@ -170,7 +169,6 @@ typedef struct tagMENU
# define MAX_COMMAND (KEY_MAX + 128)
#endif
-
/* --------- prototypes for libmenu functions ----------------------------- */
extern NCURSES_EXPORT(ITEM **) menu_items (const MENU *);
@@ -244,7 +242,6 @@ extern NCURSES_EXPORT(int) menu_request_by_name (const char *);
extern NCURSES_EXPORT(int) set_menu_spacing (MENU *,int,int,int);
extern NCURSES_EXPORT(int) menu_spacing (const MENU *,int *,int *,int *);
-
extern NCURSES_EXPORT(bool) item_value (const ITEM *);
extern NCURSES_EXPORT(bool) item_visible (const ITEM *);
diff --git a/payloads/libpayload/curses/menu/mf_common.h b/payloads/libpayload/curses/menu/mf_common.h
index 681672dc34..d40c7b9806 100644
--- a/payloads/libpayload/curses/menu/mf_common.h
+++ b/payloads/libpayload/curses/menu/mf_common.h
@@ -66,7 +66,6 @@ extern int errno;
#define MODULE_ID(id) /*nothing*/
#endif
-
/* Maximum regular 8-bit character code */
#define MAX_REGULAR_CHARACTER (0xff)
diff --git a/payloads/libpayload/curses/tinycurses.c b/payloads/libpayload/curses/tinycurses.c
index ffd9bd4769..d3bf84efab 100644
--- a/payloads/libpayload/curses/tinycurses.c
+++ b/payloads/libpayload/curses/tinycurses.c
@@ -163,7 +163,6 @@ chtype console_acs_map[128] =
// FIXME: Ugly (and insecure!) hack!
char sprintf_tmp[1024];
-
int curses_flags = (F_ENABLE_CONSOLE | F_ENABLE_SERIAL);
/* Return bit mask for clearing color pair number if given ch has color */
diff --git a/payloads/libpayload/drivers/cbmem_console.c b/payloads/libpayload/drivers/cbmem_console.c
index 053802cbd9..22d5312c3a 100644
--- a/payloads/libpayload/drivers/cbmem_console.c
+++ b/payloads/libpayload/drivers/cbmem_console.c
@@ -38,7 +38,7 @@ struct cbmem_console {
#define CURSOR_MASK ((1 << 28) - 1)
#define OVERFLOW (1 << 31)
-static struct cbmem_console *cbmem_console_p;
+static uintptr_t cbmem_console_p;
static struct console_output_driver cbmem_console_driver =
{
@@ -47,27 +47,32 @@ static struct console_output_driver cbmem_console_driver =
static void do_write(const void *buffer, size_t count)
{
- memcpy(cbmem_console_p->body + (cbmem_console_p->cursor & CURSOR_MASK),
- buffer, count);
- cbmem_console_p->cursor += count;
+ struct cbmem_console *const cbmem_cons = phys_to_virt(cbmem_console_p);
+
+ memcpy(cbmem_cons->body + (cbmem_cons->cursor & CURSOR_MASK), buffer, count);
+ cbmem_cons->cursor += count;
}
void cbmem_console_init(void)
{
+ const struct cbmem_console *const cbmem_cons = phys_to_virt(lib_sysinfo.cbmem_cons);
+
cbmem_console_p = lib_sysinfo.cbmem_cons;
- if (cbmem_console_p && cbmem_console_p->size)
+
+ if (cbmem_console_p && cbmem_cons->size)
console_add_output_driver(&cbmem_console_driver);
}
void cbmem_console_write(const void *buffer, size_t count)
{
- while ((cbmem_console_p->cursor & CURSOR_MASK) + count >=
- cbmem_console_p->size) {
- size_t still_fits = cbmem_console_p->size -
- (cbmem_console_p->cursor & CURSOR_MASK);
+ struct cbmem_console *const cbmem_cons = phys_to_virt(cbmem_console_p);
+
+ while ((cbmem_cons->cursor & CURSOR_MASK) + count >=
+ cbmem_cons->size) {
+ size_t still_fits = cbmem_cons->size - (cbmem_cons->cursor & CURSOR_MASK);
do_write(buffer, still_fits);
- cbmem_console_p->cursor &= ~CURSOR_MASK;
- cbmem_console_p->cursor |= OVERFLOW;
+ cbmem_cons->cursor &= ~CURSOR_MASK;
+ cbmem_cons->cursor |= OVERFLOW;
buffer += still_fits;
count -= still_fits;
}
@@ -77,7 +82,7 @@ void cbmem_console_write(const void *buffer, size_t count)
char *cbmem_console_snapshot(void)
{
- const struct cbmem_console *console_p = cbmem_console_p;
+ const struct cbmem_console *const console_p = phys_to_virt(cbmem_console_p);
char *console_c;
uint32_t size, cursor, overflow;
diff --git a/payloads/libpayload/drivers/i8042/i8042.c b/payloads/libpayload/drivers/i8042/i8042.c
index 50d013dbaf..a89b9d9717 100644
--- a/payloads/libpayload/drivers/i8042/i8042.c
+++ b/payloads/libpayload/drivers/i8042/i8042.c
@@ -28,6 +28,7 @@
#include
#include
+#include
#include
#include "i8042.h"
@@ -111,6 +112,19 @@ static u8 fifo_pop(struct fifo *fifo)
return ret;
}
+/** Peek on the head of fifo queue.
+ * Returns the oldest object on the queue if any.
+ * In case the queue is empty 0 is returned.
+ * @fifo: Fifo to use
+ */
+static u8 fifo_peek(struct fifo *fifo)
+{
+ if (fifo_is_empty(fifo))
+ return 0;
+
+ return fifo->buf[fifo->rx];
+}
+
/** Destroys a fifo queue.
* @fifo: Fifo to use
*/
@@ -159,7 +173,7 @@ static u8 i8042_wait_cmd_rdy(void)
*/
static u8 i8042_wait_data_rdy(void)
{
- int retries = 10000;
+ int retries = 30000;
while (retries-- && !(read_status() & OBF))
udelay(50);
@@ -318,6 +332,24 @@ void i8042_write_data(u8 data)
return;
}
+/**
+ * Send command & data to keyboard controller.
+ *
+ * @param cmd: The command to be sent.
+ * @param data: The data to be sent.
+ * Returns 0 on success, -1 on failure.
+ */
+static int i8042_cmd_with_data(const u8 cmd, const u8 data)
+{
+ const int ret = i8042_cmd(cmd);
+ if (ret != 0)
+ return ret;
+
+ i8042_write_data(data);
+
+ return ret;
+}
+
/**
* Probe for keyboard controller data and queue it.
*/
@@ -371,6 +403,14 @@ u8 i8042_read_data_ps2(void)
return fifo_pop(ps2_fifo);
}
+/**
+ * Returns available keyboard data without advancing the queue.
+ */
+u8 i8042_peek_data_ps2(void)
+{
+ return fifo_peek(ps2_fifo);
+}
+
/**
* Returns available mouse data, if any.
*/
@@ -408,3 +448,36 @@ int i8042_wait_read_aux(void)
return (retries <= 0) ? -1 : i8042_read_data_aux();
}
+
+/**
+ * Get the keyboard scancode translation state.
+ *
+ * Returns: -1 on timeout, 1 if the controller translates
+ * scancode set #2 to #1, and 0 if not.
+ */
+int i8042_get_kbd_translation(void)
+{
+ const int cfg = i8042_cmd_with_response(I8042_CMD_RD_CMD_BYTE);
+ if (cfg < 0)
+ return cfg;
+
+ return !!(cfg & I8042_CMD_BYTE_XLATE);
+}
+
+/**
+ * Sets the keyboard scancode translation state.
+ *
+ * Returns: -1 on timeout, 0 otherwise.
+ */
+int i8042_set_kbd_translation(const bool xlate)
+{
+ int cfg = i8042_cmd_with_response(I8042_CMD_RD_CMD_BYTE);
+ if (cfg < 0)
+ return cfg;
+
+ if (xlate)
+ cfg |= I8042_CMD_BYTE_XLATE;
+ else
+ cfg &= ~I8042_CMD_BYTE_XLATE;
+ return i8042_cmd_with_data(I8042_CMD_WR_CMD_BYTE, cfg);
+}
diff --git a/payloads/libpayload/drivers/i8042/i8042.h b/payloads/libpayload/drivers/i8042/i8042.h
index 6d15d1e0c5..bcb42fd13d 100644
--- a/payloads/libpayload/drivers/i8042/i8042.h
+++ b/payloads/libpayload/drivers/i8042/i8042.h
@@ -56,9 +56,6 @@
#define I8042_MODE_SCROLL_LOCK_ON (1 << 0)
#define I8042_MODE_SCROLL_LOCK_OFF (0 << 0)
#define I8042_KBCMD_SET_SCANCODE 0xf0
-#define I8042_SCANCODE_SET_1 (1)
-#define I8042_SCANCODE_SET_2 (2)
-#define I8042_SCANCODE_SET_3 (3)
#define I8042_KBCMD_SET_TYPEMATIC 0xf3
#define I8042_KBCMD_EN 0xf4
#define I8042_KBCMD_DEFAULT_DIS 0xf5
diff --git a/payloads/libpayload/drivers/i8042/keyboard.c b/payloads/libpayload/drivers/i8042/keyboard.c
index eb94199ec0..91a51bb0ee 100644
--- a/payloads/libpayload/drivers/i8042/keyboard.c
+++ b/payloads/libpayload/drivers/i8042/keyboard.c
@@ -27,12 +27,21 @@
* SUCH DAMAGE.
*/
+#include
+#include
+
#include
#include
#include
#include "i8042.h"
+#ifdef DEBUG
+#define debug(x...) printf(x)
+#else
+#define debug(x...) do {} while (0)
+#endif
+
#define POWER_BUTTON 0x90
#define MEDIA_KEY_PREFIX 0xE0
@@ -169,16 +178,253 @@ static struct layout_maps keyboard_layouts[] = {
#endif
};
-static unsigned char keyboard_cmd(unsigned char cmd)
+static void keyboard_drain_input(void)
{
- i8042_write_data(cmd);
-
- return i8042_wait_read_ps2() == 0xfa;
+ while (i8042_data_ready_ps2())
+ (void)i8042_read_data_ps2();
}
-int keyboard_havechar(void)
+static bool keyboard_cmd(unsigned char cmd)
{
- return i8042_data_ready_ps2();
+ const uint64_t timeout_us = cmd == I8042_KBCMD_RESET ? 1*1000*1000 : 200*1000;
+ const uint64_t start_time = timer_us(0);
+
+ i8042_write_data(cmd);
+
+ do {
+ if (!i8042_data_ready_ps2()) {
+ udelay(50);
+ continue;
+ }
+
+ const uint8_t data = i8042_read_data_ps2();
+ switch (data) {
+ case 0xfa:
+ return true;
+ case 0xfe:
+ return false;
+ default:
+ /* Warn only if we already disabled keyboard input. */
+ if (cmd != I8042_KBCMD_DEFAULT_DIS)
+ debug("WARNING: Keyboard sent spurious 0x%02x.\n", data);
+ break;
+ }
+ } while (timer_us(start_time) < timeout_us);
+
+ debug("ERROR: Keyboard command timed out.\n");
+ return false;
+}
+
+static bool set_scancode_set(const unsigned char set)
+{
+ bool ret;
+
+ if (set < 1 || set > 3)
+ return false;
+
+ ret = keyboard_cmd(I8042_KBCMD_SET_SCANCODE);
+ if (!ret) {
+ debug("ERROR: Keyboard set scancode failed!\n");
+ return ret;
+ }
+
+ ret = keyboard_cmd(set);
+ if (!ret) {
+ debug("ERROR: Keyboard scancode set#%u failed!\n", set);
+ return ret;
+ }
+
+ return ret;
+}
+
+static enum keyboard_state {
+ STATE_INIT = 0,
+ STATE_SIMPLIFIED_INIT,
+ STATE_DISABLE_SCAN,
+ STATE_DRAIN_INPUT,
+ STATE_DISABLE_TRANSLATION,
+ STATE_START_SELF_TEST,
+ STATE_SELF_TEST,
+ STATE_CONFIGURE,
+ STATE_CONFIGURE_SET1,
+ STATE_ENABLE_TRANSLATION,
+ STATE_ENABLE_SCAN,
+ STATE_RUNNING,
+ STATE_IGNORE,
+} keyboard_state;
+
+#define STATE_NAMES_ENTRY(name) [STATE_##name] = #name
+static const char *const state_names[] = {
+ STATE_NAMES_ENTRY(INIT),
+ STATE_NAMES_ENTRY(SIMPLIFIED_INIT),
+ STATE_NAMES_ENTRY(DISABLE_SCAN),
+ STATE_NAMES_ENTRY(DRAIN_INPUT),
+ STATE_NAMES_ENTRY(DISABLE_TRANSLATION),
+ STATE_NAMES_ENTRY(START_SELF_TEST),
+ STATE_NAMES_ENTRY(SELF_TEST),
+ STATE_NAMES_ENTRY(CONFIGURE),
+ STATE_NAMES_ENTRY(CONFIGURE_SET1),
+ STATE_NAMES_ENTRY(ENABLE_TRANSLATION),
+ STATE_NAMES_ENTRY(ENABLE_SCAN),
+ STATE_NAMES_ENTRY(RUNNING),
+ STATE_NAMES_ENTRY(IGNORE),
+};
+
+__attribute__((unused))
+static const char *state_name(enum keyboard_state state)
+{
+ if (state >= ARRAY_SIZE(state_names) || !state_names[state])
+ return "";
+ return state_names[state];
+}
+
+static uint64_t keyboard_time;
+static uint64_t state_time;
+
+static void keyboard_poll(void)
+{
+ enum keyboard_state next_state = keyboard_state;
+ unsigned int i;
+
+ switch (keyboard_state) {
+
+ case STATE_INIT:
+ /* Wait until keyboard_init() has been called. */
+ break;
+
+ case STATE_SIMPLIFIED_INIT:
+ /* On the first try, start opportunistically, do
+ the first steps at once and skip the self-test. */
+ (void)keyboard_cmd(I8042_KBCMD_DEFAULT_DIS);
+ keyboard_drain_input();
+ (void)i8042_set_kbd_translation(false);
+ next_state = STATE_CONFIGURE;
+ break;
+
+ case STATE_DISABLE_SCAN:
+ (void)keyboard_cmd(I8042_KBCMD_DEFAULT_DIS);
+ next_state = STATE_DRAIN_INPUT;
+ break;
+
+ case STATE_DRAIN_INPUT:
+ /* Limit number of bytes drained per poll. */
+ for (i = 0; i < 50 && i8042_data_ready_ps2(); ++i)
+ (void)i8042_read_data_ps2();
+ if (i == 0)
+ next_state = STATE_DISABLE_TRANSLATION;
+ break;
+
+ case STATE_DISABLE_TRANSLATION:
+ /* Be opportunistic and assume it's disabled on failure. */
+ (void)i8042_set_kbd_translation(false);
+ next_state = STATE_START_SELF_TEST;
+ break;
+
+ case STATE_START_SELF_TEST:
+ if (!keyboard_cmd(I8042_KBCMD_RESET))
+ debug("ERROR: Keyboard self-test couldn't be started.\n");
+ /* We ignore errors and always move to the self-test state
+ which will simply try again if necessary. */
+ next_state = STATE_SELF_TEST;
+ break;
+
+ case STATE_SELF_TEST:
+ if (!i8042_data_ready_ps2()) {
+ if (timer_us(state_time) > 5*1000*1000) {
+ debug("WARNING: Keyboard self-test timed out.\n");
+ next_state = STATE_DISABLE_SCAN;
+ }
+ break;
+ }
+
+ const uint8_t self_test_result = i8042_read_data_ps2();
+ switch (self_test_result) {
+ case 0xaa:
+ debug("INFO: Keyboard self-test succeeded.\n");
+ next_state = STATE_CONFIGURE;
+ break;
+ case 0xfc:
+ case 0xfd:
+ /* Failure. Try again. */
+ debug("WARNING: Keyboard self-test failed.\n");
+ next_state = STATE_START_SELF_TEST;
+ break;
+ default:
+ debug("WARNING: Keyboard self-test received spurious 0x%02x\n",
+ self_test_result);
+ break;
+ }
+ break;
+
+ case STATE_CONFIGURE:
+ if (set_scancode_set(2))
+ next_state = STATE_ENABLE_TRANSLATION;
+ else
+ next_state = STATE_CONFIGURE_SET1;
+ break;
+
+ case STATE_CONFIGURE_SET1:
+ if (!set_scancode_set(1)) {
+ debug("ERROR: Keyboard failed to set any scancode set.\n");
+ next_state = STATE_DISABLE_SCAN;
+ break;
+ }
+
+ next_state = STATE_ENABLE_SCAN;
+ break;
+
+ case STATE_ENABLE_TRANSLATION:
+ if (i8042_set_kbd_translation(true) != 0) {
+ debug("ERROR: Keyboard controller set translation failed!\n");
+ next_state = STATE_DISABLE_SCAN;
+ break;
+ }
+
+ next_state = STATE_ENABLE_SCAN;
+ break;
+
+ case STATE_ENABLE_SCAN:
+ if (!keyboard_cmd(I8042_KBCMD_EN)) {
+ debug("ERROR: Keyboard enable scanning failed!\n");
+ next_state = STATE_DISABLE_SCAN;
+ break;
+ }
+
+ next_state = STATE_RUNNING;
+ break;
+
+ case STATE_RUNNING:
+ /* TODO: Use echo command to detect detach. */
+ break;
+
+ case STATE_IGNORE:
+ /* TODO: Try again after timeout if it ever seems useful. */
+ break;
+
+ }
+
+ switch (next_state) {
+ case STATE_INIT:
+ case STATE_RUNNING:
+ case STATE_IGNORE:
+ break;
+ default:
+ if (timer_us(keyboard_time) > 30*1000*1000)
+ next_state = STATE_IGNORE;
+ break;
+ }
+
+ if (keyboard_state != next_state) {
+ debug("INFO: Keyboard advancing state to '%s'.\n", state_name(next_state));
+ keyboard_state = next_state;
+ state_time = timer_us(0);
+ }
+}
+
+bool keyboard_havechar(void)
+{
+ keyboard_poll();
+ return keyboard_state == STATE_RUNNING && i8042_data_ready_ps2();
}
unsigned char keyboard_get_scancode(void)
@@ -306,88 +552,27 @@ int keyboard_set_layout(char *country)
}
static struct console_input_driver cons = {
- .havekey = keyboard_havechar,
+ .havekey = (int (*)(void))keyboard_havechar,
.getchar = keyboard_getchar,
.input_type = CONSOLE_INPUT_TYPE_EC,
};
-/* Enable keyboard translated */
-static int enable_translated(void)
-{
- if (!i8042_cmd(I8042_CMD_RD_CMD_BYTE)) {
- int cmd = i8042_read_data_ps2();
- cmd |= I8042_CMD_BYTE_XLATE;
- if (!i8042_cmd(I8042_CMD_WR_CMD_BYTE)) {
- i8042_write_data(cmd);
- } else {
- printf("ERROR: i8042_cmd WR_CMD failed!\n");
- return 0;
- }
- } else {
- printf("ERROR: i8042_cmd RD_CMD failed!\n");
- return 0;
- }
- return 1;
-}
-
-/* Set scancode set 1 */
-static int set_scancode_set(void)
-{
- unsigned int ret;
- ret = keyboard_cmd(I8042_KBCMD_SET_SCANCODE);
- if (!ret) {
- printf("ERROR: Keyboard set scancode failed!\n");
- return ret;
- }
-
- ret = keyboard_cmd(I8042_SCANCODE_SET_1);
- if (!ret) {
- printf("ERROR: Keyboard scancode set#1 failed!\n");
- return ret;
- }
-
- /*
- * Set default parameters.
- * Fix for broken QEMU PS/2 make scancodes.
- */
- ret = keyboard_cmd(I8042_KBCMD_SET_DEFAULT);
- if (!ret) {
- printf("ERROR: Keyboard set default params failed!\n");
- return ret;
- }
-
- /* Enable scanning */
- ret = keyboard_cmd(I8042_KBCMD_EN);
- if (!ret) {
- printf("ERROR: Keyboard enable scanning failed!\n");
- return ret;
- }
-
- return ret;
-}
-
void keyboard_init(void)
{
+ if (keyboard_state != STATE_INIT)
+ return;
+
map = &keyboard_layouts[0];
/* Initialized keyboard controller. */
if (!i8042_probe() || !i8042_has_ps2())
return;
- /* Empty keyboard buffer */
- while (keyboard_havechar())
- keyboard_getchar();
-
/* Enable first PS/2 port */
i8042_cmd(I8042_CMD_EN_KB);
- if (CONFIG(LP_PC_KEYBOARD_AT_TRANSLATED)) {
- if (!enable_translated())
- return;
- } else {
- if (!set_scancode_set())
- return;
- }
+ keyboard_state = STATE_SIMPLIFIED_INIT;
+ keyboard_time = state_time = timer_us(0);
console_add_input_driver(&cons);
}
@@ -402,20 +587,18 @@ void keyboard_disconnect(void)
if (!i8042_has_ps2())
return;
- /* Empty keyboard buffer */
- while (keyboard_havechar())
- keyboard_getchar();
-
/* Disable scanning */
keyboard_cmd(I8042_KBCMD_DEFAULT_DIS);
+ keyboard_drain_input();
/* Send keyboard disconnect command */
i8042_cmd(I8042_CMD_DIS_KB);
/* Hand off with empty buffer */
- while (keyboard_havechar())
- keyboard_getchar();
+ keyboard_drain_input();
/* Release keyboard controller driver */
i8042_close();
+
+ keyboard_state = STATE_INIT;
}
diff --git a/payloads/libpayload/drivers/nvram.c b/payloads/libpayload/drivers/nvram.c
index 40bd2fc882..4794e9b249 100644
--- a/payloads/libpayload/drivers/nvram.c
+++ b/payloads/libpayload/drivers/nvram.c
@@ -42,7 +42,6 @@
#include
#include
-
/**
* PCs can have either 64 (very old ones), 128, or 256 bytes of CMOS RAM.
*
diff --git a/payloads/libpayload/drivers/options.c b/payloads/libpayload/drivers/options.c
index 3a14d77df9..b6d234222d 100644
--- a/payloads/libpayload/drivers/options.c
+++ b/payloads/libpayload/drivers/options.c
@@ -26,8 +26,11 @@
* SUCH DAMAGE.
*/
+#define __STDC_FORMAT_MACROS
+
#include
#include
+#include
u8 *mem_accessor_base;
@@ -53,7 +56,7 @@ struct nvram_accessor *use_mem = &(struct nvram_accessor) {
struct cb_cmos_option_table *get_system_option_table(void)
{
- return lib_sysinfo.option_table;
+ return phys_to_virt(lib_sysinfo.cmos_option_table);
}
int options_checksum_valid(const struct nvram_accessor *nvram)
@@ -325,7 +328,7 @@ int get_option_as_string(const struct nvram_accessor *nvram, struct cb_cmos_opti
/* only works on little endian.
26 bytes is enough for a 64bit value in decimal */
*dest = malloc(26);
- sprintf(*dest, "%llu", *(u64*)raw);
+ sprintf(*dest, "%" PRIu64, *(u64 *)raw);
break;
case 's':
*dest = strdup(raw);
diff --git a/payloads/libpayload/drivers/serial/8250.c b/payloads/libpayload/drivers/serial/8250.c
index b0e9d03c20..1df34c41ea 100644
--- a/payloads/libpayload/drivers/serial/8250.c
+++ b/payloads/libpayload/drivers/serial/8250.c
@@ -132,9 +132,9 @@ void serial_init(void)
void serial_console_init(void)
{
- if (!lib_sysinfo.serial)
+ if (!lib_sysinfo.cb_serial)
return;
- cb_serial = *lib_sysinfo.serial;
+ cb_serial = *(struct cb_serial *)phys_to_virt(lib_sysinfo.cb_serial);
serial_init();
diff --git a/payloads/libpayload/drivers/serial/ipq40xx.c b/payloads/libpayload/drivers/serial/ipq40xx.c
index 5a9079b46b..bc5ebbbc1b 100644
--- a/payloads/libpayload/drivers/serial/ipq40xx.c
+++ b/payloads/libpayload/drivers/serial/ipq40xx.c
@@ -553,9 +553,7 @@ static struct console_output_driver consout = {};
/* For simplicity's sake, let's rely on coreboot initializing the UART. */
void serial_console_init(void)
{
- struct cb_serial *sc_ptr = lib_sysinfo.serial;
-
- if (!sc_ptr)
+ if (!lib_sysinfo.cb_serial)
return;
consin.havekey = serial_havechar;
diff --git a/payloads/libpayload/drivers/serial/ipq806x.c b/payloads/libpayload/drivers/serial/ipq806x.c
index ef4ce80849..93e2129185 100644
--- a/payloads/libpayload/drivers/serial/ipq806x.c
+++ b/payloads/libpayload/drivers/serial/ipq806x.c
@@ -343,9 +343,9 @@ int serial_getchar(void)
/* For simplicity's sake, let's rely on coreboot initializing the UART. */
void serial_console_init(void)
{
- struct cb_serial *sc_ptr = lib_sysinfo.serial;
+ struct cb_serial *sc_ptr = phys_to_virt(lib_sysinfo.cb_serial);
- if (!sc_ptr)
+ if (!lib_sysinfo.cb_serial)
return;
base_uart_addr = (void *) sc_ptr->baseaddr;
diff --git a/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c b/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c
index 3d0e6de335..77def46831 100644
--- a/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c
+++ b/payloads/libpayload/drivers/serial/qcom_qupv3_serial.c
@@ -27,7 +27,6 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/* For simplicity sake let's rely on coreboot initializing the UART. */
#include
#include
@@ -275,7 +274,8 @@ static struct console_output_driver consout = {
static struct qup_regs *uart_base_address(void)
{
- return (void *)(uintptr_t)lib_sysinfo.serial->baseaddr;
+ const struct cb_serial *const serial = phys_to_virt(lib_sysinfo.cb_serial);
+ return phys_to_virt(serial->baseaddr);
}
static void uart_qupv3_tx_flush(void)
@@ -332,7 +332,7 @@ int serial_getchar(void)
void serial_console_init(void)
{
- if (!lib_sysinfo.serial)
+ if (!lib_sysinfo.cb_serial)
return;
console_add_output_driver(&consout);
diff --git a/payloads/libpayload/drivers/serial/qcs405.c b/payloads/libpayload/drivers/serial/qcs405.c
index 1a7b9e901b..2ed6af1749 100644
--- a/payloads/libpayload/drivers/serial/qcs405.c
+++ b/payloads/libpayload/drivers/serial/qcs405.c
@@ -541,9 +541,9 @@ int serial_getchar(void)
/* For simplicity's sake, let's rely on coreboot initializing the UART. */
void serial_console_init(void)
{
- struct cb_serial *sc_ptr = lib_sysinfo.serial;
+ struct cb_serial *sc_ptr = phys_to_virt(lib_sysinfo.cb_serial);
- if (!sc_ptr)
+ if (!lib_sysinfo.cb_serial)
return;
uart_board_param.uart_dm_base = (void *)(uintptr_t)sc_ptr->baseaddr;
diff --git a/payloads/libpayload/drivers/serial/s5p.c b/payloads/libpayload/drivers/serial/s5p.c
index 6ca5dc4717..7a6f0e1c39 100644
--- a/payloads/libpayload/drivers/serial/s5p.c
+++ b/payloads/libpayload/drivers/serial/s5p.c
@@ -90,10 +90,12 @@ static struct console_input_driver s5p_serial_input =
void serial_init(void)
{
- if (!lib_sysinfo.serial || !lib_sysinfo.serial->baseaddr)
+ const struct cb_serial *const serial = phys_to_virt(lib_sysinfo.cb_serial);
+
+ if (!lib_sysinfo.cb_serial || !serial->baseaddr)
return;
- uart_regs = (struct s5p_uart *)lib_sysinfo.serial->baseaddr;
+ uart_regs = (struct s5p_uart *)serial->baseaddr;
}
void serial_console_init(void)
diff --git a/payloads/libpayload/drivers/storage/Kconfig b/payloads/libpayload/drivers/storage/Kconfig
index fea52c8903..0c2cc8a665 100644
--- a/payloads/libpayload/drivers/storage/Kconfig
+++ b/payloads/libpayload/drivers/storage/Kconfig
@@ -12,7 +12,7 @@ config STORAGE
config STORAGE_64BIT_LBA
bool "Use 64-bit integers to address sectors"
depends on STORAGE
- default n
+ default y
help
If this is selected, sectors will be addressed by an 64-bit integer.
Select this to support LBA-48 for ATA drives.
@@ -45,7 +45,7 @@ config STORAGE_AHCI
config STORAGE_AHCI_ONLY_TESTED
bool "Only enable tested controllers"
depends on STORAGE_AHCI
- default y
+ default n
help
- If this option is selected only AHCI controllers which are known
+ If this option is selected, only AHCI controllers which are known
to work will be used.
diff --git a/payloads/libpayload/drivers/storage/ahci.c b/payloads/libpayload/drivers/storage/ahci.c
index 9f9b9b589a..6a6fbfd418 100644
--- a/payloads/libpayload/drivers/storage/ahci.c
+++ b/payloads/libpayload/drivers/storage/ahci.c
@@ -39,7 +39,6 @@
#include "ahci_private.h"
-
#ifdef DEBUG_STATUS
static inline u32 _ahci_clear_status(volatile u32 *const reg,
const char *const r,
@@ -64,7 +63,6 @@ static inline u32 _ahci_clear_status(volatile u32 *const reg)
#define ahci_clear_status(p, r) _ahci_clear_status(&(p)->r)
#endif
-
static inline int ahci_port_is_active(const hba_port_t *const port)
{
return (port->sata_status & (HBA_PxSSTS_IPM_MASK | HBA_PxSSTS_DET_MASK))
@@ -229,34 +227,28 @@ static u32 working_controllers[] = {
0x8086 | 0x5ae3 << 16, /* Apollo Lake */
};
#endif
-static void ahci_init_pci(pcidev_t dev)
+
+void ahci_initialize(struct pci_dev *dev)
{
int i;
- const u16 class = pci_read_config16(dev, 0xa);
- if (class != 0x0106)
- return;
- const u16 vendor = pci_read_config16(dev, 0x00);
- const u16 device = pci_read_config16(dev, 0x02);
-
#if CONFIG(LP_STORAGE_AHCI_ONLY_TESTED)
- const u32 vendor_device = pci_read_config32(dev, 0x0);
+ const u32 vendor_device = dev->vendor_id | dev->device_id << 16;
for (i = 0; i < ARRAY_SIZE(working_controllers); ++i)
if (vendor_device == working_controllers[i])
break;
if (i == ARRAY_SIZE(working_controllers)) {
printf("ahci: Not using untested SATA controller "
- "%02x:%02x.%02x (%04x:%04x).\n", PCI_BUS(dev),
- PCI_SLOT(dev), PCI_FUNC(dev), vendor, device);
+ "%02x:%02x.%02x (%04x:%04x).\n", dev->bus,
+ dev->dev, dev->func, dev->vendor_id, dev->device_id);
return;
}
#endif
printf("ahci: Found SATA controller %02x:%02x.%02x (%04x:%04x).\n",
- PCI_BUS(dev), PCI_SLOT(dev), PCI_FUNC(dev), vendor, device);
+ dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id);
- hba_ctrl_t *const ctrl = phys_to_virt(
- pci_read_config32(dev, 0x24) & ~0x3ff);
+ hba_ctrl_t *const ctrl = phys_to_virt(pci_read_long(dev, 0x24) & ~0x3ff);
hba_port_t *const ports = ctrl->ports;
/* Reset host controller. */
@@ -275,8 +267,8 @@ static void ahci_init_pci(pcidev_t dev)
ctrl->global_ctrl |= HBA_CTRL_AHCI_EN;
/* Enable bus mastering. */
- const u16 command = pci_read_config16(dev, PCI_COMMAND);
- pci_write_config16(dev, PCI_COMMAND, command | PCI_COMMAND_MASTER);
+ const u16 command = pci_read_word(dev, PCI_COMMAND);
+ pci_write_word(dev, PCI_COMMAND, command | PCI_COMMAND_MASTER);
/* Probe for devices. */
for (i = 0; i < 32; ++i) {
@@ -284,19 +276,3 @@ static void ahci_init_pci(pcidev_t dev)
ahci_port_probe(ctrl, &ports[i], i + 1);
}
}
-
-void ahci_initialize(void)
-{
- int bus, dev, func;
-
- for (bus = 0; bus < 256; ++bus) {
- for (dev = 0; dev < 32; ++dev) {
- const u16 class =
- pci_read_config16(PCI_DEV(bus, dev, 0), 0xa);
- if (class != 0xffff) {
- for (func = 0; func < 8; ++func)
- ahci_init_pci(PCI_DEV(bus, dev, func));
- }
- }
- }
-}
diff --git a/payloads/libpayload/drivers/storage/ahci_ata.c b/payloads/libpayload/drivers/storage/ahci_ata.c
index 514692e39f..062b7ac71b 100644
--- a/payloads/libpayload/drivers/storage/ahci_ata.c
+++ b/payloads/libpayload/drivers/storage/ahci_ata.c
@@ -37,7 +37,6 @@
#include "ahci_private.h"
-
ssize_t ahci_ata_read_sectors(ata_dev_t *const ata_dev,
const lba_t start, size_t count,
u8 *const buf)
diff --git a/payloads/libpayload/drivers/storage/ahci_atapi.c b/payloads/libpayload/drivers/storage/ahci_atapi.c
index 9984b4b78d..1a757d7e9b 100644
--- a/payloads/libpayload/drivers/storage/ahci_atapi.c
+++ b/payloads/libpayload/drivers/storage/ahci_atapi.c
@@ -35,10 +35,8 @@
#include
#include
-
#include "ahci_private.h"
-
ssize_t ahci_packet_read_cmd(atapi_dev_t *const _dev,
const u8 *const cmd, const size_t cmdlen,
u8 *const buf, const size_t buflen)
diff --git a/payloads/libpayload/drivers/storage/ahci_common.c b/payloads/libpayload/drivers/storage/ahci_common.c
index b8fdad202c..f3abc5f7fb 100644
--- a/payloads/libpayload/drivers/storage/ahci_common.c
+++ b/payloads/libpayload/drivers/storage/ahci_common.c
@@ -37,7 +37,6 @@
#include "ahci_private.h"
-
#ifdef DEBUG_STATUS
static inline u32 _ahci_clear_status(volatile u32 *const reg,
const char *const r,
@@ -62,7 +61,6 @@ static inline u32 _ahci_clear_status(volatile u32 *const reg)
#define ahci_clear_status(p, r) _ahci_clear_status(&(p)->r)
#endif
-
/** Give a buffer with even address. */
static u8 *ahci_prdbuf_init(ahci_dev_t *const dev,
u8 *const user_buf, const size_t len,
diff --git a/payloads/libpayload/drivers/storage/ahci_private.h b/payloads/libpayload/drivers/storage/ahci_private.h
index 7f7c592048..1e8c85f199 100644
--- a/payloads/libpayload/drivers/storage/ahci_private.h
+++ b/payloads/libpayload/drivers/storage/ahci_private.h
@@ -120,7 +120,6 @@ typedef volatile struct {
#define HBA_CTRL_INTR_EN (1 << 1)
#define HBA_CTRL_RESET (1 << 0)
-
typedef volatile struct {
u8 dma_setup_fis[28];
u8 _reserved0[4];
@@ -229,5 +228,4 @@ ssize_t ahci_ata_read_sectors(ata_dev_t *const ata_dev,
const lba_t start, size_t count,
u8 *const buf);
-
#endif /* _AHCI_PRIVATE_H */
diff --git a/payloads/libpayload/drivers/storage/ata.c b/payloads/libpayload/drivers/storage/ata.c
index 68f88f6eb7..00f1d88854 100644
--- a/payloads/libpayload/drivers/storage/ata.c
+++ b/payloads/libpayload/drivers/storage/ata.c
@@ -33,7 +33,6 @@
#include
-
/** Reads non-sector-aligned blocks of 512 bytes. */
static ssize_t ata_read_unaligned(ata_dev_t *const dev,
const lba_t blk_start, size_t blk_count,
diff --git a/payloads/libpayload/drivers/storage/atapi.c b/payloads/libpayload/drivers/storage/atapi.c
index f42c1f4b80..7f46e9cc3e 100644
--- a/payloads/libpayload/drivers/storage/atapi.c
+++ b/payloads/libpayload/drivers/storage/atapi.c
@@ -33,7 +33,6 @@
#include
#include
-
static int atapi_request_sense(atapi_dev_t *const dev)
{
u8 cdb[12] = { 0, };
diff --git a/payloads/libpayload/drivers/storage/storage.c b/payloads/libpayload/drivers/storage/storage.c
index 3ddafdce07..4b585bae3a 100644
--- a/payloads/libpayload/drivers/storage/storage.c
+++ b/payloads/libpayload/drivers/storage/storage.c
@@ -27,12 +27,10 @@
*/
#include
-#if CONFIG(LP_STORAGE_AHCI)
-# include
-#endif
+#include
+#include
#include
-
static storage_dev_t **devices = NULL;
static size_t devices_length = 0;
static size_t dev_count = 0;
@@ -109,7 +107,18 @@ ssize_t storage_read_blocks512(const size_t dev_num,
*/
void storage_initialize(void)
{
+#if CONFIG(LP_PCI)
+ struct pci_dev *dev;
+ for (dev = lib_sysinfo.pacc.devices; dev; dev = dev->next) {
+ switch (dev->device_class) {
#if CONFIG(LP_STORAGE_AHCI)
- ahci_initialize();
+ case PCI_CLASS_STORAGE_AHCI:
+ ahci_initialize(dev);
+ break;
+#endif
+ default:
+ break;
+ }
+ }
#endif
}
diff --git a/payloads/libpayload/drivers/udc/chipidea.c b/payloads/libpayload/drivers/udc/chipidea.c
index dd1601367b..3df7d2409c 100644
--- a/payloads/libpayload/drivers/udc/chipidea.c
+++ b/payloads/libpayload/drivers/udc/chipidea.c
@@ -300,7 +300,6 @@ static void start_setup(struct usbdev_ctrl *this, int ep)
udc_handle_setup(this, ep, &dr);
}
-
static void chipidea_enqueue_packet(struct usbdev_ctrl *this, int endpoint,
int in_dir, void *data, int len, int zlp, int autofree)
{
diff --git a/payloads/libpayload/drivers/usb/dwc2_rh.c b/payloads/libpayload/drivers/usb/dwc2_rh.c
index ff15e9902d..c0f25f907a 100644
--- a/payloads/libpayload/drivers/usb/dwc2_rh.c
+++ b/payloads/libpayload/drivers/usb/dwc2_rh.c
@@ -12,7 +12,6 @@
* GNU General Public License for more details.
*/
-
#include
#include "generic_hub.h"
#include "dwc2_private.h"
diff --git a/payloads/libpayload/drivers/usb/ehci.c b/payloads/libpayload/drivers/usb/ehci.c
index cb3c1c543e..58fc64eead 100644
--- a/payloads/libpayload/drivers/usb/ehci.c
+++ b/payloads/libpayload/drivers/usb/ehci.c
@@ -28,6 +28,7 @@
//#define USB_DEBUG
+#include
#include
#include
#include
@@ -46,15 +47,15 @@ static void dump_td(u32 addr)
usb_debug("|..[OUT]............................................|\n");
else
usb_debug("|..[]...............................................|\n");
- usb_debug("|:|============ EHCI TD at [0x%08lx] ==========|:|\n", addr);
- usb_debug("|:| ERRORS = [%ld] | TOKEN = [0x%08lx] | |:|\n",
+ usb_debug("|:|============ EHCI TD at [0x%08"PRIx32"] ==========|:|\n", addr);
+ usb_debug("|:| ERRORS = [%"PRId32"] | TOKEN = [0x%08"PRIx32"] | |:|\n",
3 - ((td->token & QTD_CERR_MASK) >> QTD_CERR_SHIFT), td->token);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| Next qTD [0x%08lx] |:|\n", td->next_qtd);
+ usb_debug("|:| Next qTD [0x%08"PRIx32"] |:|\n", td->next_qtd);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| Alt. Next qTD [0x%08lx] |:|\n", td->alt_next_qtd);
+ usb_debug("|:| Alt. Next qTD [0x%08"PRIx32"] |:|\n", td->alt_next_qtd);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| | Bytes to Transfer |[%05ld] |:|\n", (td->token & QTD_TOTAL_LEN_MASK) >> 16);
+ usb_debug("|:| | Bytes to Transfer |[%05"PRId32"] |:|\n", (td->token & QTD_TOTAL_LEN_MASK) >> 16);
usb_debug("|:| | PID CODE: | [%ld] |:|\n", (td->token & (3UL << 8)) >> 8);
usb_debug("|:| | Interrupt On Complete (IOC) | [%ld] |:|\n", (td->token & (1UL << 15)) >> 15);
usb_debug("|:| | Status Active | [%ld] |:|\n", (td->token & (1UL << 7)) >> 7);
@@ -277,9 +278,11 @@ static int wait_for_tds(qtd_t *head)
if (cur->next_qtd & 1) {
break;
}
- if (0) dump_td(virt_to_phys(cur));
+ if (0)
+ dump_td(virt_to_phys(cur));
/* helps debugging the TD chain */
- if (0) usb_debug("\nmoving from %x to %x\n", cur, phys_to_virt(cur->next_qtd));
+ if (0)
+ usb_debug("\nmoving from %p to %p\n", cur, phys_to_virt(cur->next_qtd));
cur = phys_to_virt(cur->next_qtd);
}
return result;
@@ -426,7 +429,6 @@ oom:
return -1;
}
-
/* FIXME: Handle control transfers as 3 QHs, so the 2nd stage can be >0x4000 bytes */
static int ehci_control (usbdev_t *dev, direction_t dir, int drlen, void *setup,
int dalen, u8 *src)
@@ -544,7 +546,6 @@ oom:
return -1;
}
-
typedef struct _intr_qtd_t intr_qtd_t;
struct _intr_qtd_t {
diff --git a/payloads/libpayload/drivers/usb/ehci_rh.c b/payloads/libpayload/drivers/usb/ehci_rh.c
index e51f332822..edb1b4ad4d 100644
--- a/payloads/libpayload/drivers/usb/ehci_rh.c
+++ b/payloads/libpayload/drivers/usb/ehci_rh.c
@@ -171,7 +171,6 @@ ehci_rh_poll (usbdev_t *dev)
ehci_rh_scanport (dev, port);
}
-
void
ehci_rh_init (usbdev_t *dev)
{
diff --git a/payloads/libpayload/drivers/usb/ohci.c b/payloads/libpayload/drivers/usb/ohci.c
index 87674eec6b..f35d1ff0e8 100644
--- a/payloads/libpayload/drivers/usb/ohci.c
+++ b/payloads/libpayload/drivers/usb/ohci.c
@@ -29,6 +29,7 @@
//#define USB_DEBUG
#include
+#include
#include
#include "ohci_private.h"
#include "ohci.h"
@@ -59,7 +60,7 @@ dump_td (td_t *cur)
else
usb_debug("|..[]...............................................|\n");
usb_debug("|:|============ OHCI TD at [0x%08lx] ==========|:|\n", virt_to_phys(cur));
- usb_debug("|:| ERRORS = [%ld] | CONFIG = [0x%08lx] | |:|\n",
+ usb_debug("|:| ERRORS = [%ld] | CONFIG = [0x%08"PRIx32"] | |:|\n",
3 - ((cur->config & (3UL << 26)) >> 26), cur->config);
usb_debug("|:+-----------------------------------------------+:|\n");
usb_debug("|:| C | Condition Code | [%02ld] |:|\n", (cur->config & (0xFUL << 28)) >> 28);
@@ -69,11 +70,11 @@ dump_td (td_t *cur)
usb_debug("|:| I | Data Toggle | [%ld] |:|\n", (cur->config & (3UL << 24)) >> 24);
usb_debug("|:| G | Error Count | [%ld] |:|\n", (cur->config & (3UL << 26)) >> 26);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| Current Buffer Pointer [0x%08lx] |:|\n", cur->current_buffer_pointer);
+ usb_debug("|:| Current Buffer Pointer [0x%08"PRIx32"] |:|\n", cur->current_buffer_pointer);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| Next TD [0x%08lx] |:|\n", cur->next_td);
+ usb_debug("|:| Next TD [0x%08"PRIx32"] |:|\n", cur->next_td);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| Current Buffer End [0x%08lx] |:|\n", cur->buffer_end);
+ usb_debug("|:| Current Buffer End [0x%08"PRIx32"] |:|\n", cur->buffer_end);
usb_debug("|:|-----------------------------------------------|:|\n");
usb_debug("|...................................................|\n");
usb_debug("+---------------------------------------------------+\n");
@@ -88,9 +89,9 @@ dump_ed (ed_t *cur)
usb_debug("+---------------------------------------------------+\n");
usb_debug("| Next Endpoint Descriptor [0x%08lx] |\n", cur->next_ed & ~0xFUL);
usb_debug("+---------------------------------------------------+\n");
- usb_debug("| | @ 0x%08lx : |\n", cur->config);
+ usb_debug("| | @ 0x%08"PRIx32" : |\n", cur->config);
usb_debug("| C | Maximum Packet Length | [%04ld] |\n", ((cur->config & (0x3fffUL << 16)) >> 16));
- usb_debug("| O | Function Address | [%04ld] |\n", cur->config & 0x7F);
+ usb_debug("| O | Function Address | [%04"PRIx32"] |\n", cur->config & 0x7F);
usb_debug("| N | Endpoint Number | [%02ld] |\n", (cur->config & (0xFUL << 7)) >> 7);
usb_debug("| F | Endpoint Direction | [%ld] |\n", ((cur->config & (3UL << 11)) >> 11));
usb_debug("| I | Endpoint Speed | [%ld] |\n", ((cur->config & (1UL << 13)) >> 13));
@@ -468,7 +469,7 @@ ohci_control (usbdev_t *dev, direction_t dir, int drlen, void *setup, int dalen,
head->tail_pointer = virt_to_phys(final_td);
head->head_pointer = virt_to_phys(first_td);
- usb_debug("ohci_control(): doing transfer with %x. first_td at %x\n",
+ usb_debug("%s(): doing transfer with %x. first_td at %"PRIxPTR"\n", __func__,
head->config & ED_FUNC_MASK, virt_to_phys(first_td));
#ifdef USB_DEBUG
dump_ed(head);
@@ -506,7 +507,7 @@ ohci_bulk (endpoint_t *ep, int dalen, u8 *src, int finalize)
td_t *cur, *next;
int remaining = dalen;
u8 *data = src;
- usb_debug("bulk: %x bytes from %x, finalize: %x, maxpacketsize: %x\n", dalen, src, finalize, ep->maxpacketsize);
+ usb_debug("bulk: %x bytes from %p, finalize: %x, maxpacketsize: %x\n", dalen, src, finalize, ep->maxpacketsize);
if (!dma_coherent(src)) {
data = OHCI_INST(ep->dev->controller)->dma_buffer;
@@ -596,7 +597,7 @@ ohci_bulk (endpoint_t *ep, int dalen, u8 *src, int finalize)
head->tail_pointer = virt_to_phys(cur);
head->head_pointer = virt_to_phys(first_td) | (ep->toggle?ED_TOGGLE:0);
- usb_debug("doing bulk transfer with %x(%x). first_td at %x, last %x\n",
+ usb_debug("doing bulk transfer with %x(%x). first_td at %"PRIxPTR", last %"PRIxPTR"\n",
head->config & ED_FUNC_MASK,
(head->config & ED_EP_MASK) >> ED_EP_SHIFT,
virt_to_phys(first_td), virt_to_phys(cur));
@@ -627,7 +628,6 @@ ohci_bulk (endpoint_t *ep, int dalen, u8 *src, int finalize)
return result;
}
-
struct _intr_queue;
struct _intrq_td {
diff --git a/payloads/libpayload/drivers/usb/ohci_private.h b/payloads/libpayload/drivers/usb/ohci_private.h
index 796be29a01..e29e5901bf 100644
--- a/payloads/libpayload/drivers/usb/ohci_private.h
+++ b/payloads/libpayload/drivers/usb/ohci_private.h
@@ -36,7 +36,7 @@
// FIXME: fake
typedef enum { CMD} reg;
- enum {
+ enum HcRhDescriptorAReg {
NumberDownstreamPorts = 1 << 0,
PowerSwitchingMode = 1 << 8,
NoPowerSwitching = 1 << 9,
@@ -44,19 +44,19 @@
OverCurrentProtectionMode = 1 << 11,
NoOverCurrentProtection = 1 << 12,
PowerOnToPowerGoodTime = 1 << 24
- } HcRhDescriptorAReg;
+ };
- enum {
+ enum HcRhDescriptorAMask {
NumberDownstreamPortsMask = MASK(0, 8),
PowerOnToPowerGoodTimeMask = MASK(24, 8)
- } HcRhDescriptorAMask;
+ };
- enum {
+ enum HcRhDescriptorBReg {
DeviceRemovable = 1 << 0,
PortPowerControlMask = 1 << 16
- } HcRhDescriptorBReg;
+ };
- enum {
+ enum HcRhPortStatusRead {
CurrentConnectStatus = 1 << 0,
PortEnableStatus = 1 << 1,
PortSuspendStatus = 1 << 2,
@@ -69,8 +69,9 @@
PortSuspendStatusChange = 1 << 18,
PortOverCurrentIndicatorChange = 1 << 19,
PortResetStatusChange = 1 << 20
- } HcRhPortStatusRead;
- enum {
+ };
+
+ enum HcRhPortStatusSet {
ClearPortEnable = 1 << 0,
SetPortEnable = 1 << 1,
SetPortSuspend = 1 << 2,
@@ -78,29 +79,30 @@
SetPortReset = 1 << 4,
SetPortPower = 1 << 8,
ClearPortPower = 1 << 9,
- } HcRhPortStatusSet;
+ };
- enum {
+ enum HcRhStatusReg {
LocalPowerStatus = 1 << 0,
OverCurrentIndicator = 1 << 1,
DeviceRemoteWakeupEnable = 1 << 15,
LocalPowerStatusChange = 1 << 16,
OverCurrentIndicatorChange = 1 << 17,
ClearRemoteWakeupEnable = 1 << 31
- } HcRhStatusReg;
+ };
- enum {
+ enum HcFmIntervalOffset {
FrameInterval = 1 << 0,
FSLargestDataPacket = 1 << 16,
FrameIntervalToggle = 1 << 31
- } HcFmIntervalOffset;
- enum {
+ };
+
+ enum HcFmIntervalMask {
FrameIntervalMask = MASK(0, 14),
FSLargestDataPacketMask = MASK(16, 15),
FrameIntervalToggleMask = MASK(31, 1)
- } HcFmIntervalMask;
+ };
- enum {
+ enum HcControlReg {
ControlBulkServiceRatio = 1 << 0,
PeriodicListEnable = 1 << 2,
IsochronousEnable = 1 << 3,
@@ -110,12 +112,12 @@
InterruptRouting = 1 << 8,
RemoteWakeupConnected = 1 << 9,
RemoteWakeupEnable = 1 << 10
- } HcControlReg;
+ };
- enum {
+ enum HcControlMask {
ControlBulkServiceRatioMask = MASK(0, 2),
HostControllerFunctionalStateMask = MASK(6, 2)
- } HcControlMask;
+ };
enum {
USBReset = 0*HostControllerFunctionalState,
@@ -124,24 +126,24 @@
USBSuspend = 3*HostControllerFunctionalState
};
- enum {
+ enum HcCommandStatusReg {
HostControllerReset = 1 << 0,
ControlListFilled = 1 << 1,
BulkListFilled = 1 << 2,
OwnershipChangeRequest = 1 << 3,
SchedulingOverrunCount = 1 << 16
- } HcCommandStatusReg;
+ };
- enum {
+ enum HcCommandStatusMask {
SchedulingOverrunCountMask = MASK(16, 2)
- } HcCommandStatusMask;
+ };
- enum {
+ enum HcFmRemainingReg {
FrameRemaining = 1 << 0,
FrameRemainingToggle = 1 << 31
- } HcFmRemainingReg;
+ };
- enum {
+ enum HcInterruptStatusReg {
SchedulingOverrung = 1 << 0,
WritebackDoneHead = 1 << 1,
StartofFrame = 1 << 2,
@@ -150,7 +152,7 @@
FrameNumberOverflow = 1 << 5,
RootHubStatusChange = 1 << 6,
OwnershipChange = 1 << 30
- } HcInterruptStatusReg;
+ };
typedef struct {
// Control and Status Partition
diff --git a/payloads/libpayload/drivers/usb/uhci.c b/payloads/libpayload/drivers/usb/uhci.c
index c6a178703c..b87ec26965 100644
--- a/payloads/libpayload/drivers/usb/uhci.c
+++ b/payloads/libpayload/drivers/usb/uhci.c
@@ -29,6 +29,7 @@
//#define USB_DEBUG
#include
+#include
#include
#include "uhci.h"
#include "uhci_private.h"
@@ -79,14 +80,14 @@ static void td_dump(td_t *td)
(td->ptr & (1UL << 2)) >> 2, (td->ptr & (1UL << 1)) >> 1, td->ptr & 1UL);
usb_debug("|:+-----------------------------------------------+:|\n");
usb_debug("|:| T | Maximum Length | [%04lx] |:|\n", (td->token & (0x7FFUL << 21)) >> 21);
- usb_debug("|:| O | PID CODE | [%04lx] |:|\n", td->token & 0xFF);
- usb_debug("|:| K | Endpoint | [%04lx] |:|\n", (td->token & TD_EP_MASK) >> TD_EP_SHIFT);
+ usb_debug("|:| O | PID CODE | [%04"PRIx32"] |:|\n", td->token & 0xFF);
+ usb_debug("|:| K | Endpoint | [%04"PRIx32"] |:|\n", (td->token & TD_EP_MASK) >> TD_EP_SHIFT);
usb_debug("|:| E | Device Address | [%04lx] |:|\n", (td->token & (0x7FUL << 8)) >> 8);
usb_debug("|:| N | Data Toggle | [%lx] |:|\n", (td->token & (1UL << 19)) >> 19);
usb_debug("|:+-----------------------------------------------+:|\n");
usb_debug("|:| C | Short Packet Detector | [%lx] |:|\n", (td->ctrlsts & (1UL << 29)) >> 29);
usb_debug("|:| O | Error Counter | [%lx] |:|\n",
- (td->ctrlsts & (3UL << TD_COUNTER_SHIFT)) >> TD_COUNTER_SHIFT);
+ (td->ctrlsts & (3UL << TD_COUNTER_SHIFT)) >> TD_COUNTER_SHIFT);
usb_debug("|:| N | Low Speed Device | [%lx] |:|\n", (td->ctrlsts & (1UL << 26)) >> 26);
usb_debug("|:| T | Isochronous Select | [%lx] |:|\n", (td->ctrlsts & (1UL << 25)) >> 25);
usb_debug("|:| R | Interrupt on Complete (IOC) | [%lx] |:|\n", (td->ctrlsts & (1UL << 24)) >> 24);
@@ -101,7 +102,7 @@ static void td_dump(td_t *td)
usb_debug("|:| S ----------------------------------------|:|\n");
usb_debug("|:| | Actual Length | [%04lx] |:|\n", td->ctrlsts & 0x7FFUL);
usb_debug("|:+-----------------------------------------------+:|\n");
- usb_debug("|:| Buffer pointer [0x%08lx] |:|\n", td->bufptr);
+ usb_debug("|:| Buffer pointer [0x%08"PRIx32"] |:|\n", td->bufptr);
usb_debug("|:|-----------------------------------------------|:|\n");
usb_debug("|...................................................|\n");
usb_debug("+---------------------------------------------------+\n");
diff --git a/payloads/libpayload/drivers/usb/usb.c b/payloads/libpayload/drivers/usb/usb.c
index b14abb4b35..ed33147c51 100644
--- a/payloads/libpayload/drivers/usb/usb.c
+++ b/payloads/libpayload/drivers/usb/usb.c
@@ -28,6 +28,7 @@
//#define USB_DEBUG
+#include
#include
#include
@@ -229,7 +230,7 @@ get_free_address (hci_t *controller)
int i = controller->latest_address + 1;
for (; i != controller->latest_address; i++) {
if (i >= ARRAY_SIZE(controller->devices) || i < 1) {
- usb_debug("WARNING: Device addresses for controller %#x"
+ usb_debug("WARNING: Device addresses for controller %#" PRIxPTR
" wrapped around!\n", controller->reg_base);
i = 0;
continue;
@@ -275,7 +276,7 @@ usb_decode_mps0(usb_speed speed, u8 bMaxPacketSize0)
bMaxPacketSize0 = 9;
}
return 1 << bMaxPacketSize0;
- default: /* GCC is stupid and cannot deal with enums correctly */
+ default: /* GCC is stupid and cannot deal with enums correctly */
return 8;
}
}
diff --git a/payloads/libpayload/drivers/usb/usbhid.c b/payloads/libpayload/drivers/usb/usbhid.c
index 921e17608e..87e87411fe 100644
--- a/payloads/libpayload/drivers/usb/usbhid.c
+++ b/payloads/libpayload/drivers/usb/usbhid.c
@@ -131,8 +131,6 @@ const char *countries[36][2] = {
/* 36 - 255: Reserved */
};
-
-
struct layout_maps {
const char *country;
const short map[4][0x80];
@@ -247,7 +245,6 @@ static const struct layout_maps keyboard_layouts[] = {
//#endif
};
-
static void usb_hid_keyboard_queue(int ch) {
/* ignore key presses if buffer full */
if (keycount < KEYBOARD_BUFFER_SIZE)
@@ -316,7 +313,6 @@ usb_hid_process_keyboard_event(usbhid_inst_t *const inst,
if (skip)
continue;
-
/* Mask off KB_MOD_CTRL */
keypress = map->map[modifiers & 0x03][current->keys[i]];
@@ -397,7 +393,6 @@ static struct console_input_driver cons = {
.input_type = CONSOLE_INPUT_TYPE_USB,
};
-
static int usb_hid_set_layout (const char *country)
{
/* FIXME should be per keyboard */
diff --git a/payloads/libpayload/drivers/usb/usbmsc.c b/payloads/libpayload/drivers/usb/usbmsc.c
old mode 100755
new mode 100644
index ed91c9938b..96c4946b76
--- a/payloads/libpayload/drivers/usb/usbmsc.c
+++ b/payloads/libpayload/drivers/usb/usbmsc.c
@@ -613,7 +613,6 @@ usb_msc_init (usbdev_t *dev)
usb_debug (" it uses %s protocol\n",
msc_protocol_strings[interface->bInterfaceProtocol]);
-
if (interface->bInterfaceProtocol != 0x50) {
usb_debug (" Protocol not supported.\n");
usb_detach_device (dev->controller, dev->address);
diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c
index 749ff0a066..c40e641c4c 100644
--- a/payloads/libpayload/drivers/usb/xhci.c
+++ b/payloads/libpayload/drivers/usb/xhci.c
@@ -194,7 +194,7 @@ xhci_init (unsigned long physical_bar)
xhci->hcrreg = phys_to_virt(physical_bar) + xhci->capreg->rtsoff;
xhci->dbreg = phys_to_virt(physical_bar) + xhci->capreg->dboff;
- xhci_debug("regbase: 0x%"PRIx32"\n", physical_bar);
+ xhci_debug("regbase: 0x%"PRIxPTR"\n", physical_bar);
xhci_debug("caplen: 0x%"PRIx32"\n", CAP_GET(CAPLEN, xhci->capreg));
xhci_debug("rtsoff: 0x%"PRIx32"\n", xhci->capreg->rtsoff);
xhci_debug("dboff: 0x%"PRIx32"\n", xhci->capreg->dboff);
@@ -208,8 +208,8 @@ xhci_init (unsigned long physical_bar)
}
xhci_debug("context size: %dB\n", CTXSIZE(xhci));
- xhci_debug("maxslots: 0x%02lx\n", CAP_GET(MAXSLOTS, xhci->capreg));
- xhci_debug("maxports: 0x%02lx\n", CAP_GET(MAXPORTS, xhci->capreg));
+ xhci_debug("maxslots: 0x%02"PRIx32"\n", CAP_GET(MAXSLOTS, xhci->capreg));
+ xhci_debug("maxports: 0x%02"PRIx32"\n", CAP_GET(MAXPORTS, xhci->capreg));
const unsigned pagesize = xhci->opreg->pagesize << 12;
xhci_debug("pagesize: 0x%04x\n", pagesize);
@@ -374,7 +374,7 @@ xhci_reinit (hci_t *controller)
/* Initialize command ring */
xhci_init_cycle_ring(&xhci->cr, COMMAND_RING_SIZE);
- xhci_debug("command ring @%p (0x%08x)\n",
+ xhci_debug("command ring @%p (0x%08"PRIxPTR")\n",
xhci->cr.ring, virt_to_phys(xhci->cr.ring));
xhci->opreg->crcr_lo = virt_to_phys(xhci->cr.ring) | CRCR_RCS;
xhci->opreg->crcr_hi = 0;
@@ -384,9 +384,9 @@ xhci_reinit (hci_t *controller)
/* Initialize event ring */
xhci_reset_event_ring(&xhci->er);
- xhci_debug("event ring @%p (0x%08x)\n",
+ xhci_debug("event ring @%p (0x%08"PRIxPTR")\n",
xhci->er.ring, virt_to_phys(xhci->er.ring));
- xhci_debug("ERST Max: 0x%lx -> 0x%lx entries\n",
+ xhci_debug("ERST Max: 0x%"PRIx32" -> 0x%x entries\n",
CAP_GET(ERST_MAX, xhci->capreg),
1 << CAP_GET(ERST_MAX, xhci->capreg));
memset((void*)xhci->ev_ring_table, 0x00, sizeof(erst_entry_t));
diff --git a/payloads/libpayload/drivers/usb/xhci_commands.c b/payloads/libpayload/drivers/usb/xhci_commands.c
index d633cc5762..a4078030c6 100644
--- a/payloads/libpayload/drivers/usb/xhci_commands.c
+++ b/payloads/libpayload/drivers/usb/xhci_commands.c
@@ -75,7 +75,13 @@ xhci_wait_for_command(xhci_t *const xhci,
/* Abort command on timeout */
xhci_debug("Aborting command (@%p), CRCR: 0x%"PRIx32"\n",
cmd_trb, xhci->opreg->crcr_lo);
- xhci->opreg->crcr_lo |= CRCR_CS | CRCR_CA;
+ /*
+ * Ref. xHCI Specification Revision 1.2, May 2019.
+ * Section 5.4.5, Table 5-24.
+ *
+ * Abort the command and stop the ring.
+ */
+ xhci->opreg->crcr_lo |= CRCR_CA;
xhci->opreg->crcr_hi = 0;
cc = xhci_wait_for_command_aborted(xhci, cmd_trb);
diff --git a/payloads/libpayload/drivers/usb/xhci_events.c b/payloads/libpayload/drivers/usb/xhci_events.c
index 32a43fcfeb..139ea59619 100644
--- a/payloads/libpayload/drivers/usb/xhci_events.c
+++ b/payloads/libpayload/drivers/usb/xhci_events.c
@@ -226,7 +226,15 @@ xhci_wait_for_event_type(xhci_t *const xhci,
return *timeout_us;
}
-/* returns cc of command in question (pointed to by `address`) */
+/*
+ * Ref. xHCI Specification Revision 1.2, May 2019.
+ * Section 4.6.1.2.
+ *
+ * Process events from xHCI Abort command.
+ *
+ * Returns CC_COMMAND_RING_STOPPED on success and TIMEOUT on failure.
+ */
+
int
xhci_wait_for_command_aborted(xhci_t *const xhci, const trb_t *const address)
{
@@ -239,12 +247,13 @@ xhci_wait_for_command_aborted(xhci_t *const xhci, const trb_t *const address)
int cc = TIMEOUT;
/*
* Expects two command completion events:
- * The first with CC == COMMAND_ABORTED should point to address,
+ * The first with CC == COMMAND_ABORTED should point to address
+ * (not present if command was not running),
* the second with CC == COMMAND_RING_STOPPED should point to new dq.
*/
while (xhci_wait_for_event_type(xhci, TRB_EV_CMD_CMPL, &timeout_us)) {
if ((xhci->er.cur->ptr_low == virt_to_phys(address)) &&
- (xhci->er.cur->ptr_high == 0)) {
+ (xhci->er.cur->ptr_high == 0)) {
cc = TRB_GET(CC, xhci->er.cur);
xhci_advance_event_ring(xhci);
break;
@@ -252,20 +261,31 @@ xhci_wait_for_command_aborted(xhci_t *const xhci, const trb_t *const address)
xhci_handle_command_completion_event(xhci);
}
- if (!timeout_us)
- xhci_debug("Warning: Timed out waiting for COMMAND_ABORTED.\n");
+ if (timeout_us == 0) {
+ xhci_debug("Warning: Timed out waiting for "
+ "COMMAND_ABORTED or COMMAND_RING_STOPPED.\n");
+ goto update_and_return;
+ }
+ if (cc == CC_COMMAND_RING_STOPPED) {
+ /* There may not have been a command to abort. */
+ goto update_and_return;
+ }
+
+ timeout_us = USB_MAX_PROCESSING_TIME_US; /* 5s */
while (xhci_wait_for_event_type(xhci, TRB_EV_CMD_CMPL, &timeout_us)) {
if (TRB_GET(CC, xhci->er.cur) == CC_COMMAND_RING_STOPPED) {
- xhci->cr.cur = phys_to_virt(xhci->er.cur->ptr_low);
+ cc = CC_COMMAND_RING_STOPPED;
xhci_advance_event_ring(xhci);
break;
}
xhci_handle_command_completion_event(xhci);
}
- if (!timeout_us)
+ if (timeout_us == 0)
xhci_debug("Warning: Timed out "
"waiting for COMMAND_RING_STOPPED.\n");
+
+update_and_return:
xhci_update_event_dq(xhci);
return cc;
}
diff --git a/payloads/libpayload/drivers/usb/xhci_private.h b/payloads/libpayload/drivers/usb/xhci_private.h
index 8e11937ac5..34d3651daf 100644
--- a/payloads/libpayload/drivers/usb/xhci_private.h
+++ b/payloads/libpayload/drivers/usb/xhci_private.h
@@ -204,7 +204,7 @@ typedef transfer_ring_t command_ring_t;
#define SC_UADDR_LEN 8
#define SC_STATE_FIELD f4 /* STATE - Slot State */
#define SC_STATE_START 27
-#define SC_STATE_LEN 8
+#define SC_STATE_LEN 5
#define SC_MASK(tok) MASK(SC_##tok##_START, SC_##tok##_LEN)
#define SC_GET(tok, sc) (((sc)->SC_##tok##_FIELD & SC_MASK(tok)) \
>> SC_##tok##_START)
@@ -363,7 +363,7 @@ typedef struct erst_entry {
#define CAP_CSZ_LEN 1
#define CAP_MASK(tok) MASK(CAP_##tok##_START, CAP_##tok##_LEN)
-#define CAP_GET(tok, cap) (((cap)->CAP_##tok##_FIELD & CAP_MASK(tok)) \
+#define CAP_GET(tok, cap) ((read32(&(cap)->CAP_##tok##_FIELD) & CAP_MASK(tok)) \
>> CAP_##tok##_START)
#define CTXSIZE(xhci) (CAP_GET(CSZ, (xhci)->capreg) ? 64 : 32)
@@ -515,7 +515,6 @@ static inline int xhci_ep_id(const endpoint_t *const ep) {
return ((ep->endpoint & 0x7f) * 2) + (ep->direction != OUT);
}
-
#ifdef XHCI_DUMPS
void xhci_dump_slotctx(const slotctx_t *);
void xhci_dump_epctx(const epctx_t *);
diff --git a/payloads/libpayload/drivers/usb/xhci_rh.c b/payloads/libpayload/drivers/usb/xhci_rh.c
index 9b711c8586..bf4c2bc5c1 100644
--- a/payloads/libpayload/drivers/usb/xhci_rh.c
+++ b/payloads/libpayload/drivers/usb/xhci_rh.c
@@ -135,7 +135,6 @@ xhci_rh_enable_port(usbdev_t *const dev, int port)
return 0;
}
-
static const generic_hub_ops_t xhci_rh_ops = {
.hub_status_changed = xhci_rh_hub_status_changed,
.port_status_changed = xhci_rh_port_status_changed,
diff --git a/payloads/libpayload/drivers/video/corebootfb.c b/payloads/libpayload/drivers/video/corebootfb.c
index c21665d0c0..51922d9b06 100644
--- a/payloads/libpayload/drivers/video/corebootfb.c
+++ b/payloads/libpayload/drivers/video/corebootfb.c
@@ -60,7 +60,7 @@ static const u32 vga_colors[] = {
(0xFF << 16) | (0xFF << 8) | 0xFF,
};
-struct cb_framebuffer fbinfo;
+static struct cb_framebuffer fbinfo;
static unsigned short *chars;
/* Shorthand for up-to-date virtual framebuffer address */
@@ -138,7 +138,6 @@ static void corebootfb_putchar(u8 row, u8 col, unsigned int ch)
((((vga_colors[fg] >> 16) & 0xff) >> (8 - fbinfo.red_mask_size)) << fbinfo.red_mask_pos);
}
-
dst = FB + ((row * font_height) * fbinfo.bytes_per_line);
dst += (col * font_width * (fbinfo.bits_per_pixel >> 3));
@@ -223,13 +222,10 @@ static void corebootfb_set_cursor(unsigned int x, unsigned int y)
static int corebootfb_init(void)
{
- if (lib_sysinfo.framebuffer == NULL)
+ if (!lib_sysinfo.framebuffer.physical_address)
return -1;
- fbinfo = *lib_sysinfo.framebuffer;
-
- if (fbinfo.physical_address == 0)
- return -1;
+ fbinfo = lib_sysinfo.framebuffer;
font_init(fbinfo.x_resolution);
diff --git a/payloads/libpayload/drivers/video/geodelx.c b/payloads/libpayload/drivers/video/geodelx.c
index 7c51fc21e6..8799bca669 100644
--- a/payloads/libpayload/drivers/video/geodelx.c
+++ b/payloads/libpayload/drivers/video/geodelx.c
@@ -176,7 +176,6 @@ static void init_video_mode(void)
writel(((vga_mode.hactive - 1) << 16) | (vga_mode.vactive - 1),
DC + 0x5C);
-
/* Write the VG configuration */
writel(0x290000F | vga_mode.synccfg, VG + 0x08);
diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c
index 54d3dfa2b2..563f2961c7 100644
--- a/payloads/libpayload/drivers/video/graphics.c
+++ b/payloads/libpayload/drivers/video/graphics.c
@@ -41,12 +41,17 @@
static struct rect canvas;
static struct rect screen;
+static uint8_t *gfx_buffer;
+
/*
* Framebuffer is assumed to assign a higher coordinate (larger x, y) to
* a higher address
*/
-static struct cb_framebuffer *fbinfo;
-static uint8_t *fbaddr;
+static const struct cb_framebuffer *fbinfo;
+
+/* Shorthand for up-to-date virtual framebuffer address */
+#define REAL_FB ((unsigned char *)phys_to_virt(fbinfo->physical_address))
+#define FB (gfx_buffer ? gfx_buffer : REAL_FB)
#define LOG(x...) printf("CBGFX: " x)
#define PIVOT_H_MASK (PIVOT_H_LEFT|PIVOT_H_CENTER|PIVOT_H_RIGHT)
@@ -61,17 +66,53 @@ static const struct vector vzero = {
.y = 0,
};
+struct color_transformation {
+ uint8_t base;
+ int16_t scale;
+};
+
+struct color_mapping {
+ struct color_transformation red;
+ struct color_transformation green;
+ struct color_transformation blue;
+ int enabled;
+};
+
+static struct color_mapping color_map;
+
+static inline void set_color_trans(struct color_transformation *trans,
+ uint8_t bg_color, uint8_t fg_color)
+{
+ trans->base = bg_color;
+ trans->scale = fg_color - bg_color;
+}
+
+int set_color_map(const struct rgb_color *background,
+ const struct rgb_color *foreground)
+{
+ if (background == NULL || foreground == NULL)
+ return CBGFX_ERROR_INVALID_PARAMETER;
+
+ set_color_trans(&color_map.red, background->red, foreground->red);
+ set_color_trans(&color_map.green, background->green,
+ foreground->green);
+ set_color_trans(&color_map.blue, background->blue, foreground->blue);
+ color_map.enabled = 1;
+
+ return CBGFX_SUCCESS;
+}
+
+void clear_color_map(void)
+{
+ color_map.enabled = 0;
+}
+
struct blend_value {
uint8_t alpha;
struct rgb_color rgb;
};
-static struct blend_value blend = {
- .alpha = 0,
- .rgb.red = 0,
- .rgb.green = 0,
- .rgb.blue = 0,
-};
+static struct blend_value blend;
int set_blend(const struct rgb_color *rgb, uint8_t alpha)
{
@@ -99,6 +140,11 @@ static void add_vectors(struct vector *out,
out->y = v1->y + v2->y;
}
+static int fraction_equal(const struct fraction *f1, const struct fraction *f2)
+{
+ return (int64_t)f1->n * f2->d == (int64_t)f2->n * f1->d;
+}
+
static int is_valid_fraction(const struct fraction *f)
{
return f->d != 0;
@@ -109,17 +155,31 @@ static int is_valid_scale(const struct scale *s)
return is_valid_fraction(&s->x) && is_valid_fraction(&s->y);
}
+static void reduce_fraction(struct fraction *out, int64_t n, int64_t d)
+{
+ /* Simplest way to reduce the fraction until fitting in int32_t */
+ int shift = log2(MAX(ABS(n), ABS(d)) >> 31) + 1;
+ out->n = n >> shift;
+ out->d = d >> shift;
+}
+
+/* out = f1 + f2 */
static void add_fractions(struct fraction *out,
const struct fraction *f1, const struct fraction *f2)
{
- int64_t n, d;
- int shift;
- n = (int64_t)f1->n * f2->d + (int64_t)f2->n * f1->d;
- d = (int64_t)f1->d * f2->d;
- /* Simplest way to reduce the fraction until fitting in int32_t */
- shift = log2(MAX(ABS(n), ABS(d)) >> 31) + 1;
- out->n = n >> shift;
- out->d = d >> shift;
+ reduce_fraction(out,
+ (int64_t)f1->n * f2->d + (int64_t)f2->n * f1->d,
+ (int64_t)f1->d * f2->d);
+}
+
+/* out = f1 - f2 */
+static void subtract_fractions(struct fraction *out,
+ const struct fraction *f1,
+ const struct fraction *f2)
+{
+ reduce_fraction(out,
+ (int64_t)f1->n * f2->d - (int64_t)f2->n * f1->d,
+ (int64_t)f1->d * f2->d);
}
static void add_scales(struct scale *out,
@@ -166,6 +226,15 @@ static int within_box(const struct vector *v, const struct rect *bound)
return -1;
}
+/* Helper function that applies color_map to the color. */
+static inline uint8_t apply_map(uint8_t color,
+ const struct color_transformation *trans)
+{
+ if (!color_map.enabled)
+ return color;
+ return trans->base + trans->scale * color / UINT8_MAX;
+}
+
/*
* Helper function that applies color and opacity from blend struct
* into the color.
@@ -184,13 +253,16 @@ static inline uint32_t calculate_color(const struct rgb_color *rgb,
{
uint32_t color = 0;
- color |= (apply_blend(rgb->red, blend.rgb.red)
+ color |= (apply_blend(apply_map(rgb->red, &color_map.red),
+ blend.rgb.red)
>> (8 - fbinfo->red_mask_size))
<< fbinfo->red_mask_pos;
- color |= (apply_blend(rgb->green, blend.rgb.green)
+ color |= (apply_blend(apply_map(rgb->green, &color_map.green),
+ blend.rgb.green)
>> (8 - fbinfo->green_mask_size))
<< fbinfo->green_mask_pos;
- color |= (apply_blend(rgb->blue, blend.rgb.blue)
+ color |= (apply_blend(apply_map(rgb->blue, &color_map.blue),
+ blend.rgb.blue)
>> (8 - fbinfo->blue_mask_size))
<< fbinfo->blue_mask_pos;
if (invert)
@@ -229,7 +301,7 @@ static inline void set_pixel(struct vector *coord, uint32_t color)
break;
}
- uint8_t * const pixel = fbaddr + rcoord.y * bpl + rcoord.x * bpp / 8;
+ uint8_t * const pixel = FB + rcoord.y * bpl + rcoord.x * bpp / 8;
for (i = 0; i < bpp / 8; i++)
pixel[i] = (color >> (i * 8));
}
@@ -243,12 +315,9 @@ static int cbgfx_init(void)
if (initialized)
return 0;
- fbinfo = lib_sysinfo.framebuffer;
- if (!fbinfo)
- return CBGFX_ERROR_FRAMEBUFFER_INFO;
+ fbinfo = &lib_sysinfo.framebuffer;
- fbaddr = phys_to_virt((uint8_t *)(uintptr_t)(fbinfo->physical_address));
- if (!fbaddr)
+ if (!fbinfo->physical_address)
return CBGFX_ERROR_FRAMEBUFFER_ADDR;
switch (fbinfo->orientation) {
@@ -477,6 +546,59 @@ int draw_rounded_box(const struct scale *pos_rel, const struct scale *dim_rel,
return CBGFX_SUCCESS;
}
+int draw_line(const struct scale *pos1, const struct scale *pos2,
+ const struct fraction *thickness, const struct rgb_color *rgb)
+{
+ struct fraction len;
+ struct vector top_left;
+ struct vector size;
+ struct vector p, t;
+
+ if (cbgfx_init())
+ return CBGFX_ERROR_INIT;
+
+ const uint32_t color = calculate_color(rgb, 0);
+
+ if (!is_valid_fraction(thickness))
+ return CBGFX_ERROR_INVALID_PARAMETER;
+
+ transform_vector(&top_left, &canvas.size, pos1, &canvas.offset);
+ if (fraction_equal(&pos1->y, &pos2->y)) {
+ /* Horizontal line */
+ subtract_fractions(&len, &pos2->x, &pos1->x);
+ struct scale dim = {
+ .x = { .n = len.n, .d = len.d },
+ .y = { .n = thickness->n, .d = thickness->d },
+ };
+ transform_vector(&size, &canvas.size, &dim, &vzero);
+ size.y = MAX(size.y, 1);
+ } else if (fraction_equal(&pos1->x, &pos2->x)) {
+ /* Vertical line */
+ subtract_fractions(&len, &pos2->y, &pos1->y);
+ struct scale dim = {
+ .x = { .n = thickness->n, .d = thickness->d },
+ .y = { .n = len.n, .d = len.d },
+ };
+ transform_vector(&size, &canvas.size, &dim, &vzero);
+ size.x = MAX(size.x, 1);
+ } else {
+ LOG("Only support horizontal and vertical lines\n");
+ return CBGFX_ERROR_INVALID_PARAMETER;
+ }
+
+ add_vectors(&t, &top_left, &size);
+ if (within_box(&t, &canvas) < 0) {
+ LOG("Line exceeds canvas boundary\n");
+ return CBGFX_ERROR_BOUNDARY;
+ }
+
+ for (p.y = top_left.y; p.y < t.y; p.y++)
+ for (p.x = top_left.x; p.x < t.x; p.x++)
+ set_pixel(&p, color);
+
+ return CBGFX_SUCCESS;
+}
+
int clear_canvas(const struct rgb_color *rgb)
{
const struct rect box = {
@@ -507,7 +629,7 @@ int clear_screen(const struct rgb_color *rgb)
* We assume that for 32bpp the high byte gets ignored anyway. */
if ((((color >> 8) & 0xff) == (color & 0xff)) && (bpp == 16 ||
(((color >> 16) & 0xff) == (color & 0xff)))) {
- memset(fbaddr, color & 0xff, fbinfo->y_resolution * bpl);
+ memset(FB, color & 0xff, fbinfo->y_resolution * bpl);
} else {
for (p.y = 0; p.y < screen.size.height; p.y++)
for (p.x = 0; p.x < screen.size.width; p.x++)
@@ -736,24 +858,25 @@ static int draw_bitmap_v3(const struct vector *top_left,
}
/*
- * Initialize the sample array for this line. For pixels to the
- * left of S0 there are no corresponding input pixels so just
- * copy the S0 values over.
- *
- * Also initialize the equals counter, which counts how many of
- * the latest pixels were exactly equal. We know the columns
- * left of S0 must be equal to S0, so start with that number.
+ * Initialize the sample array for this line, and also
+ * the equals counter, which counts how many of the latest
+ * pixels were exactly equal.
*/
- int equals = S0 * SSZ;
+ int equals = 0;
uint8_t last_equal = ypix[0][0];
- for (sy = 0; sy < SSZ; sy++) {
- for (sx = S0; sx < SSZ; sx++) {
- if (sx >= dim_org->width) {
+ for (sx = 0; sx < SSZ; sx++) {
+ for (sy = 0; sy < SSZ; sy++) {
+ if (sx - S0 >= dim_org->width) {
sample[sx][sy] = sample[sx - 1][sy];
equals++;
continue;
}
- uint8_t i = ypix[sy][sx - S0];
+ /*
+ * For pixels to the left of S0 there are no
+ * corresponding input pixels so just use
+ * ypix[sy][0].
+ */
+ uint8_t i = ypix[sy][MAX(0, sx - S0)];
if (pal_to_rgb(i, pal, header->colors_used,
&sample[sx][sy]))
goto bitmap_error;
@@ -764,8 +887,6 @@ static int draw_bitmap_v3(const struct vector *top_left,
equals = 1;
}
}
- for (sx = S0 - 1; sx >= 0; sx--)
- sample[sx][sy] = sample[S0][sy];
}
ix = 0;
@@ -1138,3 +1259,37 @@ int get_bitmap_dimension(const void *bitmap, size_t sz, struct scale *dim_rel)
return CBGFX_SUCCESS;
}
+
+int enable_graphics_buffer(void)
+{
+ if (gfx_buffer)
+ return CBGFX_SUCCESS;
+
+ if (cbgfx_init())
+ return CBGFX_ERROR_INIT;
+
+ size_t buffer_size = fbinfo->y_resolution * fbinfo->bytes_per_line;
+ gfx_buffer = malloc(buffer_size);
+ if (!gfx_buffer) {
+ LOG("%s: Failed to create graphics buffer (%zu bytes).\n",
+ __func__, buffer_size);
+ return CBGFX_ERROR_GRAPHICS_BUFFER;
+ }
+
+ return CBGFX_SUCCESS;
+}
+
+int flush_graphics_buffer(void)
+{
+ if (!gfx_buffer)
+ return CBGFX_ERROR_GRAPHICS_BUFFER;
+
+ memcpy(REAL_FB, gfx_buffer, fbinfo->y_resolution * fbinfo->bytes_per_line);
+ return CBGFX_SUCCESS;
+}
+
+void disable_graphics_buffer(void)
+{
+ free(gfx_buffer);
+ gfx_buffer = NULL;
+}
diff --git a/payloads/libpayload/include/arm64/arch/mmu.h b/payloads/libpayload/include/arm64/arch/mmu.h
index 5a1dd98a59..2b1e9e120c 100644
--- a/payloads/libpayload/include/arm64/arch/mmu.h
+++ b/payloads/libpayload/include/arm64/arch/mmu.h
@@ -194,4 +194,12 @@ struct mmu_memrange* mmu_init_ranges_from_sysinfo(struct memrange *cb_ranges,
*/
void mmu_presysinfo_memory_used(uint64_t base, uint64_t size);
void mmu_presysinfo_enable(void);
+
+/*
+ * Functions for exposing the used memory ranges to payloads. The ranges contain
+ * all used memory ranges that are actually used by payload. i.e. _start -> _end
+ * in linker script, the coreboot tables and framebuffer/DMA allocated in MMU
+ * initialization.
+ */
+const struct mmu_ranges *mmu_get_used_ranges(void);
#endif // __ARCH_ARM64_MMU_H__
diff --git a/payloads/libpayload/include/cbfs_core.h b/payloads/libpayload/include/cbfs_core.h
index 397e08b301..fc4caa4417 100644
--- a/payloads/libpayload/include/cbfs_core.h
+++ b/payloads/libpayload/include/cbfs_core.h
@@ -49,7 +49,6 @@
#include
#include
#include
-#include
/** These are standard values for the known compression
alogrithms that coreboot knows about for stages and
diff --git a/payloads/libpayload/include/cbgfx.h b/payloads/libpayload/include/cbgfx.h
index 84e76f26d1..72e512267a 100644
--- a/payloads/libpayload/include/cbgfx.h
+++ b/payloads/libpayload/include/cbgfx.h
@@ -56,6 +56,8 @@
#define CBGFX_ERROR_FRAMEBUFFER_ADDR 0x15
/* portrait screen not supported */
#define CBGFX_ERROR_PORTRAIT_SCREEN 0x16
+/* cannot use buffered I/O */
+#define CBGFX_ERROR_GRAPHICS_BUFFER 0x17
struct fraction {
int32_t n;
@@ -132,6 +134,22 @@ int draw_rounded_box(const struct scale *pos_rel, const struct scale *dim_rel,
const struct fraction *thickness,
const struct fraction *radius);
+/**
+ * Draw a horizontal or vertical line segment on screen. If horizontal, pos1
+ * must be the left endpoint. If vertical, pos1 must be the top endpoint. When
+ * the specified thickness is zero (or truncated to zero), a line with 1-pixel
+ * width will be drawn.
+ *
+ * @param[in] pos1 Start position of the line relative to the canvas.
+ * @param[in] pos2 End position of the line relative to the canvas.
+ * @param[in] thickness Thickness of the line relative to the canvas.
+ * @param[in] rgb Color of the line.
+ *
+ * @return CBGFX_* error codes
+ */
+int draw_line(const struct scale *pos1, const struct scale *pos2,
+ const struct fraction *thickness, const struct rgb_color *rgb);
+
/**
* Clear the canvas
*/
@@ -211,6 +229,24 @@ int draw_bitmap_direct(const void *bitmap, size_t size,
*/
int get_bitmap_dimension(const void *bitmap, size_t sz, struct scale *dim_rel);
+/**
+ * Setup color mappings of background and foreground colors. Black and white
+ * pixels will be mapped to the background and foreground colors, respectively.
+ * Call clear_color_map() to disabled color mapping.
+ *
+ * @param[in] background Background color.
+ * @param[in] foreground Foreground color.
+ *
+ * @return CBGFX_* error codes
+ */
+int set_color_map(const struct rgb_color *background,
+ const struct rgb_color *foreground);
+
+/**
+ * Clear color mappings.
+ */
+void clear_color_map(void);
+
/**
* Setup alpha and rgb values for alpha blending. When alpha is != 0,
* this enables a translucent layer of color (defined by rgb) to be
@@ -228,8 +264,6 @@ int set_blend(const struct rgb_color *rgb, uint8_t alpha);
/**
* Clear alpha and rgb values, thus disabling any alpha blending.
- *
- * @return CBGFX_* error codes
*/
void clear_blend(void);
@@ -240,3 +274,24 @@ void clear_blend(void);
* 0 = min alpha argument, 0% opacity
*/
#define ALPHA(percentage) MIN(255, (256 * percentage / 100))
+
+/**
+ * Enable buffered I/O. All CBGFX operations will be redirected to a working
+ * buffer, and only updated (redrawn) when flush_graphics_buffer() is called.
+ *
+ * @return CBGFX_* error codes
+ */
+int enable_graphics_buffer(void);
+
+/**
+ * Redraw buffered graphics data to real screen if graphics buffer is already
+ * enabled.
+ *
+ * @return CBGFX_* error codes
+ */
+int flush_graphics_buffer(void);
+
+/**
+ * Stop using buffered I/O and release allocated memory.
+ */
+void disable_graphics_buffer(void);
diff --git a/payloads/libpayload/include/compiler.h b/payloads/libpayload/include/compiler.h
index 0d56cbea4b..ee2ff88d10 100644
--- a/payloads/libpayload/include/compiler.h
+++ b/payloads/libpayload/include/compiler.h
@@ -1,29 +1,39 @@
-/*
- *
- * Copyright 2017 Google Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only */
-#ifndef __COMPILER_H__
-#define __COMPILER_H__
+#ifndef _COMMONLIB_BSD_COMPILER_H_
+#define _COMMONLIB_BSD_COMPILER_H_
+#ifndef __packed
#if defined(__WIN32) || defined(__WIN64)
#define __packed __attribute__((gcc_struct, packed))
#else
#define __packed __attribute__((packed))
#endif
+#endif
+#ifndef __aligned
#define __aligned(x) __attribute__((aligned(x)))
+#endif
+
+#ifndef __always_unused
#define __always_unused __attribute__((unused))
+#endif
+
+#ifndef __must_check
#define __must_check __attribute__((warn_unused_result))
+#endif
+
+#ifndef __weak
+#define __weak __attribute__((weak))
+#endif
+
+#ifndef __noreturn
+#define __noreturn __attribute__((noreturn))
+#endif
+
+#ifndef __always_inline
+#define __always_inline inline __attribute__((always_inline))
+#endif
/* This evaluates to the type of the first expression, unless that is constant
in which case it evalutates to the type of the second. This is useful when
@@ -32,7 +42,7 @@
literals. By using this macro, the promotion can happen at the time the
literal is assigned to the temporary variable. If the literal doesn't fit in
the chosen type, -Werror=overflow will catch it, so this should be safe. */
-#define __TYPEOF_UNLESS_CONST(expr, fallback_expr) typeof( \
+#define __TYPEOF_UNLESS_CONST(expr, fallback_expr) __typeof__( \
__builtin_choose_expr(__builtin_constant_p(expr), fallback_expr, expr))
/* This creates a unique local variable name for use in macros. */
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index 91d3520ad5..e042a900b9 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -31,6 +31,7 @@
#include
#include
+#include
enum {
CB_TAG_UNUSED = 0x0000,
@@ -78,6 +79,8 @@ enum {
CB_TAG_MMC_INFO = 0x0035,
CB_TAG_TCPA_LOG = 0x0036,
CB_TAG_FMAP = 0x0037,
+ CB_TAG_SMMSTOREV2 = 0x0039,
+ CB_TAG_BOARD_CONFIG = 0x0040,
CB_TAG_CMOS_OPTION_TABLE = 0x00c8,
CB_TAG_OPTION = 0x00c9,
CB_TAG_OPTION_ENUM = 0x00ca,
@@ -258,10 +261,11 @@ struct cb_x86_rom_mtrr {
uint32_t index;
};
-struct cb_strapping_id {
- uint32_t tag;
+/* Memory map windows to translate addresses between SPI flash space and host address space. */
+struct flash_mmap_window {
+ uint32_t flash_base;
+ uint32_t host_base;
uint32_t size;
- uint32_t id_code;
};
struct cb_spi_flash {
@@ -270,6 +274,12 @@ struct cb_spi_flash {
uint32_t flash_size;
uint32_t sector_size;
uint32_t erase_cmd;
+ /*
+ * Number of mmap windows used by the platform to decode addresses between SPI flash
+ * space and host address space. This determines the number of entries in mmap_table.
+ */
+ uint32_t mmap_count;
+ struct flash_mmap_window mmap_table[0];
};
struct cb_boot_media_params {
@@ -315,6 +325,16 @@ struct cb_mmc_info {
int32_t early_cmd1_status;
};
+struct cb_board_config {
+ uint32_t tag;
+ uint32_t size;
+
+ struct cbuint64 fw_config;
+ uint32_t board_id;
+ uint32_t ram_code;
+ uint32_t sku_id;
+};
+
#define CB_MAX_SERIALNO_LENGTH 32
struct cb_cmos_option_table {
@@ -395,5 +415,5 @@ static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
+ (sizeof((_rec)->map[0]) * (_idx)))
/* Helper functions */
-void *get_cbmem_ptr(unsigned char *ptr);
+uintptr_t get_cbmem_addr(const void *cbmem_tab_entry);
#endif
diff --git a/payloads/libpayload/include/ctype.h b/payloads/libpayload/include/ctype.h
index c1ca698e1c..98cb306180 100644
--- a/payloads/libpayload/include/ctype.h
+++ b/payloads/libpayload/include/ctype.h
@@ -50,5 +50,4 @@ int tolower(int c);
int toupper(int c);
/** @} */
-
#endif
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 25080d85ed..a33d8bb382 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -42,8 +42,8 @@
#ifndef _LIBPAYLOAD_H
#define _LIBPAYLOAD_H
+#include
#include
-#include
#include
#include
#include
@@ -186,7 +186,7 @@ int add_reset_handler(void (*new_handler)(void));
*/
void keyboard_init(void);
void keyboard_disconnect(void);
-int keyboard_havechar(void);
+bool keyboard_havechar(void);
unsigned char keyboard_get_scancode(void);
int keyboard_getchar(void);
int keyboard_set_layout(char *country);
@@ -233,11 +233,15 @@ u8 i8042_data_ready_ps2(void);
u8 i8042_data_ready_aux(void);
u8 i8042_read_data_ps2(void);
+u8 i8042_peek_data_ps2(void);
u8 i8042_read_data_aux(void);
int i8042_wait_read_ps2(void);
int i8042_wait_read_aux(void);
+int i8042_get_kbd_translation(void);
+int i8042_set_kbd_translation(bool xlate);
+
/** @} */
/**
@@ -445,6 +449,8 @@ u8 hex2bin(u8 h);
void hexdump(const void *memory, size_t length);
void fatal(const char *msg) __attribute__((noreturn));
+/* Population Count: number of bits that are one */
+static inline int popcnt(u32 x) { return __builtin_popcount(x); }
/* Count Leading Zeroes: clz(0) == 32, clz(0xf) == 28, clz(1 << 31) == 0 */
static inline int clz(u32 x)
{
@@ -454,8 +460,16 @@ static inline int clz(u32 x)
static inline int log2(u32 x) { return (int)sizeof(x) * 8 - clz(x) - 1; }
/* Find First Set: __ffs(0xf) == 0, __ffs(0) == -1, __ffs(1 << 31) == 31 */
static inline int __ffs(u32 x) { return log2(x & (u32)(-(s32)x)); }
-/** @} */
+static inline int popcnt64(u64 x) { return __builtin_popcountll(x); }
+static inline int clz64(u64 x)
+{
+ return x ? __builtin_clzll(x) : sizeof(x) * 8;
+}
+
+static inline int log2_64(u64 x) { return sizeof(x) * 8 - clz64(x) - 1; }
+static inline int __ffs64(u64 x) { return log2_64(x & (u64)(-(s64)x)); }
+/** @} */
/**
* @defgroup mmio MMIO helper functions
@@ -475,7 +489,6 @@ static inline void buffer_to_fifo32(void *buffer, size_t size, void *fifo,
#endif
/** @} */
-
/**
* @defgroup hash Hashing functions
* @{
diff --git a/payloads/libpayload/include/pci/pci.h b/payloads/libpayload/include/pci/pci.h
index 8c11d6b33f..5e21060130 100644
--- a/payloads/libpayload/include/pci/pci.h
+++ b/payloads/libpayload/include/pci/pci.h
@@ -66,6 +66,7 @@
#define PCI_ROM_ADDRESS1 0x38 // on bridges
#define PCI_ROM_ADDRESS_MASK ~0x7ff
+#define PCI_CLASS_STORAGE_AHCI 0x0106
#define PCI_CLASS_MEMORY_OTHER 0x0580
#define PCI_VENDOR_ID_INTEL 0x8086
@@ -74,6 +75,7 @@ struct pci_dev {
u16 domain;
u8 bus, dev, func;
u16 vendor_id, device_id;
+ u16 device_class;
struct pci_dev *next;
};
diff --git a/payloads/libpayload/include/queue.h b/payloads/libpayload/include/queue.h
index 7d579a7bc4..c9ac701987 100644
--- a/payloads/libpayload/include/queue.h
+++ b/payloads/libpayload/include/queue.h
@@ -344,7 +344,6 @@ struct { \
#define XSIMPLEQ_EMPTY(head) (XSIMPLEQ_FIRST(head) == XSIMPLEQ_END(head))
#define XSIMPLEQ_NEXT(head, elm, field) XSIMPLEQ_XOR(head, ((elm)->field.sqx_next))
-
#define XSIMPLEQ_FOREACH(var, head, field) \
for ((var) = XSIMPLEQ_FIRST(head); \
(var) != XSIMPLEQ_END(head); \
@@ -398,7 +397,6 @@ struct { \
XSIMPLEQ_XOR(head, &(elm)->field.sqx_next); \
} while (0)
-
/*
* Tail queue definitions.
*/
@@ -442,7 +440,6 @@ struct { \
((tvar) = TAILQ_NEXT(var, field), 1); \
(var) = (tvar))
-
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for((var) = TAILQ_LAST(head, headname); \
(var) != TAILQ_END(head); \
diff --git a/payloads/libpayload/include/stdbool.h b/payloads/libpayload/include/stdbool.h
new file mode 100644
index 0000000000..33858d51f2
--- /dev/null
+++ b/payloads/libpayload/include/stdbool.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
+#ifndef __STDBOOL_H
+#define __STDBOOL_H
+
+#define bool _Bool
+#define false 0
+#define true (!false)
+
+#endif
diff --git a/payloads/libpayload/include/storage/ahci.h b/payloads/libpayload/include/storage/ahci.h
index 0aa032297a..18a0920a61 100644
--- a/payloads/libpayload/include/storage/ahci.h
+++ b/payloads/libpayload/include/storage/ahci.h
@@ -26,9 +26,11 @@
* SUCH DAMAGE.
*/
+#include
+
#ifndef _STORAGE_AHCI_H
#define _STORAGE_AHCI_H
-void ahci_initialize(void);
+void ahci_initialize(struct pci_dev *dev);
#endif
diff --git a/payloads/libpayload/include/storage/ata.h b/payloads/libpayload/include/storage/ata.h
index 39937dbe34..43249e7513 100644
--- a/payloads/libpayload/include/storage/ata.h
+++ b/payloads/libpayload/include/storage/ata.h
@@ -33,7 +33,6 @@
#include "storage.h"
-
/* ATA commands */
enum {
ATA_READ_DMA = 0xc8,
diff --git a/payloads/libpayload/include/storage/atapi.h b/payloads/libpayload/include/storage/atapi.h
index eea5c332f8..5a6e244032 100644
--- a/payloads/libpayload/include/storage/atapi.h
+++ b/payloads/libpayload/include/storage/atapi.h
@@ -34,7 +34,6 @@
#include "storage.h"
#include "ata.h"
-
/* ATAPI commands */
enum {
ATAPI_TEST_UNIT_READY = 0x00,
diff --git a/payloads/libpayload/include/storage/storage.h b/payloads/libpayload/include/storage/storage.h
index 7a2a84bef7..32933fd97c 100644
--- a/payloads/libpayload/include/storage/storage.h
+++ b/payloads/libpayload/include/storage/storage.h
@@ -32,14 +32,12 @@
#include
#include
-
#if !CONFIG(LP_STORAGE_64BIT_LBA)
typedef u32 lba_t;
#else
typedef u64 lba_t;
#endif
-
typedef enum {
PORT_TYPE_IDE = (1 << 0),
PORT_TYPE_SATA = (1 << 1),
@@ -54,7 +52,6 @@ typedef enum {
POLL_MEDIUM_PRESENT = 1,
} storage_poll_t;
-
struct storage_dev;
typedef struct storage_dev {
@@ -70,7 +67,6 @@ typedef struct storage_dev {
int storage_device_count(void);
int storage_attach_device(storage_dev_t *dev);
-
storage_poll_t storage_probe(size_t dev_num);
ssize_t storage_read_blocks512(size_t dev_num, lba_t start, size_t count, unsigned char *buf);
diff --git a/payloads/libpayload/include/string.h b/payloads/libpayload/include/string.h
index ca263e4410..393881d9cc 100644
--- a/payloads/libpayload/include/string.h
+++ b/payloads/libpayload/include/string.h
@@ -83,5 +83,4 @@ size_t strlcpy(char *d, const char *s, size_t n);
size_t strlcat(char *d, const char *s, size_t n);
/** @} */
-
#endif
diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h
index 6e83f684df..5a24e1405f 100644
--- a/payloads/libpayload/include/sysinfo.h
+++ b/payloads/libpayload/include/sysinfo.h
@@ -29,6 +29,9 @@
#ifndef _SYSINFO_H
#define _SYSINFO_H
+#include
+#include
+
/* Maximum number of memory range definitions. */
#define SYSINFO_MAX_MEM_RANGES 32
/* Allow a maximum of 8 GPIOs */
@@ -37,19 +40,21 @@
/* Up to 10 MAC addresses */
#define SYSINFO_MAX_MACS 10
+/* Maximum of 2 MMAP windows for decoding SPI flash. */
+#define SYSINFO_MAX_MMAP_WINDOWS 2
+
#include
-struct cb_serial;
-
/*
- * All pointers in here shall be virtual.
+ * This is a collection of information and pointers gathered
+ * mostly from the coreboot table.
*
- * If a relocation happens after the last call to lib_get_sysinfo(),
- * it is up to the user to call lib_get_sysinfo() again.
+ * We do not store virtual pointers in here to avoid problems
+ * with self-relocating payloads.
*/
struct sysinfo_t {
unsigned int cpu_khz;
- struct cb_serial *serial;
+ uintptr_t cb_serial;
unsigned short ser_ioport;
unsigned long ser_base; // for mmapped serial
@@ -61,62 +66,71 @@ struct sysinfo_t {
unsigned int type;
} memrange[SYSINFO_MAX_MEM_RANGES];
- struct cb_cmos_option_table *option_table;
+ uintptr_t cmos_option_table;
u32 cmos_range_start;
u32 cmos_range_end;
u32 cmos_checksum_location;
u32 vbnv_start;
u32 vbnv_size;
- char *version;
- char *extra_version;
- char *build;
- char *compile_time;
- char *compile_by;
- char *compile_host;
- char *compile_domain;
- char *compiler;
- char *linker;
- char *assembler;
+ uintptr_t version;
+ uintptr_t extra_version;
+ uintptr_t build;
+ uintptr_t compile_time;
+ uintptr_t compile_by;
+ uintptr_t compile_host;
+ uintptr_t compile_domain;
+ uintptr_t compiler;
+ uintptr_t linker;
+ uintptr_t assembler;
- char *cb_version;
+ uintptr_t cb_version;
- struct cb_framebuffer *framebuffer;
+ struct cb_framebuffer framebuffer;
int num_gpios;
struct cb_gpio gpios[SYSINFO_MAX_GPIOS];
int num_macs;
struct mac_address macs[SYSINFO_MAX_MACS];
- char *serialno;
+ uintptr_t serialno;
unsigned long *mbtable; /** Pointer to the multiboot table */
- struct cb_header *header;
- struct cb_mainboard *mainboard;
+ uintptr_t cb_header;
+ uintptr_t cb_mainboard;
- void *vboot_workbuf;
+ uintptr_t vboot_workbuf;
#if CONFIG(LP_ARCH_X86)
int x86_rom_var_mtrr_index;
#endif
- void *tstamp_table;
- void *cbmem_cons;
- void *mrc_cache;
- void *acpi_gnvs;
+ uintptr_t tstamp_table;
+ uintptr_t cbmem_cons;
+ uintptr_t mrc_cache;
+ uintptr_t acpi_gnvs;
-#define UNDEFINED_STRAPPING_ID (~0)
+#define UNDEFINED_STRAPPING_ID (~0)
+#define UNDEFINED_FW_CONFIG ~((uint64_t)0)
u32 board_id;
u32 ram_code;
u32 sku_id;
- void *wifi_calibration;
+ /*
+ * A payload using this field is responsible for ensuring it checks its
+ * value against UNDEFINED_FW_CONFIG before using it.
+ */
+ u64 fw_config;
+
+ uintptr_t wifi_calibration;
uint64_t ramoops_buffer;
uint32_t ramoops_buffer_size;
struct {
uint32_t size;
uint32_t sector_size;
uint32_t erase_cmd;
+ uint32_t mmap_window_count;
+ struct flash_mmap_window mmap_table[SYSINFO_MAX_MMAP_WINDOWS];
} spi_flash;
uint64_t fmap_offset;
uint64_t cbfs_offset;
@@ -124,11 +138,15 @@ struct sysinfo_t {
uint64_t boot_media_size;
uint64_t mtc_start;
uint32_t mtc_size;
- void *chromeos_vpd;
- int mmc_early_wake_status;
+ uintptr_t chromeos_vpd;
+ int mmc_early_wake_status;
/* Pointer to FMAP cache in CBMEM */
- void *fmap_cache;
+ uintptr_t fmap_cache;
+
+#if CONFIG(LP_PCI)
+ struct pci_access pacc;
+#endif
};
extern struct sysinfo_t lib_sysinfo;
diff --git a/payloads/libpayload/include/usb/usb.h b/payloads/libpayload/include/usb/usb.h
index f79fc27711..43c7b4279d 100644
--- a/payloads/libpayload/include/usb/usb.h
+++ b/payloads/libpayload/include/usb/usb.h
@@ -334,7 +334,7 @@ int usb_interface_check(u16 vendor, u16 device);
#define USB_QUIRK_TEST (1 << 31)
#define USB_QUIRK_NONE 0
-static inline void usb_debug(const char *fmt, ...)
+static inline void __attribute__((format(printf, 1, 2))) usb_debug(const char *fmt, ...)
{
#ifdef USB_DEBUG
va_list ap;
diff --git a/payloads/libpayload/include/x86/arch/cpuid.h b/payloads/libpayload/include/x86/arch/cpuid.h
index 83733016fe..ddd606a072 100644
--- a/payloads/libpayload/include/x86/arch/cpuid.h
+++ b/payloads/libpayload/include/x86/arch/cpuid.h
@@ -32,4 +32,52 @@
#define cpuid(fn, eax, ebx, ecx, edx) \
asm("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(fn))
+#define _declare_cpuid(reg) \
+ static inline unsigned int cpuid_##reg(unsigned int fn) \
+ { \
+ unsigned int eax, ebx, ecx, edx; \
+ cpuid(fn, eax, ebx, ecx, edx); \
+ return reg; \
+ }
+
+_declare_cpuid(eax)
+_declare_cpuid(ebx)
+_declare_cpuid(ecx)
+_declare_cpuid(edx)
+
+#undef _declare_cpuid
+
+static inline unsigned int cpuid_max(void)
+{
+ return cpuid_eax(0);
+}
+
+static inline unsigned int cpuid_family(void)
+{
+ const unsigned int eax = cpuid_eax(1);
+ return (eax & 0xff00000) >> (20 - 4) | (eax & 0xf00) >> 8;
+}
+
+static inline unsigned int cpuid_model(void)
+{
+ const unsigned int eax = cpuid_eax(1);
+ return (eax & 0xf0000) >> (16 - 4) | (eax & 0xf0) >> 4;
+}
+
+enum intel_fam6_model {
+ NEHALEM = 0x25,
+ SANDYBRIDGE = 0x2a,
+ IVYBRIDGE = 0x3a,
+ HASWELL = 0x3c,
+ BROADWELL_U = 0x3d,
+ HASWELL_U = 0x45,
+ HASWELL_GT3E = 0x46,
+ BROADWELL = 0x47,
+ SKYLAKE_U_Y = 0x4e,
+ APOLLOLAKE = 0x5c,
+ SKYLAKE_S_H = 0x5e,
+ KABYLAKE_U_Y = 0x8e,
+ KABYLAKE_S_H = 0x9e,
+};
+
#endif
diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c
index c6fb57fde9..7e23afe2e5 100644
--- a/payloads/libpayload/libc/coreboot.c
+++ b/payloads/libpayload/libc/coreboot.c
@@ -41,10 +41,10 @@
/* === Parsing code === */
/* This is the generic parsing code. */
-void *get_cbmem_ptr(unsigned char *ptr)
+uintptr_t get_cbmem_addr(const void *const cbmem_tab_entry)
{
- struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
- return phys_to_virt(cbmem->cbmem_tab);
+ const struct cb_cbmem_tab *const cbmem = cbmem_tab_entry;
+ return cbmem->cbmem_tab;
}
static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
@@ -80,12 +80,12 @@ static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
{
- info->serial = ((struct cb_serial *)ptr);
+ info->cb_serial = virt_to_phys(ptr);
}
static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info)
{
- info->vboot_workbuf = get_cbmem_ptr(ptr);
+ info->vboot_workbuf = get_cbmem_addr(ptr);
}
static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
@@ -130,42 +130,33 @@ static void cb_parse_mac_addresses(unsigned char *ptr,
static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info)
{
- info->tstamp_table = get_cbmem_ptr(ptr);
+ info->tstamp_table = get_cbmem_addr(ptr);
}
static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info)
{
- info->cbmem_cons = get_cbmem_ptr(ptr);
+ info->cbmem_cons = get_cbmem_addr(ptr);
}
static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info)
{
- info->acpi_gnvs = get_cbmem_ptr(ptr);
+ info->acpi_gnvs = get_cbmem_addr(ptr);
}
-static void cb_parse_board_id(unsigned char *ptr, struct sysinfo_t *info)
+static void cb_parse_board_config(unsigned char *ptr, struct sysinfo_t *info)
{
- struct cb_strapping_id *const cbbid = (struct cb_strapping_id *)ptr;
- info->board_id = cbbid->id_code;
-}
-
-static void cb_parse_ram_code(unsigned char *ptr, struct sysinfo_t *info)
-{
- struct cb_strapping_id *const ram_code = (struct cb_strapping_id *)ptr;
- info->ram_code = ram_code->id_code;
-}
-
-static void cb_parse_sku_id(unsigned char *ptr, struct sysinfo_t *info)
-{
- struct cb_strapping_id *const sku_id = (struct cb_strapping_id *)ptr;
- info->sku_id = sku_id->id_code;
+ struct cb_board_config *const config = (struct cb_board_config *)ptr;
+ info->fw_config = cb_unpack64(config->fw_config);
+ info->board_id = config->board_id;
+ info->ram_code = config->ram_code;
+ info->sku_id = config->sku_id;
}
#if CONFIG(LP_NVRAM)
static void cb_parse_optiontable(void *ptr, struct sysinfo_t *info)
{
- /* ptr points to a coreboot table entry and is already virtual */
- info->option_table = ptr;
+ /* ptr is already virtual, but we want to keep physical addresses */
+ info->cmos_option_table = virt_to_phys(ptr);
}
static void cb_parse_checksum(void *ptr, struct sysinfo_t *info)
@@ -180,19 +171,21 @@ static void cb_parse_checksum(void *ptr, struct sysinfo_t *info)
#if CONFIG(LP_COREBOOT_VIDEO_CONSOLE)
static void cb_parse_framebuffer(void *ptr, struct sysinfo_t *info)
{
- /* ptr points to a coreboot table entry and is already virtual */
- info->framebuffer = ptr;
+ info->framebuffer = *(struct cb_framebuffer *)ptr;
}
#endif
-static void cb_parse_string(unsigned char *ptr, char **info)
+static void cb_parse_string(const void *const ptr, uintptr_t *const info)
{
- *info = (char *)((struct cb_string *)ptr)->string;
+ /* ptr is already virtual (str->string just an offset to that),
+ but we want to keep physical addresses */
+ const struct cb_string *const str = ptr;
+ *info = virt_to_phys(str->string);
}
static void cb_parse_wifi_calibration(void *ptr, struct sysinfo_t *info)
{
- info->wifi_calibration = get_cbmem_ptr(ptr);
+ info->wifi_calibration = get_cbmem_addr(ptr);
}
static void cb_parse_ramoops(void *ptr, struct sysinfo_t *info)
@@ -218,6 +211,13 @@ static void cb_parse_spi_flash(void *ptr, struct sysinfo_t *info)
info->spi_flash.size = flash->flash_size;
info->spi_flash.sector_size = flash->sector_size;
info->spi_flash.erase_cmd = flash->erase_cmd;
+
+ if (flash->mmap_count == 0)
+ return;
+
+ info->spi_flash.mmap_window_count = MIN(flash->mmap_count, SYSINFO_MAX_MMAP_WINDOWS);
+ memcpy(info->spi_flash.mmap_table, flash->mmap_table,
+ info->spi_flash.mmap_window_count * sizeof(struct flash_mmap_window));
}
static void cb_parse_boot_media_params(unsigned char *ptr,
@@ -233,12 +233,12 @@ static void cb_parse_boot_media_params(unsigned char *ptr,
static void cb_parse_vpd(void *ptr, struct sysinfo_t *info)
{
- info->chromeos_vpd = get_cbmem_ptr(ptr);
+ info->chromeos_vpd = get_cbmem_addr(ptr);
}
static void cb_parse_fmap_cache(void *ptr, struct sysinfo_t *info)
{
- info->fmap_cache = get_cbmem_ptr(ptr);
+ info->fmap_cache = get_cbmem_addr(ptr);
}
#if CONFIG(LP_TIMER_RDTSC)
@@ -282,12 +282,13 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
header->table_bytes) != header->table_checksum)
return -1;
- info->header = header;
+ info->cb_header = virt_to_phys(header);
/* Initialize IDs as undefined in case they don't show up in table. */
info->board_id = UNDEFINED_STRAPPING_ID;
info->ram_code = UNDEFINED_STRAPPING_ID;
info->sku_id = UNDEFINED_STRAPPING_ID;
+ info->fw_config = UNDEFINED_FW_CONFIG;
/* Now, walk the tables. */
ptr += header->header_bytes;
@@ -353,7 +354,7 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
break;
#endif
case CB_TAG_MAINBOARD:
- info->mainboard = (struct cb_mainboard *)ptr;
+ info->cb_mainboard = virt_to_phys(ptr);
break;
case CB_TAG_GPIO:
cb_parse_gpios(ptr, info);
@@ -379,14 +380,8 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
case CB_TAG_ACPI_GNVS:
cb_parse_acpi_gnvs(ptr, info);
break;
- case CB_TAG_BOARD_ID:
- cb_parse_board_id(ptr, info);
- break;
- case CB_TAG_RAM_CODE:
- cb_parse_ram_code(ptr, info);
- break;
- case CB_TAG_SKU_ID:
- cb_parse_sku_id(ptr, info);
+ case CB_TAG_BOARD_CONFIG:
+ cb_parse_board_config(ptr, info);
break;
case CB_TAG_WIFI_CALIBRATION:
cb_parse_wifi_calibration(ptr, info);
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 8b22daa9cc..20f9ef38e1 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -123,7 +123,8 @@ int dma_coherent(void *ptr)
return !dma_initialized() || (dma->start <= ptr && dma->end > ptr);
}
-static void *alloc(int len, struct memory_type *type)
+/* Find free block of size >= len */
+static hdrtype_t volatile *find_free_block(int len, struct memory_type *type)
{
hdrtype_t header;
hdrtype_t volatile *ptr = (hdrtype_t volatile *)type->start;
@@ -156,37 +157,53 @@ static void *alloc(int len, struct memory_type *type)
halt();
}
- if (header & FLAG_FREE) {
- if (len <= size) {
- hdrtype_t volatile *nptr = (hdrtype_t volatile *)((uintptr_t)ptr + HDRSIZE + len);
- int nsize = size - (HDRSIZE + len);
-
- /* If there is still room in this block,
- * then mark it as such otherwise account
- * the whole space for that block.
- */
-
- if (nsize > 0) {
- /* Mark the block as used. */
- *ptr = USED_BLOCK(len);
-
- /* Create a new free block. */
- *nptr = FREE_BLOCK(nsize);
- } else {
- /* Mark the block as used. */
- *ptr = USED_BLOCK(size);
- }
-
- return (void *)((uintptr_t)ptr + HDRSIZE);
- }
- }
+ if ((header & FLAG_FREE) && len <= size)
+ return ptr;
ptr = (hdrtype_t volatile *)((uintptr_t)ptr + HDRSIZE + size);
} while (ptr < (hdrtype_t *) type->end);
/* Nothing available. */
- return (void *)NULL;
+ return NULL;
+}
+
+/* Mark the block with length 'len' as used */
+static void use_block(hdrtype_t volatile *ptr, int len)
+{
+ /* Align the size. */
+ len = ALIGN_UP(len, HDRSIZE);
+
+ hdrtype_t volatile *nptr = (hdrtype_t volatile *)
+ ((uintptr_t)ptr + HDRSIZE + len);
+ int size = SIZE(*ptr);
+ int nsize = size - (HDRSIZE + len);
+
+ /*
+ * If there is still room in this block, then mark it as such otherwise
+ * account the whole space for that block.
+ */
+ if (nsize > 0) {
+ /* Mark the block as used. */
+ *ptr = USED_BLOCK(len);
+
+ /* Create a new free block. */
+ *nptr = FREE_BLOCK(nsize);
+ } else {
+ /* Mark the block as used. */
+ *ptr = USED_BLOCK(size);
+ }
+}
+
+static void *alloc(int len, struct memory_type *type)
+{
+ hdrtype_t volatile *ptr = find_free_block(len, type);
+
+ if (ptr == NULL)
+ return NULL;
+
+ use_block(ptr, len);
+ return (void *)((uintptr_t)ptr + HDRSIZE);
}
static void _consolidate(struct memory_type *type)
@@ -229,6 +246,10 @@ void free(void *ptr)
hdrtype_t hdr;
struct memory_type *type = heap;
+ /* No action occurs on NULL. */
+ if (ptr == NULL)
+ return;
+
/* Sanity check. */
if (ptr < type->start || ptr >= type->end) {
type = dma;
@@ -277,6 +298,7 @@ void *calloc(size_t nmemb, size_t size)
void *realloc(void *ptr, size_t size)
{
void *ret, *pptr;
+ hdrtype_t volatile *block;
unsigned int osize;
struct memory_type *type = heap;
@@ -300,18 +322,23 @@ void *realloc(void *ptr, size_t size)
* reallocated the new space.
*/
free(ptr);
- ret = alloc(size, type);
+
+ block = find_free_block(size, type);
+ if (block == NULL)
+ return NULL;
+
+ ret = (void *)((uintptr_t)block + HDRSIZE);
/*
- * if ret == NULL, then doh - failure.
- * if ret == ptr then woo-hoo! no copy needed.
+ * If ret == ptr, then no copy is needed. Otherwise, move the memory to
+ * the new location, which might be before the old one and overlap since
+ * the free() above includes a _consolidate().
*/
- if (ret == NULL || ret == ptr)
- return ret;
+ if (ret != ptr)
+ memmove(ret, ptr, osize > size ? size : osize);
- /* Move the memory to the new location. Might be before the old location
- and overlap since the free() above includes a _consolidate(). */
- memmove(ret, ptr, osize > size ? size : osize);
+ /* Mark the block as used. */
+ use_block(block, size);
return ret;
}
diff --git a/payloads/libpayload/libc/memory.c b/payloads/libpayload/libc/memory.c
index daa53f1bcb..fff295e54c 100644
--- a/payloads/libpayload/libc/memory.c
+++ b/payloads/libpayload/libc/memory.c
@@ -90,7 +90,7 @@ static void *default_memmove(void *dst, const void *src, size_t n)
ssize_t i;
if (src > dst)
- return memcpy(dst, src, n);
+ return default_memcpy(dst, src, n);
if (!IS_ALIGNED((uintptr_t)dst, sizeof(unsigned long)) ||
!IS_ALIGNED((uintptr_t)src, sizeof(unsigned long))) {
@@ -145,7 +145,6 @@ static int default_memcmp(const void *s1, const void *s2, size_t n)
int memcmp(const void *s1, const void *s2, size_t n)
__attribute__((weak, alias("default_memcmp")));
-
void *memchr(const void *s, int c, size_t n)
{
unsigned char *p = (unsigned char *)s;
diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c
index a481fef7eb..46c3c019bd 100644
--- a/payloads/libpayload/libc/string.c
+++ b/payloads/libpayload/libc/string.c
@@ -521,7 +521,6 @@ unsigned long int strtoul(const char *ptr, char **endptr, int base)
return val;
}
-
/**
* Determine the number of leading characters in s that match characters in a
* @param s A pointer to the string to analyse
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index c0a3313e86..6780008d4c 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -31,11 +31,14 @@
* General time functions
*/
+#define __STDC_FORMAT_MACROS
+
#include
#include
#if CONFIG(LP_ARCH_X86) && CONFIG(LP_NVRAM)
#include
#endif
+#include
extern u32 cpu_khz;
@@ -173,7 +176,7 @@ u64 timer_us(u64 base)
if (hz == 0) {
hz = timer_hz();
if (hz < 1000000) {
- printf("Timer frequency %lld is too low, "
+ printf("Timer frequency %" PRIu64 " is too low, "
"must be at least 1MHz.\n", hz);
halt();
}
diff --git a/payloads/libpayload/liblzma/lzmadecode.c b/payloads/libpayload/liblzma/lzmadecode.c
index 1cf647d27b..c8115d308a 100644
--- a/payloads/libpayload/liblzma/lzmadecode.c
+++ b/payloads/libpayload/liblzma/lzmadecode.c
@@ -33,12 +33,10 @@
#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
{ int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
-
#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
-
#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
@@ -56,7 +54,6 @@
do { CProb *cp = probs + res; RC_GET_BIT(cp, res) } while(--i != 0); \
res -= (1 << numLevels); }
-
#define kNumPosBitsMax 4
#define kNumPosStatesMax (1 << kNumPosBitsMax)
@@ -74,7 +71,6 @@
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
-
#define kNumStates 12
#define kNumLitStates 7
@@ -143,7 +139,6 @@ int LzmaDecode(CLzmaDecoderState *vs,
UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
int lc = vs->Properties.lc;
-
int state = 0;
UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
int len = 0;
@@ -164,7 +159,6 @@ int LzmaDecode(CLzmaDecoderState *vs,
RC_INIT(inStream, inSize);
-
while(nowPos < outSize)
{
CProb *prob;
@@ -379,7 +373,6 @@ int LzmaDecode(CLzmaDecoderState *vs,
if (rep0 > nowPos)
return LZMA_RESULT_DATA_ERROR;
-
do
{
previousByte = outStream[nowPos - rep0];
@@ -391,7 +384,6 @@ int LzmaDecode(CLzmaDecoderState *vs,
}
RC_NORMALIZE;
-
*inSizeProcessed = (SizeT)(Buffer - inStream);
*outSizeProcessed = nowPos;
return LZMA_RESULT_OK;
diff --git a/payloads/libpayload/liblzma/lzmadecode.h b/payloads/libpayload/liblzma/lzmadecode.h
index 34c9f14c33..05ff0a3397 100644
--- a/payloads/libpayload/liblzma/lzmadecode.h
+++ b/payloads/libpayload/liblzma/lzmadecode.h
@@ -32,7 +32,6 @@ typedef UInt32 SizeT;
#define LZMA_RESULT_OK 0
#define LZMA_RESULT_DATA_ERROR 1
-
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
@@ -56,10 +55,8 @@ typedef struct _CLzmaDecoderState
CLzmaProperties Properties;
CProb *Probs;
-
} CLzmaDecoderState;
-
int LzmaDecode(CLzmaDecoderState *vs,
const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
diff --git a/payloads/libpayload/libpci/libpci.c b/payloads/libpayload/libpci/libpci.c
index 27347e3bf8..200ae18435 100644
--- a/payloads/libpayload/libpci/libpci.c
+++ b/payloads/libpayload/libpci/libpci.c
@@ -72,8 +72,7 @@ int pci_write_long(struct pci_dev *dev, int pos, u32 data)
struct pci_access *pci_alloc(void)
{
- struct pci_access *pacc = malloc(sizeof(*pacc));
- return pacc;
+ return malloc(sizeof(struct pci_access));
}
void pci_init(struct pci_access *pacc)
@@ -179,6 +178,7 @@ static struct pci_dev *pci_scan_single_bus(struct pci_dev *dev, uint8_t bus)
dev->func = func;
dev->vendor_id = val & 0xffff;
dev->device_id = (uint16_t)(val >> 16);
+ dev->device_class = pci_read_config16(PCI_DEV(bus, slot, func), PCI_CLASS_DEVICE);
dev->next = 0;
hdr = pci_read_config8(PCI_DEV(bus, slot, func),
diff --git a/payloads/libpayload/sample/Makefile b/payloads/libpayload/sample/Makefile
index eb70af90b7..637e45dee1 100644
--- a/payloads/libpayload/sample/Makefile
+++ b/payloads/libpayload/sample/Makefile
@@ -28,7 +28,7 @@
# Sample libpayload Makefile.
include ../.config
-include ../.xcompile
+include ../build/xcompile
ARCH-$(CONFIG_LP_ARCH_ARM) := arm
ARCH-$(CONFIG_LP_ARCH_X86) := x86_32
diff --git a/payloads/nvramcui/.gitignore b/payloads/nvramcui/.gitignore
new file mode 100644
index 0000000000..4885853d42
--- /dev/null
+++ b/payloads/nvramcui/.gitignore
@@ -0,0 +1,2 @@
+build
+libpayload
diff --git a/payloads/nvramcui/Makefile b/payloads/nvramcui/Makefile
index bf7053b9a6..269d558d19 100644
--- a/payloads/nvramcui/Makefile
+++ b/payloads/nvramcui/Makefile
@@ -26,9 +26,9 @@ else
endif
clean:
- rm -f nvramcui.elf
+ rm -rf build libpayload nvramcui.elf
distclean: clean
- rm -rf build libpayload .config .config.old
+ rm -rf .config .config.old
.PHONY: all clean distclean
diff --git a/payloads/nvramcui/nvramcui.c b/payloads/nvramcui/nvramcui.c
index ee3de1cde0..db3e522d60 100644
--- a/payloads/nvramcui/nvramcui.c
+++ b/payloads/nvramcui/nvramcui.c
@@ -37,7 +37,7 @@ static int max(int x, int y)
return y;
}
-void render_form(FORM *form)
+static void render_form(FORM *form)
{
int y, x, line;
WINDOW *w = form_win(form);
diff --git a/src/Kconfig b/src/Kconfig
index a4c2fa6010..33065cbddb 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -270,6 +270,45 @@ config UBSAN
say N because it adds a small performance penalty and may abort
on code that happens to work in spite of the UB.
+config HAVE_ASAN_IN_ROMSTAGE
+ bool
+ default n
+
+config ASAN_IN_ROMSTAGE
+ bool
+ default n
+ help
+ Enable address sanitizer in romstage for platform.
+
+config HAVE_ASAN_IN_RAMSTAGE
+ bool
+ default n
+
+config ASAN_IN_RAMSTAGE
+ bool
+ default n
+ help
+ Enable address sanitizer in ramstage for platform.
+
+config ASAN
+ bool "Address sanitizer support"
+ default n
+ select ASAN_IN_ROMSTAGE if HAVE_ASAN_IN_ROMSTAGE
+ select ASAN_IN_RAMSTAGE if HAVE_ASAN_IN_RAMSTAGE
+ help
+ Enable address sanitizer - runtime memory debugger,
+ designed to find out-of-bounds accesses and use-after-scope bugs.
+
+ This feature consumes up to 1/8 of available memory and brings about
+ ~1.5x performance slowdown.
+
+ If unsure, say N.
+
+if ASAN
+ comment "Before using this feature, make sure that "
+ comment "asan_shadow_offset_callback patch is applied to GCC."
+endif
+
choice
prompt "Stage Cache for ACPI S3 resume"
default NO_STAGE_CACHE if !HAVE_ACPI_RESUME
@@ -497,6 +536,17 @@ source "src/vendorcode/*/Kconfig"
source "src/arch/*/Kconfig"
+config CHIPSET_DEVICETREE
+ string
+ default ""
+ help
+ This symbol allows a chipset to provide a set of default settings in
+ a devicetree which are common to all mainboards. This may include
+ devices (including alias names), chip drivers, register settings,
+ and others. This path is relative to the src/ directory.
+
+ Example: "chipset.cb"
+
endmenu
source "src/device/Kconfig"
@@ -504,6 +554,7 @@ source "src/device/Kconfig"
menu "Generic Drivers"
source "src/drivers/*/Kconfig"
source "src/drivers/*/*/Kconfig"
+source "src/drivers/*/*/*/Kconfig"
source "src/commonlib/storage/Kconfig"
endmenu
@@ -839,7 +890,7 @@ config DEBUG_SMI
bool "Output verbose SMI debug messages"
default n
depends on HAVE_SMI_HANDLER
- select SPI_FLASH_SMM if SPI_CONSOLE || CONSOLE_SPI_FLASH
+ select SPI_FLASH_SMM if EM100PRO_SPI_CONSOLE || CONSOLE_SPI_FLASH
help
This option enables additional SMI related debug messages.
@@ -854,7 +905,7 @@ config DEBUG_PERIODIC_SMI
# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
# printk(BIOS_DEBUG, ...) calls.
config DEBUG_MALLOC
- prompt "Output verbose malloc debug messages" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
+ prompt "Output verbose malloc debug messages" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8 || CONSOLE_OVERRIDE_LOGLEVEL
bool
default n
help
@@ -864,6 +915,15 @@ config DEBUG_MALLOC
If unsure, say N.
+# Only visible if DEBUG_SPEW (8) is set.
+config DEBUG_RESOURCES
+ bool "Output verbose PCI MEM and IO resource debug messages" if DEFAULT_CONSOLE_LOGLEVEL_8 || CONSOLE_OVERRIDE_LOGLEVEL
+ default n
+ help
+ This option enables additional PCI memory and IO debug messages.
+ Note: This option will increase the size of the coreboot image.
+ If unsure, say N.
+
config DEBUG_CONSOLE_INIT
bool "Debug console initialisation code"
default n
@@ -879,7 +939,7 @@ config DEBUG_CONSOLE_INIT
# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
# printk(BIOS_DEBUG, ...) calls.
config REALMODE_DEBUG
- prompt "Enable debug messages for option ROM execution" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
+ prompt "Enable debug messages for option ROM execution" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8 || CONSOLE_OVERRIDE_LOGLEVEL
bool
default n
depends on PCI_OPTION_ROM_RUN_REALMODE
@@ -1053,15 +1113,14 @@ config DEBUG_INTEL_ME
is present on Intel 6-series chipsets.
endif
-config TRACE
- bool "Trace function calls"
+config DEBUG_FUNC
+ bool "Enable function entry and exit reporting macros" if DEFAULT_CONSOLE_LOGLEVEL_8
default n
help
- If enabled, every function will print information to console once
- the function is entered. The syntax is ~0xaaaabbbb(0xccccdddd)
- the 0xaaaabbbb is the actual function and 0xccccdddd is EIP
- of calling function. Please note some printk related functions
- are omitted from trace to have good looking console dumps.
+ This option enables additional function entry and exit debug messages
+ for select functions.
+ Note: This option will increase the size of the coreboot image.
+ If unsure, say N.
config DEBUG_COVERAGE
bool "Debug code coverage"
@@ -1105,7 +1164,6 @@ config EM100
endmenu
-
###############################################################################
# Set variables with no prompt - these can be set anywhere, and putting at
# the end of this file gives the most flexibility.
diff --git a/src/acpi/Kconfig b/src/acpi/Kconfig
index 07008db7a9..2727889f9e 100644
--- a/src/acpi/Kconfig
+++ b/src/acpi/Kconfig
@@ -24,8 +24,11 @@ config ACPI_INTEL_HARDWARE_SLEEP_VALUES
Provide common definitions for Intel hardware PM1_CNT register sleep
values.
-config ACPI_NO_SMI_GNVS
+config ACPI_SOC_NVS
bool
+ help
+ Set to indicate exists for the platform with a definition
+ for global_nvs.
config ACPI_NO_PCAT_8259
bool
@@ -37,3 +40,9 @@ config HAVE_ACPI_TABLES
help
This variable specifies whether a given board has ACPI table support.
It is usually set in mainboard/*/Kconfig.
+
+config ACPI_LPIT
+ bool
+ depends on HAVE_ACPI_TABLES
+ help
+ Selected by platforms that support and fill Intel Low Power Idle Table.
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc
index f70b23ff5b..1cd837dd88 100644
--- a/src/acpi/Makefile.inc
+++ b/src/acpi/Makefile.inc
@@ -3,6 +3,7 @@
ifeq ($(CONFIG_HAVE_ACPI_TABLES),y)
ramstage-y += acpi.c
+ramstage-y += acpi_pm.c
ramstage-y += acpigen.c
ramstage-y += acpigen_dptf.c
ramstage-y += acpigen_dsm.c
@@ -11,10 +12,13 @@ ramstage-y += acpigen_usb.c
ramstage-y += device.c
ramstage-$(CONFIG_CHROMEOS) += chromeos-gnvs.c
ramstage-y += gnvs.c
+ramstage-$(CONFIG_ACPI_SOC_NVS) += nvs.c
ramstage-y += pld.c
ramstage-y += sata.c
ramstage-y += soundwire.c
+postcar-y += acpi_pm.c
+
ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/acpi_tables.c),)
ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/acpi_tables.c
endif
diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c
index ccd8d2526d..6f64d108f9 100644
--- a/src/acpi/acpi.c
+++ b/src/acpi/acpi.c
@@ -468,7 +468,7 @@ void acpi_create_ssdt_generator(acpi_header_t *ssdt, const char *oem_table_id)
{
struct device *dev;
for (dev = all_devices; dev; dev = dev->next)
- if (dev->ops && dev->ops->acpi_fill_ssdt)
+ if (dev->enabled && dev->ops && dev->ops->acpi_fill_ssdt)
dev->ops->acpi_fill_ssdt(dev);
current = (unsigned long) acpigen_get_current();
}
@@ -752,7 +752,7 @@ void acpi_create_hpet(acpi_hpet_t *hpet)
header->revision = get_acpi_table_revision(HPET);
/* Fill out HPET address. */
- addr->space_id = 0; /* Memory */
+ addr->space_id = ACPI_ADDRESS_SPACE_MEMORY;
addr->bit_width = 64;
addr->bit_offset = 0;
addr->addrl = CONFIG_HPET_ADDRESS & 0xffffffff;
@@ -878,6 +878,35 @@ void acpi_create_ivrs(acpi_ivrs_t *ivrs,
header->checksum = acpi_checksum((void *)ivrs, header->length);
}
+void acpi_create_crat(struct acpi_crat_header *crat,
+ unsigned long (*acpi_fill_crat)(struct acpi_crat_header *crat_struct,
+ unsigned long current))
+{
+ acpi_header_t *header = &(crat->header);
+ unsigned long current = (unsigned long)crat + sizeof(struct acpi_crat_header);
+
+ memset((void *)crat, 0, sizeof(struct acpi_crat_header));
+
+ if (!header)
+ return;
+
+ /* Fill out header fields. */
+ memcpy(header->signature, "CRAT", 4);
+ memcpy(header->oem_id, OEM_ID, 6);
+ memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
+ memcpy(header->asl_compiler_id, ASLC, 4);
+
+ header->asl_compiler_revision = asl_revision;
+ header->length = sizeof(struct acpi_crat_header);
+ header->revision = get_acpi_table_revision(CRAT);
+
+ current = acpi_fill_crat(crat, current);
+
+ /* (Re)calculate length and checksum. */
+ header->length = current - (unsigned long)crat;
+ header->checksum = acpi_checksum((void *)crat, header->length);
+}
+
unsigned long acpi_write_hpet(const struct device *device, unsigned long current,
acpi_rsdp_t *rsdp)
{
@@ -1251,14 +1280,7 @@ void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
/* should be 0 ACPI 3.0 */
fadt->reserved = 0;
- if (CONFIG(SYSTEM_TYPE_CONVERTIBLE) ||
- CONFIG(SYSTEM_TYPE_LAPTOP))
- fadt->preferred_pm_profile = PM_MOBILE;
- else if (CONFIG(SYSTEM_TYPE_DETACHABLE) ||
- CONFIG(SYSTEM_TYPE_TABLET))
- fadt->preferred_pm_profile = PM_TABLET;
- else
- fadt->preferred_pm_profile = PM_DESKTOP;
+ fadt->preferred_pm_profile = acpi_get_preferred_pm_profile();
arch_fill_fadt(fadt);
@@ -1271,6 +1293,44 @@ void acpi_create_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, void *dsdt)
acpi_checksum((void *) fadt, header->length);
}
+void acpi_create_lpit(acpi_lpit_t *lpit)
+{
+ acpi_header_t *header = &(lpit->header);
+ unsigned long current = (unsigned long)lpit + sizeof(acpi_lpit_t);
+
+ memset((void *)lpit, 0, sizeof(acpi_lpit_t));
+
+ if (!header)
+ return;
+
+ /* Fill out header fields. */
+ memcpy(header->signature, "LPIT", 4);
+ memcpy(header->oem_id, OEM_ID, 6);
+ memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8);
+ memcpy(header->asl_compiler_id, ASLC, 4);
+
+ header->asl_compiler_revision = asl_revision;
+ header->revision = get_acpi_table_revision(LPIT);
+ header->oem_revision = 42;
+ header->length = sizeof(acpi_lpit_t);
+
+ current = acpi_fill_lpit(current);
+
+ /* (Re)calculate length and checksum. */
+ header->length = current - (unsigned long)lpit;
+ header->checksum = acpi_checksum((void *)lpit, header->length);
+}
+
+unsigned long acpi_create_lpi_desc_ncst(acpi_lpi_desc_ncst_t *lpi_desc, uint16_t uid)
+{
+ memset(lpi_desc, 0, sizeof(acpi_lpi_desc_ncst_t));
+ lpi_desc->header.length = sizeof(acpi_lpi_desc_ncst_t);
+ lpi_desc->header.type = ACPI_LPI_DESC_TYPE_NATIVE_CSTATE;
+ lpi_desc->header.uid = uid;
+
+ return lpi_desc->header.length;
+}
+
unsigned long __weak fw_cfg_acpi_tables(unsigned long start)
{
return 0;
@@ -1291,6 +1351,7 @@ unsigned long write_acpi_tables(unsigned long start)
acpi_tcpa_t *tcpa;
acpi_tpm2_t *tpm2;
acpi_madt_t *madt;
+ acpi_lpit_t *lpit;
struct device *dev;
unsigned long fw;
size_t slic_size, dsdt_size;
@@ -1347,9 +1408,7 @@ unsigned long write_acpi_tables(unsigned long start)
return fw;
}
- dsdt_file = cbfs_boot_map_with_leak(
- CONFIG_CBFS_PREFIX "/dsdt.aml",
- CBFS_TYPE_RAW, &dsdt_size);
+ dsdt_file = cbfs_map(CONFIG_CBFS_PREFIX "/dsdt.aml", &dsdt_size);
if (!dsdt_file) {
printk(BIOS_ERR, "No DSDT file, skipping ACPI tables\n");
return current;
@@ -1362,12 +1421,12 @@ unsigned long write_acpi_tables(unsigned long start)
return current;
}
- slic_file = cbfs_boot_map_with_leak(CONFIG_CBFS_PREFIX "/slic",
- CBFS_TYPE_RAW, &slic_size);
+ slic_file = cbfs_map(CONFIG_CBFS_PREFIX "/slic", &slic_size);
if (slic_file
&& (slic_file->length > slic_size
|| slic_file->length < sizeof(acpi_header_t)
- || memcmp(slic_file->signature, "SLIC", 4) != 0)) {
+ || (memcmp(slic_file->signature, "SLIC", 4) != 0
+ && memcmp(slic_file->signature, "MSDM", 4) != 0))) {
slic_file = 0;
}
@@ -1413,6 +1472,9 @@ unsigned long write_acpi_tables(unsigned long start)
current += sizeof(acpi_header_t);
acpigen_set_current((char *) current);
+
+ acpi_fill_gnvs();
+
for (dev = all_devices; dev; dev = dev->next)
if (dev->ops && dev->ops->acpi_inject_dsdt)
dev->ops->acpi_inject_dsdt(dev);
@@ -1487,6 +1549,18 @@ unsigned long write_acpi_tables(unsigned long start)
}
}
+ if (CONFIG(ACPI_LPIT)) {
+ printk(BIOS_DEBUG, "ACPI: * LPIT\n");
+
+ lpit = (acpi_lpit_t *)current;
+ acpi_create_lpit(lpit);
+ if (lpit->header.length >= sizeof(acpi_lpit_t)) {
+ current += lpit->header.length;
+ current = acpi_align_current(current);
+ acpi_add_table(rsdp, lpit);
+ }
+ }
+
printk(BIOS_DEBUG, "ACPI: * MADT\n");
madt = (acpi_madt_t *) current;
@@ -1495,6 +1569,7 @@ unsigned long write_acpi_tables(unsigned long start)
current += madt->header.length;
acpi_add_table(rsdp, madt);
}
+
current = acpi_align_current(current);
printk(BIOS_DEBUG, "current = %lx\n", current);
@@ -1540,7 +1615,7 @@ void *acpi_find_wakeup_vector(void)
void *wake_vec;
int i;
- if (!acpi_is_wakeup())
+ if (!acpi_is_wakeup_s3())
return NULL;
printk(BIOS_DEBUG, "Trying to find the wakeup vector...\n");
@@ -1626,7 +1701,7 @@ int get_acpi_table_revision(enum acpi_tables table)
case VFCT: /* ACPI 2.0/3.0/4.0: 1 */
return 1;
case IVRS:
- return IVRS_FORMAT_FIXED;
+ return IVRS_FORMAT_MIXED;
case DBG2:
return 0;
case FACS: /* ACPI 2.0/3.0: 1, ACPI 4.0 upto 6.3: 2 */
@@ -1643,6 +1718,10 @@ int get_acpi_table_revision(enum acpi_tables table)
return 5;
case BERT:
return 1;
+ case CRAT:
+ return 1;
+ case LPIT: /* ACPI 5.1 up to 6.3: 0 */
+ return 0;
default:
return -1;
}
diff --git a/src/acpi/acpi_pm.c b/src/acpi/acpi_pm.c
new file mode 100644
index 0000000000..540b6d2bee
--- /dev/null
+++ b/src/acpi/acpi_pm.c
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include
+#include
+#include
+#include
+
+/* This is filled with acpi_handoff_wakeup_s3() call early in ramstage. */
+static int acpi_slp_type = -1;
+
+static void acpi_handoff_wakeup(void)
+{
+ if (acpi_slp_type < 0) {
+ if (romstage_handoff_is_resume()) {
+ printk(BIOS_DEBUG, "S3 Resume\n");
+ acpi_slp_type = ACPI_S3;
+ } else {
+ printk(BIOS_DEBUG, "Normal boot\n");
+ acpi_slp_type = ACPI_S0;
+ }
+ }
+}
+
+int acpi_handoff_wakeup_s3(void)
+{
+ acpi_handoff_wakeup();
+ return (acpi_slp_type == ACPI_S3);
+}
+
+void __weak mainboard_suspend_resume(void)
+{
+}
+
+/* Default mapping to ACPI FADT preferred_pm_profile field. */
+uint8_t acpi_get_preferred_pm_profile(void)
+{
+ switch (smbios_mainboard_enclosure_type()) {
+ case SMBIOS_ENCLOSURE_LAPTOP:
+ case SMBIOS_ENCLOSURE_CONVERTIBLE:
+ return PM_MOBILE;
+ case SMBIOS_ENCLOSURE_DETACHABLE:
+ case SMBIOS_ENCLOSURE_TABLET:
+ return PM_TABLET;
+ case SMBIOS_ENCLOSURE_DESKTOP:
+ return PM_DESKTOP;
+ case SMBIOS_ENCLOSURE_UNKNOWN:
+ default:
+ return PM_UNSPECIFIED;
+ }
+}
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c
index a4a74f65d7..9a5543d5a4 100644
--- a/src/acpi/acpigen.c
+++ b/src/acpi/acpigen.c
@@ -10,6 +10,8 @@
#define ACPIGEN_MAXLEN 0xfffff
+#define CPPC_PACKAGE_NAME "GCPC"
+
#include
#include
#include
@@ -284,12 +286,15 @@ static void acpigen_emit_multi_namestring(const char *name)
pathlen[0] = count;
}
-
void acpigen_emit_namestring(const char *namepath)
{
int dotcount = 0, i;
int dotpos = 0;
+ /* Check for NULL pointer */
+ if (!namepath)
+ return;
+
/* We can start with a '\'. */
if (namepath[0] == '\\') {
acpigen_emit_byte('\\');
@@ -341,7 +346,7 @@ void acpigen_write_scope(const char *name)
void acpigen_get_package_op_element(uint8_t package_op, unsigned int element, uint8_t dest_op)
{
- /* = DeRefOf ([ = DeRefOf ([]) */
acpigen_write_store();
acpigen_emit_byte(DEREF_OP);
acpigen_emit_byte(INDEX_OP);
@@ -351,6 +356,52 @@ void acpigen_get_package_op_element(uint8_t package_op, unsigned int element, ui
acpigen_emit_byte(dest_op);
}
+void acpigen_set_package_op_element_int(uint8_t package_op, unsigned int element, uint64_t src)
+{
+ /* DeRefOf ([]) = */
+ acpigen_write_store();
+ acpigen_write_integer(src);
+ acpigen_emit_byte(DEREF_OP);
+ acpigen_emit_byte(INDEX_OP);
+ acpigen_emit_byte(package_op);
+ acpigen_write_integer(element);
+ acpigen_emit_byte(ZERO_OP); /* Ignore Index() Destination */
+}
+
+void acpigen_get_package_element(const char *package, unsigned int element, uint8_t dest_op)
+{
+ /* = [] */
+ acpigen_write_store();
+ acpigen_emit_byte(INDEX_OP);
+ acpigen_emit_namestring(package);
+ acpigen_write_integer(element);
+ acpigen_emit_byte(ZERO_OP); /* Ignore Index() Destination */
+ acpigen_emit_byte(dest_op);
+}
+
+void acpigen_set_package_element_int(const char *package, unsigned int element, uint64_t src)
+{
+ /* [] = */
+ acpigen_write_store();
+ acpigen_write_integer(src);
+ acpigen_emit_byte(INDEX_OP);
+ acpigen_emit_namestring(package);
+ acpigen_write_integer(element);
+ acpigen_emit_byte(ZERO_OP); /* Ignore Index() Destination */
+}
+
+void acpigen_set_package_element_namestr(const char *package, unsigned int element,
+ const char *src)
+{
+ /* [] = */
+ acpigen_write_store();
+ acpigen_emit_namestring(src);
+ acpigen_emit_byte(INDEX_OP);
+ acpigen_emit_namestring(package);
+ acpigen_write_integer(element);
+ acpigen_emit_byte(ZERO_OP); /* Ignore Index() Destination */
+}
+
void acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len)
{
/*
@@ -409,7 +460,7 @@ void acpigen_write_processor_cnot(const unsigned int number_of_cores)
* len is region length.
* OperationRegion(regionname, regionspace, regionoffset, regionlength)
*/
-void acpigen_write_opregion(struct opregion *opreg)
+void acpigen_write_opregion(const struct opregion *opreg)
{
/* OpregionOp */
acpigen_emit_ext_op(OPREGION_OP);
@@ -506,6 +557,12 @@ static void acpigen_write_field_name(const char *name, uint32_t size)
acpigen_write_field_length(size);
}
+static void acpigen_write_field_reserved(uint32_t size)
+{
+ acpigen_emit_byte(0);
+ acpigen_write_field_length(size);
+}
+
/*
* Generate ACPI AML code for Field
* Arg0: region name
@@ -516,6 +573,7 @@ static void acpigen_write_field_name(const char *name, uint32_t size)
* struct fieldlist l[] = {
* FIELDLIST_OFFSET(0x84),
* FIELDLIST_NAMESTR("PMCS", 2),
+ * FIELDLIST_RESERVED(6),
* };
* acpigen_write_field("UART", l, ARRAY_SIZE(l), FIELD_ANYACC | FIELD_NOLOCK |
* FIELD_PRESERVE);
@@ -523,7 +581,8 @@ static void acpigen_write_field_name(const char *name, uint32_t size)
* Field (UART, AnyAcc, NoLock, Preserve)
* {
* Offset (0x84),
- * PMCS, 2
+ * PMCS, 2,
+ * , 6,
* }
*/
void acpigen_write_field(const char *name, const struct fieldlist *l, size_t count,
@@ -547,6 +606,10 @@ void acpigen_write_field(const char *name, const struct fieldlist *l, size_t cou
acpigen_write_field_name(l[i].name, l[i].bits);
current_bit_pos += l[i].bits;
break;
+ case RESERVED:
+ acpigen_write_field_reserved(l[i].bits);
+ current_bit_pos += l[i].bits;
+ break;
case OFFSET:
acpigen_write_field_offset(l[i].bits, current_bit_pos);
current_bit_pos = l[i].bits;
@@ -687,7 +750,7 @@ void acpigen_write_empty_PTC(void)
.space_id = ACPI_ADDRESS_SPACE_FIXED,
.bit_width = 0,
.bit_offset = 0,
- .access_size = 0,
+ .access_size = ACPI_ACCESS_SIZE_UNDEFINED,
.addrl = 0,
.addrh = 0,
};
@@ -833,6 +896,23 @@ void acpigen_write_PSS_package(u32 coreFreq, u32 power, u32 transLat,
coreFreq, power, control, status);
}
+void acpigen_write_pss_object(const struct acpi_sw_pstate *pstate_values, size_t nentries)
+{
+ size_t pstate;
+
+ acpigen_write_name("_PSS");
+ acpigen_write_package(nentries);
+ for (pstate = 0; pstate < nentries; pstate++) {
+ acpigen_write_PSS_package(
+ pstate_values->core_freq, pstate_values->power,
+ pstate_values->transition_latency, pstate_values->bus_master_latency,
+ pstate_values->control_value, pstate_values->status_value);
+ pstate_values++;
+ }
+
+ acpigen_pop_len();
+}
+
void acpigen_write_PSD_package(u32 domain, u32 numprocs, PSD_coord coordtype)
{
acpigen_write_name("_PSD");
@@ -851,8 +931,8 @@ void acpigen_write_CST_package_entry(acpi_cstate_t *cstate)
{
acpigen_write_package(4);
acpigen_write_register_resource(&cstate->resource);
- acpigen_write_dword(cstate->ctype);
- acpigen_write_dword(cstate->latency);
+ acpigen_write_byte(cstate->ctype);
+ acpigen_write_word(cstate->latency);
acpigen_write_dword(cstate->power);
acpigen_pop_len();
}
@@ -862,7 +942,7 @@ void acpigen_write_CST_package(acpi_cstate_t *cstate, int nentries)
int i;
acpigen_write_name("_CST");
acpigen_write_package(nentries+1);
- acpigen_write_dword(nentries);
+ acpigen_write_integer(nentries);
for (i = 0; i < nentries; i++)
acpigen_write_CST_package_entry(cstate + i);
@@ -876,7 +956,7 @@ void acpigen_write_CSD_package(u32 domain, u32 numprocs, CSD_coord coordtype,
acpigen_write_name("_CSD");
acpigen_write_package(1);
acpigen_write_package(6);
- acpigen_write_byte(6); // 6 values
+ acpigen_write_integer(6); // 6 values
acpigen_write_byte(0); // revision 0
acpigen_write_dword(domain);
acpigen_write_dword(coordtype);
@@ -930,8 +1010,6 @@ void acpigen_write_TSD_package(u32 domain, u32 numprocs, PSD_coord coordtype)
acpigen_pop_len();
}
-
-
void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size)
{
/*
@@ -1217,6 +1295,22 @@ void acpigen_write_store_op_to_namestr(uint8_t src, const char *dst)
acpigen_emit_namestring(dst);
}
+/* Store (src, "namestr") */
+void acpigen_write_store_int_to_namestr(uint64_t src, const char *dst)
+{
+ acpigen_write_store();
+ acpigen_write_integer(src);
+ acpigen_emit_namestring(dst);
+}
+
+/* Store (src, dst) */
+void acpigen_write_store_int_to_op(uint64_t src, uint8_t dst)
+{
+ acpigen_write_store();
+ acpigen_write_integer(src);
+ acpigen_emit_byte(dst);
+}
+
/* Or (arg1, arg2, res) */
void acpigen_write_or(uint8_t arg1, uint8_t arg2, uint8_t res)
{
@@ -1276,6 +1370,14 @@ void acpigen_write_debug_op(uint8_t op)
acpigen_emit_ext_op(DEBUG_OP);
}
+/* Store (str, DEBUG) */
+void acpigen_write_debug_namestr(const char *str)
+{
+ acpigen_write_store();
+ acpigen_emit_namestring(str);
+ acpigen_emit_ext_op(DEBUG_OP);
+}
+
void acpigen_write_if(void)
{
acpigen_emit_byte(IF_OP);
@@ -1339,6 +1441,14 @@ void acpigen_write_else(void)
acpigen_write_len_f();
}
+void acpigen_write_shiftleft_op_int(uint8_t src_result, uint64_t count)
+{
+ acpigen_emit_byte(SHIFT_LEFT_OP);
+ acpigen_emit_byte(src_result);
+ acpigen_write_integer(count);
+ acpigen_emit_byte(ZERO_OP);
+}
+
void acpigen_write_to_buffer(uint8_t src, uint8_t dst)
{
acpigen_emit_byte(TO_BUFFER_OP);
@@ -1353,6 +1463,13 @@ void acpigen_write_to_integer(uint8_t src, uint8_t dst)
acpigen_emit_byte(dst);
}
+void acpigen_write_to_integer_from_namestring(const char *source, uint8_t dst_op)
+{
+ acpigen_emit_byte(TO_INTEGER_OP);
+ acpigen_emit_namestring(source);
+ acpigen_emit_byte(dst_op);
+}
+
void acpigen_write_byte_buffer(uint8_t *arr, size_t size)
{
size_t i;
@@ -1396,6 +1513,12 @@ void acpigen_write_return_integer(uint64_t arg)
acpigen_write_integer(arg);
}
+void acpigen_write_return_namestr(const char *arg)
+{
+ acpigen_emit_byte(RETURN_OP);
+ acpigen_emit_namestring(arg);
+}
+
void acpigen_write_return_string(const char *arg)
{
acpigen_emit_byte(RETURN_OP);
@@ -1521,8 +1644,6 @@ void acpigen_write_dsm_uuid_arr(struct dsm_uuid *ids, size_t count)
acpigen_pop_len(); /* Method _DSM */
}
-#define CPPC_PACKAGE_NAME "\\GCPC"
-
void acpigen_write_CPPC_package(const struct cppc_config *config)
{
u32 i;
@@ -1553,7 +1674,7 @@ void acpigen_write_CPPC_package(const struct cppc_config *config)
for (i = 0; i < max; ++i) {
const acpi_addr_t *reg = &(config->regs[i]);
if (reg->space_id == ACPI_ADDRESS_SPACE_MEMORY &&
- reg->bit_width == 32 && reg->access_size == 0) {
+ reg->bit_width == 32 && reg->access_size == ACPI_ACCESS_SIZE_UNDEFINED) {
acpigen_write_dword(reg->addrl);
} else {
acpigen_write_register_resource(reg);
@@ -1564,9 +1685,12 @@ void acpigen_write_CPPC_package(const struct cppc_config *config)
void acpigen_write_CPPC_method(void)
{
+ char pscope[16];
+ snprintf(pscope, sizeof(pscope), CONFIG_ACPI_CPU_STRING "." CPPC_PACKAGE_NAME, 0);
+
acpigen_write_method("_CPC", 0);
acpigen_emit_byte(RETURN_OP);
- acpigen_emit_namestring(CPPC_PACKAGE_NAME);
+ acpigen_emit_namestring(pscope);
acpigen_pop_len();
}
@@ -1772,7 +1896,6 @@ void acpigen_write_rom(void *bios, const size_t length)
acpigen_pop_len();
}
-
/* Soc-implemented functions -- weak definitions. */
int __weak acpigen_soc_read_rx_gpio(unsigned int gpio_num)
{
@@ -1809,7 +1932,7 @@ int __weak acpigen_soc_clear_tx_gpio(unsigned int gpio_num)
*
* Returns 0 on success and -1 on error.
*/
-int acpigen_enable_tx_gpio(struct acpi_gpio *gpio)
+int acpigen_enable_tx_gpio(const struct acpi_gpio *gpio)
{
if (gpio->active_low)
return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
@@ -1817,7 +1940,7 @@ int acpigen_enable_tx_gpio(struct acpi_gpio *gpio)
return acpigen_soc_set_tx_gpio(gpio->pins[0]);
}
-int acpigen_disable_tx_gpio(struct acpi_gpio *gpio)
+int acpigen_disable_tx_gpio(const struct acpi_gpio *gpio)
{
if (gpio->active_low)
return acpigen_soc_set_tx_gpio(gpio->pins[0]);
@@ -1825,7 +1948,7 @@ int acpigen_disable_tx_gpio(struct acpi_gpio *gpio)
return acpigen_soc_clear_tx_gpio(gpio->pins[0]);
}
-void acpigen_get_rx_gpio(struct acpi_gpio *gpio)
+void acpigen_get_rx_gpio(const struct acpi_gpio *gpio)
{
acpigen_soc_read_rx_gpio(gpio->pins[0]);
@@ -1833,7 +1956,7 @@ void acpigen_get_rx_gpio(struct acpi_gpio *gpio)
acpigen_write_xor(LOCAL0_OP, 1, LOCAL0_OP);
}
-void acpigen_get_tx_gpio(struct acpi_gpio *gpio)
+void acpigen_get_tx_gpio(const struct acpi_gpio *gpio)
{
acpigen_soc_get_tx_gpio(gpio->pins[0]);
@@ -1971,3 +2094,103 @@ void acpigen_notify(const char *namestr, int value)
acpigen_emit_namestring(namestr);
acpigen_write_integer(value);
}
+
+static void _create_field(uint8_t aml_op, uint8_t srcop, size_t byte_offset, const char *name)
+{
+ acpigen_emit_byte(aml_op);
+ acpigen_emit_byte(srcop);
+ acpigen_write_integer(byte_offset);
+ acpigen_emit_namestring(name);
+}
+
+void acpigen_write_create_byte_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_BYTE_OP, op, byte_offset, name);
+}
+
+void acpigen_write_create_word_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_WORD_OP, op, byte_offset, name);
+}
+
+void acpigen_write_create_dword_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_DWORD_OP, op, byte_offset, name);
+}
+
+void acpigen_write_create_qword_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_QWORD_OP, op, byte_offset, name);
+}
+
+void acpigen_write_pct_package(const acpi_addr_t *perf_ctrl, const acpi_addr_t *perf_sts)
+{
+ acpigen_write_name("_PCT");
+ acpigen_write_package(0x02);
+ acpigen_write_register_resource(perf_ctrl);
+ acpigen_write_register_resource(perf_sts);
+
+ acpigen_pop_len();
+}
+
+void acpigen_write_xpss_package(const struct acpi_xpss_sw_pstate *pstate_value)
+{
+ acpigen_write_package(0x08);
+ acpigen_write_dword(pstate_value->core_freq);
+ acpigen_write_dword(pstate_value->power);
+ acpigen_write_dword(pstate_value->transition_latency);
+ acpigen_write_dword(pstate_value->bus_master_latency);
+
+ acpigen_write_byte_buffer((uint8_t *)&pstate_value->control_value, sizeof(uint64_t));
+ acpigen_write_byte_buffer((uint8_t *)&pstate_value->status_value, sizeof(uint64_t));
+ acpigen_write_byte_buffer((uint8_t *)&pstate_value->control_mask, sizeof(uint64_t));
+ acpigen_write_byte_buffer((uint8_t *)&pstate_value->status_mask, sizeof(uint64_t));
+
+ acpigen_pop_len();
+}
+
+void acpigen_write_xpss_object(const struct acpi_xpss_sw_pstate *pstate_values, size_t nentries)
+{
+ size_t pstate;
+
+ acpigen_write_name("XPSS");
+ acpigen_write_package(nentries);
+ for (pstate = 0; pstate < nentries; pstate++) {
+ acpigen_write_xpss_package(pstate_values);
+ pstate_values++;
+ }
+
+ acpigen_pop_len();
+}
+
+/* Delay up to wait_ms until provided namestr matches expected value. */
+void acpigen_write_delay_until_namestr_int(uint32_t wait_ms, const char *name, uint64_t value)
+{
+ uint32_t wait_ms_segment = 1;
+ uint32_t segments = wait_ms;
+
+ /* Sleep in 16ms segments if delay is more than 32ms. */
+ if (wait_ms > 32) {
+ wait_ms_segment = 16;
+ segments = wait_ms / 16;
+ }
+
+ acpigen_write_store_int_to_op(segments, LOCAL7_OP);
+ acpigen_emit_byte(WHILE_OP);
+ acpigen_write_len_f();
+ acpigen_emit_byte(LGREATER_OP);
+ acpigen_emit_byte(LOCAL7_OP);
+ acpigen_emit_byte(ZERO_OP);
+
+ /* If name is not provided then just delay in a loop. */
+ if (name) {
+ acpigen_write_if_lequal_namestr_int(name, value);
+ acpigen_emit_byte(BREAK_OP);
+ acpigen_pop_len(); /* If */
+ }
+
+ acpigen_write_sleep(wait_ms_segment);
+ acpigen_emit_byte(DECREMENT_OP);
+ acpigen_emit_byte(LOCAL7_OP);
+ acpigen_pop_len(); /* While */
+}
diff --git a/src/acpi/acpigen_dptf.c b/src/acpi/acpigen_dptf.c
index 0c44b8f8ba..3877daa88b 100644
--- a/src/acpi/acpigen_dptf.c
+++ b/src/acpi/acpigen_dptf.c
@@ -2,6 +2,8 @@
#include
#include
+#include
+#include
/* Defaults */
#define DEFAULT_RAW_UNIT "ma"
@@ -17,6 +19,7 @@ enum {
DEFAULT_TRIP_POINT = 0xFFFFFFFFull,
DEFAULT_WEIGHT = 100,
DPTF_MAX_ART_THRESHOLDS = 10,
+ FPS_REVISION = 0,
PPCC_REVISION = 2,
RAPL_PL1_INDEX = 0,
RAPL_PL2_INDEX = 1,
@@ -353,7 +356,8 @@ void dptf_write_fan_perf(const struct dptf_fan_perf *states, int max_count)
/* _FPS - Fan Performance States */
acpigen_write_name("_FPS");
- pkg_count = acpigen_write_package(0);
+ pkg_count = acpigen_write_package(1); /* 1 for Revision */
+ acpigen_write_integer(FPS_REVISION); /* revision */
for (i = 0; i < max_count; ++i) {
/*
diff --git a/src/acpi/acpigen_dsm.c b/src/acpi/acpigen_dsm.c
index 2336537d0b..fc53ddff4d 100644
--- a/src/acpi/acpigen_dsm.c
+++ b/src/acpi/acpigen_dsm.c
@@ -7,28 +7,27 @@
#define ACPI_DSM_I2C_HID_UUID "3CDFF6F7-4267-4555-AD05-B30A3D8938DE"
+/* I2C HID currently supports revision 1 only, for which, only 1 additional
+ * function is supported. Thus, the query function should return 0x3:
+ * bit 0 = additional function supported
+ * bit 1 = function with index 1 supported
+ * All other revisions do not support additional functions and hence return 0
+*/
+
static void i2c_hid_func0_cb(void *arg)
{
/* ToInteger (Arg1, Local2) */
acpigen_write_to_integer(ARG1_OP, LOCAL2_OP);
- /* If (LEqual (Local2, 0x0)) */
- acpigen_write_if_lequal_op_int(LOCAL2_OP, 0x0);
- /* Return (Buffer (One) { 0x1f }) */
- acpigen_write_return_singleton_buffer(0x1f);
+ /* If (LEqual (Local2, 0x1)) */
+ acpigen_write_if_lequal_op_int(LOCAL2_OP, 0x1);
+ /* Return (Buffer (One) { 0x3 }) */
+ acpigen_write_return_singleton_buffer(0x3);
acpigen_pop_len(); /* Pop : If */
/* Else */
acpigen_write_else();
- /* If (LEqual (Local2, 0x1)) */
- acpigen_write_if_lequal_op_int(LOCAL2_OP, 0x1);
- /* Return (Buffer (One) { 0x3f }) */
- acpigen_write_return_singleton_buffer(0x3f);
- acpigen_pop_len(); /* Pop : If */
- /* Else */
- acpigen_write_else();
/* Return (Buffer (One) { 0x0 }) */
acpigen_write_return_singleton_buffer(0x0);
acpigen_pop_len(); /* Pop : Else */
- acpigen_pop_len(); /* Pop : Else */
}
static void i2c_hid_func1_cb(void *arg)
diff --git a/src/acpi/acpigen_ps2_keybd.c b/src/acpi/acpigen_ps2_keybd.c
index 1379a89c18..be20220e31 100644
--- a/src/acpi/acpigen_ps2_keybd.c
+++ b/src/acpi/acpigen_ps2_keybd.c
@@ -1,13 +1,12 @@
-/*
- *
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
#include
#include
#include
#include
#include
+#include
+#include
#define KEYMAP(scancode, keycode) (((uint32_t)(scancode) << 16) | (keycode & 0xFFFF))
#define SCANCODE(keymap) ((keymap >> 16) & 0xFFFF)
diff --git a/src/acpi/acpigen_usb.c b/src/acpi/acpigen_usb.c
index 90a9b77c60..7448b3b569 100644
--- a/src/acpi/acpigen_usb.c
+++ b/src/acpi/acpigen_usb.c
@@ -71,7 +71,7 @@ static void add_device_ref(struct acpi_dp *dsd,
const char *path;
char *fresh;
- if (!dev)
+ if (!dev || !dev->enabled)
return;
/*
diff --git a/src/acpi/chromeos-gnvs.c b/src/acpi/chromeos-gnvs.c
index 4bcf892745..8d96769160 100644
--- a/src/acpi/chromeos-gnvs.c
+++ b/src/acpi/chromeos-gnvs.c
@@ -6,7 +6,10 @@
void gnvs_assign_chromeos(void)
{
- chromeos_acpi_t *gnvs_chromeos = gnvs_chromeos_ptr();
+ chromeos_acpi_t *gnvs_chromeos = gnvs_chromeos_ptr(acpi_get_gnvs());
+ if (!gnvs_chromeos)
+ return;
+
chromeos_init_chromeos_acpi(gnvs_chromeos);
/* EC can override to ECFW_RW. */
@@ -15,3 +18,12 @@ void gnvs_assign_chromeos(void)
if (CONFIG(EC_GOOGLE_CHROMEEC) && !google_ec_running_ro())
gnvs_chromeos->vbt2 = ACTIVE_ECFW_RW;
}
+
+void gnvs_set_ecfw_rw(void)
+{
+ chromeos_acpi_t *gnvs_chromeos = gnvs_chromeos_ptr(acpi_get_gnvs());
+ if (!gnvs_chromeos)
+ return;
+
+ gnvs_chromeos->vbt2 = ACTIVE_ECFW_RW;
+}
diff --git a/src/acpi/device.c b/src/acpi/device.c
index b119abd61f..5de31b7776 100644
--- a/src/acpi/device.c
+++ b/src/acpi/device.c
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include
#if CONFIG(GENERIC_GPIO_LIB)
@@ -197,7 +198,6 @@ int acpi_device_status(const struct device *dev)
return ACPI_STATUS_DEVICE_ALL_ON;
}
-
/* Write the unique _UID based on ACPI device path. */
void acpi_device_write_uid(const struct device *dev)
{
@@ -1019,33 +1019,72 @@ struct acpi_dp *acpi_dp_add_integer_array(struct acpi_dp *dp, const char *name,
return dp_array;
}
+struct acpi_dp *acpi_dp_add_gpio_array(struct acpi_dp *dp, const char *name,
+ const struct acpi_gpio_res_params *params,
+ size_t param_count)
+{
+ struct acpi_dp *gpio;
+ uint32_t i;
+
+ if (!dp || !param_count)
+ return NULL;
+
+ gpio = acpi_dp_new_table(name);
+ if (!gpio)
+ return NULL;
+
+ /*
+ * Generate ACPI identifiers as follows:
+ * Package () {
+ * name, // e.g. cs-gpios
+ * Package() {
+ * ref, index, pin, active_low, // GPIO-0 (params[0])
+ * ref, index, pin, active_low, // GPIO-1 (params[1])
+ * ...
+ * }
+ * }
+ */
+ for (i = 0; i < param_count; i++, params++) {
+ /*
+ * If refs is NULL, leave a hole in the gpio array. This can be used in
+ * conditions where some controllers use both GPIOs and native signals.
+ */
+ if (!params->ref) {
+ acpi_dp_add_integer(gpio, NULL, 0);
+ continue;
+ }
+
+ /* The device that has _CRS containing GpioIO()/GpioInt() */
+ acpi_dp_add_reference(gpio, NULL, params->ref);
+
+ /* Index of the GPIO resource in _CRS starting from zero */
+ acpi_dp_add_integer(gpio, NULL, params->index);
+
+ /* Pin in the GPIO resource, typically zero */
+ acpi_dp_add_integer(gpio, NULL, params->pin);
+
+ /* Set if pin is active low */
+ acpi_dp_add_integer(gpio, NULL, params->active_low);
+ }
+ acpi_dp_add_array(dp, gpio);
+
+ return gpio;
+
+}
+
+
struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name,
const char *ref, int index, int pin,
int active_low)
{
- if (!dp)
- return NULL;
+ struct acpi_gpio_res_params param = {
+ .ref = ref,
+ .index = index,
+ .pin = pin,
+ .active_low = active_low,
+ };
- struct acpi_dp *gpio = acpi_dp_new_table(name);
-
- if (!gpio)
- return NULL;
-
- /* The device that has _CRS containing GpioIO()/GpioInt() */
- acpi_dp_add_reference(gpio, NULL, ref);
-
- /* Index of the GPIO resource in _CRS starting from zero */
- acpi_dp_add_integer(gpio, NULL, index);
-
- /* Pin in the GPIO resource, typically zero */
- acpi_dp_add_integer(gpio, NULL, pin);
-
- /* Set if pin is active low */
- acpi_dp_add_integer(gpio, NULL, active_low);
-
- acpi_dp_add_array(dp, gpio);
-
- return gpio;
+ return acpi_dp_add_gpio_array(dp, name, ¶m, 1);
}
/*
diff --git a/src/acpi/gnvs.c b/src/acpi/gnvs.c
index fbc84b36fd..10a77d39de 100644
--- a/src/acpi/gnvs.c
+++ b/src/acpi/gnvs.c
@@ -24,11 +24,20 @@ void *acpi_get_gnvs(void)
static void gnvs_assign_cbmc(void)
{
- uint32_t *gnvs_cbmc = gnvs_cbmc_ptr();
+ uint32_t *gnvs_cbmc = gnvs_cbmc_ptr(gnvs);
if (gnvs_cbmc)
*gnvs_cbmc = (uintptr_t)cbmem_find(CBMEM_ID_CONSOLE);
}
+/* Needs implementation in platform code. */
+__weak uint32_t *gnvs_cbmc_ptr(struct global_nvs *gnvs_)
+{
+ return NULL;
+}
+
+__weak void soc_fill_gnvs(struct global_nvs *gnvs_) { }
+__weak void mainboard_fill_gnvs(struct global_nvs *gnvs_) { }
+
void *gnvs_get_or_create(void)
{
size_t gnvs_size;
@@ -41,10 +50,12 @@ void *gnvs_get_or_create(void)
return gnvs;
gnvs_size = gnvs_size_of_array();
+ if (!gnvs_size)
+ return NULL;
gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, gnvs_size);
if (!gnvs)
- return gnvs;
+ return NULL;
memset(gnvs, 0, gnvs_size);
@@ -57,13 +68,15 @@ void *gnvs_get_or_create(void)
return gnvs;
}
-void acpi_inject_nvsa(void)
+void acpi_fill_gnvs(void)
{
- uintptr_t gnvs_address = (uintptr_t)acpi_get_gnvs();
- if (!gnvs_address)
+ if (!gnvs)
return;
+ soc_fill_gnvs(gnvs);
+ mainboard_fill_gnvs(gnvs);
+
acpigen_write_scope("\\");
- acpigen_write_name_dword("NVSA", gnvs_address);
+ acpigen_write_name_dword("NVSA", (uintptr_t)gnvs);
acpigen_pop_len();
}
diff --git a/src/acpi/nvs.c b/src/acpi/nvs.c
new file mode 100644
index 0000000000..063819158c
--- /dev/null
+++ b/src/acpi/nvs.c
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include
+#include
+#include
+
+size_t gnvs_size_of_array(void)
+{
+ return sizeof(struct global_nvs);
+}
+
+uint32_t *gnvs_cbmc_ptr(struct global_nvs *gnvs)
+{
+ return &gnvs->cbmc;
+}
+
+/* Some have no chromeos entry. */
+#if CONFIG(MAINBOARD_HAS_CHROMEOS)
+void *gnvs_chromeos_ptr(struct global_nvs *gnvs)
+{
+ return &gnvs->chromeos;
+}
+#endif
diff --git a/src/arch/arm/Makefile.inc b/src/arch/arm/Makefile.inc
index eef2650685..63367bb2c0 100644
--- a/src/arch/arm/Makefile.inc
+++ b/src/arch/arm/Makefile.inc
@@ -27,11 +27,6 @@ endif # CONFIG_ARCH_ARM
ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM),y)
-decompressor-y += id.S
-bootblock-y += id.S
-$(call src-to-obj,decompressor,$(dir)/id.S): $(obj)/build.h
-$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
-
decompressor-y += boot.c
bootblock-y += boot.c
decompressor-y += div0.c
@@ -119,6 +114,8 @@ ramstage-y += memset.S
ramstage-y += memcpy.S
ramstage-y += memmove.S
ramstage-y += clock.c
+ramstage-y += boot_linux.S
+ramstage-$(CONFIG_PAYLOAD_FIT_SUPPORT) += fit_payload.c
rmodules_arm-y += memset.S
rmodules_arm-y += memcpy.S
diff --git a/src/arch/arm/armv4/cache.c b/src/arch/arm/armv4/cache.c
index 5f34c6049b..0ed11ac8d1 100644
--- a/src/arch/arm/armv4/cache.c
+++ b/src/arch/arm/armv4/cache.c
@@ -5,7 +5,6 @@
* Reference: ARM Architecture Reference Manual, ARMv7-A and ARMv7-R edition
*/
-
#include
void tlb_invalidate_all(void)
diff --git a/src/arch/arm/armv7/bootblock.S b/src/arch/arm/armv7/bootblock.S
index e1879c0b30..47813a78f8 100644
--- a/src/arch/arm/armv7/bootblock.S
+++ b/src/arch/arm/armv7/bootblock.S
@@ -62,14 +62,43 @@ init_stack_loop:
cmp r0, r1
bne init_stack_loop
+ /* Set stackpointer in internal RAM */
+ ldr sp, =_estack
+
+ /*
+ * For platforms where the flash is memory mapped (qemu), check if the
+ * bootblock needs to relocate itself.
+ */
+check_position:
+ adr r0, check_position
+ ldr r1, =check_position
+
+ cmp r0, r1
+ beq call_bootblock
+
+ /* Calculate source */
+ ldr r2, =_program
+ sub r1, r1, r2
+ sub r1, r0, r1
+ /* Get destination */
+ ldr r0, =_program
+ /* Get size */
+ ldr r2, =_eprogram
+ sub r2, r2, r0
+
+ bl memcpy
+
+ /* Get absolute address */
+ ldr lr, =call_bootblock
+ /* Directly modify pc as branch instruction changes the state */
+ mov pc, lr
+
call_bootblock:
/* Restore parameter passed in by maskrom/vendor firmware. */
ldr r0, =maskrom_param
str r10, [r0]
- /* Set stackpointer in internal RAM to call bootblock main() */
- ldr sp, =_estack
ldr r0,=0x00000000
/*
* The current design of cpu_info places the struct at the top of the
diff --git a/src/arch/arm/armv7/cache_m.c b/src/arch/arm/armv7/cache_m.c
index 7267e83948..06ed599c44 100644
--- a/src/arch/arm/armv7/cache_m.c
+++ b/src/arch/arm/armv7/cache_m.c
@@ -3,7 +3,6 @@
* cache.c: Cache maintenance routines for ARMv7-M
*/
-
#include
void tlb_invalidate_all(void)
diff --git a/src/arch/arm/armv7/cpu.S b/src/arch/arm/armv7/cpu.S
index 610659243d..c53119c8d1 100644
--- a/src/arch/arm/armv7/cpu.S
+++ b/src/arch/arm/armv7/cpu.S
@@ -23,6 +23,19 @@
* THIS FUNCTION MUST PRESERVE THE VALUE OF r10
*/
+#if ENV_USER_SPACE
+/*
+ * Empty macro for code running in userspace. Trying to manipulate the
+ * cache from userspace hangs the system. To run code at a privileged level,
+ * the userspace code needs to execute an API call to the privileged mode
+ * code.
+ */
+.macro dcache_apply_all crm
+ bx lr
+.endm
+
+#else
+
.macro dcache_apply_all crm
dsb
mov r3, #-2 @ initialize level so that we start at 0
@@ -82,6 +95,8 @@
bx lr
.endm
+#endif /* ENV_USER_SPACE */
+
/*
* Bring an ARM processor we just gained control of (e.g. from IROM) into a
* known state regarding caches/SCTLR. Completely cleans and invalidates
diff --git a/src/arch/arm/armv7/mmu.c b/src/arch/arm/armv7/mmu.c
index 51b4860768..66ce53392d 100644
--- a/src/arch/arm/armv7/mmu.c
+++ b/src/arch/arm/armv7/mmu.c
@@ -87,9 +87,6 @@ typedef uint32_t pte_t;
static pte_t *const ttb_buff = (void *)_ttb;
-/* Not all boards want to use subtables and declare them in memlayout.ld. */
-DECLARE_OPTIONAL_REGION(ttb_subtables);
-
static struct {
pte_t value;
const char *name;
diff --git a/src/arch/arm/boot.c b/src/arch/arm/boot.c
index 8c876de0b0..b18473b924 100644
--- a/src/arch/arm/boot.c
+++ b/src/arch/arm/boot.c
@@ -1,14 +1,32 @@
/* SPDX-License-Identifier: GPL-2.0-only */
+#include
#include
#include
+void boot_linux(void *kernel_ptr, void *fdt_ptr);
+
void arch_prog_run(struct prog *prog)
{
void (*doit)(void *);
cache_sync_instructions();
- doit = prog_entry(prog);
- doit(prog_entry_arg(prog));
+ switch (prog_cbfs_type(prog)) {
+ case CBFS_TYPE_FIT:
+ /*
+ * We only load Linux payloads from the ramstage, so provide a hint to
+ * the linker that the below functions do not need to be included in
+ * earlier stages.
+ */
+ if (!ENV_RAMSTAGE)
+ break;
+
+ dcache_mmu_disable();
+ boot_linux(prog_entry(prog), prog_entry_arg(prog));
+ break;
+ default:
+ doit = prog_entry(prog);
+ doit(prog_entry_arg(prog));
+ }
}
diff --git a/src/arch/arm/boot_linux.S b/src/arch/arm/boot_linux.S
new file mode 100644
index 0000000000..e3985eae56
--- /dev/null
+++ b/src/arch/arm/boot_linux.S
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include
+
+/* Required to jump to kernel in ARM state */
+.arm
+/* void boot_linux(void *kernel_ptr, void *fdt_ptr); */
+ENTRY(boot_linux)
+ /* Save kernel ptr */
+ mov r3, r0
+ /* Set R2 = fdt */
+ mov r2, r1
+ /* Set R0 = 0x00000000 as expected by Linux ABI */
+ mov r0, #0
+ /* Set R1 = 0xffffffff as expected by Linux ABI */
+ mov r1, #-1
+ /* Linux ABI expects SVC mode (0x13) with IRQ(7) and FIQ(6) disabled. */
+ msr cpsr_cxf, #0xd3
+ /* Jump to kernel */
+ mov pc, r3
+ENDPROC(boot_linux)
diff --git a/src/arch/arm/fit_payload.c b/src/arch/arm/fit_payload.c
new file mode 100644
index 0000000000..9777e3c1e5
--- /dev/null
+++ b/src/arch/arm/fit_payload.c
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * Place the region in free memory range.
+ */
+static bool fit_place_mem(const struct range_entry *r, void *arg)
+{
+ struct region *region = arg;
+ resource_t start;
+
+ if (range_entry_tag(r) != BM_MEM_RAM)
+ return true;
+
+ /* Linux 4.15 doesn't like 4KiB alignment. Align to 1 MiB for now. */
+ start = ALIGN_UP(MAX(region->offset, range_entry_base(r)), 1 * MiB);
+
+ if (start + region->size < range_entry_end(r)) {
+ region->offset = (size_t)start;
+ return false;
+ }
+
+ return true;
+}
+
+bool fit_payload_arch(struct prog *payload, struct fit_config_node *config,
+ struct region *kernel,
+ struct region *fdt,
+ struct region *initrd)
+{
+ void *arg = NULL;
+
+ /**
+ * The kernel ARM documentation recommends loading the kernel above 32MiB
+ * in order to avoid the need to need to relocate prior to decompression.
+ */
+ kernel->offset = (uintptr_t)_dram + 32 * MiB;
+
+ /**
+ * The code assumes that bootmem_walk provides a sorted list of memory
+ * regions, starting from the lowest address.
+ * The order of the calls here doesn't matter, as the placement is
+ * enforced in the called functions.
+ * For details check code on top.
+ */
+ if (!bootmem_walk(fit_place_mem, kernel))
+ return false;
+
+ /* Mark as reserved for future allocations. */
+ bootmem_add_range(kernel->offset, kernel->size, BM_MEM_PAYLOAD);
+
+ /**
+ * To ensure the fdt is not overwritten by the kernel decompressor, place
+ * the fdt above the 128 MB from the start of RAM, as recommended by the
+ * kernel documentation.
+ */
+ fdt->offset = (uintptr_t)_dram + 128 * MiB;
+
+ if (!bootmem_walk(fit_place_mem, fdt))
+ return false;
+
+ /* Mark as reserved for future allocations. */
+ bootmem_add_range(fdt->offset, fdt->size, BM_MEM_PAYLOAD);
+
+ /* Place INITRD */
+ if (config->ramdisk) {
+ initrd->offset = fdt->offset + fdt->size;
+
+ if (!bootmem_walk(fit_place_mem, initrd))
+ return false;
+
+ /* Mark as reserved for future allocations. */
+ bootmem_add_range(initrd->offset, initrd->size, BM_MEM_PAYLOAD);
+ }
+
+ /* Kernel expects FDT as argument */
+ arg = (void *)fdt->offset;
+
+ prog_set_entry(payload, (void *)kernel->offset, arg);
+
+ bootmem_dump_ranges();
+
+ return true;
+}
diff --git a/src/arch/arm/id.S b/src/arch/arm/id.S
deleted file mode 100644
index 3d3df9643a..0000000000
--- a/src/arch/arm/id.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#include
-
- .section ".id", "a", %progbits
-
- .globl __id_start
-__id_start:
-ver:
- .asciz COREBOOT_VERSION
-vendor:
- .asciz CONFIG_MAINBOARD_VENDOR
-part:
- .asciz CONFIG_MAINBOARD_PART_NUMBER
-.long __id_end - ver /* Reverse offset to the vendor id */
-.long __id_end - vendor /* Reverse offset to the vendor id */
-.long __id_end - part /* Reverse offset to the part number */
-.long CONFIG_ROM_SIZE /* Size of this romimage */
- .globl __id_end
-
-__id_end:
-.previous
diff --git a/src/arch/arm/include/armv4/arch/smp/spinlock.h b/src/arch/arm/include/armv4/arch/smp/spinlock.h
index 5245bd1a02..0a3a4d4676 100644
--- a/src/arch/arm/include/armv4/arch/smp/spinlock.h
+++ b/src/arch/arm/include/armv4/arch/smp/spinlock.h
@@ -4,12 +4,10 @@
#define _ARCH_SMP_SPINLOCK_H
#define DECLARE_SPIN_LOCK(x)
-#define barrier() do {} while (0)
#define spin_is_locked(lock) 0
#define spin_unlock_wait(lock) do {} while (0)
#define spin_lock(lock) do {} while (0)
#define spin_unlock(lock) do {} while (0)
-#define cpu_relax() do {} while (0)
#include
#define boot_cpu() 1
diff --git a/src/arch/arm/tables.c b/src/arch/arm/tables.c
index 3b47a5bf0c..0c68fc7c51 100644
--- a/src/arch/arm/tables.c
+++ b/src/arch/arm/tables.c
@@ -11,8 +11,6 @@ void arch_write_tables(uintptr_t coreboot_table)
void bootmem_arch_add_ranges(void)
{
- DECLARE_OPTIONAL_REGION(ttb_subtables);
-
bootmem_add_range((uintptr_t)_ttb, REGION_SIZE(ttb), BM_MEM_RAMSTAGE);
bootmem_add_range((uintptr_t)_ttb_subtables, REGION_SIZE(ttb_subtables),
BM_MEM_RAMSTAGE);
diff --git a/src/arch/arm64/Makefile.inc b/src/arch/arm64/Makefile.inc
index 920ff5db51..6b49743633 100644
--- a/src/arch/arm64/Makefile.inc
+++ b/src/arch/arm64/Makefile.inc
@@ -26,11 +26,8 @@ decompressor-y += div0.c
bootblock-y += div0.c
decompressor-y += eabi_compat.c
bootblock-y += eabi_compat.c
-decompressor-y += id.S
-bootblock-y += id.S
-$(call src-to-obj,decompressor,$(dir)/id.S): $(obj)/build.h
-$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
+decompressor-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
bootblock-$(CONFIG_ARM64_USE_ARCH_TIMER) += arch_timer.c
bootblock-y += transition.c transition_asm.S
diff --git a/src/arch/arm64/armv8/exception.c b/src/arch/arm64/armv8/exception.c
index 88e68e759e..f3a075522e 100644
--- a/src/arch/arm64/armv8/exception.c
+++ b/src/arch/arm64/armv8/exception.c
@@ -63,10 +63,8 @@ static void print_regs(struct exc_state *exc_state)
regs->x[30], regs->sp);
}
-
static struct exception_handler *handlers[NUM_EXC_VIDS];
-
int exception_handler_register(uint64_t vid, struct exception_handler *h)
{
if (vid >= NUM_EXC_VIDS)
@@ -122,7 +120,6 @@ static void print_exception_and_die(struct exc_state *state, uint64_t idx)
die("exception death");
}
-
static int handle_exception(struct exc_state *state, uint64_t idx)
{
int ret = EXC_RET_ABORT;
diff --git a/src/arch/arm64/id.S b/src/arch/arm64/id.S
deleted file mode 100644
index 3d3df9643a..0000000000
--- a/src/arch/arm64/id.S
+++ /dev/null
@@ -1,22 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-#include
-
- .section ".id", "a", %progbits
-
- .globl __id_start
-__id_start:
-ver:
- .asciz COREBOOT_VERSION
-vendor:
- .asciz CONFIG_MAINBOARD_VENDOR
-part:
- .asciz CONFIG_MAINBOARD_PART_NUMBER
-.long __id_end - ver /* Reverse offset to the vendor id */
-.long __id_end - vendor /* Reverse offset to the vendor id */
-.long __id_end - part /* Reverse offset to the part number */
-.long CONFIG_ROM_SIZE /* Size of this romimage */
- .globl __id_end
-
-__id_end:
-.previous
diff --git a/src/arch/arm64/include/armv8/arch/exception.h b/src/arch/arm64/include/armv8/arch/exception.h
index 58bedda9c5..72ed772500 100644
--- a/src/arch/arm64/include/armv8/arch/exception.h
+++ b/src/arch/arm64/include/armv8/arch/exception.h
@@ -27,7 +27,6 @@ struct exception_handler {
struct exception_handler *next;
};
-
/*
* Register a handler provided with the associated vector id. Returns 0 on
* success, < 0 on error. Note that registration is not thread/interrupt safe.
diff --git a/src/arch/arm64/tables.c b/src/arch/arm64/tables.c
index 321d348602..b97297c1b9 100644
--- a/src/arch/arm64/tables.c
+++ b/src/arch/arm64/tables.c
@@ -5,8 +5,6 @@
#include
#include
-DECLARE_OPTIONAL_REGION(bl31);
-
void arch_write_tables(uintptr_t coreboot_table)
{
}
diff --git a/src/arch/ppc64/bootblock.S b/src/arch/ppc64/bootblock.S
index 106c61ad95..b443f056d1 100644
--- a/src/arch/ppc64/bootblock.S
+++ b/src/arch/ppc64/bootblock.S
@@ -8,27 +8,3 @@
.org 0x100, 0xff
_start:
b _start
- .section ".id", "a", %progbits
-
- .section ".id", "a", @progbits
-
- .globl __id_start
-__id_start:
-ver:
- .asciz "4" //COREBOOT_VERSION
-vendor:
- .asciz "qemu" //CONFIG_MAINBOARD_VENDOR
-part:
- .asciz "1" //CONFIG_MAINBOARD_PART_NUMBER
- /* Reverse offset to the vendor id */
-.long __id_end + CONFIG_ID_SECTION_OFFSET - ver
- /* Reverse offset to the vendor id */
-.long __id_end + CONFIG_ID_SECTION_OFFSET - vendor
- /* Reverse offset to the part number */
-.long __id_end + CONFIG_ID_SECTION_OFFSET - part
- /* of this romimage */
-.long CONFIG_ROM_SIZE
- .globl __id_end
-
-__id_end:
-.previous
diff --git a/src/arch/ppc64/id.ld b/src/arch/ppc64/id.ld
deleted file mode 100644
index 74497408b2..0000000000
--- a/src/arch/ppc64/id.ld
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-SECTIONS {
- . = (0xffffffff - CONFIG_ID_SECTION_OFFSET) - (__id_end - __id_start) + 1;
- .id (.): {
- *(.id)
- }
-}
diff --git a/src/arch/ppc64/include/arch/io.h b/src/arch/ppc64/include/arch/io.h
index d3d15ff055..f8c1121f1a 100644
--- a/src/arch/ppc64/include/arch/io.h
+++ b/src/arch/ppc64/include/arch/io.h
@@ -17,13 +17,11 @@ static inline void outl(uint32_t value, uint16_t port)
{
}
-
static inline uint8_t inb(uint16_t port)
{
return 0;
}
-
static inline uint16_t inw(uint16_t port)
{
return 0;
diff --git a/src/arch/ppc64/prologue.inc b/src/arch/ppc64/prologue.inc
deleted file mode 100644
index 21f7d49ac3..0000000000
--- a/src/arch/ppc64/prologue.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-.section ".rom.data", "a", @progbits
-.section ".rom.text", "ax", @progbits
diff --git a/src/arch/riscv/arch_timer.c b/src/arch/riscv/arch_timer.c
index 7e9072b6cd..ad678b7fe5 100644
--- a/src/arch/riscv/arch_timer.c
+++ b/src/arch/riscv/arch_timer.c
@@ -3,7 +3,6 @@
#include
#include
#include
-#include
#include
#include
diff --git a/src/arch/riscv/include/vm.h b/src/arch/riscv/include/vm.h
index 5501a0c710..c1894c70ca 100644
--- a/src/arch/riscv/include/vm.h
+++ b/src/arch/riscv/include/vm.h
@@ -12,7 +12,6 @@
void mstatus_init(void); // need to setup mstatus so we know we have virtual memory
-
#define DEFINE_MPRV_READ_FLAGS(name, type, insn, flags) \
static inline type name(type *p); \
static inline type name(type *p) \
diff --git a/src/arch/riscv/misaligned.c b/src/arch/riscv/misaligned.c
index eff51fc96e..a17b7dd454 100644
--- a/src/arch/riscv/misaligned.c
+++ b/src/arch/riscv/misaligned.c
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include
#include
#include
#include
@@ -132,7 +131,6 @@ static struct memory_instruction_info *match_instruction(uintptr_t insn)
return NULL;
}
-
static int fetch_16bit_instruction(uintptr_t vaddr, uintptr_t *insn, int *size)
{
uint16_t ins = mprv_read_mxr_u16((uint16_t *)vaddr);
@@ -158,7 +156,6 @@ static int fetch_32bit_instruction(uintptr_t vaddr, uintptr_t *insn, int *size)
return -1;
}
-
void handle_misaligned(trapframe *tf)
{
uintptr_t insn = 0;
diff --git a/src/arch/riscv/sbi.c b/src/arch/riscv/sbi.c
index 38fc05e210..654bef03d6 100644
--- a/src/arch/riscv/sbi.c
+++ b/src/arch/riscv/sbi.c
@@ -49,7 +49,6 @@ static uintptr_t sbi_clear_ipi(void)
return 0;
}
-
/*
* sbi is triggered by the s-mode ecall
* parameter : register a0 a1 a2
diff --git a/src/arch/riscv/smp.c b/src/arch/riscv/smp.c
index b3e13ff9fb..1d58602627 100644
--- a/src/arch/riscv/smp.c
+++ b/src/arch/riscv/smp.c
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include
#include
#include
#include