2,441 changes: 0 additions & 2,441 deletions Documentation/Doxyfile.coreboot

This file was deleted.

2,441 changes: 0 additions & 2,441 deletions Documentation/Doxyfile.coreboot_simple

This file was deleted.

319 changes: 0 additions & 319 deletions Documentation/doxygen/Doxyfile.coreboot_platform

This file was deleted.

2 changes: 1 addition & 1 deletion Documentation/getting_started/architecture.md
Expand Up @@ -3,7 +3,7 @@
## Overview
![][architecture]

[architecture]: comparision_coreboot_uefi.svg
[architecture]: comparison_coreboot_uefi.svg

## Stages
coreboot consists of multiple stages that are compiled as separate binaries and
Expand Down
1 change: 1 addition & 0 deletions Documentation/index.md
Expand Up @@ -189,5 +189,6 @@ Contents:
* [Vendorcode](vendorcode/index.md)
* [Utilities](util.md)
* [Project infrastructure & services](infrastructure/index.md)
* [Boards supported in each release directory](releases/boards_supported_on_branches.md)
* [Release notes](releases/index.md)
* [Documentation License](documentation_license.md)
2 changes: 1 addition & 1 deletion Documentation/mainboard/acer/g43t-am3.md
Expand Up @@ -134,7 +134,7 @@ SPI_ROM1 header while the board is off and disconnected from power. There
seems to be a diode that prevents the external programmer from powering the
whole board.

The signal assigment on the header is identical to the pinout of the flash
The signal assignment on the header is identical to the pinout of the flash
chip. The pinout diagram below is valid when the PCI slots are on the left
and the CPU is on the right. Note that HOLD# and WP# must be pulled high
(to VCC) to be able to flash the chip.
Expand Down
3 changes: 3 additions & 0 deletions Documentation/mainboard/index.md
Expand Up @@ -30,6 +30,7 @@ This section contains documentation about coreboot on specific mainboards.
- [P8H77-V](asus/p8h77-v.md)
- [P8Z77-M Pro](asus/p8z77-m_pro.md)
- [P8Z77-V](asus/p8z77-v.md)
- [wifigo_v1](asus/wifigo_v1.md)

## Cavium

Expand Down Expand Up @@ -180,10 +181,12 @@ The boards in this section are not real mainboards, but emulators.

## Star Labs Systems

- [LabTop Mk III](starlabs/labtop_kbl.md)
- [LabTop Mk IV](starlabs/labtop_cml.md)
- [StarLite Mk III](starlabs/lite_glk.md)
- [StarLite Mk IV](starlabs/lite_glkr.md)
- [StarBook Mk V](starlabs/starbook_tgl.md)
- [Flashing devices](starlabs/common/flashing.md)

## Supermicro

Expand Down
6 changes: 3 additions & 3 deletions Documentation/mainboard/starlabs/common/flashing.md
Expand Up @@ -16,7 +16,7 @@ fwupdmgr --version
```

This will show the version number. **1.5.6** or greater will work.
![fwupd version](fwupdVersion.png)
![fwupd version](../fwupdVersion.png)
On Ubuntu 20.04, Ubuntu 20.10, Linux Mint 20.1 and elementaryOS 6, fwupd 1.5.6 can be installed from our PPA with the below terminal commands:

```
Expand All @@ -40,7 +40,7 @@ BIOS Lock must be disabled when switching from the standard AMI (American Megatr
2\. When the BIOS settings load, use the arrow keys to navigate to the **Advanced** tab\. Here you will see **BIOS Lock**\.
3\. Press `Enter` to change this setting from **Enabled** to **Disabled**

![Disable BIOS Lock](BiosLock.jpg)
![Disable BIOS Lock](../BiosLock.jpg)

4\. Next, press the `F10` key to **Save & Exit** and then `Enter` to confirm.

Expand All @@ -61,7 +61,7 @@ fwupdmgr switch-branch
```

You can then select which branch you would like to use, by typing in the corresponding number:
![Switch Branch](SwitchBranch.png)
![Switch Branch](../SwitchBranch.png)
You will be prompted to confirm, press `y` to continue or `n` to cancel.

Once the switch has been completed, you will be prompted to restart.
Expand Down
83 changes: 83 additions & 0 deletions Documentation/mainboard/starlabs/labtop_kbl.md
@@ -0,0 +1,83 @@
# Star LabTop Mk III

## Specs

- CPU (full processor specs available at https://ark.intel.com)
- Intel i7-8550u (Kaby Lake Refresh)
- EC
- ITE IT8987E
- Backlit Keyboard, with standard PS/2 keycodes and SCI hotkeys
- Battery
- Charger, using AC adapter or USB-C PD
- Suspend / resume
- GPU
- Intel UHD Graphics 620
- GOP driver is recommended, VBT is provided
- eDP 13-inch 1920x1080 LCD
- HDMI video
- USB-C DisplayPort video
- Memory
- 8GB on-board
- Networking
- 8265 PCIe WiFi / Bluetooth soldered to PCBA
- Sound
- Realtek ALC256
- Internal speakers
- Internal microphone
- Combined headphone / microphone 3.5-mm jack
- HDMI audio
- USB-C DisplayPort audio
- Storage
- M.2 PCIe SSD
- RTS5129 MicroSD card reader
- USB
- 1280x720 CCD camera
- USB 3.1 Gen 2 Type-C (left)
- USB 3.1 Gen 2 Type-A (left)
- USB 3.1 Gen 1 Type-A (right)

## Building coreboot

### Preliminaries

Prior to building coreboot the following files are required:
* Intel Flash Descriptor file (descriptor.bin)
* Intel Management Engine firmware (me.bin)

The below are optional:
- Splash screen image in Windows 3.1 BMP format (Logo.bmp)

These files exist in the correct location in the StarLabsLtd/blobs repo on GitHub which is used in place of the standard 3rdparty/blobs repo.

### Build

The following commands will build a working image:

```bash
make distclean
make defconfig KBUILD_DEFCONFIG=configs/config.starlabs_labtop_kbl
make
```

## Flashing coreboot

```eval_rst
+---------------------+------------+
| Type | Value |
+=====================+============+
| Socketed flash | no |
+---------------------+------------+
| Vendor | Gigadevice |
+---------------------+------------+
| Model | 25Q128JVSQ |
+---------------------+------------+
| Size | 8 MiB |
+---------------------+------------+
| Package | SOIC-8 |
+---------------------+------------+
| Internal flashing | yes |
+---------------------+------------+
| External flashing | yes |
+---------------------+------------+
Please see [here](../common/flashing.md) for instructions on how to flash with fwupd.
Expand Up @@ -1899,7 +1899,7 @@ Please handle with care!
+===========+==================================================================+
| 0:7| PDWN_idle_counter, This defines the rank indle period in DCLK |
| | cycles that causes power-down entrance. The minimum value |
| | should be greater then or equal to the worst roundtrip time |
| | should be greater than or equal to the worst roundtrip time |
| | plus burst length. |
+-----------+------------------------------------------------------------------+
| 8:10| PDWN_mode, selects the mode of power-down: |
Expand Down
16 changes: 12 additions & 4 deletions Documentation/payloads.md
Expand Up @@ -11,9 +11,17 @@ payload or can be made to work as one.

[SeaBIOS](https://www.seabios.org) is an open source implementation of
the PCBIOS API that exists since the original IBM PC and was extended
since. While originally written for emulators such as QEMU, it can be made
to work as a coreboot payload and all the necessary code is in SeaBIOS'
mainline code.
since. While originally written for emulators such as QEMU, it can be built
as a coreboot payload. It supports executing Option ROMs in a more complete
fashion than coreboot. It also supports Multiboot.

When chainloaded from GRUB2, the following menuentry could be used:

menuentry "SeaBIOS" --unrestricted {
root=(cbfsdisk)
multiboot /img/seabios
module /vgaroms/seavgabios.bin
}

## Tianocore

Expand Down Expand Up @@ -51,4 +59,4 @@ updates, but only works on a limited amount of mainboards.
For more details have a look at [heads-wiki].

[Heads]: https://github.com/osresearch/heads
[heads-wiki]: http://osresearch.net/
[heads-wiki]: http://osresearch.net/
32 changes: 16 additions & 16 deletions Documentation/releases/boards_supported_on_branches.md
Expand Up @@ -22,33 +22,33 @@ branches as needed. The coreboot project will take care of backporting
critical security fixes, but other patches will need to handled by
anyone using that release.

## [4.16 Release](releases/coreboot-4.16-relnotes.md)
## [4.16 Release](coreboot-4.16-relnotes.md)
Branch created, builder configured

* No platforms maintained on this release


## [4.15 Release](releases/coreboot-4.15-relnotes.md)
## [4.15 Release](coreboot-4.15-relnotes.md)
Branch created, builder configured

* No platforms maintained on this release


## [4.14 Release](releases/coreboot-4.14-relnotes.md)
## [4.14 Release](coreboot-4.14-relnotes.md)
Branch created, builder configured

* No platforms maintained on this release


## [4.13 Release](releases/coreboot-4.13-relnotes.md)
## [4.13 Release](coreboot-4.13-relnotes.md)
Tag only

| Vendor/Board | Processor | Date added | Brd type |
|-----------------------------|------------------------|------------|----------|
| intel/cannonlake_rvp | INTEL_CANNONLAKE | 2017-07-19 | eval |


## [4.12 Release](releases/coreboot-4.12-relnotes.md)
## [4.12 Release](coreboot-4.12-relnotes.md)

Branch created, builder configured

Expand All @@ -59,7 +59,7 @@ Branch created, builder configured
| ocp/sonorapass | INTEL_COOPERLAKE_SP | 2020-05-01 | server |


## [4.11 Release](releases/coreboot-4.11-relnotes.md)
## [4.11 Release](coreboot-4.11-relnotes.md)

Branch created, builder configured

Expand Down Expand Up @@ -114,15 +114,15 @@ Branch created, builder configured
| via/epia-m850 | VIA_VX900 | 2013-06-10 | mini |


## [4.10 Release](releases/coreboot-4.10-relnotes.md)
## [4.10 Release](coreboot-4.10-relnotes.md)
Branch created

| Vendor/Board | Processor | Date added | Brd type |
|-----------------------------|------------------------|------------|----------|
| cubietech/cubieboard | ALLWINNER_A10 | 2014-01-08 | sbc |


## [4.9 Release](releases/coreboot-4.9-relnotes.md)
## [4.9 Release](coreboot-4.9-relnotes.md)
Tag only

| Vendor/Board | Processor | Date added | Brd type |
Expand All @@ -133,7 +133,7 @@ Tag only
| pcengines/alix2d | AMD_LX | 2010-08-31 | half |


## [4.8.1 Release](releases/coreboot-4.8.1-relnotes.md)
## [4.8.1 Release](coreboot-4.8.1-relnotes.md)
Branch created

| Vendor/Board | Processor | Date added | Brd type |
Expand Down Expand Up @@ -203,7 +203,7 @@ Branch created
| winnet/g170 | VIA_C7 | 2017-08-28 | mini |


## [4.7 Release](releases/coreboot-4.7-relnotes.md)
## [4.7 Release](coreboot-4.7-relnotes.md)
Tag only

| Vendor/Board | Processor | Date added | Brd type |
Expand Down Expand Up @@ -249,7 +249,7 @@ Tag only
| wyse/s50 | AMD_GEODE_GX2 | 2010-05-08 | settop |


## [4.6](releases/coreboot-4.6-relnotes.md)
## [4.6](coreboot-4.6-relnotes.md)
Tag only

| Vendor/Board | Processor | Date added | Brd type |
Expand All @@ -259,7 +259,7 @@ Tag only
| intel/bakersport_fsp | INTEL_FSP_BAYTRAIL | 2014-08-11 | eval |


## [4.5](releases/coreboot-4.5-relnotes.md)
## [4.5](coreboot-4.5-relnotes.md)
Tag only

| Vendor/Board | Processor | Date added | Brd type |
Expand All @@ -275,7 +275,7 @@ Tag only
| google/tidus | INTEL_BROADWELL | 2016-01-21 | half |


## [4.4](releases/coreboot-4.4-relnotes.md)
## [4.4](coreboot-4.4-relnotes.md)
Branch created

| Vendor/Board | Processor | Date added | Brd type |
Expand All @@ -287,13 +287,13 @@ Branch created
| intel/amenia | INTEL_APOLLOLAKE | 2016-04-20 | eval |


## [4.3](releases/coreboot-4.3-relnotes.md)
## [4.3](coreboot-4.3-relnotes.md)
Branch created

* No platforms maintained on this release


## [4.2](releases/coreboot-4.2-relnotes.md)
## [4.2](coreboot-4.2-relnotes.md)
Branch created

| Vendor/Board | Processor | Date added | Brd type |
Expand All @@ -320,7 +320,7 @@ Branch created
| tyan/s4882 | AMD_AMDK8 | 2009-10-08 | server |


## [4.1](releases/coreboot-4.1-relnotes.md)
## [4.1](coreboot-4.1-relnotes.md)
Branch Created

* No platforms maintained on this release
2 changes: 1 addition & 1 deletion Documentation/releases/coreboot-4.16-relnotes.md
Expand Up @@ -132,7 +132,7 @@ HECI based on Intel Core processors from Skylake to Alder Lake. State is
set based on a CMOS value of `me_state`. A value of `0` will result in a
(CS)ME state of `0` (working) and value of `1` will result in a (CS)ME
state of `3` (disabled). For an example CMOS layout and more info, see
[cse.c](../../src/soc/intel/common/block/cse/cse.c).
[cse.c](https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/soc/intel/common/block/cse/cse.c).


### Add [AMD] apcb_v3_edit tool
Expand Down
352 changes: 339 additions & 13 deletions Documentation/releases/coreboot-4.17-relnotes.md
@@ -1,19 +1,345 @@
Upcoming release - coreboot 4.17
================================
coreboot 4.17
========================================================================

The 4.17 release is planned for May, 2022.
The coreboot 4.17 release was done on June 3, 2022.

We are continuing the quarterly release cadence in order to enable others to
release quarterly on a fresher version of coreboot.
Since the 4.16 release, we've had over 1300 new commits by around 150
contributors. Of those people, roughly 15 were first-time contributors.

Update this document with changes that should be in the release notes.
As always, we appreciate everyone who has contributed and done the hard
work to make the coreboot project successful.

* 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
-------------------
Major Bugfixes in this release
------------------------------
* [CVE-2022-29264](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29264)

### Add significant changes here

New Mainboards
--------------

* Clevo L140MU / L141MU / L142MU
* Dell Precision T1650
* Google Craask
* Google Gelarshie
* Google Kuldax
* Google Mithrax
* Google Osiris
* HP Z220 CMT Workstation
* Star Labs LabTop Mk III (i7-8550u)
* Star Labs LabTop Mk IV (i3-10110U and i7-10710U)
* Star Labs Lite Mk III (N5000)
* Star Labs Lite Mk IV (N5030)


Removed Mainboards
------------------

* Google Deltan
* Google Deltaur

Significant or interesting changes
----------------------------------

These changes are a few that were selected as a sampling of particularly
interesting commits.


### CBMEM init hooks changed

Instead of having per stage x_CBMEM_INIT_HOOK, we now have only 2 hooks:
* CBMEM_CREATION_HOOK: Used only in the first stage that creates cbmem,
typically romstage. For instance code that migrates data from cache
as ram to dram would use this hook.
* CBMEM_READY_HOOK: Used in every stage that has cbmem. An example would
be initializing the cbmem console by appending to what previous stages
logged.
The reason for this change is improved flexibility with regards to which
stage initializes cbmem.


### Payloads

* SeaBIOS: Update stable release from 1.14.0 to 1.16.0
* iPXE: Update stable release from 2019.3 to 2022.1
* Add "GRUB2 atop SeaBIOS" aka "SeaGRUB" option, which builds GRUB2 as a
secondary payload for SeaBIOS with GRUB2 set as the default boot
entry. This allows GRUB2 to use BIOS callbacks provided by SeaBIOS as
a fallback method to access hardware that the native GRUB2 payload
cannot access.
* Add option to build SeaBIOS and GRUB2 as secondary payloads
* Add new coreDOOM payload. See commit message below.


### payloads/external: Add support for coreDOOM payload

coreDOOM is a port of DOOM to libpayload, based on the doomgeneric
source port. It renders the game to the coreboot linear framebuffer,
and loads WAD files from CBFS.


### cpu/x86/smm_module_load: Rewrite setup_stub

This code was hard to read as it did too much and had a lot of state
to keep track of.

It also looks like the staggered entry points were first copied and
only later the parameters of the first stub were filled in. This
means that only the BSP stub is actually jumping to the permanent
smihandler. On the APs the stub would jump to wherever c_handler
happens to point to, which is likely 0. This effectively means that on
APs it's likely easy to have arbitrary code execution in SMM which is a
security problem.

Note: This patch fixes CVE-2022-29264 for the 4.17 release.


### cpu/x86/smm_module_loader.c: Rewrite setup

This code is much easier to read if one does not have to keep track of
mutable variables.

This also fixes the alignment code on the TSEG smihandler setup code.
It was aligning the code upwards instead of downwards which would cause
it to encroach a part of the save state.


### cpu/x86/smm: Add sinkhole mitigation to relocatable smmstub

The sinkhole exploit exists in placing the lapic base such that it
messes with GDT. This can be mitigated by checking the lapic MSR
against the current program counter.


### cpu/x86/64bit: Generate static page tables from an assembly file

This removes the need for a tool to generate simple identity pages.
Future patches will link this page table directly into the stages on
some platforms so having an assembly file makes a lot of sense.

This also optimizes the size of the page of each 4K page by placing
the PDPE_table below the PDE.


### cpu/x86/smm,lib/cbmem_console: Enable CBMEMC when using DEBUG_SMI

This change will allow the SMI handler to write to the cbmem console
buffer. Normally SMIs can only be debugged using some kind of serial
port (UART). By storing the SMI logs into cbmem we can debug SMIs using
'cbmem -1'. Now that these logs are available to the OS we could also
verify there were no errors in the SMI handler.

Since SMM can write to all of DRAM, we can't trust any pointers
provided by cbmem after the OS has booted. For this reason we store the
cbmem console pointer as part of the SMM runtime parameters. The cbmem
console is implemented as a circular buffer so it will never write
outside of this area.


### security/tpm/crtm: Add a function to measure the bootblock on SoC level

On platforms where the bootblock is not included in CBFS anymore
because it is part of another firmware section (IFWI or a different
CBFS), the CRTM measurement fails.

This patch adds a new function to provide a way at SoC level to measure
the bootblock. Following patches will add functionality to retrieve the
bootblock from the SoC related location and measure it from there.
In this way the really executed code will be measured.


### soc/amd/common/block/psp: Add platform secure boot support

Add Platform Secure Boot (PSB) enablement via the PSP if it is not
already enabled. Upon receiving psb command, PSP will program PSB fuses
as long as BIOS signing key token is valid.
Refer to the AMD PSB user guide doc# 56654, Revision# 1.00.
Unfortunately this document is only available with NDA customers.


### drivers/intel/fsp2_0: Add native implementation for FSP Debug Handler

This patch implements coreboot native debug handler to manage the FSP
event messages.

'FSP Event Handlers' feature introduced in FSP to generate event
messages to aid in the debugging of firmware issues. This eliminates
the need for FSP to directly write debug messages to the UART and FSP
might not need to know the board related UART port configuration.
Instead FSP signals the bootloader to inform it of a new debug message.
This allows the coreboot to provide board specific methods of reporting
debug messages, example: legacy UART or LPSS UART etc.

This implementation has several advantages as:
1. FSP relies on XIP 'DebugLib' driver even while printing FSP-S debug
messages, hence, without ROM being cached, post 'romstage' would
results into sluggish boot with FSP debug enabled.
This patch utilities coreboot native debug implementation which is
XIP during FSP-M and relocatable to DRAM based resource for FSP-S.

2. This patch simplifies the FSP DebugLib implementation and remove the
need to have serial port library. Instead coreboot 'printk' can be
used for display FSP serial messages. Additionally, unifies the debug
library between coreboot and FSP.

3. This patch is also useful to get debug prints even with FSP
non-serial image (refer to 'Note' below) as FSP PEIMs are now
leveraging coreboot debug library instead FSP 'NULL' DebugLib
reference for release build.

4. Can optimize the FSP binary size by removing the DebugLib dependency
from most of FSP PEIMs, for example: on Alder Lake FSP-M debug binary
size is reduced by ~100KB+ and FSP-S debug library size is also
reduced by ~300KB+ (FSP-S debug and release binary size is exactly
same with this code changes). The total savings is ~400KB for each
FSP copy, and in case of Chrome AP firmware with 3 copies, the total
savings would be 400KB * 3 = ~1.2MB.

Note: Need to modify FSP source code to remove 'MDEPKG_NDEBUG' as
compilation flag for release build and generate FSP binary with non-NULL
FSP debug wrapper module injected (to allow FSP event handler to execute
even with FSP non-serial image) in the final FSP.fd.


### security/tpm: Add vendor-specific tis functions to read/write TPM regs

In order to abstract bus-specific logic from TPM logic, the prototype
for two vendor-specific tis functions are added in this
patch. tis_vendor_read() can be used to read directly from TPM
registers, and tis_vendor_write() can be used to write directly to TPM
registers.


### arch/x86: Add support for catching null dereferences through debug regs

This commit adds support for catching null dereferences and execution
through x86's debug registers. This is particularly useful when running
32-bit coreboot as paging is not enabled to catch these through page
faults. This commit adds three new configs to support this feature:
DEBUG_HW_BREAKPOINTS, DEBUG_NULL_DEREF_BREAKPOINTS and
DEBUG_NULL_DEREF_HALT.


### drivers/i2c/generic: Add support for i2c device detection

Add 'detect' flag which can be attached to devices which may or may not
be present at runtime, and for which coreboot should probe the i2c bus
to confirm device presence prior to adding an entry for it in the SSDT.

This is useful for boards which may utilize touchpads/touchscreens from
multiple vendors, so that only the device(s) present are added to the
SSDT. This relieves the burden from the OS to detect/probe if a device
is actually present and allows the OS to trust the ACPI _STA value.


### util/cbmem: Add FlameGraph-compatible timestamps output

Flame graphs are used to visualize hierarchical data, like call stacks.
Timestamps collected by coreboot can be processed to resemble
profiler-like output, and thus can be feed to flame graph generation
tools.

Generating flame graph using https://github.com/brendangregg/FlameGraph:
```
cbmem -S > trace.txt
FlameGraph/flamegraph.pl --flamechart trace.txt > output.svg
```


### src/console/Kconfig: Add option to disable loglevel prefix

This patch adds an option to disable loglevel prefixes. This patch helps
to achieve clear messages when low loglevel is used and very few
messages are displayed on a terminal. This option also allows to
maintain compatibility with log readers and continuous integration
systems that depend on fixed log content.

If the code contains:
printk(BIOS_DEBUG, "This is a debug message!\n")
it will show as:
[DEBUG] This is a debug message!
but if the Kconfig contains:
CONFIG_CONSOLE_USE_LOGLEVEL_PREFIX=n
the same message will show up as
This is a debug message!


### util/cbmem: add an option to append timestamp

Add an option to the cbmem utility that can be used to append an entry
to the cbmem timestamp table from userspace. This is useful for
bookkeeping of post-coreboot timing information while still being able
to use cbmem-based tooling for processing the generated data.


`-a | --add-timestamp ID: append timestamp with ID\n`


Additional changes
------------------

The following are changes across a number of patches, or changes worth
noting, but not needing a full description.

* As always, general documentation, code cleanup, and refactoring
* Remove doxygen config files and targets
* Get clang compile working for all x86 platforms
* Work on updating checkpatch to match the current Linux version
* Timestamps: Rename timestamps to make names more consistent
* Continue updating ACPI code to ASL 2.0
* Remove redundant or unnecessary headers from C files
* arch/x86/acpi_bert_storage.c: Use a common implementation
* Postcar stage improvements
* arch/x86/acpi: Consolidate POST code handling
* intel/common: Enable ROM caching in ramstage
* vendorcode/amd/agesa: Fix improper use of .data (const is important)
* sandybridge & gm45: Support setting PCI bars above 4G


Plans for Code Deprecation
--------------------------


### Intel Icelake

Intel Icelake is unmaintained. Also, the only user of this platform ever was
the CRB board. From the looks of it the code never was ready for production as
only engineering sample CPUIDs are supported.

Thus, to reduce the maintanence overhead for the community, it is deprecated
from this release on and support for the following components will be dropped
with the release 4.19.

* Intel Icelake SoC
* Intel Icelake RVP mainboard


### LEGACY_SMP_INIT

As of release 4.18 (August 2022) we plan to deprecate LEGACY_SMP_INIT.
This also includes the codepath for SMM_ASEG. This code is used to start
APs and do some feature programming on each AP, but also set up SMM.
This has largely been superseded by PARALLEL_MP, which should be able to
cover all use cases of LEGACY_SMP_INIT, with little code changes. The
reason for deprecation is that having 2 codepaths to do the virtually
the same increases maintenance burden on the community a lot, while also
being rather confusing.

No platforms in the tree have any hardware limitations that would block
migrating to PARALLEL_MP / a simple !CONFIG_SMP codebase.


Statistics
----------

- Total Commits: 1305
- Average Commits per day: 13.42
- Total lines added: 51422
- Average lines added per commit: 39.40
- Number of patches adding more than 100 lines: 59
- Average lines added per small commit: 24.73
- Total lines removed: 66206
- Average lines removed per commit: 50.73
- Total difference between added and removed: -14784
- Total authors: 146
- New authors: 17
56 changes: 56 additions & 0 deletions Documentation/releases/coreboot-4.18-relnotes.md
@@ -0,0 +1,56 @@
Upcoming release - coreboot 4.18
================================

The 4.18 release is planned for August 2022.

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











Plans for Code Deprecation
--------------------------


### Intel Icelake

Intel Icelake code will be removed following the 4.19 release, planned
for November 2022. This consists of the Intel Icelake SOC and Intel
Icelake RVP mainboard

Intel Icelake is unmaintained. Also, the only user of this platform ever
was the CRB board. From the looks of it the code never was ready for
production as only engineering sample CPUIDs are supported. This reduces
the maintanence overhead for the coreboot project.


### LEGACY_SMP_INIT

Legacy SMP init will be removed from the coreboot master branch
immediately following this release. Anyone looking for the latest
version of the code should find it on the 4.18 branch.

This also includes the codepath for SMM_ASEG. This code is used to start
APs and do some feature programming on each AP, but also set up SMM.
This has largely been superseded by PARALLEL_MP, which should be able to
cover all use cases of LEGACY_SMP_INIT, with little code changes. The
reason for deprecation is that having 2 codepaths to do the virtually
the same increases maintenance burden on the community a lot, while also
being rather confusing.
3 changes: 2 additions & 1 deletion Documentation/releases/index.md
Expand Up @@ -3,7 +3,7 @@
## Upcoming release

Please add to the release notes as changes are added:
* [4.17 - May 2022](coreboot-4.17-relnotes.md)
* [4.18 - Aug 2022](coreboot-4.18-relnotes.md)

The [checklist] contains instructions to ensure that a release covers all
important things and provides a reliable format for tarballs, branch
Expand All @@ -15,6 +15,7 @@ important is taken care of.

## Previous releases

* [4.17 - May 2022](coreboot-4.17-relnotes.md)
* [4.16 - Feb 2022](coreboot-4.16-relnotes.md)
* [4.15 - November 2021](coreboot-4.15-relnotes.md)
* [4.14 - May 2021](coreboot-4.14-relnotes.md)
Expand Down
2 changes: 1 addition & 1 deletion Documentation/soc/intel/mp_init/mp_init.md
Expand Up @@ -51,6 +51,6 @@ option in order to perform SGX and C6DRAM enabling.
Typically all platforms supported by FSP 2.1 specification will have
external PPI service feature implemented.

[References]
## References
- [PPI](../fsp/ppi/ppi.md)
- [MP Service PPI](../fsp/ppi/mp_service_ppi.md)
66 changes: 39 additions & 27 deletions Documentation/util.md
@@ -1,19 +1,36 @@

[//]: # ( DO NOT EDIT - AUTOGENERATED FILE )

[//]: # ( RUN 'util/util_readme/util_readme.sh' to regenerate )

# Utilities

## List of utils

_Scripts and programs found in the coreboot `./util` directory_

* __abuild__ - coreboot autobuild script builds coreboot images for all
available targets. `bash`
* __acpi__ - Walk through all ACPI tables with their addresses. `bash`
* __amdfwtool__ - Create AMD Firmware combination `C`
* __amdtools__ - A set of tools to compare extended) K8 memory
settings. `Perl`
* __amdtools__ Various tools for AMD processors
* _update_efs_spi_speed_ - Change SPI speed in binary. `Bash`
* Tools to compare extended K8 memory settings.
* _k8-compare-pci-space.pl_ - Shows differences between values
in PCI space and the default value. `Perl`
* _k8-interpret-extended-memory-settings.pl_ - Shows
differences between memory controller values and the default value.
`Perl`
* _k8-read-mem-settings.sh_ - Makes data files understood by
the k8-interpret-extended-memory-settings script. `Bash`
* _parse-bkdg.pl_ - Make bkdg.data file used by above scripts.
`Perl`
* _example_input_ - Sample input for the above scripts. `Text`
* __apcb__ - AMD PSP Control Block tools
* _apcb_edit.py_ - This tool allows patching an existing APCB
binary with specific SPDs and GPIO selection pins. `Python3`
* _apcb_v3_edit.py_ - This tool allows patching an existing APCB V3
binary with specific SPDs. `Python3`
* _apcb_v3_edit.py_ - This tool allows patching an existing
APCB v3 binary with up to 16 specific SPDs. `Python3`
* __archive__ - Concatenate files and create an archive `C`
* __autoport__ - Automated porting coreboot to Sandy Bridge/Ivy Bridge
platforms `Go`
Expand All @@ -25,8 +42,7 @@ status repository `Bash` `Go`
* __cavium__ - Devicetree_convert Tool to convert a DTB to a static C
file `Python`
* __cbfstool__
* [_cbfstool_](cbfstool/index.md) - For manipulating CBFS file
`C`
* _cbfstool_ - For manipulating CBFS file `C`
* _fmaptool_ - Converts plaintext fmd files into fmap blobs `C`
* _rmodtool_ - Creates rmodules `C`
* _ifwitool_ - For manipulating IFWI `C`
Expand All @@ -36,31 +52,32 @@ resources, for example to extract System Agent reference code and other
blobs (e.g. mrc.bin, refcode, VGA option roms) from a Chrome OS
recovery image. `C`
* __crossgcc__ - A cross toolchain builder for -elf toolchains (ie. no
libc support)
libc support) `Bash`
* __docker__ - Dockerfiles for _coreboot-sdk_, _coreboot-jenkins-node_,
_coreboot.org-status_ and _docs.coreboot.org_
_coreboot.org-status_ and _docs.coreboot.org_ `Make`
* __dtd_parser__ - DTD structure parser `Python2`
* __ectool__ - Dumps the RAM of a laptop's Embedded/Environmental
Controller (EC). `C`
* __exynos__ - Computes and fills Exynos ROM checksum (for BL1 or BL2).
`Python3`
* __find_usbdebug__ - Help find USB debug ports
* __find_usbdebug__ - Help find USB debug ports `Bash`
* __futility__ - Firmware utility for signing ChromeOS images `Make`
* __fuzz-tests__ - Create test cases that crash the jpeg code. `C`
* __genbuild_h__ - Generate build system definitions `Shell`
* __gitconfig__ - Initialize git repository submodules install git
hooks `Bash`
* [__ifdtool__](ifdtool/index.md) - Extract and dump Intel Firmware
Descriptor information `C`
* __ifdtool__ - Extract and dump Intel Firmware Descriptor information
`C`
* __intelmetool__ - Dump interesting things about Management Engine
even if hidden `C`
* __intelp2m__ - Intel Pad to Macro (intelp2m) converter 'Go'
* __intelp2m__ - convert the configuration DW0/1 registers value from
an inteltool dump to coreboot macros. `go`
* __inteltool__ - Provides information about the Intel CPU/chipset
hardware configuration (register contents, MSRs, etc). `C`
* __intelvbttool__ - Parse VBT from VGA BIOS `C`
* __ipqheader__
* _createxbl.py_ - Concatenates XBL segments into one ELF
image `Python`
* _createxbl.py_ - Concatenates XBL segments into one ELF image
`Python`
* _ipqheader.py_ - Returns a packed MBN header image with the
specified base and size `Python`
* _mbncat.py_ - Generate ipq8064 uber SBL `Python`
Expand All @@ -71,6 +88,8 @@ firmware of many HP laptops with 8051-based SMSC KBC1098/KBC1126
embedded controller and insert them to the firmware image. `C`
* __kconfig__ - Build system `Make`
* __lint__ - Source linter and linting rules `Shell`
* __liveiso__ - A script and NixOS configuration files to create an ISO
image for testing purposes and for working on firmware. `Bash`
* __mainboard__ - mainboard specific scripts
* _google_ - Directory for google mainboard specific scripts
* __marvell__ - Add U-Boot boot loader for Marvell ARMADA38X `C`
Expand All @@ -82,14 +101,12 @@ partial deblobbing of Intel ME/TXE firmware images `Python`
* __nvidia__ - nvidia blob parsers
* __nvramtool__ - Reads and writes coreboot parameters and displaying
information from the coreboot table in CMOS/NVRAM. `C`
* __pgtblgen__ - Generates page tables based on fixed physical address.
`C`
* __pmh7tool__ - Dumps, reads and writes PMH7 registers on Lenovo
ThinkPads. PMH7 is used for switching on and off the power of some
devices on the board such as dGPU. `C`
* __post__ - Userspace utility that can be used to test POST cards. `C`
* __qemu__ - Makefile & comprehensive default config for QEMU Q35
emulation
emulation `Make`
* __qualcomm__ - CMM script to debug Qualcomm coreboot environments.
`CMM`
* __release__ - Generate coreboot release `Bash`
Expand All @@ -106,7 +123,7 @@ command line `Bash`
* _cross-repo-cherrypick_ - Pull in patches from another tree
from a gerrit repository. `Shell`
* _decode_spd.sh_ - Decodes Serial Presence Detect (SPD) files
into various human readable formats.
into various human readable formats. `Bash`
* _dts-to-fmd.sh_ -Converts a depthcharge fmap.dts into an
fmaptool compatible .fmd format `Bash`
* _find-unused-kconfig-symbols.sh_ - Points out Kconfig
Expand All @@ -127,12 +144,6 @@ file `Perl`
* __spdtool__ - Dumps SPD ROMs from a given blob to separate files
using known patterns and reserved bits. Useful for analysing firmware
that holds SPDs on boards that have soldered down DRAM. `python`
* __spd_tools__ - Tools for generating SPD files for DDR4 memory used
in platforms with memory down configuration.
* _gen_spd.go_ - Generates de-duplicated SPD files using a
global memory part list provided by the mainboard in JSON format. `Go`
* _gen_part_id.go_ - Allocates DRAM strap IDs for different
DDR4 memory parts used by the board. `Go`
* __spkmodem_recv__ - Decode spkmodem signals `C`
* __superiotool__ - A user-space utility to detect Super I/O of a
mainboard and provide detailed information about the register contents
Expand All @@ -152,10 +163,11 @@ the documentation `Bash`
`Go`
* __xcompile__ - Cross compile setup `Bash`

## In depth documentation

## In depth documentation

* [ifdtool](ifdtool/index.md)
* [cbfstool](util/cbfstool/index.md)
* [ifdtool](util/ifdtool/index.md)
* [intelp2m](util/intelp2m/index.md)

## Generated documentation

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@

A coreboot image for an Intel SoC contains two separate definitions of the
layout of the flash. The Intel Flash Descriptor (IFD) which defines offsets and
sizes of various regions of flash and the [coreboot FMAP](../lib/flashmap.md).
sizes of various regions of flash and the [coreboot FMAP](../../lib/flashmap.md).

The FMAP should define all of the of the regions defined by the IFD to ensure
that those regions are accounted for by coreboot and will not be accidentally
Expand Down
File renamed without changes
210 changes: 210 additions & 0 deletions Documentation/util/intelp2m/index.md
@@ -0,0 +1,210 @@
Intel Pad to Macro (intelp2m) converter
=======================================

This utility allows one to convert the configuration DW0/1 register
values from an inteltool dump to coreboot macros.

```bash
cd util/intelp2m
make
./intelp2m -h
./intelp2m -file /path/to/inteltool.log
```

### Platforms

It is possible to use templates for parsing inteltool.log files.
To specify such a pattern, use the option `-t <template number>`.

```text
-t
template type number
0 - inteltool.log (default)
1 - gpio.h
2 - your template
```

For example, using template type 1, you can parse gpio.h from an
existing board in the coreboot project.

```bash
./intelp2m -t 1 -file coreboot/src/mainboard/yourboard/gpio.h
```

You can also add a template to 'parser/template.go' for your file type
with the configuration of the pads.

platform type is set using the -p option (Sunrise by default):

```text
-p string
set up a platform
snr - Sunrise PCH with Skylake/Kaby Lake CPU
lbg - Lewisburg PCH with Xeon SP CPU
apl - Apollo Lake SoC
cnl - CannonLake-LP or Whiskeylake/Coffeelake/Cometlake-U SoC
adl - AlderLake PCH
(default "snr")
```

```bash
./intelp2m -p <platform> -file path/to/inteltool.log
```

### Packages

![][pckgs]

[pckgs]: gopackages.png

### Bit fields in macros

Use the `-fld=cb` option to only generate a sequence of bit fields in
a new macro:

```bash
./intelp2m -fld cb -p apl -file ../apollo-inteltool.log
```

```c
_PAD_CFG_STRUCT(GPIO_37, PAD_FUNC(NF1) | PAD_TRIG(OFF) | PAD_TRIG(OFF), \
PAD_PULL(DN_20K)), /* LPSS_UART0_TXD */
```
### Raw DW0, DW1 register value
To generate the gpio.c with raw PAD_CFG_DW0 and PAD_CFG_DW1 register
values you need to use the -fld=raw option:
```bash
./intelp2m -fld raw -file /path/to/inteltool.log
```

```c
_PAD_CFG_STRUCT(GPP_A10, 0x44000500, 0x00000000),
```
```bash
./intelp2m -iiii -fld raw -file /path/to/inteltool.log
```

```c
/* GPP_A10 - CLKOUT_LPC1 */
/* DW0: 0x44000500, DW1: 0x00000000 */
/* DW0: 0x04000100 - IGNORED */
/* PAD_CFG_NF(GPP_A10, NONE, DEEP, NF1), */
_PAD_CFG_STRUCT(GPP_A10, 0x44000500, 0x00000000),
```
### Macro Check
After generating the macro, the utility checks all used
fields of the configuration registers. If some field has been
ignored, the utility generates field macros. To not check
macros, use the -n option:
```bash
./intelp2m -n -file /path/to/inteltool.log
```

In this case, some fields of the configuration registers
DW0 will be ignored.

```c
PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_38, UP_20K, DEEP, NF1, HIZCRx1, DISPUPD),
PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, DISPUPD),
```
### Information level
The utility can generate additional information about the bit
fields of the DW0 and DW1 configuration registers. Using the
options -i, -ii, -iii, -iiii you can set the info level from
1 to 4:
```bash
./intelp2m -i -file /path/to/inteltool.log
```

```c
_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(OFF),\
PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)), /* LPSS_UART0_TXD */
```
```bash
./intelp2m -ii -file /path/to/inteltool.log
./intelp2m -iii -file /path/to/inteltool.log
./intelp2m -iiii -file /path/to/inteltool.log
```

```c
/* GPIO_39 - LPSS_UART0_TXD */
/* DW0: 0x44000400, DW1: 0x00003100 */ --> (ii)
/* DW0 : PAD_TRIG(OFF) - IGNORED */ --> (iii)
/* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE,
DISPUPD), */ --> (iiii)
_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP) | PAD_TRIG(OFF),
PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)),
```
If the -n switch was used and macros was generated without checking:
```c
/* GPIO_39 - LPSS_UART0_TXD */ --> (i)
/* DW0: 0x44000400, DW1: 0x00003100 */ --> (ii)
/* DW0: PAD_TRIG(OFF) - IGNORED */ --> (iii)
/* _PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP) |
PAD_TRIG(OFF), PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)), */ --> (iiii)
PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1, TxLASTRxE, \
DISPUPD),
```

### Ignoring Fields

Utilities can generate the _PAD_CFG_STRUCT macro and exclude fields
from it that are not in the corresponding PAD_CFG_*() macro:

```bash
./intelp2m -iiii -fld cb -ign -file /path/to/inteltool.log
```

```c
/* GPIO_39 - LPSS_UART0_TXD */
/* DW0: 0x44000400, DW1: 0x00003100 */
/* DW0: PAD_TRIG(OFF) - IGNORED */
/* PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_39, UP_20K, DEEP, NF1,
TxLASTRxE, DISPUPD), */
_PAD_CFG_STRUCT(GPIO_39, PAD_FUNC(NF1) | PAD_RESET(DEEP), \
PAD_PULL(UP_20K) | PAD_IOSTERM(DISPUPD)),
```
### FSP-style macro
The utility allows one to generate macros that include fsp/edk2-platform
style bitfields:
```bash
./intelp2m -i -fld fsp -p lbg -file ../crb-inteltool.log
```

```c
{ GPIO_SKL_H_GPP_A12, { GpioPadModeGpio, GpioHostOwnAcpi, GpioDirInInvOut,
GpioOutLow, GpioIntSci | GpioIntLvlEdgDis, GpioResetNormal, GpioTermNone,
GpioPadConfigLock }, /* GPIO */
```
```bash
./intelp2m -iiii -fld fsp -p lbg -file ../crb-inteltool.log
```

```c
/* GPP_A12 - GPIO */
/* DW0: 0x80880102, DW1: 0x00000000 */
/* PAD_CFG_GPI_SCI(GPP_A12, NONE, PLTRST, LEVEL, INVERT), */
{ GPIO_SKL_H_GPP_A12, { GpioPadModeGpio, GpioHostOwnAcpi, GpioDirInInvOut,
GpioOutLow, GpioIntSci | GpioIntLvlEdgDis, GpioResetNormal, GpioTermNone,
GpioPadConfigLock },
```
### Supported Chipsets
Sunrise PCH, Lewisburg PCH, Apollo Lake SoC, CannonLake-LP SoCs
13 changes: 13 additions & 0 deletions MAINTAINERS
Expand Up @@ -417,6 +417,13 @@ F: src/mainboard/protectli/



PRODRIVE ATLAS MAINBOARD
M: Angel Pons <th3fanbus@gmail.com>
M: Christian Walter <christian.walter@9elements.com>
M: Lean Sheng Tan <sheng.tan@9elements.com>
S: Maintained
F: src/mainboard/prodrive/atlas/

PRODRIVE HERMES MAINBOARD
M: Christian Walter <christian.walter@9elements.com>
M: Patrick Rudolph <patrick.rudolph@9elements.com>
Expand Down Expand Up @@ -678,6 +685,12 @@ M: Mariusz Szafranski <mariuszx.szafranski@intel.com>
S: Maintained
F: src/soc/intel/denverton_ns/

INTEL ELKHARTLAKE SOC
M: Lean Sheng Tan <sheng.tan@9elements.com>
M: Werner Zeh <werner.zeh@siemens.com>
S: Maintained
F: src/soc/intel/elkhartlake/

INTEL TIGERLAKE SOC
M: Tim Wawrzynczak <twawrzynczak@chromium.org>
S: Maintained
Expand Down
29 changes: 2 additions & 27 deletions Makefile
Expand Up @@ -64,9 +64,6 @@ HOSTCXXFLAGS := -g

PREPROCESS_ONLY := -E -P -x assembler-with-cpp -undef -I .

DOXYGEN := doxygen
DOXYGEN_OUTPUT_DIR := doxygen

export $(COREBOOT_EXPORTS)

all: real-all
Expand All @@ -77,8 +74,6 @@ help_coreboot help::
@echo ' all - Build coreboot'
@echo ' clean - Remove coreboot build artifacts'
@echo ' distclean - Remove build artifacts and config files'
@echo ' doxygen - Build doxygen documentation for coreboot'
@echo ' doxyplatform - Build doxygen documentation for the current platform'
@echo ' sphinx - Build sphinx documentation for coreboot'
@echo ' sphinx-lint - Build sphinx documenttion for coreboot with warnings as errors'
@echo ' filelist - Show files used in current build'
Expand Down Expand Up @@ -450,27 +445,7 @@ sphinx:
sphinx-lint:
$(MAKE) SPHINXOPTS=-W -C Documentation -f Makefile.sphinx html

doxy: doxygen
doxygen:
$(DOXYGEN) Documentation/Doxyfile.coreboot

doxygen_simple:
$(DOXYGEN) Documentation/Doxyfile.coreboot_simple

doxyplatform doxygen_platform: $(obj)/project_filelist.txt
echo
echo "Building doxygen documentation for $(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="$(call strip_quotes, $(CONFIG_MAINBOARD_DIR)) \($(call strip_quotes, $(CONFIG_MAINBOARD_PART_NUMBER))\) version $(KERNELVERSION)"; \
$(DOXYGEN) Documentation/doxygen/Doxyfile.coreboot_platform

doxyclean: doxygen-clean
doxygen-clean:
rm -rf $(DOXYGEN_OUTPUT_DIR)

clean-for-update: doxygen-clean
clean-for-update:
rm -rf $(obj) .xcompile

clean: clean-for-update clean-utils clean-payloads
Expand All @@ -496,5 +471,5 @@ distclean: clean clean-ctags clean-cscope distclean-payloads distclean-utils
rm -rf coreboot-builds coreboot-builds-chromeos
rm -f abuild*.xml junit.xml* util/lint/junit.xml

.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean doxygen doxy doxygen_simple sphinx sphinx-lint
.PHONY: $(PHONY) clean clean-for-update clean-cscope cscope distclean sphinx sphinx-lint
.PHONY: ctags-project cscope-project clean-ctags
21 changes: 14 additions & 7 deletions Makefile.inc
Expand Up @@ -1100,13 +1100,19 @@ ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y)
TS_OPTIONS := -j $(CONFIG_INTEL_TOP_SWAP_BOOTBLOCK_SIZE)
endif

ifneq ($(CONFIG_ARCH_X86),y)
add_bootblock = $(CBFSTOOL) $(1) write -u -r BOOTBLOCK -f $(2)
endif

# coreboot.pre doesn't follow the standard Make conventions. It gets modified
# by multiple rules, and thus we can't compute the dependencies correctly.
$(shell rm -f $(obj)/coreboot.pre)

ifneq ($(CONFIG_UPDATE_IMAGE),y)
$(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) $(obj)/fmap.fmap $(obj)/fmap.desc
$(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) $(obj)/fmap.fmap $(obj)/fmap.desc $(objcbfs)/bootblock.bin
$(CBFSTOOL) $@.tmp create -M $(obj)/fmap.fmap -r $(shell cat $(obj)/fmap.desc)
printf " BOOTBLOCK\n"
$(call add_bootblock,$@.tmp,$(objcbfs)/bootblock.bin)
$(prebuild-files) true
mv $@.tmp $@
else # ifneq ($(CONFIG_UPDATE_IMAGE),y)
Expand Down Expand Up @@ -1136,12 +1142,6 @@ add_intermediate = \
$(1): $(obj)/coreboot.pre $(2) | $(INTERMEDIATE) \
$(eval INTERMEDIATE+=$(1)) $(eval PHONY+=$(1))

ifneq ($(CONFIG_ARCH_X86),y)
$(call add_intermediate, add_bootblock, $(objcbfs)/bootblock.bin)
printf " FMAP writing BOOTBLOCK region\n"
$(CBFSTOOL) $< write -u -r BOOTBLOCK -f $(objcbfs)/bootblock.bin
endif

$(obj)/coreboot.rom: $(obj)/coreboot.pre $(CBFSTOOL) $(IFITTOOL) $$(INTERMEDIATE)
@printf " CBFS $(subst $(obj)/,,$(@))\n"
# The full ROM may be larger than the CBFS part, so create an empty
Expand All @@ -1165,6 +1165,13 @@ endif
$(CBFSTOOL) $@ layout
@printf " CBFSPRINT $(subst $(obj)/,,$(@))\n\n"
$(CBFSTOOL) $@ print -r $(subst $(spc),$(comma),$(all-regions))
ifeq ($(CONFIG_CBFS_VERIFICATION),y)
line=$$($(CBFSTOOL) $@ print -kv 2>/dev/null | grep -F '[CBFS VERIFICATION (COREBOOT)]') ;\
if ! printf "$$line" | grep -q 'fully valid'; then \
echo "CBFS verification error: $$line" ;\
exit 1 ;\
fi
endif # CONFIG_CBFS_VERIFICATION

cbfs-files-y += $(CONFIG_CBFS_PREFIX)/romstage
$(CONFIG_CBFS_PREFIX)/romstage-file := $(objcbfs)/romstage.elf
Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -54,8 +54,7 @@ Build Requirements

Optional:

* doxygen (for generating/viewing documentation)
* gdb (for better debugging facilities on some targets)
* gdb (for better debugging facilities on some targets)
* ncurses (for `make menuconfig` and `make nconfig`)
* flex and bison (for regenerating parsers)

Expand Down
4 changes: 2 additions & 2 deletions configs/config.pcengines_apu1
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.16.0.4"
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_CBFS_SIZE=0x00200000
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
Expand Down Expand Up @@ -29,4 +29,4 @@ CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.23"
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
4 changes: 2 additions & 2 deletions configs/config.pcengines_apu2
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.16.0.4"
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_PXE_ROM_ID="8086,157b"
Expand Down Expand Up @@ -33,4 +33,4 @@ CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.23"
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
4 changes: 2 additions & 2 deletions configs/config.pcengines_apu3
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.16.0.4"
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_PXE_ROM_ID="8086,1539"
Expand Down Expand Up @@ -33,4 +33,4 @@ CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.23"
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
4 changes: 2 additions & 2 deletions configs/config.pcengines_apu4
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.16.0.4"
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_PXE_ROM_ID="8086,1539"
Expand Down Expand Up @@ -33,4 +33,4 @@ CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.23"
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
4 changes: 2 additions & 2 deletions configs/config.pcengines_apu5
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.16.0.4"
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_PXE_ROM_ID="8086,1539"
Expand Down Expand Up @@ -33,4 +33,4 @@ CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.23"
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
4 changes: 2 additions & 2 deletions configs/config.pcengines_apu6
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.16.0.4"
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_PXE_ROM_ID="8086,1539"
Expand Down Expand Up @@ -33,4 +33,4 @@ CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.23"
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
30 changes: 30 additions & 0 deletions configs/config.pcengines_apu7
@@ -0,0 +1,30 @@
CONFIG_LOCALVERSION="v4.17.0.1"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_CONSOLE_CBMEM_BUFFER_SIZE=0x20000
CONFIG_BOARD_PCENGINES_APU7=y
CONFIG_BOTTOMIO_POSITION=0xD0000000
CONFIG_UART_PCI_ADDR=0x0
CONFIG_HUDSON_SATA_MODE=2
CONFIG_AGESA_BINARY_PI_LOCATION=0xFFE00000
CONFIG_NO_GFX_INIT=y
CONFIG_SUBSYSTEM_VENDOR_ID=0x0000
CONFIG_SUBSYSTEM_DEVICE_ID=0x0000
CONFIG_TPM2=y
CONFIG_DEFAULT_CONSOLE_LOGLEVEL_1=y
CONFIG_CONSOLE_USE_ANSI_ESCAPES=n
CONFIG_CONSOLE_USE_LOGLEVEL_PREFIX=n
CONFIG_POST_IO_PORT=0x80
CONFIG_SEABIOS_REVISION=y
CONFIG_SEABIOS_REVISION_ID="rel-1.16.0.1"
CONFIG_SEABIOS_BOOTORDER_IN_FMAP=y
CONFIG_SEABIOS_BOOTORDER_FILE="$(top)/src/mainboard/$(MAINBOARDDIR)/variants/$(CONFIG_VARIANT_DIR)/bootorder"
CONFIG_SEABIOS_DEBUG_LEVEL=0
CONFIG_SEABIOS_SERCON_PORT_ADDR=0x3f8
CONFIG_SEABIOS_NO_OPROMS=y
CONFIG_MEMTEST_SECONDARY_PAYLOAD=y
CONFIG_SORTBOOTORDER_SECONDARY_PAYLOAD=y
CONFIG_MEMTEST_REVISION=y
CONFIG_MEMTEST_REVISION_ID="0b756257276729c1a12bc1d95e7a1f044894bda2"
CONFIG_SORTBOOTORDER_REVISION=y
CONFIG_SORTBOOTORDER_REVISION_ID="v4.6.24"
30 changes: 30 additions & 0 deletions payloads/Kconfig
Expand Up @@ -121,6 +121,15 @@ config COREINFO_SECONDARY_PAYLOAD
coreinfo can be loaded as a secondary payload under SeaBIOS, GRUB,
or any other payload that can load additional payloads.

config GRUB2_SECONDARY_PAYLOAD
bool "Load GRUB2 as a secondary payload"
default n
depends on !PAYLOAD_GRUB2
select PAYLOAD_BUILD_GRUB2
help
GRUB2 can be loaded as a secondary payload under SeaBIOS or any
other payload that can load additional payloads.

config MEMTEST_SECONDARY_PAYLOAD
bool "Load Memtest86+ as a secondary payload"
default n
Expand All @@ -137,6 +146,17 @@ config NVRAMCUI_SECONDARY_PAYLOAD
nvramcui can be loaded as a secondary payload under SeaBIOS, GRUB,
or any other payload that can load additional payloads.

config SEABIOS_SECONDARY_PAYLOAD
bool "Load SeaBIOS as a secondary payload"
default n
depends on ARCH_X86
depends on !PAYLOAD_SEABIOS
depends on !PAYLOAD_SEAGRUB
select PAYLOAD_BUILD_SEABIOS
help
SeaBIOS can be loaded as a secondary payload under GRUB or any
other payload that can load additional payloads.

config TINT_SECONDARY_PAYLOAD
bool "Load tint as a secondary payload"
default n
Expand All @@ -153,6 +173,16 @@ config SORTBOOTORDER_SECONDARY_PAYLOAD
sortbootorder can be loaded as a secondary payload under SeaBIOS
or any other payload that can load additional payloads.

config COREDOOM_SECONDARY_PAYLOAD
bool "Load coreDOOM as a secondary payload"
default n
depends on ARCH_X86
help
coreDOOM can be loaded as a secondary payload under SeaBIOS, GRUB,
or any other payload that can load additional payloads. Requires a
linear framebuffer. If built as a secondary payload for SeaBIOS, the
generated VGA BIOS option rom is also required.

source "payloads/external/*/Kconfig.secondary"

endmenu # "Secondary Payloads"
Expand Down
1 change: 1 addition & 0 deletions payloads/Makefile.inc
Expand Up @@ -30,6 +30,7 @@ payloads/external/GRUB2 \
payloads/external/LinuxBoot \
payloads/external/Yabits \
payloads/external/skiboot \
payloads/external/coreDOOM \

force-payload:

Expand Down
33 changes: 29 additions & 4 deletions payloads/external/GRUB2/Kconfig
@@ -1,5 +1,15 @@
config PAYLOAD_BUILD_GRUB2
bool

if PAYLOAD_GRUB2

config PAYLOAD_FILE
default "payloads/external/GRUB2/grub2/build/default_payload.elf"

endif

if PAYLOAD_BUILD_GRUB2

choice
prompt "GRUB2 version"
default GRUB2_STABLE
Expand Down Expand Up @@ -42,12 +52,9 @@ config GRUB2_EXTRA_MODULES
* gfxmenu for graphical menus (you'll need a theme as well)
* gfxterm_background for setting background

config PAYLOAD_FILE
default "payloads/external/GRUB2/grub2/build/default_payload.elf"

config GRUB2_INCLUDE_RUNTIME_CONFIG_FILE
bool "Include GRUB2 runtime config file into ROM image"
depends on PAYLOAD_GRUB2
depends on PAYLOAD_BUILD_GRUB2
default n
help
The GRUB2 payload reads its runtime configuration file from etc/grub.cfg
Expand All @@ -72,3 +79,21 @@ config GRUB2_RUNTIME_CONFIG_FILE
The path of the GRUB2 runtime configuration file to be added to CBFS.

endif

if PAYLOAD_SEAGRUB

config PAYLOAD_FILE
default "payloads/external/SeaBIOS/seabios/out/bios.bin.elf"

config SEABIOS_BOOTORDER_FILE
default "payloads/external/GRUB2/bootorder-seagrub"

config SEAGRUB_ALLOW_SEABIOS_BOOTMENU
bool "Allow to access SeaBIOS boot menu before launching GRUB"
help
Enable this to allow the access to the boot menu of SeaBIOS. It
increases the flexibility but allows to entirely bypass GRUB, along
with all secure mechanism implemented in its runtime config.
Please use this with caution.

endif
13 changes: 13 additions & 0 deletions payloads/external/GRUB2/Kconfig.name
@@ -1,9 +1,22 @@
config PAYLOAD_GRUB2
bool "GRUB2"
depends on ARCH_X86 || ARCH_ARM
select PAYLOAD_BUILD_GRUB2
help
Select this option if you want to build a coreboot image
with a GRUB2 payload. If you don't know what this is
about, just leave it enabled.

See https://coreboot.org/Payloads for more information.

config PAYLOAD_SEAGRUB
bool "GRUB2 atop SeaBIOS"
depends on ARCH_X86
select PAYLOAD_BUILD_SEABIOS
select GRUB2_SECONDARY_PAYLOAD
help
Select this option if you want to build a coreboot image
with a GRUB2 payload running atop SeaBIOS to improve its
hardware compatibility.

See https://coreboot.org/Payloads for more information.
1 change: 1 addition & 0 deletions payloads/external/GRUB2/bootorder-seagrub
@@ -0,0 +1 @@
/rom@img/grub2
55 changes: 55 additions & 0 deletions payloads/external/LinuxBoot/Kconfig
Expand Up @@ -258,6 +258,61 @@ config LINUXBOOT_UROOT_COMMANDS
List of additional modules to include,
separated by space. (default "boot coreboot-app")

if LINUXBOOT_UROOT_MAIN

choice
prompt "Choose a specific bootloader"
default SPECIFIC_BOOTLOADER_SYSTEMBOOT
help
Specify a bootloader which starts after u-root init. It will be a symlink
to /bin/uinit. Default: systemboot

config SPECIFIC_BOOTLOADER_NONE
bool "none"
help
Leave u-root to decide which bootloaders to load first after init, if
any at all. Most likely u-root will start into the defined u-root shell.

config SPECIFIC_BOOTLOADER_SYSTEMBOOT
bool "systemboot"
help
If systemboot has been used as a bootloader wrapper in the past,
enable this option. It will invoke -uinitcmd=systemboot and result in
a BIOS/UEFI BDS boot behavior.

config SPECIFIC_BOOTLOADER_BOOT2
bool "boot2"

config SPECIFIC_BOOTLOADER_PXEBOOT
bool "pxeboot"

config SPECIFIC_BOOTLOADER_STBOOT
bool "stboot"

config SPECIFIC_BOOTLOADER_CUSTOM
bool "custom"

endchoice

config SPECIFIC_BOOTLOADER_CUSTOM_CMD
string "Specify a custom program to start"
depends on SPECIFIC_BOOTLOADER_CUSTOM
help
This option will symlink the input to /bin/unit which will set it as the
first boot program after the u-root init. Program flags are not
symlinkable.

config LINUXBOOT_UROOT_UINITCMD
string
default "" if SPECIFIC_BOOTLOADER_NONE
default "systemboot" if SPECIFIC_BOOTLOADER_SYSTEMBOOT
default "boot2" if SPECIFIC_BOOTLOADER_BOOT2
default "pxeboot" if SPECIFIC_BOOTLOADER_PXEBOOT
default "stboot" if SPECIFIC_BOOTLOADER_STBOOT
default SPECIFIC_BOOTLOADER_CUSTOM_CMD if SPECIFIC_BOOTLOADER_CUSTOM

endif #LINUXBOOT_UROOT_MAIN

endif #LINUXBOOT_UROOT

endif #LINUXBOOT_BUILD_INITRAMFS
Expand Down
4 changes: 2 additions & 2 deletions payloads/external/LinuxBoot/Makefile
@@ -1,7 +1,6 @@
## SPDX-License-Identifier: GPL-2.0-only

project_dir=linuxboot
kernel_dir=$(project_dir)/kernel

unexport $(COREBOOT_EXPORTS)

Expand Down Expand Up @@ -52,9 +51,10 @@ endif
linuxboot: kernel initramfs_compressed

clean:
if [ -d "$(kernel_dir)" ]; then rm -rf $(kernel_dir); fi
rm -rf $(project_dir)/kernel*
rm -f $(project_dir)/u-root
rm -f $(project_dir)/initramfs*
rm -f $(project_dir)/bzImage

distclean:
rm -rf $(project_dir)
Expand Down
15 changes: 9 additions & 6 deletions payloads/external/LinuxBoot/targets/u-root.mk
Expand Up @@ -15,6 +15,7 @@ go_version_minor=$(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?

uroot_args+=-build=$(CONFIG_LINUXBOOT_UROOT_FORMAT)
uroot_args+=-initcmd $(CONFIG_LINUXBOOT_UROOT_INITCMD)
uroot_args+=-uinitcmd=$(CONFIG_LINUXBOOT_UROOT_UINITCMD)
uroot_args+=-defaultsh $(CONFIG_LINUXBOOT_UROOT_SHELL)
ifneq (CONFIG_LINUXBOOT_UROOT_FILES,)
uroot_args+=$(foreach file,$(CONFIG_LINUXBOOT_UROOT_FILES),-files $(PWD)/$(file))
Expand All @@ -40,22 +41,24 @@ endif
get: version
if [ -d "$(go_path_dir)/src/$(uroot_package)" ]; then \
git -C $(go_path_dir)/src/$(uroot_package) checkout --quiet main; \
GOPATH=$(go_path_dir) go get -d -u -v $(uroot_package) || \
echo -e "\n<<u-root package update failed>>\n"; \
git -C $(go_path_dir)/src/$(uroot_package) pull || \
echo -e "\n<<Pulling u-root package from GitHub failed>>\n"; \
else \
GOPATH=$(go_path_dir) go get -d -u -v $(uroot_package) || \
(echo -e "\n<<failed to get u-root package. Please check your internet access>>\n" && \
git clone https://${uroot_package} ${go_path_dir}/src/${uroot_package} || \
(echo -e "\n<<Failed to clone u-root package. Please check your internet access>>\n" && \
exit 1); \
fi

checkout: get
git -C $(go_path_dir)/src/$(uroot_package) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)

build: checkout
GOPATH=$(go_path_dir) go build -o $(uroot_bin) $(uroot_package)
cd ${go_path_dir}/src/${uroot_package}; \
go build -o ${uroot_bin} .

u-root: build
GOARCH=$(ARCH-y) GOPATH=$(go_path_dir) $(uroot_bin) \
GOARCH=$(ARCH-y) $(uroot_bin) \
-uroot-source ${go_path_dir}/src/${uroot_package} \
$(uroot_args) -o $(project_dir)/initramfs_u-root.cpio $(uroot_cmds)

.PHONY: all u-root build checkout get version
63 changes: 57 additions & 6 deletions payloads/external/Makefile.inc
@@ -1,7 +1,7 @@
## SPDX-License-Identifier: GPL-2.0-only

# set up payload config and version files for later inclusion
ifeq ($(CONFIG_PAYLOAD_SEABIOS),y)
ifeq ($(CONFIG_PAYLOAD_BUILD_SEABIOS),y)
PAYLOAD_CONFIG=payloads/external/SeaBIOS/seabios/.config
PAYLOAD_VERSION=payloads/external/SeaBIOS/seabios/out/autoversion.h
endif
Expand Down Expand Up @@ -61,7 +61,8 @@ etc/grub.cfg-required := the GRUB runtime configuration file ($(CONFIG_GRUB2_RUN
# SeaBIOS

SEABIOS_CC_OFFSET=$(if $(filter %ccache,$(HOSTCC)),2,1)
payloads/external/SeaBIOS/seabios/out/bios.bin.elf: $(DOTCONFIG)
SEABIOS_TARGET_PATH=payloads/external/SeaBIOS/seabios/out/bios.bin.elf
$(SEABIOS_TARGET_PATH): $(DOTCONFIG)
$(MAKE) -C payloads/external/SeaBIOS \
HOSTCC="$(HOSTCC)" \
CC=$(word $(SEABIOS_CC_OFFSET),$(CC_x86_32)) \
Expand All @@ -88,9 +89,14 @@ payloads/external/SeaBIOS/seabios/out/bios.bin.elf: $(DOTCONFIG)
CONFIG_CONSOLE_UART_BASE_ADDRESS=$(CONFIG_CONSOLE_UART_BASE_ADDRESS) \
CONFIG_SEABIOS_HARDWARE_IRQ=$(CONFIG_SEABIOS_HARDWARE_IRQ)

payloads/external/SeaBIOS/seabios/out/vgabios.bin: payloads/external/SeaBIOS/seabios/out/bios.bin.elf
payloads/external/SeaBIOS/seabios/.config: payloads/external/SeaBIOS/seabios/out/bios.bin.elf
payloads/external/SeaBIOS/seabios/out/autoversion.h: payloads/external/SeaBIOS/seabios/out/bios.bin.elf
payloads/external/SeaBIOS/seabios/out/vgabios.bin: $(SEABIOS_TARGET_PATH)
payloads/external/SeaBIOS/seabios/.config: $(SEABIOS_TARGET_PATH)
payloads/external/SeaBIOS/seabios/out/autoversion.h: $(SEABIOS_TARGET_PATH)

cbfs-files-$(CONFIG_SEABIOS_SECONDARY_PAYLOAD) += img/seabios
img/seabios-file := $(SEABIOS_TARGET_PATH)
img/seabios-type := payload
img/seabios-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)

# add a SeaBIOS bootorder file
ifneq ($(CONFIG_SEABIOS_BOOTORDER_IN_FMAP),y)
Expand Down Expand Up @@ -145,6 +151,13 @@ etc/sercon-port-file := $(strip $(CONFIG_SEABIOS_SERCON_PORT_FILE))
etc/sercon-port-type := raw
endif

ifeq ($(CONFIG_SEABIOS_NO_OPROMS),y)
$(call add_intermediate, seabios_no_oproms, $(CBFSTOOL))
@printf " SeaBIOS Add pci-optionrom-exec file\n"
$(if $(CONFIG_UPDATE_IMAGE),-$(CBFSTOOL) $< remove -n etc/pci-optionrom-exec 2>/dev/null)
$(CBFSTOOL) $< add-int -i 0 -n etc/pci-optionrom-exec
endif

ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),)
ifneq ($(CONFIG_SEABIOS_PS2_TIMEOUT),0)
$(call add_intermediate, seabios_ps2_timeout, $(CBFSTOOL))
Expand Down Expand Up @@ -177,6 +190,18 @@ $(call add_intermediate, seabios_bootorder_fmap, $(CBFSTOOL))
endif
endif

ifeq ($(CONFIG_PAYLOAD_SEAGRUB),y)
ifneq ($(CONFIG_SEAGRUB_ALLOW_SEABIOS_BOOTMENU),y)
$(call add_intermediate, seabios_bootmenu, $(CBFSTOOL))
@printf " SeaBIOS Disable boot menu\n"
$(if $(CONFIG_UPDATE_IMAGE),-$(CBFSTOOL) $< remove -n etc/show-boot-menu 2>/dev/null)
$(CBFSTOOL) $< add-int -i 0 -n etc/show-boot-menu
else
$(call add_intermediate, seabios_bootmenu, $(CBFSTOOL))
$(if $(CONFIG_UPDATE_IMAGE),-$(CBFSTOOL) $< remove -n etc/show-boot-menu 2>/dev/null)
endif
endif

# Depthcharge

payloads/external/depthcharge/depthcharge/build/depthcharge.elf depthcharge: $(DOTCONFIG) $(CBFSTOOL)
Expand All @@ -199,6 +224,7 @@ $(obj)/UEFIPAYLOAD.fd tianocore: $(DOTCONFIG)
CONFIG_TIANOCORE_TAG_OR_REV=$(CONFIG_TIANOCORE_TAG_OR_REV) \
CONFIG_TIANOCORE_UEFIPAYLOAD=$(CONFIG_TIANOCORE_UEFIPAYLOAD) \
CONFIG_TIANOCORE_UPSTREAM=$(CONFIG_TIANOCORE_UPSTREAM) \
CONFIG_TIANOCORE_CUSTOM=$(CONFIG_TIANOCORE_CUSTOM) \
CONFIG_TIANOCORE_COREBOOTPAYLOAD=$(CONFIG_TIANOCORE_COREBOOTPAYLOAD) \
CONFIG_TIANOCORE_DEBUG=$(CONFIG_TIANOCORE_DEBUG) \
CONFIG_TIANOCORE_RELEASE=$(CONFIG_TIANOCORE_RELEASE) \
Expand All @@ -214,6 +240,7 @@ $(obj)/UEFIPAYLOAD.fd tianocore: $(DOTCONFIG)
CONFIG_TIANOCORE_SD_MMC_TIMEOUT=$(CONFIG_TIANOCORE_SD_MMC_TIMEOUT) \
CONFIG_TIANOCORE_USE_8254_TIMER=$(CONFIG_TIANOCORE_USE_8254_TIMER) \
CONFIG_ECAM_MMCONF_BASE_ADDRESS=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS) \
CONFIG_TIANOCORE_CUSTOM_BUILD_PARAMS=$(CONFIG_TIANOCORE_CUSTOM_BUILD_PARAMS) \
GCC_CC_x86_32=$(GCC_CC_x86_32) \
GCC_CC_x86_64=$(GCC_CC_x86_64) \
GCC_CC_arm=$(GCC_CC_arm) \
Expand Down Expand Up @@ -244,6 +271,13 @@ payloads/external/FILO/filo/build/version.h: filo

# Grub

GRUB_TARGET_PATH=payloads/external/GRUB2/grub2/build/default_payload.elf

cbfs-files-$(CONFIG_GRUB2_SECONDARY_PAYLOAD) += img/grub2
img/grub2-file := $(GRUB_TARGET_PATH)
img/grub2-type := payload
img/grub2-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)

grub2: $(obj)/config.h
$(MAKE) -C payloads/external/GRUB2 \
HOSTCC="$(HOSTCC)" \
Expand All @@ -256,7 +290,7 @@ grub2: $(obj)/config.h
CONFIG_GRUB2_REVISION_ID=$(CONFIG_GRUB2_REVISION_ID) \
CONFIG_GRUB2_EXTRA_MODULES=$(CONFIG_GRUB2_EXTRA_MODULES)

payloads/external/GRUB2/grub2/build/default_payload.elf: grub2
$(GRUB_TARGET_PATH): grub2

# U-Boot

Expand Down Expand Up @@ -393,6 +427,7 @@ linuxboot:
CONFIG_LINUXBOOT_UROOT_VERSION=$(CONFIG_LINUXBOOT_UROOT_VERSION) \
CONFIG_LINUXBOOT_UROOT_FORMAT=$(CONFIG_LINUXBOOT_UROOT_FORMAT) \
CONFIG_LINUXBOOT_UROOT_INITCMD=$(CONFIG_LINUXBOOT_UROOT_INITCMD) \
CONFIG_LINUXBOOT_UROOT_UINITCMD=$(CONFIG_LINUXBOOT_UROOT_UINITCMD)\
CONFIG_LINUXBOOT_UROOT_SHELL=$(CONFIG_LINUXBOOT_UROOT_SHELL) \
CONFIG_LINUXBOOT_UROOT_COMMANDS=$(CONFIG_LINUXBOOT_UROOT_COMMANDS) \
CONFIG_LINUXBOOT_UROOT_FILES=$(CONFIG_LINUXBOOT_UROOT_FILES) \
Expand Down Expand Up @@ -424,3 +459,19 @@ payloads/external/skiboot/build/skiboot.elf:
$(MAKE) -C payloads/external/skiboot all \
CONFIG_SKIBOOT_GIT_REPO=$(CONFIG_SKIBOOT_GIT_REPO) \
CONFIG_SKIBOOT_REVISION=$(CONFIG_SKIBOOT_REVISION)
# COREDOOM

payloads/external/coreDOOM/coredoom/doomgeneric/coredoom.elf coredoom:
$(MAKE) -C payloads/external/coreDOOM

cbfs-files-$(CONFIG_COREDOOM_SECONDARY_PAYLOAD) += img/coreDOOM
img/coreDOOM-file := payloads/external/coreDOOM/coredoom/doomgeneric/coredoom.elf
img/coreDOOM-type := payload
img/coreDOOM-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)
# WAD file
ifneq ($(strip $(CONFIG_COREDOOM_WAD_FILE)),)
cbfs-files-y += doom.wad
doom.wad-file := $(strip $(CONFIG_COREDOOM_WAD_FILE))
doom.wad-type := raw
doom.wad-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)
endif
21 changes: 18 additions & 3 deletions payloads/external/SeaBIOS/Kconfig
@@ -1,5 +1,15 @@
config PAYLOAD_BUILD_SEABIOS
bool

if PAYLOAD_SEABIOS

config PAYLOAD_FILE
default "payloads/external/SeaBIOS/seabios/out/bios.bin.elf"

endif

if PAYLOAD_BUILD_SEABIOS

choice
prompt "SeaBIOS version"
default SEABIOS_STABLE
Expand Down Expand Up @@ -40,6 +50,13 @@ config SEABIOS_PS2_TIMEOUT
after powering on. This specifies how long SeaBIOS will wait for the
keyboard controller to become ready before giving up.

config SEABIOS_NO_OPROMS
prompt "Disable Option ROM execution in SeaBIOS"
default n
bool
help
Select this option to disable Option ROM execution in SeaBIOS

config SEABIOS_THREAD_OPTIONROMS
prompt "Hardware init during option ROM execution"
default n
Expand All @@ -64,6 +81,7 @@ config SEABIOS_HARDWARE_IRQ
config SEABIOS_VGA_COREBOOT
prompt "Include generated option rom that implements legacy VGA BIOS compatibility"
default y if !VENDOR_EMULATION
default y if COREDOOM_SECONDARY_PAYLOAD
depends on !VGA_ROM_RUN && (VGA_TEXT_FRAMEBUFFER || LINEAR_FRAMEBUFFER)
bool
help
Expand Down Expand Up @@ -169,9 +187,6 @@ config SEABIOS_SERCON_PORT_ADDR

By default primary console UART defined by TTYS0_BASE is used.

config PAYLOAD_FILE
default "payloads/external/SeaBIOS/seabios/out/bios.bin.elf"

config PAYLOAD_VGABIOS_FILE
string
depends on SEABIOS_VGA_COREBOOT
Expand Down
1 change: 1 addition & 0 deletions payloads/external/SeaBIOS/Kconfig.name
@@ -1,6 +1,7 @@
config PAYLOAD_SEABIOS
bool "SeaBIOS"
depends on ARCH_X86
select PAYLOAD_BUILD_SEABIOS
help
Select this option if you want to build a coreboot image
with a SeaBIOS payload. If you don't know what this is
Expand Down
25 changes: 25 additions & 0 deletions payloads/external/coreDOOM/Kconfig.secondary
@@ -0,0 +1,25 @@
if COREDOOM_SECONDARY_PAYLOAD

config COREDOOM_WAD_FILE
string "DOOM WAD file"
depends on COREDOOM_SECONDARY_PAYLOAD
default "doom.wad"
help
Add a WAD file to be loaded by coreDOOM.

A WAD file contains all the game data for the Doom-engine, and
is required to play the game.

A list of the WAD files included in the official games can be
found here: https://doomwiki.org/wiki/IWAD
These WADs can be extracted from copies of the game that you
own, and the shareware WADs may be freely downloaded from the
internet.

For a completely free (as in freedom) experience, the Freedoom
project (https://freedoom.github.io) provides original game
content under the BSD license. Other WADs not mentioned here are
also available and may be found from various sources such as
the internet and copies of other games using the Doom engine.

endif
34 changes: 34 additions & 0 deletions payloads/external/coreDOOM/Makefile
@@ -0,0 +1,34 @@
## SPDX-License-Identifier: GPL-2.0-only
project_git_repo=https://github.com/nic3-14159/coreDOOM.git
project_dir=coredoom

unexport KCONFIG_AUTOHEADER
unexport KCONFIG_AUTOCONFIG
unexport KCONFIG_DEPENDENCIES
unexport KCONFIG_SPLITCONFIG
unexport KCONFIG_TRISTATE
unexport KCONFIG_NEGATIVES

all: coredoom

checkout:
test -d coredoom || \
git clone $(project_git_repo) $(project_dir)
cd $(project_dir) && \
git checkout libpayload_port

coredoom: libpayload
$(MAKE) -C $(project_dir)/doomgeneric

libpayload: checkout
cp libpayload-config ../../libpayload/.config && \
cd ../../libpayload && $(MAKE) olddefconfig && $(MAKE) && \
$(MAKE) DESTDIR=../external/coreDOOM/coredoom/doomgeneric install

clean:
test -d coredoom && $(MAKE) -C coredoom/doomgeneric clean || exit 0

distclean:
rm -rf coredoom

.PHONY: checkout coredoom clean distclean
13 changes: 13 additions & 0 deletions payloads/external/coreDOOM/libpayload-config
@@ -0,0 +1,13 @@
# CONFIG_LP_MULTIBOOT is not set
CONFIG_LP_HEAP_SIZE=67108864
CONFIG_LP_STACK_SIZE=16384
CONFIG_LP_BASE_ADDRESS=0x00100000
# CONFIG_LP_CURSES is not set
CONFIG_LP_SERIAL_IOBASE=0x3f8
CONFIG_LP_COREBOOT_VIDEO_CONSOLE=y
# CONFIG_LP_PCI is not set
# CONFIG_LP_NVRAM is not set
CONFIG_LP_TIMER_GENERIC_REG=0x0
CONFIG_LP_TIMER_GENERIC_HIGH_REG=0x0
# CONFIG_LP_STORAGE is not set
# CONFIG_LP_USB_MSC is not set
11 changes: 11 additions & 0 deletions payloads/external/tianocore/Kconfig
Expand Up @@ -186,4 +186,15 @@ config TIANOCORE_USE_8254_TIMER

endif

if TIANOCORE_CUSTOM

config TIANOCORE_CUSTOM_BUILD_PARAMS
string "TianoCore additional custom build parameters"
help
Custom TianoCore forks may have different sets of parameters passed
to build command. You may specify additional parameters to the custom
TianoCore build

endif

endif
8 changes: 7 additions & 1 deletion payloads/external/tianocore/Makefile
Expand Up @@ -86,6 +86,12 @@ endif

bootloader = $(word 8,$(subst /, ,$(BUILD_STR)))

ifeq ($(CONFIG_TIANOCORE_CUSTOM),y)
ifneq ($(CONFIG_TIANOCORE_CUSTOM_BUILD_PARAMS),)
BUILD_STR += $(CONFIG_TIANOCORE_CUSTOM_BUILD_PARAMS)
endif
endif

all: clean build

$(project_dir):
Expand All @@ -104,7 +110,7 @@ update: $(project_dir)
echo " $(CONFIG_TIANOCORE_TAG_OR_REV) is not a valid git reference"; \
exit 1; \
fi; \
if git status --ignore-submodules=dirty | grep -qv clean; then \
if git status --ignore-submodules=dirty | grep -q clean; then \
echo " Checking out $(project_name) revision $(CONFIG_TIANOCORE_TAG_OR_REV)"; \
git checkout --detach $(CONFIG_TIANOCORE_TAG_OR_REV) -f; \
else \
Expand Down
15 changes: 13 additions & 2 deletions payloads/libpayload/Kconfig
Expand Up @@ -404,8 +404,19 @@ menu "Drivers"

config PCI
bool "Support for PCI devices"
depends on ARCH_X86 # for now
default y
default y if ARCH_X86
default n

config PCI_IO_OPS
bool "Support for PCI devices with port IO"
depends on PCI && IO_ADDRESS_SPACE
default y if ARCH_X86
default n

config PCIE_MEDIATEK
bool "Support for PCIe devices on MediaTek platforms"
depends on PCI && !PCI_IO_OPS
default n

config NVRAM
bool "Support for reading/writing NVRAM bytes"
Expand Down
14 changes: 13 additions & 1 deletion payloads/libpayload/Makefile.inc
Expand Up @@ -28,6 +28,13 @@
## SUCH DAMAGE.
##

ifneq ($(NOCOMPILE),1)
GIT:=$(shell git -C "$(top)" rev-parse --git-dir 1>/dev/null 2>&1 \
&& command -v git)
else
GIT:=
endif

export KERNELVERSION := 0.2.0

ARCHDIR-$(CONFIG_LP_ARCH_ARM) := arm
Expand Down Expand Up @@ -60,7 +67,8 @@ subdirs-$(CONFIG_LP_LZ4) += liblz4
subdirs-$(CONFIG_LP_VBOOT_LIB) += vboot

INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
INCLUDES += -include include/kconfig.h -include include/compiler.h
INCLUDES += -include include/kconfig.h
INCLUDES += -include $(coreboottop)/src/commonlib/bsd/include/commonlib/bsd/compiler.h
INCLUDES += -I$(coreboottop)/src/commonlib/bsd/include
INCLUDES += -I$(VBOOT_SOURCE)/firmware/include

Expand All @@ -75,6 +83,10 @@ ifeq ($(CONFIG_LP_LTO),y)
CFLAGS += -flto
endif

# Some of the commonlib cbfs headers include vboot headers, so initialize the
# submodule in case we are building a payload outside the main coreboot build
forgetthis:=$(if $(GIT),$(shell git submodule update --init ../../3rdparty/vboot $(quiet_errors)))

$(obj)/libpayload.config: $(DOTCONFIG)
cp $< $@

Expand Down
22 changes: 12 additions & 10 deletions payloads/libpayload/Makefile.payload
Expand Up @@ -36,7 +36,7 @@ ARCH ?=
OBJS ?=
CCACHE ?=

CFLAGS = $(GCC_CFLAGS_$(ARCH))
CFLAGS = $(CFLAGS_$(ARCH))
CFLAGS += -Os -ffreestanding
CFLAGS += -Wall -Wextra -Wmissing-prototypes -Wvla -Werror

Expand All @@ -56,6 +56,8 @@ export V

ifeq ($(filter %clean,$(MAKECMDGOALS)),)

-include $(LIBPAYLOAD_DOTCONFIG)

xcompile := $(obj)/xcompile
xcompile_script := $(LIBPAYLOAD_SRC)/../../util/xcompile/xcompile

Expand Down Expand Up @@ -122,26 +124,26 @@ LIBPAYLOAD_OPTS += DOTCONFIG="$(LIBPAYLOAD_DOTCONFIG)"
LIBPAYLOAD_OPTS += CONFIG_=CONFIG_LP_
LIBPAYLOAD_OPTS += $(if $(CCACHE),CONFIG_LP_CCACHE=y)

defconfig: lp-defconfig
lp-defconfig: $(LIBPAYLOAD_DOTCONFIG)
$(LIBPAYLOAD_DOTCONFIG): $(LIBPAYLOAD_DEFCONFIG) | $(PAYLOAD_DEPS)
ifneq ($(LIBPAYLOAD_DEFCONFIG),)
$(LIBPAYLOAD_DOTCONFIG): $(LIBPAYLOAD_DEFCONFIG)
$(MAKE) -C $(LIBPAYLOAD_SRC) $(LIBPAYLOAD_OPTS) \
KBUILD_DEFCONFIG=$(LIBPAYLOAD_DEFCONFIG) defconfig
endif

$(LIBPAYLOAD_CONFIG_H): $(LIBPAYLOAD_DOTCONFIG)
$(MAKE) -C $(LIBPAYLOAD_SRC) $(LIBPAYLOAD_OPTS) $(LIBPAYLOAD_CONFIG_H)

oldconfig: lp-oldconfig
lp-oldconfig:
[ ! -f $(LIBPAYLOAD_DOTCONFIG) ] || \
$(MAKE) -C $(LIBPAYLOAD_SRC) $(LIBPAYLOAD_OPTS) oldconfig
force-relay:

lp-%: force-relay
$(MAKE) -C $(LIBPAYLOAD_SRC) $(LIBPAYLOAD_OPTS) $*

$(LIBPAYLOAD): lp-defconfig | $(LIBPAYLOAD_CONFIG_H)
$(LIBPAYLOAD): force-relay | $(LIBPAYLOAD_CONFIG_H)
$(MAKE) -C $(LIBPAYLOAD_SRC) $(LIBPAYLOAD_OPTS)

$(shell mkdir -p $(sort $(dir $(OBJS))))

.PHONY: oldconfig lp-oldconfig defconfig lp-defconfig
.PHONY: force-relay

else # %clean,$(MAKECMDGOALS)

Expand Down
4 changes: 3 additions & 1 deletion payloads/libpayload/bin/lpgcc
Expand Up @@ -168,9 +168,11 @@ if [ $_LIBDIR = $_OBJ ]; then
_CFLAGS="$_CFLAGS -I$BASE/../curses"
fi

_CFLAGS="$_CFLAGS -include $BASE/../../../src/commonlib/bsd/include/commonlib/bsd/compiler.h"
_CFLAGS="$_CFLAGS -I$BASE/../../../src/commonlib/bsd/include"
_CFLAGS="$_CFLAGS -I$BASE/../../../3rdparty/vboot/firmware/include"
else
_CFLAGS="$_CFLAGS -include $BASE/../include/commonlib/bsd/compiler.h"
_CFLAGS="$_CFLAGS -I$_VBOOTINCDIR"
fi

Expand All @@ -179,7 +181,7 @@ fi
trygccoption -fno-stack-protector
[ $? -eq 0 ] && _CFLAGS="$_CFLAGS -fno-stack-protector"

_CFLAGS="$_CFLAGS -include $BASE/../include/kconfig.h -include $BASE/../include/compiler.h"
_CFLAGS="$_CFLAGS -include $BASE/../include/kconfig.h"
_CFLAGS="$_CFLAGS -I`$DEFAULT_CC $_ARCHEXTRA -print-search-dirs | head -n 1 | cut -d' ' -f2`include"

if [ "$CONFIG_LP_VBOOT_LIB" = y ]; then
Expand Down
10 changes: 9 additions & 1 deletion payloads/libpayload/drivers/Makefile.inc
Expand Up @@ -28,7 +28,15 @@
## SUCH DAMAGE.
##

libc-$(CONFIG_LP_PCI) += pci.c
libc-$(CONFIG_LP_PCI) += pci_ops.c

ifeq ($(CONFIG_LP_PCI_IO_OPS),y)
libc-$(CONFIG_LP_PCI) += pci_io_ops.c
else
libc-$(CONFIG_LP_PCI) += pci_map_bus_ops.c
endif

libc-$(CONFIG_LP_PCIE_MEDIATEK) += pcie_mediatek.c

libc-$(CONFIG_LP_SPEAKER) += speaker.c

Expand Down
67 changes: 67 additions & 0 deletions payloads/libpayload/drivers/pci_io_ops.c
@@ -0,0 +1,67 @@
/*
*
* Copyright (C) 2008 Advanced Micro Devices, Inc.
* Copyright (C) 2008 coresystems GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#include <libpayload.h>
#include <pci.h>

u8 pci_read_config8(pcidev_t dev, u16 reg)
{
outl(dev | (reg & ~3), 0xCF8);
return inb(0xCFC + (reg & 3));
}

u16 pci_read_config16(pcidev_t dev, u16 reg)
{
outl(dev | (reg & ~3), 0xCF8);
return inw(0xCFC + (reg & 3));
}

u32 pci_read_config32(pcidev_t dev, u16 reg)
{
outl(dev | (reg & ~3), 0xCF8);
return inl(0xCFC + (reg & 3));
}

void pci_write_config8(pcidev_t dev, u16 reg, u8 val)
{
outl(dev | (reg & ~3), 0xCF8);
outb(val, 0xCFC + (reg & 3));
}

void pci_write_config16(pcidev_t dev, u16 reg, u16 val)
{
outl(dev | (reg & ~3), 0xCF8);
outw(val, 0xCFC + (reg & 3));
}

void pci_write_config32(pcidev_t dev, u16 reg, u32 val)
{
outl(dev | (reg & ~3), 0xCF8);
outl(val, 0xCFC + (reg & 3));
}
46 changes: 46 additions & 0 deletions payloads/libpayload/drivers/pci_map_bus_ops.c
@@ -0,0 +1,46 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <libpayload.h>
#include <pci.h>

u8 pci_read_config8(pcidev_t dev, u16 reg)
{
uintptr_t cfg_base = pci_map_bus(dev);

return read8((void *)(cfg_base | reg));
}

u16 pci_read_config16(pcidev_t dev, u16 reg)
{
uintptr_t cfg_base = pci_map_bus(dev);

return read16((void *)(cfg_base | (reg & ~1)));
}

u32 pci_read_config32(pcidev_t dev, u16 reg)
{
uintptr_t cfg_base = pci_map_bus(dev);

return read32((void *)(cfg_base | (reg & ~3)));
}

void pci_write_config8(pcidev_t dev, u16 reg, u8 val)
{
uintptr_t cfg_base = pci_map_bus(dev);

write8((void *)(cfg_base | reg), val);
}

void pci_write_config16(pcidev_t dev, u16 reg, u16 val)
{
uintptr_t cfg_base = pci_map_bus(dev);

write16((void *)(cfg_base | (reg & ~1)), val);
}

void pci_write_config32(pcidev_t dev, u16 reg, u32 val)
{
uintptr_t cfg_base = pci_map_bus(dev);

write32((void *)(cfg_base | (reg & ~3)), val);
}
Expand Up @@ -30,42 +30,6 @@
#include <libpayload.h>
#include <pci.h>

u8 pci_read_config8(pcidev_t device, u16 reg)
{
outl(device | (reg & ~3), 0xCF8);
return inb(0xCFC + (reg & 3));
}

u16 pci_read_config16(pcidev_t device, u16 reg)
{
outl(device | (reg & ~3), 0xCF8);
return inw(0xCFC + (reg & 3));
}

u32 pci_read_config32(pcidev_t device, u16 reg)
{
outl(device | (reg & ~3), 0xCF8);
return inl(0xCFC + (reg & 3));
}

void pci_write_config8(pcidev_t device, u16 reg, u8 val)
{
outl(device | (reg & ~3), 0xCF8);
outb(val, 0xCFC + (reg & 3));
}

void pci_write_config16(pcidev_t device, u16 reg, u16 val)
{
outl(device | (reg & ~3), 0xCF8);
outw(val, 0xCFC + (reg & 3));
}

void pci_write_config32(pcidev_t device, u16 reg, u32 val)
{
outl(device | (reg & ~3), 0xCF8);
outl(val, 0xCFC + (reg & 3));
}

static int find_on_bus(int bus, unsigned short vid, unsigned short did,
pcidev_t * dev)
{
Expand Down
20 changes: 20 additions & 0 deletions payloads/libpayload/drivers/pcie_mediatek.c
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <libpayload.h>
#include <pci.h>

#define PCIE_CFGNUM_REG 0x140
#define PCIE_CFG_DEVFN(devfn) ((devfn) & GENMASK(7, 0))
#define PCIE_CFG_BUS(bus) (((bus) << 8) & GENMASK(15, 8))
#define PCIE_CFG_OFFSET_ADDR 0x1000
#define PCIE_CFG_HEADER(bus, devfn) \
(PCIE_CFG_BUS(bus) | PCIE_CFG_DEVFN(devfn))

uintptr_t pci_map_bus(pcidev_t dev)
{
u32 devfn = (PCI_SLOT(dev) << 3) | PCI_FUNC(dev);
u32 val = PCIE_CFG_HEADER(PCI_BUS(dev), devfn);
write32((void *)(lib_sysinfo.pcie_ctrl_base + PCIE_CFGNUM_REG), val);

return lib_sysinfo.pcie_ctrl_base + PCIE_CFG_OFFSET_ADDR;
}
53 changes: 0 additions & 53 deletions payloads/libpayload/include/compiler.h

This file was deleted.

7 changes: 7 additions & 0 deletions payloads/libpayload/include/coreboot_tables.h
Expand Up @@ -84,6 +84,7 @@ enum {
CB_TAG_ACPI_CNVS = 0x0041,
CB_TAG_TYPE_C_INFO = 0x0042,
CB_TAG_ACPI_RSDP = 0x0043,
CB_TAG_PCIE = 0x0044,
CB_TAG_CMOS_OPTION_TABLE = 0x00c8,
CB_TAG_OPTION = 0x00c9,
CB_TAG_OPTION_ENUM = 0x00ca,
Expand Down Expand Up @@ -265,6 +266,12 @@ struct cb_gpios {
struct cb_gpio gpios[0];
};

struct cb_pcie {
uint32_t tag;
uint32_t size;
cb_uint64_t ctrl_base; /* Base address of PCIe controller */
};

struct lb_range {
uint32_t tag;
uint32_t size;
Expand Down
1 change: 1 addition & 0 deletions payloads/libpayload/include/libpayload.h
Expand Up @@ -45,6 +45,7 @@
#include <stdbool.h>
#include <libpayload-config.h>
#include <cbgfx.h>
#include <commonlib/bsd/elog.h>
#include <commonlib/bsd/fmap_serialized.h>
#include <commonlib/bsd/helpers.h>
#include <commonlib/bsd/mem_chip_info.h>
Expand Down
16 changes: 10 additions & 6 deletions payloads/libpayload/include/pci.h
Expand Up @@ -31,6 +31,8 @@
#define _PCI_H

#include <arch/types.h>
#include <stdint.h>

typedef u32 pcidev_t;

/* Device config space registers. */
Expand Down Expand Up @@ -100,13 +102,15 @@ typedef u32 pcidev_t;
#define PCI_SLOT(_d) ((_d >> 11) & 0x1f)
#define PCI_FUNC(_d) ((_d >> 8) & 0x7)

u8 pci_read_config8(u32 device, u16 reg);
u16 pci_read_config16(u32 device, u16 reg);
u32 pci_read_config32(u32 device, u16 reg);
uintptr_t pci_map_bus(pcidev_t dev);

u8 pci_read_config8(pcidev_t dev, u16 reg);
u16 pci_read_config16(pcidev_t dev, u16 reg);
u32 pci_read_config32(pcidev_t dev, u16 reg);

void pci_write_config8(u32 device, u16 reg, u8 val);
void pci_write_config16(u32 device, u16 reg, u16 val);
void pci_write_config32(u32 device, u16 reg, u32 val);
void pci_write_config8(pcidev_t dev, u16 reg, u8 val);
void pci_write_config16(pcidev_t dev, u16 reg, u16 val);
void pci_write_config32(pcidev_t dev, u16 reg, u32 val);

int pci_find_device(u16 vid, u16 did, pcidev_t *dev);
u32 pci_read_resource(pcidev_t dev, int bar);
Expand Down
1 change: 1 addition & 0 deletions payloads/libpayload/include/sysinfo.h
Expand Up @@ -84,6 +84,7 @@ struct sysinfo_t {
uintptr_t linker;
uintptr_t assembler;
uintptr_t mem_chip_base;
uintptr_t pcie_ctrl_base; /* Base address of PCIe controller */

uintptr_t cb_version;

Expand Down
4 changes: 4 additions & 0 deletions payloads/libpayload/libc/Makefile.inc
Expand Up @@ -39,3 +39,7 @@ libc-$(CONFIG_LP_LIBC) += die.c
libc-$(CONFIG_LP_LIBC) += coreboot.c
libc-$(CONFIG_LP_LIBC) += fmap.c
libc-$(CONFIG_LP_LIBC) += fpmath.c

ifeq ($(CONFIG_LP_LIBC),y)
libc-srcs += $(coreboottop)/src/commonlib/bsd/elog.c
endif
10 changes: 10 additions & 0 deletions payloads/libpayload/libc/coreboot.c
Expand Up @@ -264,6 +264,13 @@ static void cb_parse_cbmem_entry(void *ptr, struct sysinfo_t *info)
}
}

static void cb_parse_pcie(void *ptr, struct sysinfo_t *info)
{
const struct cb_pcie *pcie = ptr;

info->pcie_ctrl_base = pcie->ctrl_base;
}

static void cb_parse_rsdp(void *ptr, struct sysinfo_t *info)
{
const struct cb_acpi_rsdp *cb_acpi_rsdp = ptr;
Expand Down Expand Up @@ -413,6 +420,9 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
case CB_TAG_ACPI_RSDP:
cb_parse_rsdp(ptr, info);
break;
case CB_TAG_PCIE:
cb_parse_pcie(ptr, info);
break;
default:
cb_parse_arch_specific(rec, info);
break;
Expand Down
2 changes: 1 addition & 1 deletion payloads/libpayload/libcbfs/cbfs.c
Expand Up @@ -120,7 +120,7 @@ static size_t cbfs_load_and_decompress(size_t offset, size_t in_size, void *buff
goto out;
}

if (cbfs_file_hash_mismatch(buffer, in_size, mdata, skip_verification))
if (cbfs_file_hash_mismatch(load, in_size, mdata, skip_verification))
goto out;

switch (compression) {
Expand Down
3 changes: 2 additions & 1 deletion payloads/libpayload/tests/Makefile.inc
Expand Up @@ -30,7 +30,8 @@ TEST_CONFIG_ := CONFIG_LP_


# Default includes
TEST_CFLAGS := -include include/kconfig.h -include include/compiler.h
TEST_CFLAGS := -include include/kconfig.h
TEST_CFLAGS += -include $(coreboottop)/src/commonlib/bsd/include/commonlib/bsd/compiler.h
TEST_CFLAGS += -Iinclude -Iinclude/mock
TEST_CFLAGS += -I$(coreboottop)/src/commonlib/bsd/include
TEST_CFLAGS += -I$(dir $(TEST_KCONFIG_AUTOHEADER))
Expand Down
36 changes: 30 additions & 6 deletions payloads/libpayload/tests/libcbfs/cbfs-verification-test.c
Expand Up @@ -43,14 +43,18 @@ vb2_error_t vb2_hash_verify(const void *buf, uint32_t size, const struct vb2_has
unsigned long ulzman(const unsigned char *src, unsigned long srcn, unsigned char *dst,
unsigned long dstn)
{
fail_msg("Unexpected call to %s", __func__);
return 0;
size_t copy_size = MIN(srcn, dstn);
function_called();
memcpy(dst, src, copy_size);
return copy_size;
}

size_t ulz4fn(const void *src, size_t srcn, void *dst, size_t dstn)
{
fail_msg("Unexpected call to %s", __func__);
return 0;
size_t copy_size = MIN(srcn, dstn);
function_called();
memcpy(dst, src, copy_size);
return copy_size;
}

enum cb_err cbfs_mcache_lookup(const void *mcache, size_t mcache_size, const char *name,
Expand Down Expand Up @@ -167,7 +171,7 @@ static void test_cbfs_map_no_hash(void **state)
}
}

static void test_cbfs_map_valid_hash(void **state)
static void test_cbfs_map_valid_hash_impl(void **state, bool lz4_compressed)
{
void *mapping = NULL;
size_t size = 0;
Expand All @@ -181,8 +185,17 @@ static void test_cbfs_map_valid_hash(void **state)
expect_cbfs_lookup(TEST_DATA_1_FILENAME, CB_SUCCESS,
(const union cbfs_mdata *)&file_valid_hash,
be32toh(file_valid_hash.header.offset));
will_return(cbfs_find_attr, NULL);

if (lz4_compressed) {
struct cbfs_file_attr_compression cattr = {
.compression = htobe32(CBFS_COMPRESS_LZ4),
.decompressed_size = htobe32(TEST_DATA_1_SIZE),
};
will_return(cbfs_find_attr, &cattr);
expect_function_call(ulz4fn);
} else {
will_return(cbfs_find_attr, NULL);
}

if (CONFIG(LP_CBFS_VERIFICATION)) {
will_return(cbfs_file_hash, &hash);
Expand All @@ -203,6 +216,16 @@ static void test_cbfs_map_valid_hash(void **state)
}
}

static void test_cbfs_map_valid_hash(void **state)
{
test_cbfs_map_valid_hash_impl(state, false);
}

static void test_cbfs_map_valid_hash_with_lz4(void **state)
{
test_cbfs_map_valid_hash_impl(state, true);
}

static void test_cbfs_map_invalid_hash(void **state)
{
void *mapping = NULL;
Expand Down Expand Up @@ -240,6 +263,7 @@ int main(void)
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup(test_cbfs_map_no_hash, setup_test_cbfs),
cmocka_unit_test_setup(test_cbfs_map_valid_hash, setup_test_cbfs),
cmocka_unit_test_setup(test_cbfs_map_valid_hash_with_lz4, setup_test_cbfs),
cmocka_unit_test_setup(test_cbfs_map_invalid_hash, setup_test_cbfs),
};

Expand Down
40 changes: 40 additions & 0 deletions spd/lp5/memory_parts.json
Expand Up @@ -59,6 +59,46 @@
"ranksPerChannel": 2,
"speedMbps": 6400
}
},
{
"name": "K3LKLKL0EM-MGCN",
"attribs": {
"densityPerDieGb": 8,
"diesPerPackage": 2,
"bitWidthPerChannel": 16,
"ranksPerChannel": 1,
"speedMbps": 5500
}
},
{
"name": "H58G56AK6BX069",
"attribs": {
"densityPerDieGb": 16,
"diesPerPackage": 2,
"bitWidthPerChannel": 16,
"ranksPerChannel": 1,
"speedMbps": 6400
}
},
{
"name": "MT62F1G32D4DS-031 WT:B",
"attribs": {
"densityPerDieGb": 8,
"diesPerPackage": 4,
"bitWidthPerChannel": 16,
"ranksPerChannel": 2,
"speedMbps": 6400
}
},
{
"name": "K3LKCKC0BM-MGCP",
"attribs": {
"densityPerDieGb": 16,
"diesPerPackage": 4,
"bitWidthPerChannel": 16,
"ranksPerChannel": 2,
"speedMbps": 6400
}
}
]
}
4 changes: 4 additions & 0 deletions spd/lp5/set-0/parts_spd_manifest.generated.txt
Expand Up @@ -7,3 +7,7 @@ H9JCNNNCP3MLYR-N6E,spd-2.hex
K3LKBKB0BM-MGCP,spd-3.hex
H9JCNNNBK3MLYR-N6E,spd-1.hex
MT62F2G32D8DR-031 WT:B,spd-4.hex
K3LKLKL0EM-MGCN,spd-5.hex
H58G56AK6BX069,spd-3.hex
MT62F1G32D4DS-031 WT:B,spd-2.hex
K3LKCKC0BM-MGCP,spd-6.hex