44 changes: 44 additions & 0 deletions Documentation/mainboard/lenovo/r60.md
@@ -0,0 +1,44 @@
# Lenovo Thinkpad R60

Untested on boards with external Radeon graphics adapter. If you have such
board, proceed at your own risk and document if it does work.

## Flashing instructions

### External flashing

The flash IC is located at the bottom center of the mainboard. Access to
the flash chip is blocked by the magnesium frame, so you need to disassemble
the entire laptop and remove the mainboard. The flash chip is referenced as U49 in
the schematics and in the boardview.

![](r60_chip.jpg)

To disassemble the laptop, follow the [Hardware Maintenance Manual](https://thinkpads.com/support/hmm/hmm_pdf/42x3749_02.pdf).

### Internal flashing on Vendor BIOS

This [method](https://gist.github.com/ArthurHeymans/c5ef494ada01af372735f237f6c6adbe) describes a way to install coreboot with vendor firmware still
installed on the Lenovo Thinkpad X60. It is reported to also work in Thinkpad
R60, with the only difference being the board target you build coreboot for.

### Flashing on coreboot

Default configuration of coreboot doesn't feature any flash restrictions
like the vendor firmware, therefore flashrom is able to flash any rom without problems.

## Things tested and working in Linux 5.3:

- Intel WiFi card
- Suspend and resume
- Native graphics initialization. Both legacy VGA and linear framebuffer work
- GRUB2 2.04 and SeaBIOS 1.12.1 payloads
- Reflashing with flashrom (use flashrom-git as of 17.09.2019)
- 2G+1G memory configuration working
- 2504 dock USB ports if not hotplugged

## Things tested and not working:

- 2504 dock hotplugging
- Black bar at the left side of the screen. Doesn't appear in Linux. See picture at top
- Sometimes it takes several second to run coreboot. Just wait for it
Binary file added Documentation/mainboard/lenovo/r60_chip.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions Documentation/mainboard/lenovo/t410.md
@@ -0,0 +1,44 @@
# Lenovo T410

## Known issues
* Dock has wrong ACPI ID (causes "AC adapter state cannot be read" in Linux)
* TPM not working with VBOOT and C_ENV bootblock (works without C_ENV BB)

## Flashing instructions
```eval_rst
+---------------------+--------------------------------+
| Type | Value |
+=====================+================================+
| Socketed flash | no |
+---------------------+--------------------------------+
| Size | 8 MiB |
+---------------------+--------------------------------+
| In circuit flashing | Only in S3/WoL |
+---------------------+--------------------------------+
| Package | SOIC-8 |
+---------------------+--------------------------------+
| Write protection | No |
+---------------------+--------------------------------+
| Dual BIOS feature | No |
+---------------------+--------------------------------+
| Internal flashing | Yes |
+---------------------+--------------------------------+
```

The flash IC is located at the bottom center of the mainboard. Sadly,
access to the IC is blocked by the magnesum frame, so you need to disassemble
the entire laptop and remove the mainboard.

Below is a picture of IC on the mainboard, with the pinouts labeled.

![t410_chip_location](t410_chip_location.jpg)

The chip will either be a Macronix MX25L6405D or a Winbond W25Q64CVSIG.
Do not rely on dots painted in the corner of the chip (such as the blue dot
pictured) to orient the pins!

[Flashing tutorial](../../flash_tutorial/no_ext_power.md)

Steps to access the flash IC are described here [T4xx series].

[T4xx series]: t4xx_series.md
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions Documentation/mainboard/lenovo/t440p.md
@@ -0,0 +1,66 @@
# Lenovo ThinkPad T440p

This page describes how to run coreboot on [Lenovo ThinkPad T440p].

## Required proprietary blobs

Please see [mrc.bin](../../northbridge/intel/haswell/mrc.bin).

## Flashing instructions

T440p has two flash chips, an 8MB W25Q64FV and a 4MB W25Q32FV. To flash
coreboot, you just need to remove the big door according to the T440
[Hardware Maintenance Manual] and flash the 4MB chip.

![T440p flash chip](t440p_flash_chip.jpg)

To access the 8MB chip, you need to remove the base cover.

![T440p 8MB flash chip](t440p_all_flash_chips.jpg)

The flash layout of the OEM firmware is as follows:

00000000:00000fff fd
00001000:00002fff gbe
00003000:004fffff me
00500000:00bfffff bios

After flashing coreboot, you may need to re-plug the AC adapter to make
the laptop able to power on.

## Known Issues

- No audio output when using a headphone
- The touchpad is misconfigured, the 3 keys on top are all identified
as left button
- 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

## Untested

- the dGPU model

## Working

- boot Arch Linux with Linux 4.19.77 from SeaBIOS payload
- integrated graphics init with libgfxinit
- EHCI debug: the port is the non-charging USB2 port on the right
- video output: internal (eDP), miniDP, dock DP, dock HDMI
- ACPI support
- keyboard and trackpoint
- SATA
- M.2 SATA SSD
- USB
- Ethernet
- WLAN
- WWAN
- bluetooth
- virtualization: VT-x and VT-d
- dock
- CMOS options: wlan, trackpoint, fn_ctrl_swap
- internal flashing when IFD is unlocked
- using `me_cleaner`

[Lenovo ThinkPad T440p]: https://pcsupport.lenovo.com/us/zh/products/laptops-and-netbooks/thinkpad-t-series-laptops/thinkpad-t440p
[Hardware Maintenance Manual]: https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles_pdf/t440p_hmm_en_sp40a25467_04.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions Documentation/mainboard/lenovo/x301.md
@@ -0,0 +1,44 @@
# Lenovo X301

## Disassembly Instructions

You must remove the following parts to access the SPI flash:

![X301 with WSON8 chip replaced with SOIC8 chip](x301_kb_removed.jpg)

* Battery pack
* Keyboard

Its [Hardware Maintenance Manual](https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles_pdf/43y9441.pdf) can be used as a guidance of disassembly.

The WSON-8 flash chip (surrounded with red circle in the photo above,
already replaced with a SOIC-8 one) sits under a piece of insulating
tape. If solders between the chip and soldering pads fortunately
overflows beside the chip as tiny tin balls attached to soldering pads,
it will be possible to use a pomona 5250 clip to hold the chip, with
its metal tips just attached to tin balls, thus connecting the chip to
the programmer. Otherwise, it may be recommended to replace it with a
SOIC-8 one (you might need to add the chip to the IFD VSCC list), as
what is done in the photo.

The vendor IFD VSCC list contains:
-MACRONIX_MX25L6405 (0xc2, 0x2017)
-WINBOND_NEX_W25X64 (0xef, 0x3017)
-ATMEL_AT25DF641 (0x1f, 0x4800)

```eval_rst
:doc:`../../flash_tutorial/ext_power`
```
Tested:
- CPU Core 2 Duo U9400
- Slotted DIMM 4GiB*2 from samsung
- Camera
- pci-e slots
- sata and usb2
- libgfxinit-based graphic init
- NVRAM options for North and South bridges
- Sound
- Thinkpad EC
- S3
- Linux 4.19.67-2 within Debian GNU/Linux stable, loaded from
Linux payload (Heads) and Seabios.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions Documentation/mainboard/portwell/pq7-m107.md
Expand Up @@ -4,9 +4,10 @@ This page describes how to run coreboot on the [Portwell PQ7-M107].

PQ7-M107 are assembled with different onboard memory modules:
Rev 1.0 Onboard Samsung K4B8G1646D-MYKO memory
Rev 1.1 and 1.2 Onboard Micron MT41K512M16HA-125A memory
Rev 1.1 and 1.2 Onboard Micron MT41K512M16HA-125A memory
Rev 1.3 Onboard Kingston B5116ECMDXGGB memory

Use 'make menuconfig' to configure `onboard memory manufacture` in Mainboard
Use 'make menuconfig' to configure `onboard memory manufacturer` in Mainboard
menu.

## Required blobs
Expand Down Expand Up @@ -53,7 +54,7 @@ serial/video/pcie ports might be available.
- eMMC
- SATA
- serial port
- SMbus
- SMBus
- HDA (codec on carrier)
- initialization with FSP MR2
- SeaBIOS payload (version rel-1.11.0-44-g7961917)
Expand Down
2 changes: 1 addition & 1 deletion Documentation/mainboard/supermicro/x10slm-f.md
Expand Up @@ -168,7 +168,7 @@ Please also see :doc:`../../northbridge/intel/haswell/known-issues`.
- VGA graphics
- disabling VGA graphics using the jumper
- hiding the AST2400 using the CMOS setting
- super I/O hardware monitor (see [Known issues](#known-issues))
- Super I/O hardware monitor (see [Known issues](#known-issues))
- initialisation with Haswell MRC version 1.6.1 build 2
- flashrom under coreboot
- Wake-on-LAN
Expand Down
Expand Up @@ -7,6 +7,7 @@ Controller etc.
## Supported boards

- [X11SSH-TF](x11ssh-tf/x11ssh-tf.md)
- [X11SSM-F](x11ssm-f/x11ssm-f.md)

## Required proprietary blobs

Expand All @@ -29,8 +30,8 @@ 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.

- Intel SGX causes secondary APs to crash (disabled for now) when HT is enabled (Fix is WIP CB:35312)
- TianoCore doesn't work with Aspeed NGI, as it's text mode only (Fix is WIP CB:35726)
- MRC caching does not work with cold boot

## ToDo

Expand Down
@@ -0,0 +1,93 @@
# Supermicro X11SSM-F

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 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.

## 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].

## Tested and working

- GRUB2 payload with Debian testing and kernel 5.2
- ECC ram (Linux' ie31200 driver works)
- 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
- "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
+------------------+--------------------------------------------------+
| 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) |
| | 2x 3.0 x4 (in x8) |
+------------------+--------------------------------------------------+
| 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 |
| | 1x External BMC I2C Header (for IPMI card) |
| | 1x Chassis Intrusion Header |
+------------------+--------------------------------------------------+
```

## Extra links

- [Supermicro X11SSM-F]
- [Board manual]

[Supermicro X11SSM-F]: https://www.supermicro.com/en/products/motherboard/X11SSM-F
[Board manual]: https://www.supermicro.com/manuals/motherboard/C236/MNL-1785.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
[MX25L12873F]: https://media.digikey.com/pdf/Data%20Sheets/Macronix/MX25L12873F.pdf
25 changes: 25 additions & 0 deletions Documentation/releases/coreboot-4.11-relnotes.md
Expand Up @@ -11,7 +11,32 @@ notes.
* The chip and board additions and removals will be updated right
before the release, so those do not need to be added.

Clean Up
--------
Because there was only a single developer board (AMD Torpedo)
using AGESA family 12h, and because there were multiple,
unique Coverity issues with it, the associated vendorcode will
be removed shortly after this release.

Significant changes
-------------------

### Add significant changes here

### `__PRE_RAM__` is deprecated

Preprocessor use of `defined(__PRE_RAM_)` have been mostly replaced with
`if (ENV_ROMSTAGE_OR_BEFORE)` or the inverse `if (ENV_RAMSTAGE)`.

The remaining cases and `-D__PRE_RAM__` are to be removed soon after release.

### `CAR_GLOBAL` is removed where possible

For all platform code with `NO_CAR_GLOBAL_MIGRATION=y`, any `CAR_GLOBAL`
attributes have been removed. Remaining cases from common code are to be
removed soon after release.

### `TSEG` and `cbmem_top()` mapping

Significant refactoring has bee done to achieve some consistency across platforms
and to reduce code duplication.
68 changes: 68 additions & 0 deletions Documentation/soc/amd/amdblobs_license.md
@@ -0,0 +1,68 @@
# License Agreement for amd_blobs Repository

## Abstract

AMD has generated a simpler and more flexible license agreement for using
proprietary precompiled binary images. The new agreement is intended to cover
all blobs in the directory structure below where the license resides and
eliminates any unique agreements previously provided for individual products.

A [3rdparty/amd_blobs](https://review.coreboot.org/admin/repos/amd_blobs) repo
now exists for distributing new blobs to coreboot developers and consumers.
Images for older products will be moved to amd_blobs as time permits.

By cloning the amd_blobs repo, you will be agreeing to the license agreement
contained there.

## Text of License Agreement

The language of the agreement is duplicated below for your reference. The
official license agreement may be found inside the Git repository.

> Copyright (c) 2019 ADVANCED MICRO DEVICES, INC.
>
> READ CAREFULLY: DO NOT DOWNLOAD, COPY OR USE THE ASSOCIATED AMD SOFTWARE
> ("LICENSED SOFTWARE") UNTIL YOU HAVE CAREFULLY READ THE FOLLOWING. BY USING
> THE LICENSED SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE FOLLOWING TERMS:
>
> Redistribution and use in binary form, without modification, is permitted
> subject to the following conditions:
>
> a. Reverse engineering, disassembly, or de-compilation of the Licensed
> Software is not permitted;
>
> b. All the content of this document, including the above copyright notice and
> below disclaimer, must be included in the documentation or other materials
> provided with any distribution, and you may not alter or remove any copyright,
> trademark or patent notice(s) in the Licensed Software; and,
>
> c. The name “AMD” or “Advanced Micro Devices” may not be used to promote
> products derived from the Licensed Software.
>
> Except for the limited license expressly granted above, you have no other
> rights in the Licensed Software, whether express, implied, arising by estoppel
> or otherwise. The Licensed Software including all Intellectual Property Rights
> therein is and remains the sole and exclusive property of AMD or its
> licensors, and You shall have no right, title or interest therein except as
> expressly set forth above.
>
> Disclaimer of Warranty. THE LICENSED SOFTWARE IS PROVIDED "AS IS" WITHOUT
> WARRANTY OF ANY KIND. AMD DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, OR
> STATUTORY, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-
> INFRINGEMENT, THAT THE LICENSED SOFTWARE WILL RUN UNINTERRUPTED OR ERROR-FREE
> OR WARRANTIES ARISING FROM CUSTOM OF TRADE OR COURSE OF USAGE. THE ENTIRE RISK
> ASSOCIATED WITH THE USE OF THE LICENSED SOFTWARE IS ASSUMED BY YOU INCLUDING,
> WITHOUT LIMITATION, PERFORMANCE AND INTEROPERABILITY ISSUES THAT MAY ADVERSELY
> AFFECT YOUR EXPERIENCE AND THE STABILITY OF YOUR COMPUTING SYSTEM; AND
> (C) OTHER EXPERIENCES RESULTING IN ADVERSE EFFECTS, INCLUDING, BUT NOT
> LIMITED, TO DATA CORRUPTION OR LOSS. AMD WILL NOT, UNDER ANY CIRCUMSTANCES BE
> LIABLE TO YOU FOR ANY PUNITIVE, DIRECT, INCIDENTAL, INDIRECT, SPECIAL OR
> CONSEQUENTIAL DAMAGES INCLUDING LOSS OF USE, PROFITS, OR DATA ARISING FROM USE
> OF THE LICENSED SOFTWARE EVEN IF AMD AND ITS LICENSORS HAVE BEEN ADVISED OF
> THE POSSIBILITY OF SUCH DAMAGES.
>
> The Licensed Software including all Intellectual Property Rights therein is
> and remains the sole and exclusive property of AMD or its licensors, and You
> shall have no right, title or interest therein except as expressly set forth
> above or as required by law.
3 changes: 3 additions & 0 deletions Documentation/soc/amd/index.md
Expand Up @@ -7,3 +7,6 @@ This section contains documentation about coreboot on specific AMD SOCs.
- [Family 15h](family15h.md)
- [Family 17h](family17h.md)

## amd_blobs Repository License

- [amd_blobs](amdblobs_license.md)
1 change: 1 addition & 0 deletions Documentation/soc/index.md
Expand Up @@ -7,3 +7,4 @@ This section contains documentation about coreboot on specific SOCs.
- [AMD](amd/index.md)
- [Cavium](cavium/index.md)
- [Intel](intel/index.md)
- [Qualcomm](qualcomm/index.md)
7 changes: 7 additions & 0 deletions Documentation/soc/intel/fsp/index.md
Expand Up @@ -21,6 +21,12 @@ those are fixed. If possible a workaround is described here as well.
* Workaround: Don't disable this PCI device
* Issue on public tracker: [Issue 13]

* FSP Notify(EnumInitPhaseAfterPciEnumeration) hangs if 00:02.03/00:02.03 are hidden
* Release MR2
* Seems to get stuck on some SKUs only if hidden after MemoryInit
* Workaround: Hide before MemoryInit
* Issue on public tracker: [Issue 35]

### KabylakeFsp
* MfgId and ModulePartNum in the DIMM_INFO struct are empty
* Release 3.7.1
Expand Down Expand Up @@ -59,4 +65,5 @@ those are fixed. If possible a workaround is described here as well.
[Issue 13]: https://github.com/IntelFsp/FSP/issues/13
[Issue 15]: https://github.com/IntelFsp/FSP/issues/15
[Issue 22]: https://github.com/IntelFsp/FSP/issues/22
[Issue 35]: https://github.com/IntelFsp/FSP/issues/35

7 changes: 7 additions & 0 deletions Documentation/soc/qualcomm/index.md
@@ -0,0 +1,7 @@
# Qualcomm SOC-specific documentation

This section contains documentation about coreboot on specific Qualcomm SOCs.

## Platforms

- [SC7180 series](sc7180/index.md)
19 changes: 19 additions & 0 deletions Documentation/soc/qualcomm/sc7180/index.md
@@ -0,0 +1,19 @@
# Qualcomm SC7180 documentation

## SOC code

The SOC folder contains functions for:
* MMU
* CLOCK
* GPIO
* QUPv3 FW (provides a bridge to serial interfaces)
* UART
* SPI-NOR
* AOP FW
* USB

## Notes about the hardware

The timer is used from the ARMv8 architecture specific code.


@@ -0,0 +1,268 @@
Rebuilding coreboot image generation
====================================

Current situation
-----------------
Chrome OS (CrOS) probably has the most complex image bundling process in the
coreboot ecosystem. To make CrOS features more accessible to the wider
coreboot community, we want to move these capabilities into upstream
coreboot’s build system.

Right now, the CrOS build system creates coreboot images, and various
instances of the payload (with different configuration options), plus some
more files (eg. EC firmware), then passes them to a CrOS-specific utility
(`bundle_firmware.py`) to build the final image from that.

`bundle_firmware` adds a flashmap (fmap) to the final image and creates
additional CBFS filesystems in fmap regions. It then extracts some files from
the original CBFS region (that was put in place carefully to later match to
the default fmap region) and copies some of them into the others, as well as
putting more data (eg. the bitmap data, keys) as raw data into other fmap
regions.

With the recent addition of more files to CBFS, both on the coreboot side
(dsdt, FSP, and so on) and with Chrome OS specifics (eg. more files describing
boot screens) we either need to expand the scope of bundle\_firmware or move
the capability to build complex images to upstream coreboot’s build system.
This document proposes to do the latter and outlines how this could be
achieved.

Problems with the current build system parts
--------------------------------------------
One common sentiment is that it should be possible to reuse some of the
existing mechanisms that are supposed to be supplanted by this.
The main concern during this design that precluded their use was that none of
them provides a comprehensive solution to building complex coreboot based
images:
* fmap.dts and fmd provide a flash layout, but no assignment of files of regions
* cbfs-files-y ends up as an internal make variable using
`weird|formatting|to|deal|with|make’s|limitations`
* make isn’t powerful enough to deal with ordering these entries in said
variable to guarantee success if there’s enough room for the files. While that
could be added, that becomes more make macro work indistinguishable from magic
that people fail to understand, break and with good reason complain about
to work around such issues, Chrome OS firmware uses a custom tool with even
more special cases to finally build the image it needs. If coreboot upstream
is to support vboot, it should also be powerful enough not to need magic tools
that only live within downstream projects.

Requirements
------------
A complete Chrome OS coreboot image consists of (depending on the device)
* platform specific data in raw fmap regions (eg IFD, ME firmware),
* the bootblock (coming from the bootblock),
* three copies of coreboot, consisting of the stages (verstage, romstage,
ramstage) plus data,
* depthcharge plus data (with each of the coreboot copies),
* EC firmware files (with each of the coreboot copies),
* signatures over several parts of the image and
* some final checksumming over parts of the image to satisfy boot ROM
tests on ARM

A complete upstream coreboot image (with fallback/normal switch configuration,
using a yet to be implemented switching scheme based on fmaps) consists of
* platform specific data in raw fmap regions (eg IFD, ME firmware),
* two copies of coreboot, consisting of
* the bootblock and
* the stages (romstage, ramstage) plus data,
* payload plus data (with each of the coreboot copies),

Since a single platform is potentially built with different payload
configurations (eg. modding a Chromebook to not use the verified Chrome OS
boot scheme), some concerns need to be kept separate:
* Platform requirements that have nothing to do with the payload or boot schemes
* IFD, ME, … need to copied to the right place
* boot ROM requirements such as checksums must be honored
* Payload/boot scheme requirements
* Having one to three regions with certain files copied into them

Proposal
--------
The proposal is based on manifest files that describe certain aspects of the
final image.
The number of manifest files may change over time, but this seems to be a
reasonable approach for now. As long as coreboot uses fmap and cbfs, there
should be few need to change the language, since composition is done through
files.

The final image is generated by a utility that is handed a number of manifests
and the size of the flash (derived from `CONFIG_ROM_SIZE`). These manifest files
deal with different concerns, with the following an example that should match
current use cases:

Chipset manifest
----------------
The chipset details if there are any non-coreboot regions, and assigns them
names, locations, sizes and file contents and prepares a region for what is
“platform visible” (eg. IFD’s BIOS region) that may be of flexible size
(depending on the flash chip’s size). For the purpose of this document, that
region is called “BIOS”.
It can also specify if there’s a post processing requirement on the final
image.

coreboot manifest
-----------------
coreboot provides lists of the files it generates for each category it’s
building (eg. bootblock, verstage, romstage, ramstage). They not only contain
the stages themselves, but also additional files (eg. dsdt belongs to ramstage
since that’s where it is used)

Boot method manifest
--------------------
The boot method manifest can subdivide the BIOS region, eg. using it directly
(for coreboot’s “simple” bootblock), splitting it in two (for coreboot’s
fallback/normal) or in many parts (for Chrome OS, which requires two CBFS
regions, one for GBB, several for VPD, …).
It also specifies which of the file lists specified earlier belong in which
region (eg. with verstage verifying romstage, verstage needs to be only in
Chrome OS’ RO region, while romstage belongs in RO and both RW regions).
It can also specify a post processing step that is executed before the
chipset’s.

Payload and additional manifests
--------------------------------
External components should also provide manifests to add files to categories.
This way the payload and other components (eg. EC firmware) can be developed
without needing to touch the central boot method manifest (that likely resides
in the coreboot tree, given that coreboot needs to deal with choosing fmap
regions already).

coreboot build system
---------------------
The coreboot build system will be split more distinctly in two phases: The
first is about building the files (with results like romstage.elf), while the
second phase covers the assembly of the final image.

By having a global picture of the final image’s requirements, we can also
avoid issues where files added earlier may prevent later additions that have
stricter constraints - without resorting to hacks like
https://chromium-review.googlesource.com/289491 that reorder the file addition
manually.

Example
-------
As an example, we’ll define an Intel-based board with a postprocessing tool
(something that doesn’t exist, but isn’t hard to imagine):

It specifies an IFD region, an ME, and the BIOS region. After the image is
built, the entire image needs to be processed (although the tool likely works
only on a small part of it)

It’s built in a Chrome OS-like configuration (simplified at places to avoid
distracting from the important parts), so it has three CBFS regions, and
several data regions for its own purpose (similar to GBB, FWID, VPD, …). After
the regions are filled, one data region must be post-processed to contain
signatures to enable verifying other regions.

```
Chipset manifest
================
# A region called IFD, starting at 0, ending at 4K
region IFD: 0 4K
# Add the specified file “raw” into the region.
# If the file is smaller than the region, put it at the bottom and fill up
# with 0xff
raw IFD: build/ifd.bin align=bottom empty=0xff
# Call the postprocessor on the data that ends up in IFD (in this example it
# might lock the IFD)
postprocess IFD: util/ifdprocess -l
# a region called ME, starting at 4K, ending at 2M
region ME: 4K 2M
raw ME: 3rdparty/blobs/soc/intel/xanadu/me.bin align=bottom empty=0x00
# a region called BIOS, starting at 2M, filling up the free space
# filling up fails (build error) if two regions are requested to fill up
# against each other
region BIOS: 2M *
# This would define a region that covers the last 4K of flash.
# The BIOS region specified above will end right before it instead of
# expanding to end of flash
# region AUX: -4K -0
# specify the tool that post-processes the entire image.
postprocess image: util/intelchksum/intelchksum.sh
coreboot manifest
=================
# declare that build/verstage.elf belongs into the group ‘verstage’
# these groups are later referred to by the “cbfs” command.
group verstage: build/verstage.elf stage xip name=fallback/verstage
group romstage: build/romstage.elf stage xip name=fallback/romstage
group ramstage: build/ramstage.elf stage name=fallback/ramstage
compression=lzma
group ramstage: build/dsdt.aml compression=lzma
boot method manifest
====================
# Define RO as region inside BIOS, covering the upper half of the image.
# It’s a build error if the result crosses outside BIOS.
# math expressions are wrapped with ( ),
# and mentions of regions therein always refer to their size
subregion BIOS RO: ( image / 2 ) -0
# Define RW to cover the rest of BIOS.
# The order of RW and RO doesn’t matter except to keep comments clearer.
# Dynamic items like RW (“*”) will be sized to fill unused space after
# everything else is placed.
subregion BIOS RW: 0 *
# It may be necessary to separate the RO/RW definition into another manifest
# file
# that defines the RO configuration of the flash
# Some more subregions, with dynamically calculated sizes
subregion RW RW_A: 0 ( RW / 2 )
subregion RW RW_B: * -0
subregion RW_A FW_MAIN_A: RW_A * -0
subregion RW_A VBLOCK_A: 0 64K
# foo +bar specifies start + size, not (start, end)
# also, start is given as “the end of VBLOCK_A”
# (while using a region in the “end” field means “start of region”)
subregion RW_A FWID_A: VBLOCK_A +64
# To make the example not too verbose, RO only has the CBFS region
subregion RO BOOTSTUB: 0 *
# Postprocess the data that ends up in VBLOCK_A,
# passing the listed regions as additional arguments.
# Circular dependencies are build errors.
postprocess VBLOCK_A(FW_MAIN_A): signtool
# binding files to regions indirectly through groups
cbfs BOOTSTUB: verstage, romstage, ramstage, payload
cbfs FW_MAIN_A: romstage, ramstage, payload
# defining defaults: unless overridden, in all regions that use CBFS (“*”),
# we want all files to come with SHA256 hashes.
# Wildcard defaults have lower priority than specific defaults.
# Other conflicts lead to a build error.
cbfsdefaults *: hash=sha3
payload manifest
================
group payload: payload.elf payload
group payload: bootscreen.jpg name=splashscreen.jpg type=splashscreen
EC firmware manifest
====================
# overrides the cbfsdefault above
group payload: ecrw.bin name=ecrw hash=sha256
group payload: pdrw.bin name=pdrw hash=sha256
```

manifest parsing
----------------
The exact BNF is work in progress.

Some parser rules are
* one line per statement
* '#' introduces a command until the end of line

Some processing rules
* When there’s a conflict (eg. two statements on what to do to a region,
overlap, anything that can’t be determined), that is a build error.
* the order of statements doesn’t matter, enabling simple addition of more
manifests where the need arises.

4 changes: 4 additions & 0 deletions Documentation/technotes/index.md
@@ -0,0 +1,4 @@
# Technotes

* [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)
8 changes: 8 additions & 0 deletions Documentation/util.md
@@ -1,4 +1,7 @@
# Utilities

## List of utils

_Scripts and programs found in the `./util` directory_
* __abuild__ - coreboot autobuild script builds coreboot images for all
available targets. `bash`
Expand Down Expand Up @@ -131,3 +134,8 @@ CPUs. `C`
* __x86__ - Generates 32-bit PAE page tables based on a CSV input file.
`Go`
* __xcompile__ - Cross compile setup `Bash`


## In depth documentation

* [ifdtool](ifdtool/index.md)
208 changes: 208 additions & 0 deletions LICENSES/Apache-2.0.txt
@@ -0,0 +1,208 @@
Apache License

Version 2.0, January 2004

http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
AND DISTRIBUTION

1. Definitions.



"License" shall mean the terms and conditions for use, reproduction, and distribution
as defined by Sections 1 through 9 of this document.



"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.



"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct
or indirect, to cause the direction or management of such entity, whether
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
of the outstanding shares, or (iii) beneficial ownership of such entity.



"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
granted by this License.



"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.



"Object" form shall mean any form resulting from mechanical transformation
or translation of a Source form, including but not limited to compiled object
code, generated documentation, and conversions to other media types.



"Work" shall mean the work of authorship, whether in Source or Object form,
made available under the License, as indicated by a copyright notice that
is included in or attached to the work (an example is provided in the Appendix
below).



"Derivative Works" shall mean any work, whether in Source or Object form,
that is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative
Works shall not include works that remain separable from, or merely link (or
bind by name) to the interfaces of, the Work and Derivative Works thereof.



"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative
Works thereof, that is intentionally submitted to Licensor for inclusion in
the Work by the copyright owner or by an individual or Legal Entity authorized
to submit on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication
sent to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor
for the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."



"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently incorporated
within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of this
License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
Derivative Works of, publicly display, publicly perform, sublicense, and distribute
the Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of this License,
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
no-charge, royalty-free, irrevocable (except as stated in this section) patent
license to make, have made, use, offer to sell, sell, import, and otherwise
transfer the Work, where such license applies only to those patent claims
licensable by such Contributor that are necessarily infringed by their Contribution(s)
alone or by combination of their Contribution(s) with the Work to which such
Contribution(s) was submitted. If You institute patent litigation against
any entity (including a cross-claim or counterclaim in a lawsuit) alleging
that the Work or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses granted to You
under this License for that Work shall terminate as of the date such litigation
is filed.

4. Redistribution. You may reproduce and distribute copies of the Work or
Derivative Works thereof in any medium, with or without modifications, and
in Source or Object form, provided that You meet the following conditions:

(a) You must give any other recipients of the Work or Derivative Works a copy
of this License; and

(b) You must cause any modified files to carry prominent notices stating that
You changed the files; and

(c) You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source
form of the Work, excluding those notices that do not pertain to any part
of the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its distribution,
then any Derivative Works that You distribute must include a readable copy
of the attribution notices contained within such NOTICE file, excluding those
notices that do not pertain to any part of the Derivative Works, in at least
one of the following places: within a NOTICE text file distributed as part
of the Derivative Works; within the Source form or documentation, if provided
along with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works
that You distribute, alongside or as an addendum to the NOTICE text from the
Work, provided that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction,
or distribution of Your modifications, or for any such Derivative Works as
a whole, provided Your use, reproduction, and distribution of the Work otherwise
complies with the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise, any
Contribution intentionally submitted for inclusion in the Work by You to the
Licensor shall be under the terms and conditions of this License, without
any additional terms or conditions. Notwithstanding the above, nothing herein
shall supersede or modify the terms of any separate license agreement you
may have executed with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade names,
trademarks, service marks, or product names of the Licensor, except as required
for reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or agreed to
in writing, Licensor provides the Work (and each Contributor provides its
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied, including, without limitation, any warranties
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness
of using or redistributing the Work and assume any risks associated with Your
exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory, whether
in tort (including negligence), contract, or otherwise, unless required by
applicable law (such as deliberate and grossly negligent acts) or agreed to
in writing, shall any Contributor be liable to You for damages, including
any direct, indirect, special, incidental, or consequential damages of any
character arising as a result of this License or out of the use or inability
to use the Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all other commercial
damages or losses), even if such Contributor has been advised of the possibility
of such damages.

9. Accepting Warranty or Additional Liability. While redistributing the Work
or Derivative Works thereof, You may choose to offer, and charge a fee for,
acceptance of support, warranty, indemnity, or other liability obligations
and/or rights consistent with this License. However, in accepting such obligations,
You may act only on Your own behalf and on Your sole responsibility, not on
behalf of any other Contributor, and only if You agree to indemnify, defend,
and hold each Contributor harmless for any liability incurred by, or claims
asserted against, such Contributor by reason of your accepting any such warranty
or additional liability. END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own identifying
information. (Don't include the brackets!) The text should be enclosed in
the appropriate comment syntax for the file format. We also recommend that
a file or class name and description of purpose be included on the same "printed
page" as the copyright notice for easier identification within third-party
archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.
26 changes: 26 additions & 0 deletions LICENSES/BSD-3-Clause.txt
@@ -0,0 +1,26 @@
Copyright (c) <year> <owner>. All rights reserved.

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. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
324 changes: 324 additions & 0 deletions LICENSES/CC-BY-4.0.txt

Large diffs are not rendered by default.

343 changes: 343 additions & 0 deletions LICENSES/CC-BY-SA-3.0.txt

Large diffs are not rendered by default.

319 changes: 319 additions & 0 deletions LICENSES/GPL-2.0-only.txt

Large diffs are not rendered by default.

319 changes: 319 additions & 0 deletions LICENSES/GPL-2.0-or-later.txt

Large diffs are not rendered by default.

625 changes: 625 additions & 0 deletions LICENSES/GPL-3.0-only.txt

Large diffs are not rendered by default.

625 changes: 625 additions & 0 deletions LICENSES/GPL-3.0-or-later.txt

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions LICENSES/ISC.txt
@@ -0,0 +1,14 @@
ISC License Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")

Copyright (c) 1995-2003 by Internet Software Consortium

Permission to use, copy, modify, and /or distribute this software for any
purpose with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 changes: 19 additions & 0 deletions LICENSES/MIT.txt
@@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 24 additions & 0 deletions LICENSES/X11.txt
@@ -0,0 +1,24 @@
X11 License Copyright (C) 1996 X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

X Window System is a trademark of X Consortium, Inc.
5 changes: 5 additions & 0 deletions MAINTAINERS
Expand Up @@ -391,6 +391,11 @@ M: Tristan Corrick <tristan@corrick.kiwi>
S: Maintained
F: src/mainboard/supermicro/x10slm-f/

SUPERMICRO X11-LGA1151-SERIES
M: Michael Niewöhner <foss@mniewoehner.de>
S: Maintained
F: src/mainboard/supermicro/x11-lga1151-series

FACEBOOK FBG1701 MAINBOARD
M: Frans Hendriks <fhendriks@eltan.com>
M: Wim Vervoorn <wvervoorn@eltan.com>
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Expand Up @@ -144,12 +144,11 @@ endif
\mv -f $@.tmp $@ 2> /dev/null
rm -f $@.tmp

-include $(TOPLEVEL)/site-local/Makefile.inc

ifeq ($(NOCOMPILE),1)
include $(TOPLEVEL)/Makefile.inc
include $(TOPLEVEL)/payloads/Makefile.inc
include $(TOPLEVEL)/util/testing/Makefile.inc
-include $(TOPLEVEL)/site-local/Makefile.inc
real-all:
@echo "Error: Expected config file ($(DOTCONFIG)) not present." >&2
@echo "Please specify a config file or run 'make menuconfig' to" >&2
Expand Down Expand Up @@ -195,7 +194,7 @@ $(KCONFIG_AUTOHEADER): $(KCONFIG_CONFIG) $(objutil)/kconfig/conf
$(KCONFIG_AUTOCONFIG): $(KCONFIG_AUTOHEADER)
true

$(KCONFIG_AUTOADS): $(KCONFIG_AUTOCONFIG) $(objutil)/kconfig/toada
$(KCONFIG_AUTOADS): $(KCONFIG_CONFIG) $(KCONFIG_AUTOHEADER) $(objutil)/kconfig/toada
$(objutil)/kconfig/toada CB.Config <$< >$@

$(obj)/%/$(notdir $(KCONFIG_AUTOADS)): $(KCONFIG_AUTOADS)
Expand Down Expand Up @@ -253,13 +252,13 @@ includemakefiles= \
$(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
$(eval -include $(1)) \
$(foreach class,$(classes-y), $(call add-class,$(class))) \
$(foreach special,$(special-classes), \
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
$(foreach class,$(classes), \
$(eval $(class)-srcs+= \
$$(subst $(absobj)/,$(obj)/, \
$$(subst $(top)/,, \
$$(abspath $$(subst $(dir $(1))/,/,$$(addprefix $(dir $(1)),$$($(class)-y)))))))) \
$(foreach special,$(special-classes), \
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
$(eval subdirs+=$$(subst $(CURDIR)/,,$$(wildcard $$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y))))))

# For each path in $(subdirs) call includemakefiles
Expand Down
31 changes: 26 additions & 5 deletions Makefile.inc
Expand Up @@ -93,7 +93,7 @@ subdirs-y += $(wildcard src/soc/*/*) $(wildcard src/northbridge/*/*)
subdirs-y += src/superio
subdirs-y += $(wildcard src/drivers/*) $(wildcard src/drivers/*/*)
subdirs-y += src/cpu src/vendorcode
subdirs-y += util/cbfstool util/sconfig util/nvramtool
subdirs-y += util/cbfstool util/sconfig util/nvramtool util/pgtblgen
subdirs-y += util/futility util/marvell util/bincfg
subdirs-y += $(wildcard src/arch/*)
subdirs-y += src/mainboard/$(MAINBOARDDIR)
Expand All @@ -107,6 +107,10 @@ subdirs-y += util/checklist util/testing
# Add source classes and their build options
classes-y := ramstage romstage bootblock decompressor postcar smm smmstub cpu_microcode verstage

# Add a special 'all' class to add sources to all stages
$(call add-special-class,all)
all-handler = $(foreach class,bootblock verstage romstage postcar ramstage,$(eval $(class)-y += $(2)))

# Add dynamic classes for rmodules
$(foreach supported_arch,$(ARCH_SUPPORTED), \
$(eval $(call define_class,rmodules_$(supported_arch),$(supported_arch))))
Expand Down Expand Up @@ -193,15 +197,16 @@ ifneq ($(UPDATED_SUBMODULES),1)
# try to fetch non-optional submodules if the source is under git
forgetthis:=$(if $(GIT),$(shell git submodule update --init))
ifeq ($(CONFIG_USE_BLOBS),y)
# this is necessary because 3rdparty/{blobs,intel-microcode} is update=none, and so is ignored
# unless explicitly requested and enabled through --checkout
# These items are necessary because each has update=none in .gitmodules. They are ignored
# until expressly requested and enabled with --checkout
forgetthis:=$(if $(GIT),$(shell git submodule update --init --checkout 3rdparty/blobs))
forgetthis:=$(if $(GIT),$(shell git submodule update --init --checkout 3rdparty/intel-microcode))
ifeq ($(CONFIG_PLATFORM_USES_FSP1_0)$(CONFIG_PLATFORM_USES_FSP1_1)$(CONFIG_PLATFORM_USES_FSP2_0),y)
# this is necessary because 3rdparty/fsp is update=none, and so is ignored
# unless explicitly requested and enabled through --checkout
forgetthis:=$(if $(GIT),$(shell git submodule update --init --checkout 3rdparty/fsp))
endif
ifeq ($(CONFIG_USE_AMD_BLOBS),y)
forgetthis:=$(if $(GIT),$(shell git submodule update --init --checkout 3rdparty/amd_blobs))
endif
endif
UPDATED_SUBMODULES:=1
COREBOOT_EXPORTS += UPDATED_SUBMODULES
Expand Down Expand Up @@ -678,6 +683,18 @@ find-class = $(if $(filter $(1),$(basename $(1))),$(if $(CC_$(1)), $(1), $(call
# the linker marked it NOBITS automatically because there are only zeroes in it.
preserve-bss-flags := --set-section-flags .bss=load,alloc,data --set-section-flags .data=load,alloc,data

# For Intel TXT files in the CBFS needs to be marked as 'Initial Boot Block'.
# As CBFS attributes aren't cheap, only mark them if TXT is enabled.
ifeq ($(CONFIG_INTEL_TXT),y)

TXTIBB := --ibb

else

TXTIBB :=

endif

ifeq ($(CONFIG_COMPRESS_BOOTBLOCK),y)

$(objcbfs)/bootblock.lz4: $(objcbfs)/bootblock.elf $(objutil)/cbfstool/cbfs-compression-tool
Expand Down Expand Up @@ -1031,6 +1048,7 @@ ifeq ($(CONFIG_ARCH_X86),y)
-f $(objcbfs)/bootblock.bin \
-n bootblock \
-t bootblock \
$(TXTIBB) \
-b -$(call file-size,$(objcbfs)/bootblock.bin) $(cbfs-autogen-attributes) \
$(TS_OPTIONS)
else # ifeq ($(CONFIG_ARCH_X86),y)
Expand Down Expand Up @@ -1172,6 +1190,9 @@ endif # CONFIG_NO_FIXED_XIP_ROM_SIZE

endif # CONFIG_NO_XIP_EARLY_STAGES
endif # CONFIG_ARCH_ROMSTAGE_X86_32 / CONFIG_ARCH_ROMSTAGE_X86_64
ifeq ($(CONFIG_VBOOT_STARTS_IN_ROMSTAGE),y)
$(CONFIG_CBFS_PREFIX)/romstage-options += $(TXTIBB)
endif

cbfs-files-$(CONFIG_HAVE_RAMSTAGE) += $(CONFIG_CBFS_PREFIX)/ramstage
$(CONFIG_CBFS_PREFIX)/ramstage-file := $(RAMSTAGE)
Expand Down
1 change: 0 additions & 1 deletion configs/config.emulation_qemu_x86_i440fx_debug
Expand Up @@ -4,7 +4,6 @@ CONFIG_FATAL_ASSERTS=y
CONFIG_DEBUG_CBFS=y
CONFIG_DEBUG_PIRQ=y
CONFIG_DEBUG_MALLOC=y
CONFIG_DEBUG_ACPI=y
CONFIG_TRACE=y
CONFIG_DEBUG_BOOT_STATE=y
CONFIG_DEBUG_ADA_CODE=y
Expand Up @@ -8,6 +8,7 @@ CONFIG_DEBUG_RAM_SETUP=y
CONFIG_DEBUG_SMBUS=y
CONFIG_DEBUG_SMI=y
CONFIG_DEBUG_MALLOC=y
CONFIG_DEBUG_ACPI=y
CONFIG_DEBUG_BOOT_STATE=y
CONFIG_DEBUG_ADA_CODE=y
CONFIG_H8_FN_KEY_AS_VBOOT_RECOVERY_SW=y
CONFIG_VBOOT=y
Expand Up @@ -7,7 +7,6 @@ CONFIG_DEBUG_CBFS=y
CONFIG_DEBUG_SMBUS=y
CONFIG_DEBUG_SMI=y
CONFIG_DEBUG_MALLOC=y
CONFIG_DEBUG_ACPI=y
CONFIG_DEBUG_SPI_FLASH=y
CONFIG_DEBUG_BOOT_STATE=y
CONFIG_DEBUG_ADA_CODE=y
2 changes: 1 addition & 1 deletion configs/config.pcengines_apu1
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.10.0.2"
CONFIG_LOCALVERSION="v4.10.0.3"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_NO_GFX_INIT=y
Expand Down
2 changes: 1 addition & 1 deletion configs/config.pcengines_apu2
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.10.0.2"
CONFIG_LOCALVERSION="v4.10.0.3"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_BOARD_PCENGINES_APU2=y
Expand Down
2 changes: 1 addition & 1 deletion configs/config.pcengines_apu2_vboot
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.10.0.2"
CONFIG_LOCALVERSION="v4.10.0.3"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_VBOOT=y
Expand Down
2 changes: 1 addition & 1 deletion configs/config.pcengines_apu3
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.10.0.2"
CONFIG_LOCALVERSION="v4.10.0.3"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_BOARD_PCENGINES_APU3=y
Expand Down
2 changes: 1 addition & 1 deletion configs/config.pcengines_apu4
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.10.0.2"
CONFIG_LOCALVERSION="v4.10.0.3"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_BOARD_PCENGINES_APU4=y
Expand Down
2 changes: 1 addition & 1 deletion configs/config.pcengines_apu5
@@ -1,4 +1,4 @@
CONFIG_LOCALVERSION="v4.10.0.2"
CONFIG_LOCALVERSION="v4.10.0.3"
CONFIG_VENDOR_PCENGINES=y
CONFIG_PAYLOAD_CONFIGFILE="$(top)/src/mainboard/$(MAINBOARDDIR)/seabios_config"
CONFIG_BOARD_PCENGINES_APU5=y
Expand Down
18 changes: 9 additions & 9 deletions payloads/external/GRUB2/Makefile
@@ -1,4 +1,4 @@
TAG-$(CONFIG_GRUB2_MASTER)=
TAG-$(CONFIG_GRUB2_MASTER)=origin/HEAD
TAG-$(CONFIG_GRUB2_REVISION)=$(CONFIG_GRUB2_REVISION_ID)
TAG-$(CONFIG_GRUB2_STABLE)=grub-2.04
NAME-$(CONFIG_GRUB2_MASTER)=HEAD
Expand All @@ -15,14 +15,14 @@ all: grub2

checkout:
echo " GIT GRUB2 $(NAME-y)"
test -d grub2 || \
git clone $(project_git_repo) $(project_dir)
cd grub2 && \
git checkout master && \
git pull; \
test -n "$(TAG-y)" && \
git branch -f $(NAME-y) $(TAG-y) && \
git checkout $(NAME-y) || true
test -d $(project_dir) || git clone $(project_git_repo) $(project_dir)
git -C $(project_dir) fetch
ifeq ("$(shell git -C $(project_dir) status --ignored=no --untracked-files=no --porcelain)",)
git -C $(project_dir) checkout -f $(TAG-y)
else
echo "WARNING: index/tree not clean, skipping update / force checkout."
echo " Checkout manually with `git -C $(project_dir) checkout -f`."
endif

grub2/build/config.h: $(CONFIG_DEP) | checkout
echo " CONFIG GRUB2 $(NAME-y)"
Expand Down
4 changes: 2 additions & 2 deletions payloads/libpayload/Makefile
Expand Up @@ -221,12 +221,12 @@ includemakefiles= \
$(foreach class,classes subdirs $(classes) $(special-classes), $(eval $(class)-y:=)) \
$(eval -include $(1)) \
$(foreach class,$(classes-y), $(call add-class,$(class))) \
$(foreach special,$(special-classes), \
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
$(foreach class,$(classes), \
$(eval $(class)-srcs+= \
$$(subst $(top)/,, \
$$(abspath $$(addprefix $(dir $(1)),$$($(class)-y)))))) \
$(foreach special,$(special-classes), \
$(foreach item,$($(special)-y), $(call $(special)-handler,$(dir $(1)),$(item)))) \
$(eval subdirs+=$$(subst $(CURDIR)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))

# For each path in $(subdirs) call includemakefiles
Expand Down
1 change: 1 addition & 0 deletions payloads/libpayload/include/cbfs_core.h
Expand Up @@ -144,6 +144,7 @@ struct cbfs_file {
#define CBFS_FILE_ATTR_TAG_UNUSED2 0xffffffff
#define CBFS_FILE_ATTR_TAG_COMPRESSION 0x42435a4c
#define CBFS_FILE_ATTR_TAG_HASH 0x68736148
#define CBFS_FILE_ATTR_TAG_IBB 0x32494242 /* Initial BootBlock */

/* The common fields of extended cbfs file attributes.
Attributes are expected to start with tag/len, then append their
Expand Down
58 changes: 37 additions & 21 deletions src/Kconfig
Expand Up @@ -37,9 +37,26 @@ config CONFIGURABLE_CBFS_PREFIX
help
Select this to prompt to use to configure the prefix for cbfs files.

choice
prompt "CBFS prefix to use"
depends on CONFIGURABLE_CBFS_PREFIX
default CBFS_PREFIX_FALLBACK

config CBFS_PREFIX_FALLBACK
bool "fallback"

config CBFS_PREFIX_NORMAL
bool "normal"

config CBFS_PREFIX_DIY
bool "Define your own cbfs prefix"

endchoice

config CBFS_PREFIX
string "CBFS prefix to use" if CONFIGURABLE_CBFS_PREFIX
default "fallback"
string "CBFS prefix to use" if CBFS_PREFIX_DIY
default "fallback" if !CONFIGURABLE_CBFS_PREFIX || CBFS_PREFIX_FALLBACK
default "normal" if CBFS_PREFIX_NORMAL
help
Select the prefix to all files put into the image. It's "fallback"
by default, "normal" is a common alternative.
Expand Down Expand Up @@ -218,6 +235,20 @@ config USE_BLOBS
might be required for some chipsets or boards.
This flag ensures that a "Free" option remains available for users.

config USE_AMD_BLOBS
bool "Allow AMD blobs repository (with license agreement)"
depends on USE_BLOBS
help
This draws in the amd_blobs repository, which contains binary files
distributed by AMD, including VBIOS, PSP bootloaders, SMU firmwares,
etc. Selecting this item to download or clone the repo implies your
agreement to the AMD license agreement. A copy of the license text
may be reviewed by reading Documentation/soc/amd/amdblobs_license.md,
and your copy of the license is present in the repo once downloaded.

Note that for some products, omitting PSP, SMU images, or other items
may result in a nonbooting coreboot.rom.

config COVERAGE
bool "Code coverage support"
depends on COMPILER_GCC
Expand Down Expand Up @@ -707,7 +738,10 @@ source "payloads/Kconfig"
menu "Debugging"

comment "CPU Debug Settings"
source "src/cpu/*/Kconfig.debug"
source "src/cpu/*/Kconfig.debug_cpu"

comment "BLOB Debug Settings"
source "src/drivers/intel/fsp*/Kconfig.debug_blob"

comment "General Debug Settings"

Expand Down Expand Up @@ -809,19 +843,6 @@ config DEBUG_MALLOC

If unsure, say N.

# Only visible if debug level is DEBUG (7) or SPEW (8) as it does additional
# printk(BIOS_DEBUG, ...) calls.
config DEBUG_ACPI
prompt "Output verbose ACPI debug messages" if DEFAULT_CONSOLE_LOGLEVEL_7 || DEFAULT_CONSOLE_LOGLEVEL_8
bool
default n
help
This option enables additional ACPI related debug messages.

Note: This option will slightly increase the size of the coreboot image.

If unsure, say N.

config DEBUG_CONSOLE_INIT
bool "Debug console initialisation code"
default n
Expand Down Expand Up @@ -1212,11 +1233,6 @@ config HAVE_ROMSTAGE
bool
default y

config HAVE_POSTCAR
bool
depends on POSTCAR_STAGE
default y

config HAVE_RAMSTAGE
bool
default n if RAMPAYLOAD
Expand Down
1 change: 1 addition & 0 deletions src/arch/arm/Kconfig
Expand Up @@ -17,6 +17,7 @@ config ARCH_ROMSTAGE_ARM
config ARCH_RAMSTAGE_ARM
bool
select ARCH_ARM
select RAMSTAGE_CBMEM_TOP_ARG

source src/arch/arm/armv4/Kconfig
source src/arch/arm/armv7/Kconfig
Expand Down
3 changes: 2 additions & 1 deletion src/arch/arm/include/arch/stages.h
Expand Up @@ -14,8 +14,9 @@
#ifndef __ARCH_STAGES_H
#define __ARCH_STAGES_H

#include <stdint.h>
#include <main_decl.h>

void stage_entry(void);
void stage_entry(uintptr_t stage_arg);

#endif
2 changes: 1 addition & 1 deletion src/arch/arm/libgcc/udivmoddi4.c
Expand Up @@ -17,7 +17,7 @@ uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
{
uint64_t quot = 0, qbit = 1;
if (den == 0) {
return 1 / ((unsigned)den); /* Intentional divide by zero, without
return 1 / ((unsigned int)den); /* Intentional divide by zero, without
triggering a compiler warning which
would abort the build */
}
Expand Down
5 changes: 4 additions & 1 deletion src/arch/arm/stages.c
Expand Up @@ -22,13 +22,16 @@
* .text.stage_entry section created by -ffunction-sections).
*/

#include <cbmem.h>
#include <arch/stages.h>
#include <arch/cache.h>

/**
* generic stage entry point. override this if board specific code is needed.
*/
__weak void stage_entry(void)
__weak void stage_entry(uintptr_t stage_arg)
{
if (!ENV_ROMSTAGE_OR_BEFORE)
_cbmem_top_ptr = stage_arg;
main();
}
1 change: 1 addition & 0 deletions src/arch/arm64/Kconfig
Expand Up @@ -17,6 +17,7 @@ config ARCH_ROMSTAGE_ARM64
config ARCH_RAMSTAGE_ARM64
bool
select ARCH_ARM64
select RAMSTAGE_CBMEM_TOP_ARG

source src/arch/arm64/armv8/Kconfig

Expand Down
6 changes: 5 additions & 1 deletion src/arch/arm64/boot.c
Expand Up @@ -11,6 +11,7 @@
* GNU General Public License for more details.
*/

#include <cbmem.h>
#include <arch/cache.h>
#include <arch/lib_helpers.h>
#include <arch/stages.h>
Expand Down Expand Up @@ -48,7 +49,10 @@ void arch_prog_run(struct prog *prog)
}

/* Generic stage entry point. Can be overridden by board/SoC if needed. */
__weak void stage_entry(void)
__weak void stage_entry(uintptr_t stage_arg)
{
if (!ENV_ROMSTAGE_OR_BEFORE)
_cbmem_top_ptr = stage_arg;

main();
}
2 changes: 1 addition & 1 deletion src/arch/arm64/include/arch/stages.h
Expand Up @@ -17,7 +17,7 @@
#include <stdint.h>
#include <main_decl.h>

void stage_entry(void);
void stage_entry(uintptr_t stage_arg);

/* This function is the romstage platform entry point, and should contain all
chipset and mainboard setup until DRAM is initialized and accessible. */
Expand Down
1 change: 1 addition & 0 deletions src/arch/mips/Kconfig
Expand Up @@ -22,6 +22,7 @@ config ARCH_BOOTBLOCK_MIPS
default n
select BOOTBLOCK_CUSTOM
select C_ENVIRONMENT_BOOTBLOCK
select RAMSTAGE_CBMEM_TOP_ARG

config ARCH_VERSTAGE_MIPS
bool
Expand Down
3 changes: 2 additions & 1 deletion src/arch/mips/include/arch/stages.h
Expand Up @@ -14,8 +14,9 @@
#ifndef __MIPS_ARCH_STAGES_H
#define __MIPS_ARCH_STAGES_H

#include <stdint.h>
#include <main_decl.h>

void stage_entry(void);
void stage_entry(uintptr_t stage_arg);

#endif /* __MIPS_ARCH_STAGES_H */
5 changes: 4 additions & 1 deletion src/arch/mips/stages.c
Expand Up @@ -11,10 +11,13 @@
* GNU General Public License for more details.
*/

#include <cbmem.h>
#include <arch/stages.h>
#include <arch/cache.h>

void stage_entry(void)
void stage_entry(uintptr_t stage_arg)
{
if (!ENV_ROMSTAGE_OR_BEFORE)
_cbmem_top_ptr = stage_arg;
main();
}
1 change: 1 addition & 0 deletions src/arch/ppc64/Kconfig
@@ -1,5 +1,6 @@
config ARCH_PPC64
bool
select RAMSTAGE_CBMEM_TOP_ARG

config ARCH_BOOTBLOCK_PPC64
bool
Expand Down
2 changes: 1 addition & 1 deletion src/arch/ppc64/include/arch/stages.h
Expand Up @@ -16,6 +16,6 @@

#include <main_decl.h>

void stage_entry(void) __attribute__((section(".text.stage_entry")));
void stage_entry(uintptr_t stage_arg) __attribute__((section(".text.stage_entry")));

#endif
5 changes: 4 additions & 1 deletion src/arch/ppc64/stages.c
Expand Up @@ -22,9 +22,12 @@
* linker script.
*/

#include <cbmem.h>
#include <arch/stages.h>

void stage_entry(void)
void stage_entry(uintptr_t stage_arg)
{
if (!ENV_ROMSTAGE_OR_BEFORE)
_cbmem_top_ptr = stage_arg;
main();
}
3 changes: 1 addition & 2 deletions src/arch/riscv/Makefile.inc
Expand Up @@ -98,7 +98,7 @@ endif #CONFIG_ARCH_BOOTBLOCK_RISCV
ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y)

romstage-y += boot.c
romstage-y += stages.c
romstage-y += romstage.c
romstage-y += misc.c
romstage-$(ARCH_RISCV_PMP) += pmp.c
romstage-y += smp.c
Expand Down Expand Up @@ -140,7 +140,6 @@ ramstage-y += fp_asm.S
ramstage-y += misaligned.c
ramstage-y += sbi.c
ramstage-y += virtual_memory.c
ramstage-y += stages.c
ramstage-y += misc.c
ramstage-y += smp.c
ramstage-y += boot.c
Expand Down
18 changes: 4 additions & 14 deletions src/arch/riscv/boot.c
Expand Up @@ -38,20 +38,10 @@ static void do_arch_prog_run(struct arch_prog_run_args *args)
{
int hart_id;
struct prog *prog = args->prog;
void *fdt = prog_entry_arg(prog);

/*
* Workaround selfboot putting the coreboot table into prog_entry_arg
*/
if (prog_cbfs_type(prog) == CBFS_TYPE_SELF)
fdt = HLS()->fdt;

/*
* If prog_entry_arg is not set (e.g. by fit_payload), use fdt from HLS
* instead.
*/
if (fdt == NULL)
fdt = HLS()->fdt;
void *fdt = HLS()->fdt;

if (prog_cbfs_type(prog) == CBFS_TYPE_FIT)
fdt = prog_entry_arg(prog);

if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
if (CONFIG(RISCV_OPENSBI))
Expand Down
1 change: 0 additions & 1 deletion src/arch/riscv/fit_payload.c
Expand Up @@ -18,7 +18,6 @@
#include <bootmem.h>
#include <stdlib.h>
#include <program_loading.h>
#include <string.h>
#include <commonlib/compression.h>
#include <commonlib/cbfs_serialized.h>
#include <lib.h>
Expand Down
9 changes: 0 additions & 9 deletions src/arch/riscv/stages.c → src/arch/riscv/romstage.c
Expand Up @@ -14,10 +14,6 @@
*/

/*
* This file contains entry/exit functions for each stage during coreboot
* execution (bootblock entry and ramstage exit will depend on external
* loading).
*
* Entry points must be placed at the location the previous stage jumps
* to (the lowest address in the stage image). This is done by giving
* stage_entry() its own section in .text and placing it first in the
Expand All @@ -31,11 +27,6 @@

void stage_entry(int hart_id, void *fdt)
{
/*
* Save the FDT pointer before entering ramstage, because mscratch
* might be overwritten in the trap handler, and there is code in
* ramstage that generates misaligned access faults.
*/
HLS()->hart_id = hart_id;
HLS()->fdt = fdt;
smp_pause(CONFIG_RISCV_WORKING_HARTID);
Expand Down
18 changes: 9 additions & 9 deletions src/arch/x86/Kconfig
Expand Up @@ -16,6 +16,7 @@ config ARCH_X86
default n
select PCI
select RELOCATABLE_MODULES
select RAMSTAGE_CBMEM_TOP_ARG

# stage selectors for x86

Expand Down Expand Up @@ -65,6 +66,14 @@ config ARCH_RAMSTAGE_X86_64
bool
default n

config ARCH_X86_64_PGTBL_LOC
hex "x86_64 page table location in CBFS"
depends on ARCH_BOOTBLOCK_X86_64
default 0xfffea000
help
The position where to place pagetables. Needs to be known at
compile time. Must not overlap other files in CBFS.

config USE_MARCH_586
def_bool n
help
Expand Down Expand Up @@ -169,15 +178,6 @@ config BOOTBLOCK_NORTHBRIDGE_INIT
config BOOTBLOCK_RESETS
string

config BOOTBLOCK_SAVE_BIST_AND_TIMESTAMP
bool
default n
help
Select this value to provide a routine to save the BIST and timestamp
values. The default code places the BIST value in MM0 and the
timestamp value in MM2:MM1. Another file is necessary when the CPU
does not support the MMx register set.

config HAVE_CMOS_DEFAULT
def_bool n
depends on HAVE_OPTION_TABLE
Expand Down
44 changes: 16 additions & 28 deletions src/arch/x86/Makefile.inc
Expand Up @@ -47,12 +47,6 @@ cbfs-files-$(CONFIG_VGA_BIOS_DGPU) += pci$(stripped_vgabios_dgpu_id).rom
pci$(stripped_vgabios_dgpu_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_DGPU_FILE))
pci$(stripped_vgabios_dgpu_id).rom-type := optionrom

verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c

###############################################################################
# common support for early assembly includes
###############################################################################
Expand Down Expand Up @@ -94,18 +88,28 @@ $$(objcbfs)/$(1).debug: $$$$($(1)-libs) $$$$($(1)-objs)
fi
endef

###############################################################################
# all (bootblock,verstage,romstage,postcar,ramstage)
###############################################################################

ifeq ($(CONFIG_ARCH_X86),y)

all-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c
all-y += boot.c
all-y += memcpy.c
all-y += memset.c
all-y += cpu_common.c

endif

###############################################################################
# bootblock
###############################################################################

ifeq ($(CONFIG_ARCH_BOOTBLOCK_X86_32)$(CONFIG_ARCH_BOOTBLOCK_X86_64),y)

bootblock-y += boot.c
bootblock-y += cpu_common.c
bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
bootblock-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
bootblock-y += memcpy.c
bootblock-y += memset.c
bootblock-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
bootblock-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c

Expand Down Expand Up @@ -163,6 +167,8 @@ $(objgenerated)/bootblock.inc: $(src)/arch/x86/$(subst ",,$(CONFIG_BOOTBLOCK_SOU
@printf " ROMCC $(subst $(obj)/,,$(@))\n"
$(CC_bootblock) -D__ROMCC__ -D__PRE_RAM__ -D__BOOTBLOCK__ $(CPPFLAGS_bootblock) -MM -MT$(objgenerated)/bootblock.inc \
$< > $(objgenerated)/bootblock.inc.d
$(CC_bootblock) -D__ROMCC__ -D__PRE_RAM__ -D__BOOTBLOCK__ $(CPPFLAGS_bootblock) -E \
$< -o $(objgenerated)/bootblock_romcc.c
$(ROMCC) -c -S $(bootblock_romccflags) -I. $(CPPFLAGS_bootblock) $< -o $@

# bootblock.ld is part of $(bootblock-objs)
Expand All @@ -183,14 +189,10 @@ endif # CONFIG_ARCH_BOOTBLOCK_X86_32 / CONFIG_ARCH_BOOTBLOCK_X86_64

ifeq ($(CONFIG_ARCH_VERSTAGE_X86_32)$(CONFIG_ARCH_VERSTAGE_X86_64),y)

verstage-y += boot.c
verstage-$(CONFIG_VBOOT_SEPARATE_VERSTAGE) += gdt_init.S
verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
verstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S

verstage-y += cpu_common.c
verstage-y += memset.c
verstage-y += memcpy.c
verstage-y += memmove.c
verstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
# If verstage is a separate stage it means there's no need
Expand Down Expand Up @@ -219,19 +221,15 @@ endif # CONFIG_ARCH_VERSTAGE_X86_32 / CONFIG_ARCH_VERSTAGE_X86_64
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32)$(CONFIG_ARCH_ROMSTAGE_X86_64),y)

romstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
romstage-y += boot.c
# gdt_init.S is included by entry32.inc when romstage is the first C
# environment.
romstage-$(CONFIG_C_ENVIRONMENT_BOOTBLOCK) += gdt_init.S
romstage-y += cbmem.c
romstage-y += cbfs_and_run.c
romstage-y += cpu_common.c
romstage-$(CONFIG_EARLY_EBDA_INIT) += ebda.c
romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
romstage-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
romstage-y += memcpy.c
romstage-y += memmove.c
romstage-y += memset.c
romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
romstage-y += postcar_loader.c
romstage-$(CONFIG_COLLECT_TIMESTAMPS_TSC) += timestamp.c
Expand Down Expand Up @@ -261,18 +259,13 @@ $(eval $(call create_class_compiler,postcar,x86_32))
postcar-generic-ccopts += -D__POSTCAR__

postcar-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
postcar-y += boot.c
postcar-y += gdt_init.S
postcar-y += cbfs_and_run.c
postcar-y += cbmem.c
postcar-y += cpu_common.c
postcar-$(CONFIG_EARLY_EBDA_INIT) += ebda.c
postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += exception.c
postcar-$(CONFIG_IDT_IN_EVERY_STAGE) += idt.S
postcar-y += exit_car.S
postcar-y += memcpy.c
postcar-y += memmove.c
postcar-y += memset.c
postcar-y += memlayout.ld
postcar-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
postcar-y += postcar.c
Expand Down Expand Up @@ -306,20 +299,15 @@ ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_device.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi_pld.c
ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c
ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c
ramstage-y += boot.c
ramstage-y += c_start.S
ramstage-y += cbmem.c
ramstage-y += cpu.c
ramstage-y += cpu_common.c
ramstage-y += ebda.c
ramstage-y += exception.c
ramstage-y += idt.S
ramstage-y += gdt.c
ramstage-$(CONFIG_IOAPIC) += ioapic.c
ramstage-y += memcpy.c
ramstage-y += memlayout.ld
ramstage-y += memmove.c
ramstage-y += memset.c
ramstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c
ramstage-$(CONFIG_GENERATE_MP_TABLE) += mpspec.c
ramstage-$(CONFIG_GENERATE_PIRQ_TABLE) += pirq_routing.c
Expand Down
16 changes: 8 additions & 8 deletions src/arch/x86/acpi.c
Expand Up @@ -127,7 +127,7 @@ int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base,

int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic)
{
lapic->type = 0; /* Local APIC structure */
lapic->type = LOCAL_APIC; /* Local APIC structure */
lapic->length = sizeof(acpi_madt_lapic_t);
lapic->flags = (1 << 0); /* Processor/LAPIC enabled */
lapic->processor_id = cpu;
Expand Down Expand Up @@ -165,7 +165,7 @@ unsigned long acpi_create_madt_lapics(unsigned long current)
int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
u32 gsi_base)
{
ioapic->type = 1; /* I/O APIC structure */
ioapic->type = IO_APIC; /* I/O APIC structure */
ioapic->length = sizeof(acpi_madt_ioapic_t);
ioapic->reserved = 0x00;
ioapic->gsi_base = gsi_base;
Expand All @@ -178,7 +178,7 @@ int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,
int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
u8 bus, u8 source, u32 gsirq, u16 flags)
{
irqoverride->type = 2; /* Interrupt source override */
irqoverride->type = IRQ_SOURCE_OVERRIDE; /* Interrupt source override */
irqoverride->length = sizeof(acpi_madt_irqoverride_t);
irqoverride->bus = bus;
irqoverride->source = source;
Expand All @@ -191,7 +191,7 @@ int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
u16 flags, u8 lint)
{
lapic_nmi->type = 4; /* Local APIC NMI structure */
lapic_nmi->type = LOCAL_APIC_NMI; /* Local APIC NMI structure */
lapic_nmi->length = sizeof(acpi_madt_lapic_nmi_t);
lapic_nmi->flags = flags;
lapic_nmi->processor_id = cpu;
Expand Down Expand Up @@ -737,14 +737,14 @@ void acpi_create_hpet(acpi_hpet_t *hpet)
}

void acpi_create_vfct(struct device *device,
struct acpi_vfct *vfct,
acpi_vfct_t *vfct,
unsigned long (*acpi_fill_vfct)(struct device *device,
struct acpi_vfct *vfct_struct, unsigned long current))
acpi_vfct_t *vfct_struct, unsigned long current))
{
acpi_header_t *header = &(vfct->header);
unsigned long current = (unsigned long)vfct + sizeof(struct acpi_vfct);
unsigned long current = (unsigned long)vfct + sizeof(acpi_vfct_t);

memset((void *)vfct, 0, sizeof(struct acpi_vfct));
memset((void *)vfct, 0, sizeof(acpi_vfct_t));

if (!header)
return;
Expand Down
11 changes: 5 additions & 6 deletions src/arch/x86/boot.c
Expand Up @@ -30,13 +30,12 @@ int payload_arch_usable_ram_quirk(uint64_t start, uint64_t size)

void arch_prog_run(struct prog *prog)
{
__asm__ volatile (
#ifdef __x86_64__
"jmp *%%rdi\n"
void (*doit)(void *arg);
#else
"jmp *%%edi\n"
/* Ensure the argument is pushed on the stack. */
asmlinkage void (*doit)(void *arg);
#endif

:: "D"(prog_entry(prog))
);
doit = prog_entry(prog);
doit(prog_entry_arg(prog));
}
6 changes: 6 additions & 0 deletions src/arch/x86/bootblock_crt0.S
Expand Up @@ -31,6 +31,12 @@
#include <cpu/x86/16bit/reset16.inc>
#include <cpu/x86/32bit/entry32.inc>

/* BIST result in eax */
mov %eax, %ebx
/* entry64.inc preserves ebx. */
#include <cpu/x86/64bit/entry64.inc>
mov %ebx, %eax

#if CONFIG(BOOTBLOCK_DEBUG_SPINLOOP)

/* Wait for a JTAG debugger to break in and set EBX non-zero */
Expand Down
5 changes: 0 additions & 5 deletions src/arch/x86/bootblock_simple.c
Expand Up @@ -27,12 +27,7 @@ static void main(unsigned long bist)
#endif
}

#if CONFIG(VBOOT_SEPARATE_VERSTAGE)
const char *target1 = "fallback/verstage";
#else
const char *target1 = "fallback/romstage";
#endif

unsigned long entry;
entry = findstage(target1);
if (entry)
Expand Down
15 changes: 12 additions & 3 deletions src/arch/x86/c_start.S
Expand Up @@ -12,6 +12,7 @@
*/

#include <cpu/x86/post_code.h>
#include <arch/ram_segs.h>

/* Place the stack in the bss section. It's not necessary to define it in the
* the linker script. */
Expand Down Expand Up @@ -42,23 +43,31 @@ _start:
cli
lgdt %cs:gdtaddr
#ifndef __x86_64__
ljmp $0x10, $1f
ljmp $RAM_CODE_SEG, $1f
#endif
1: movl $0x18, %eax
1: movl $RAM_DATA_SEG, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %ss
movl %eax, %fs
movl %eax, %gs
#ifdef __x86_64__
mov $0x48, %ecx
mov $RAM_CODE_SEG64, %ecx
call SetCodeSelector
#endif

post_code(POST_ENTRY_C_START) /* post 13 */

cld

#ifdef __x86_64__
mov %rdi, _cbmem_top_ptr
#else
/* The return argument is at 0(%esp), the calling argument at 4(%esp) */
movl 4(%esp), %eax
movl %eax, _cbmem_top_ptr
#endif

/** poison the stack. Code should not count on the
* stack being full of zeros. This stack poisoning
* recently uncovered a bug in the broadcast SIPI
Expand Down
15 changes: 2 additions & 13 deletions src/arch/x86/cbmem.c
Expand Up @@ -16,21 +16,10 @@

#if CONFIG(CBMEM_TOP_BACKUP)

void *cbmem_top(void)
void *cbmem_top_chipset(void)
{
static void *cbmem_top_backup;
void *top_backup;

if (ENV_RAMSTAGE && cbmem_top_backup != NULL)
return cbmem_top_backup;

/* Top of CBMEM is at highest usable DRAM address below 4GiB. */
top_backup = (void *)restore_top_of_low_cacheable();

if (ENV_RAMSTAGE)
cbmem_top_backup = top_backup;

return top_backup;
return (void *)restore_top_of_low_cacheable();
}

#endif /* CBMEM_TOP_BACKUP */
2 changes: 1 addition & 1 deletion src/arch/x86/cpu.c
Expand Up @@ -315,7 +315,7 @@ void lb_arch_add_records(struct lb_header *header)
struct lb_tsc_info *tsc_info;

/* Don't advertise a TSC rate unless it's constant. */
if (!CONFIG(TSC_CONSTANT_RATE))
if (!tsc_constant_rate())
return;

freq_khz = tsc_freq_mhz() * 1000;
Expand Down
8 changes: 8 additions & 0 deletions src/arch/x86/exit_car.S
Expand Up @@ -31,6 +31,14 @@ _start:
/* Migrate GDT to this text segment */
call gdt_init

#ifdef __x86_64__
mov %rdi, _cbmem_top_ptr
#else
/* The return argument is at 0(%esp), the calling argument at 4(%esp) */
movl 4(%esp), %eax
movl %eax, _cbmem_top_ptr
#endif

/* chipset_teardown_car() is expected to disable cache-as-ram. */
call chipset_teardown_car

Expand Down
107 changes: 53 additions & 54 deletions src/arch/x86/include/arch/acpi.h
Expand Up @@ -147,41 +147,41 @@ typedef struct acpi_table_header {

/* RSDT (Root System Description Table) */
typedef struct acpi_rsdt {
struct acpi_table_header header;
acpi_header_t header;
u32 entry[MAX_ACPI_TABLES];
} __packed acpi_rsdt_t;

/* XSDT (Extended System Description Table) */
typedef struct acpi_xsdt {
struct acpi_table_header header;
acpi_header_t header;
u64 entry[MAX_ACPI_TABLES];
} __packed acpi_xsdt_t;

/* HPET timers */
typedef struct acpi_hpet {
struct acpi_table_header header;
acpi_header_t header;
u32 id;
struct acpi_gen_regaddr addr;
acpi_addr_t addr;
u8 number;
u16 min_tick;
u8 attributes;
} __packed acpi_hpet_t;

/* MCFG (PCI Express MMIO config space BAR description table) */
typedef struct acpi_mcfg {
struct acpi_table_header header;
acpi_header_t header;
u8 reserved[8];
} __packed acpi_mcfg_t;

typedef struct acpi_tcpa {
struct acpi_table_header header;
acpi_header_t header;
u16 platform_class;
u32 laml;
u64 lasa;
} __packed acpi_tcpa_t;

typedef struct acpi_tpm2 {
struct acpi_table_header header;
acpi_header_t header;
u16 platform_class;
u8 reserved[2];
u64 control_area;
Expand All @@ -202,7 +202,7 @@ typedef struct acpi_mcfg_mmconfig {

/* SRAT (System Resource Affinity Table) */
typedef struct acpi_srat {
struct acpi_table_header header;
acpi_header_t header;
u32 resv;
u64 resv1;
/* Followed by static resource allocation structure[n] */
Expand Down Expand Up @@ -239,19 +239,19 @@ typedef struct acpi_srat_mem {

/* SLIT (System Locality Distance Information Table) */
typedef struct acpi_slit {
struct acpi_table_header header;
acpi_header_t header;
/* Followed by static resource allocation 8+byte[num*num] */
} __packed acpi_slit_t;

/* MADT (Multiple APIC Description Table) */
typedef struct acpi_madt {
struct acpi_table_header header;
acpi_header_t header;
u32 lapic_addr; /* Local APIC address */
u32 flags; /* Multiple APIC flags */
} __packed acpi_madt_t;

/* VFCT image header */
struct acpi_vfct_image_hdr {
typedef struct acpi_vfct_image_hdr {
u32 PCIBus;
u32 PCIDevice;
u32 PCIFunction;
Expand All @@ -262,17 +262,17 @@ struct acpi_vfct_image_hdr {
u32 Revision;
u32 ImageLength;
u8 VbiosContent; // dummy - copy VBIOS here
} __packed;
} __packed acpi_vfct_image_hdr_t;

/* VFCT (VBIOS Fetch Table) */
struct acpi_vfct {
struct acpi_table_header header;
typedef struct acpi_vfct {
acpi_header_t header;
u8 TableUUID[16];
u32 VBIOSImageOffset;
u32 Lib1ImageOffset;
u32 Reserved[4];
struct acpi_vfct_image_hdr image_hdr;
} __packed;
acpi_vfct_image_hdr_t image_hdr;
} __packed acpi_vfct_t;

typedef struct acpi_ivrs_info {
} __packed acpi_ivrs_info_t;
Expand All @@ -294,7 +294,7 @@ typedef struct acpi_ivrs_ivhd {

/* IVRS (I/O Virtualization Reporting Structure) Type 10h */
typedef struct acpi_ivrs {
struct acpi_table_header header;
acpi_header_t header;
uint32_t iv_info;
uint32_t reserved[2];
struct acpi_ivrs_ivhd ivhd;
Expand Down Expand Up @@ -382,32 +382,31 @@ typedef struct dmar_andd_entry {

/* DMAR (DMA Remapping Reporting Structure) */
typedef struct acpi_dmar {
struct acpi_table_header header;
acpi_header_t header;
u8 host_address_width;
u8 flags;
u8 reserved[10];
dmar_entry_t structure[0];
} __packed acpi_dmar_t;

/* MADT: APIC Structure Types */
/* TODO: Convert to ALLCAPS. */
enum acpi_apic_types {
LocalApic = 0, /* Processor local APIC */
IOApic = 1, /* I/O APIC */
IRQSourceOverride = 2, /* Interrupt source override */
NMIType = 3, /* NMI source */
LocalApicNMI = 4, /* Local APIC NMI */
LApicAddressOverride = 5, /* Local APIC address override */
IOSApic = 6, /* I/O SAPIC */
LocalSApic = 7, /* Local SAPIC */
PlatformIRQSources = 8, /* Platform interrupt sources */
Localx2Apic = 9, /* Processor local x2APIC */
Localx2ApicNMI = 10, /* Local x2APIC NMI */
GICC = 11, /* GIC CPU Interface */
GICD = 12, /* GIC Distributor */
GIC_MSI_FRAME = 13, /* GIC MSI Frame */
GICR = 14, /* GIC Redistributor */
GIC_ITS = 15, /* Interrupt Translation Service */
LOCAL_APIC, /* Processor local APIC */
IO_APIC, /* I/O APIC */
IRQ_SOURCE_OVERRIDE, /* Interrupt source override */
NMI_TYPE, /* NMI source */
LOCAL_APIC_NMI, /* Local APIC NMI */
LAPIC_ADDRESS_OVERRIDE, /* Local APIC address override */
IO_SAPIC, /* I/O SAPIC */
LOCAL_SAPIC, /* Local SAPIC */
PLATFORM_IRQ_SOURCES, /* Platform interrupt sources */
LOCAL_X2APIC, /* Processor local x2APIC */
LOCAL_X2APIC_NMI, /* Local x2APIC NMI */
GICC, /* GIC CPU Interface */
GICD, /* GIC Distributor */
GIC_MSI_FRAME, /* GIC MSI Frame */
GICR, /* GIC Redistributor */
GIC_ITS, /* Interrupt Translation Service */
/* 0x10-0x7f: Reserved */
/* 0x80-0xff: Reserved for OEM use */
};
Expand Down Expand Up @@ -466,7 +465,7 @@ typedef struct acpi_madt_irqoverride {

/* DBG2: Microsoft Debug Port Table 2 header */
typedef struct acpi_dbg2_header {
struct acpi_table_header header;
acpi_header_t header;
uint32_t devices_offset;
uint32_t devices_count;
} __attribute__((packed)) acpi_dbg2_header_t;
Expand All @@ -489,7 +488,7 @@ typedef struct acpi_dbg2_device {

/* FADT (Fixed ACPI Description Table) */
typedef struct acpi_fadt {
struct acpi_table_header header;
acpi_header_t header;
u32 firmware_ctrl;
u32 dsdt;
u8 reserved; /* Should be 0 */
Expand Down Expand Up @@ -528,22 +527,22 @@ typedef struct acpi_fadt {
u16 iapc_boot_arch;
u8 res2;
u32 flags;
struct acpi_gen_regaddr reset_reg;
acpi_addr_t reset_reg;
u8 reset_value;
u16 ARM_boot_arch;
u8 FADT_MinorVersion;
u32 x_firmware_ctl_l;
u32 x_firmware_ctl_h;
u32 x_dsdt_l;
u32 x_dsdt_h;
struct acpi_gen_regaddr x_pm1a_evt_blk;
struct acpi_gen_regaddr x_pm1b_evt_blk;
struct acpi_gen_regaddr x_pm1a_cnt_blk;
struct acpi_gen_regaddr x_pm1b_cnt_blk;
struct acpi_gen_regaddr x_pm2_cnt_blk;
struct acpi_gen_regaddr x_pm_tmr_blk;
struct acpi_gen_regaddr x_gpe0_blk;
struct acpi_gen_regaddr x_gpe1_blk;
acpi_addr_t x_pm1a_evt_blk;
acpi_addr_t x_pm1b_evt_blk;
acpi_addr_t x_pm1a_cnt_blk;
acpi_addr_t x_pm1b_cnt_blk;
acpi_addr_t x_pm2_cnt_blk;
acpi_addr_t x_pm_tmr_blk;
acpi_addr_t x_gpe0_blk;
acpi_addr_t x_gpe1_blk;
} __packed acpi_fadt_t;

/* FADT TABLE Revision values */
Expand Down Expand Up @@ -634,17 +633,17 @@ typedef struct acpi_facs {

/* ECDT (Embedded Controller Boot Resources Table) */
typedef struct acpi_ecdt {
struct acpi_table_header header;
struct acpi_gen_regaddr ec_control; /* EC control register */
struct acpi_gen_regaddr ec_data; /* EC data register */
acpi_header_t header;
acpi_addr_t ec_control; /* EC control register */
acpi_addr_t ec_data; /* EC data register */
u32 uid; /* UID */
u8 gpe_bit; /* GPE bit */
u8 ec_id[]; /* EC ID */
} __packed acpi_ecdt_t;

/* HEST (Hardware Error Source Table) */
typedef struct acpi_hest {
struct acpi_table_header header;
acpi_header_t header;
u32 error_source_count;
/* error_source_struct(s) */
} __packed acpi_hest_t;
Expand Down Expand Up @@ -677,7 +676,7 @@ typedef struct acpi_hest_hen {

/* BERT (Boot Error Record Table) */
typedef struct acpi_bert {
struct acpi_table_header header;
acpi_header_t header;
u32 region_length;
u64 error_region;
} __packed acpi_bert_t;
Expand Down Expand Up @@ -794,7 +793,7 @@ enum acpi_ipmi_interface_type {

/* ACPI IPMI 2.0 */
struct acpi_spmi {
struct acpi_table_header header;
acpi_header_t header;
u8 interface_type;
u8 reserved;
u16 specification_revision;
Expand Down Expand Up @@ -864,9 +863,9 @@ void acpi_create_slit(acpi_slit_t *slit,
unsigned long (*acpi_fill_slit)(unsigned long current));

void acpi_create_vfct(struct device *device,
struct acpi_vfct *vfct,
acpi_vfct_t *vfct,
unsigned long (*acpi_fill_vfct)(struct device *device,
struct acpi_vfct *vfct_struct,
acpi_vfct_t *vfct_struct,
unsigned long current));

void acpi_create_ipmi(struct device *device,
Expand Down
5 changes: 5 additions & 0 deletions src/arch/x86/include/arch/cpu.h
Expand Up @@ -141,6 +141,11 @@ static inline unsigned int cpuid_edx(unsigned int op)
return edx;
}

static inline unsigned int cpuid_get_max_func(void)
{
return cpuid_eax(0);
}

#define X86_VENDOR_INVALID 0
#define X86_VENDOR_INTEL 1
#define X86_VENDOR_CYRIX 2
Expand Down
25 changes: 25 additions & 0 deletions src/arch/x86/include/arch/ram_segs.h
@@ -0,0 +1,25 @@
/*
* This file is part of the coreboot project.
*
* 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.
*/

#ifndef RAM_SEGS_H
#define RAM_SEGS_H

#define RAM_CODE_SEG 0x10
#define RAM_DATA_SEG 0x18
#define RAM_CODE16_SEG 0x28
#define RAM_DATA16_SEG 0x30
#define RAM_CODE_ACPI_SEG 0x38
#define RAM_DATA_ACPI_SEG 0x40
#define RAM_CODE_SEG64 0x48

#endif /* RAM_SEGS_H */
5 changes: 5 additions & 0 deletions src/arch/x86/postcar_loader.c
Expand Up @@ -23,6 +23,7 @@
#include <romstage_handoff.h>
#include <stage_cache.h>
#include <timestamp.h>
#include <security/vboot/vboot_common.h>

static inline void stack_push(struct postcar_frame *pcf, uint32_t val)
{
Expand Down Expand Up @@ -171,6 +172,8 @@ static void load_postcar_cbfs(struct prog *prog, struct postcar_frame *pcf)
.prog = prog,
};

vboot_run_logic();

if (prog_locate(prog))
die_with_post_code(POST_INVALID_ROM,
"Failed to locate after CAR program.\n");
Expand Down Expand Up @@ -225,5 +228,7 @@ void run_postcar_phase(struct postcar_frame *pcf)
/* As postcar exist, it's end of romstage here */
timestamp_add_now(TS_END_ROMSTAGE);

prog_set_arg(&prog, cbmem_top());

prog_run(&prog);
}
19 changes: 19 additions & 0 deletions src/arch/x86/smbios.c
Expand Up @@ -522,6 +522,16 @@ void __weak smbios_system_set_uuid(u8 *uuid)
/* leave all zero */
}

unsigned int __weak smbios_cpu_get_max_speed_mhz(void)
{
return 0; /* Unknown */
}

unsigned int __weak smbios_cpu_get_current_speed_mhz(void)
{
return 0; /* Unknown */
}

const char *__weak smbios_system_sku(void)
{
return "";
Expand Down Expand Up @@ -653,11 +663,20 @@ static int smbios_write_type4(unsigned long *current, int handle)
t->processor_family = (res.eax > 0) ? 0x0c : 0x6;
t->processor_type = 3; /* System Processor */
t->core_count = (res.ebx >> 16) & 0xff;
/* Assume we enable all the cores always, capped only by MAX_CPUS */
t->core_enabled = MAX(t->core_count, CONFIG_MAX_CPUS);
t->l1_cache_handle = 0xffff;
t->l2_cache_handle = 0xffff;
t->l3_cache_handle = 0xffff;
t->processor_upgrade = get_socket_type();
len = t->length + smbios_string_table_len(t->eos);
if (cpu_have_cpuid() && cpuid_get_max_func() >= 0x16) {
t->max_speed = cpuid_ebx(0x16);
t->current_speed = cpuid_eax(0x16); /* base frequency */
} else {
t->max_speed = smbios_cpu_get_max_speed_mhz();
t->current_speed = smbios_cpu_get_current_speed_mhz();
}
*current += len;
return len;
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86/timestamp.c
Expand Up @@ -22,7 +22,7 @@ uint64_t timestamp_get(void)
int timestamp_tick_freq_mhz(void)
{
/* Chipsets that have a constant TSC provide this value correctly. */
if (CONFIG(TSC_CONSTANT_RATE))
if (tsc_constant_rate())
return tsc_freq_mhz();

/* Filling tick_freq_mhz = 0 in timestamps-table will trigger
Expand Down
1 change: 1 addition & 0 deletions src/commonlib/include/commonlib/cbfs_serialized.h
Expand Up @@ -157,6 +157,7 @@ struct cbfs_file_attribute {
#define CBFS_FILE_ATTR_TAG_HASH 0x68736148
#define CBFS_FILE_ATTR_TAG_POSITION 0x42435350 /* PSCB */
#define CBFS_FILE_ATTR_TAG_ALIGNMENT 0x42434c41 /* ALCB */
#define CBFS_FILE_ATTR_TAG_IBB 0x32494242 /* Initial BootBlock */

struct cbfs_file_attr_compression {
uint32_t tag;
Expand Down
4 changes: 4 additions & 0 deletions src/commonlib/include/commonlib/cbmem_id.h
Expand Up @@ -56,6 +56,8 @@
#define CBMEM_ID_ROMSTAGE_RAM_STACK 0x90357ac4
#define CBMEM_ID_ROOT 0xff4007ff
#define CBMEM_ID_SMBIOS 0x534d4254
#define CBMEM_ID_BERT_RAW_DATA 0x42455254
#define CBMEM_ID_SMM_TSEG_SPACE 0x54534547
#define CBMEM_ID_SMM_SAVE_SPACE 0x07e9acee
#define CBMEM_ID_STAGEx_META 0x57a9e000
#define CBMEM_ID_STAGEx_CACHE 0x57a9e100
Expand Down Expand Up @@ -119,6 +121,8 @@
{ CBMEM_ID_ROMSTAGE_RAM_STACK, "ROMSTG STCK" }, \
{ CBMEM_ID_ROOT, "CBMEM ROOT " }, \
{ CBMEM_ID_SMBIOS, "SMBIOS " }, \
{ CBMEM_ID_BERT_RAW_DATA, "BERT DATA " }, \
{ CBMEM_ID_SMM_TSEG_SPACE, "TSEG " }, \
{ CBMEM_ID_SMM_SAVE_SPACE, "SMM BACKUP " }, \
{ CBMEM_ID_STORAGE_DATA, "SD/MMC/eMMC" }, \
{ CBMEM_ID_TCPA_LOG, "TCPA LOG " }, \
Expand Down
12 changes: 8 additions & 4 deletions src/commonlib/include/commonlib/helpers.h
Expand Up @@ -108,16 +108,16 @@
#define GHz (1000 * MHz)

#ifndef offsetof
#ifdef __ROMCC__
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#else
#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
#endif
#endif

#if !defined(__clang__)
#define check_member(structure, member, offset) _Static_assert( \
offsetof(struct structure, member) == offset, \
"`struct " #structure "` offset for `" #member "` is not " #offset)
#else
#define check_member(structure, member, offset)
#endif

/**
* container_of - cast a member of a structure out to the containing structure
Expand All @@ -137,4 +137,8 @@
#define __unused __attribute__((unused))
#endif

#ifndef alloca
#define alloca(x) __builtin_alloca(x)
#endif

#endif /* COMMONLIB_HELPERS_H */
7 changes: 0 additions & 7 deletions src/console/Kconfig
Expand Up @@ -176,13 +176,6 @@ config CONSOLE_USB

# TODO: Deps?
# TODO: Improve description.
config ONBOARD_VGA_IS_PRIMARY
bool "Use onboard VGA as primary video device"
default n
depends on PCI
help
If not selected, the last adapter found will be used.

config CONSOLE_NE2K
bool "Network console over NE2000 compatible Ethernet adapter"
default n
Expand Down
3 changes: 2 additions & 1 deletion src/console/Makefile.inc
Expand Up @@ -23,7 +23,8 @@ romstage-y += init.c console.c
romstage-y += post.c
romstage-y += die.c

postcar-$(CONFIG_POSTCAR_CONSOLE) += vtxprintf.c printk.c vsprintf.c
postcar-y += vtxprintf.c vsprintf.c
postcar-$(CONFIG_POSTCAR_CONSOLE) += printk.c
postcar-$(CONFIG_POSTCAR_CONSOLE) += init.c console.c
postcar-y += post.c
postcar-y += die.c
Expand Down
12 changes: 1 addition & 11 deletions src/cpu/amd/agesa/Kconfig
Expand Up @@ -28,20 +28,10 @@ config CPU_AMD_AGESA
select LAPIC_MONOTONIC_TIMER
select SPI_FLASH if HAVE_ACPI_RESUME
select SMM_ASEG
select NO_FIXED_XIP_ROM_SIZE

if CPU_AMD_AGESA

config XIP_ROM_SIZE
hex
default 0x100000
help
Overwride the default write through caching size as 1M Bytes.
On some AMD platforms, one socket supports 2 or more kinds of
processor family, compiling several CPU families agesa code
will increase the romstage size.
In order to execute romstage in place on the flash ROM,
more space is required to be set as write through caching.

config UDELAY_LAPIC_FIXED_FSB
int
default 200
Expand Down
4 changes: 0 additions & 4 deletions src/cpu/amd/agesa/family12/Kconfig
Expand Up @@ -21,8 +21,4 @@ config CPU_ADDR_BITS
int
default 48

config XIP_ROM_SIZE
hex
default 0x80000

endif
4 changes: 0 additions & 4 deletions src/cpu/amd/agesa/family14/Kconfig
Expand Up @@ -21,8 +21,4 @@ config CPU_ADDR_BITS
int
default 36

config XIP_ROM_SIZE
hex
default 0x80000

endif
19 changes: 7 additions & 12 deletions src/cpu/amd/agesa/family14/acpi/cpu.asl
Expand Up @@ -16,19 +16,14 @@
*
*/
Scope (\_PR) { /* define processor scope */
Processor(
C000, /* name space name, align with BLDCFG_PROCESSOR_SCOPE_NAME[01] */
0, /* Unique number for this processor */
0x810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (C000) {
Name (_HID, "ACPI0007")
Name (_UID, 0)
}

Processor(
C001, /* name space name */
1, /* Unique number for this processor */
0x810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
Device (C001) {
Name (_HID, "ACPI0007")
Name (_UID, 1)
}
} /* End _PR scope */
4 changes: 0 additions & 4 deletions src/cpu/amd/agesa/family15tn/Kconfig
Expand Up @@ -21,8 +21,4 @@ config CPU_ADDR_BITS
int
default 48

config XIP_ROM_SIZE
hex
default 0x100000

endif
107 changes: 45 additions & 62 deletions src/cpu/amd/agesa/family15tn/acpi/cpu.asl
Expand Up @@ -11,66 +11,49 @@
* GNU General Public License for more details.
*/

/*
* Processor Object
*
*/
Scope (\_PR) { /* define processor scope */
Processor(
P000, /* name space name */
0, /* Unique number for this processor */
0x810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
/*
* Processor Object
*
*/
Scope (\_PR) { /* define processor scope */

Device (P000) {
Name(_HID, "ACPI0007")
Name(_UID, 0)
}

Device (P001) {
Name(_HID, "ACPI0007")
Name(_UID, 1)
}

Device (P002) {
Name(_HID, "ACPI0007")
Name(_UID, 2)
}

Device (P003) {
Name(_HID, "ACPI0007")
Name(_UID, 3)
}

Device (P004) {
Name(_HID, "ACPI0007")
Name(_UID, 4)
}

Device (P005) {
Name(_HID, "ACPI0007")
Name(_UID, 5)
}

Device (P006) {
Name(_HID, "ACPI0007")
Name(_UID, 6)
}

Processor(
P001, /* name space name */
1, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
Processor(
P002, /* name space name */
2, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
Processor(
P003, /* name space name */
3, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
Processor(
P004, /* name space name */
4, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
Processor(
P005, /* name space name */
5, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
Processor(
P006, /* name space name */
6, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
Processor(
P007, /* name space name */
7, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
}
} /* End _PR scope */
Device (P007) {
Name(_HID, "ACPI0007")
Name(_UID, 7)
}
} /* End _PR scope */
4 changes: 0 additions & 4 deletions src/cpu/amd/agesa/family16kb/Kconfig
Expand Up @@ -21,10 +21,6 @@ config CPU_ADDR_BITS
int
default 40

config XIP_ROM_SIZE
hex
default 0x100000

config FORCE_AM1_SOCKET_SUPPORT
bool
default n
Expand Down
80 changes: 31 additions & 49 deletions src/cpu/amd/agesa/family16kb/acpi/cpu.asl
Expand Up @@ -15,62 +15,44 @@
* Processor Object
*
*/
Scope (\_PR) { /* define processor scope */
Processor(
P000, /* name space name */
0, /* Unique number for this processor */
0x810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
Scope (\_PR) {/* define processor scope */
Device (P000) {
Name(_HID, "ACPI0007")
Name(_UID, 0)
}

Processor(
P001, /* name space name */
1, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {
Device (P001) {
Name(_HID, "ACPI0007")
Name(_UID, 1)
}
Processor(
P002, /* name space name */
2, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (P002) {
Name(_HID, "ACPI0007")
Name(_UID, 2)
}
Processor(
P003, /* name space name */
3, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (P003) {
Name(_HID, "ACPI0007")
Name(_UID, 3)
}
Processor(
P004, /* name space name */
4, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (P004) {
Name(_HID, "ACPI0007")
Name(_UID, 4)
}
Processor(
P005, /* name space name */
5, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (P005) {
Name(_HID, "ACPI0007")
Name(_UID, 5)
}
Processor(
P006, /* name space name */
6, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (P006) {
Name(_HID, "ACPI0007")
Name(_UID, 6)
}
Processor(
P007, /* name space name */
7, /* Unique number for this processor */
0x0810, /* PBLK system I/O address !hardcoded! */
0x06 /* PBLKLEN for boot processor */
) {

Device (P007) {
Name(_HID, "ACPI0007")
Name(_UID, 7)
}
} /* End _PR scope */
3 changes: 2 additions & 1 deletion src/cpu/amd/family_10h-family_15h/fidvid.c
Expand Up @@ -91,6 +91,7 @@ b.- prep_fid_change(...)
#include <device/pci_ops.h>
#include <stdint.h>
#include <northbridge/amd/amdht/AsPsDefs.h>
#include <stdlib.h>

static inline void print_debug_fv(const char *str, u32 val)
{
Expand Down Expand Up @@ -1042,7 +1043,7 @@ struct ap_apicid_st {
u8 apicid[NODE_NUMS * 4];
};

static void store_ap_apicid(unsigned ap_apicid, void *gp)
static void store_ap_apicid(unsigned int ap_apicid, void *gp)
{
struct ap_apicid_st *p = gp;

Expand Down
2 changes: 1 addition & 1 deletion src/cpu/amd/family_10h-family_15h/init_cpus.h
Expand Up @@ -26,7 +26,7 @@
#define NODE_MC(x) NODE_PCI(x,3)
#define NODE_LC(x) NODE_PCI(x,4)

unsigned int get_sbdn(unsigned bus);
unsigned int get_sbdn(unsigned int bus);
void cpuSetAMDMSR(uint8_t node_id);

typedef void (*process_ap_t) (u32 apicid, void *gp);
Expand Down
2 changes: 2 additions & 0 deletions src/cpu/amd/family_10h-family_15h/processor_name.c
Expand Up @@ -27,6 +27,8 @@
#include <device/pci.h>
#include <device/pnp.h>
#include <device/pci_ops.h>
#include <stdlib.h>
#include <types.h>

/* The maximum length of CPU names is 48 bytes, including the final NULL byte.
* If you change these names your BIOS will _NOT_ pass the AMD validation and
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/amd/family_10h-family_15h/ram_calc.c
Expand Up @@ -86,7 +86,7 @@ uint64_t get_cc6_memory_size()
return cc6_size;
}

void *cbmem_top(void)
void *cbmem_top_chipset(void)
{
uint32_t topmem = rdmsr(TOP_MEM).lo;

Expand Down
4 changes: 0 additions & 4 deletions src/cpu/amd/pi/00630F01/Kconfig
Expand Up @@ -21,8 +21,4 @@ config CPU_ADDR_BITS
int
default 48

config XIP_ROM_SIZE
hex
default 0x100000

endif