Add support for ram payloads

This is enabled by CONFIG_RAMPAYLOAD.

The code will look for a ram payload and, if it is found, try
to run it. If the load fails or the payload returns it will
continue with ramstage.

We also include a new payload, linuxcheck, which is intended
to verify that linux can be loaded and run, e.g. as a LinuxBoot
payload. Currently, it fails.

This does not yet work but it makes sense as a foundation on which
to build. For one thing, we need to build at least a few tables
for Linux. The goal for LinuxBoot is to build as few as possible.

To test with linuxcheck (linux is not even close to working):
cd payloads/linuxcheck/
cp x86config  .config
make

cd ../..
make

./build/cbfstool build/coreboot.rom add-payload -n fallback/rampayload -f payloads/linuxcheck/linuxcheck.elf

qemu-system-x86_64 -nographic -m 8192 -bios build/coreboot.rom -monitor /dev/pts/$1 -s

We need to change the payload menu so we can add a rampayload but it's a bit
tricky as written, so that must come later.

Note that I'm still creating a special purpose romselfboot. The idea of
merging romselfboot and selfboot is probably a good idea -- in the future.
I think until we know how this should look, such a merge is premature.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>

Change-Id: I8199aae6776f6dee969b370b0e6a41ef96e854d8
clang-formatted-by: Ronald G. Minnich
Reviewed-on: https://review.coreboot.org/28402
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Tested-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
Ronald G. Minnich 2018-08-13 15:24:30 -07:00 committed by Philipp Deppenwiese
commit 4cea3a19f8
10 changed files with 464 additions and 12 deletions

View file

@ -0,0 +1,34 @@
LIBPAYLOAD_DIR=$(CURDIR)/libpayload
XCOMPILE=$(LIBPAYLOAD_DIR)/libpayload.xcompile
# build libpayload and put .config file in $(CURDIR) instead of ../libpayload
# to avoid pollute the libpayload source directory and possible conflicts
LPOPTS=obj="$(CURDIR)/build" DESTDIR="$(CURDIR)" DOTCONFIG="$(CURDIR)/.config"
CFLAGS += -Wall -Werror -Os -ffreestanding -nostdinc -nostdlib
all: linuxcheck.elf
$(LIBPAYLOAD_DIR):
$(MAKE) -C ../libpayload $(LPOPTS) defconfig
$(MAKE) -C ../libpayload $(LPOPTS)
$(MAKE) -C ../libpayload $(LPOPTS) install
ifneq ($(strip $(wildcard libpayload)),)
include $(XCOMPILE)
LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc"
%.elf: %.c Makefile
$(LPGCC) $(CFLAGS) -o $*.elf $*.c
else
# If libpayload is not found, first build libpayload,
# then do the make, this time it'll find libpayload
# and generate the linuxcheck.elf target
%.elf: $(LIBPAYLOAD_DIR)
$(MAKE) all
endif
clean:
rm -f linuxcheck.elf
distclean: clean
rm -rf build libpayload .config .config.old
.PHONY: all clean distclean

View file

@ -0,0 +1,43 @@
/*
* This file is part of the coreinfo project.
*
* Copyright (C) 2018 Google Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <libpayload-config.h>
#include <libpayload.h>
extern struct console_output_driver *console_out;
extern struct sysinfo_t lib_sysinfo;
static void buts(char *s)
{
int i;
for (i = 0; i < strlen(s); i++)
outb(s[i], 0x3f8);
}
int main(void)
{
buts("Greetings from linuxcheck, via hard-coded calls to serial functions.\n");
if (console_out == NULL)
buts("Bad news: console_out is NULL\n");
if (lib_sysinfo.serial == NULL)
buts("Bad news: lib_sysinfo.serial is NULL. Very little will work well.\n");
buts("The next line should be puts works\n");
puts("puts works\n");
buts("If you did not see puts works, then you have a console issues\n");
buts("The next line should be 'printf works'\n");
printf("printf works\n");
buts(" ... if you did not see printf works, then you have a printf issue\n");
buts("Now we will halt. Bye");
halt();
return 0;
}

View file

@ -0,0 +1,115 @@
#
# Automatically generated file; DO NOT EDIT.
# Libpayload Configuration
#
#
# Generic Options
#
# CONFIG_LP_GPL is not set
# CONFIG_LP_EXPERIMENTAL is not set
# CONFIG_LP_DEVELOPER is not set
# CONFIG_LP_CHROMEOS is not set
CONFIG_LP_COMPILER_GCC=y
# CONFIG_LP_COMPILER_LLVM_CLANG is not set
# CONFIG_LP_MEMMAP_RAM_ONLY is not set
#
# Architecture Options
#
# CONFIG_LP_ARCH_ARM is not set
CONFIG_LP_ARCH_X86=y
# CONFIG_LP_ARCH_ARM64 is not set
# CONFIG_LP_ARCH_MIPS is not set
# CONFIG_LP_MULTIBOOT is not set
CONFIG_LP_HEAP_SIZE=262144
CONFIG_LP_STACK_SIZE=16384
CONFIG_LP_BASE_ADDRESS=0x00100000
# CONFIG_LP_USE_MARCH_586 is not set
#
# Standard Libraries
#
CONFIG_LP_LIBC=y
CONFIG_LP_CURSES=y
# CONFIG_LP_TINYCURSES is not set
CONFIG_LP_PDCURSES=y
CONFIG_LP_CBFS=y
CONFIG_LP_LZMA=y
CONFIG_LP_LZ4=y
#
# Console Options
#
# CONFIG_LP_SKIP_CONSOLE_INIT is not set
CONFIG_LP_CBMEM_CONSOLE=y
CONFIG_LP_SERIAL_CONSOLE=y
CONFIG_LP_8250_SERIAL_CONSOLE=y
# CONFIG_LP_S5P_SERIAL_CONSOLE is not set
# CONFIG_LP_IPQ806X_SERIAL_CONSOLE is not set
# CONFIG_LP_IPQ40XX_SERIAL_CONSOLE is not set
# CONFIG_LP_BG4CD_SERIAL_CONSOLE is not set
# CONFIG_LP_PL011_SERIAL_CONSOLE is not set
CONFIG_LP_SERIAL_IOBASE=0x3f8
# CONFIG_LP_SERIAL_SET_SPEED is not set
# CONFIG_LP_SERIAL_ACS_FALLBACK is not set
CONFIG_LP_VIDEO_CONSOLE=y
CONFIG_LP_VGA_VIDEO_CONSOLE=y
# CONFIG_LP_GEODELX_VIDEO_CONSOLE is not set
CONFIG_LP_COREBOOT_VIDEO_CONSOLE=y
CONFIG_LP_FONT_SCALE_FACTOR=0
CONFIG_LP_PC_I8042=y
CONFIG_LP_PC_MOUSE=y
CONFIG_LP_PC_KEYBOARD=y
CONFIG_LP_PC_KEYBOARD_LAYOUT_US=y
# CONFIG_LP_PC_KEYBOARD_LAYOUT_DE is not set
#
# Drivers
#
CONFIG_LP_PCI=y
CONFIG_LP_NVRAM=y
CONFIG_LP_MOUSE_CURSOR=y
# CONFIG_LP_RTC_PORT_EXTENDED_VIA is not set
CONFIG_LP_SPEAKER=y
CONFIG_LP_TIMER_RDTSC=y
# CONFIG_LP_TIMER_NONE is not set
# CONFIG_LP_TIMER_MCT is not set
# CONFIG_LP_TIMER_TEGRA_1US is not set
# CONFIG_LP_TIMER_IPQ806X is not set
# CONFIG_LP_TIMER_ARMADA38X is not set
# CONFIG_LP_TIMER_IPQ40XX is not set
# CONFIG_LP_TIMER_ARM64_ARCH is not set
# CONFIG_LP_TIMER_RK3288 is not set
# CONFIG_LP_TIMER_RK3399 is not set
# CONFIG_LP_TIMER_CYGNUS is not set
# CONFIG_LP_TIMER_IMG_PISTACHIO is not set
# CONFIG_LP_TIMER_MTK is not set
# CONFIG_LP_TIMER_MVMAP2315 is not set
CONFIG_LP_TIMER_GENERIC_HZ=0
CONFIG_LP_TIMER_GENERIC_REG=0x0
CONFIG_LP_TIMER_GENERIC_HIGH_REG=0x0
CONFIG_LP_STORAGE=y
# CONFIG_LP_STORAGE_64BIT_LBA is not set
CONFIG_LP_STORAGE_ATA=y
CONFIG_LP_STORAGE_ATAPI=y
CONFIG_LP_STORAGE_AHCI=y
CONFIG_LP_STORAGE_AHCI_ONLY_TESTED=y
CONFIG_LP_USB=y
CONFIG_LP_USB_UHCI=y
CONFIG_LP_USB_OHCI=y
CONFIG_LP_USB_EHCI=y
CONFIG_LP_USB_XHCI=y
# CONFIG_LP_USB_XHCI_MTK_QUIRK is not set
# CONFIG_LP_USB_DWC2 is not set
CONFIG_LP_USB_HID=y
CONFIG_LP_USB_HUB=y
# CONFIG_LP_USB_EHCI_HOSTPC_ROOT_HUB_TT is not set
CONFIG_LP_USB_MSC=y
CONFIG_LP_USB_GEN_HUB=y
CONFIG_LP_USB_PCI=y
# CONFIG_LP_UDC is not set
# CONFIG_LP_BIG_ENDIAN is not set
CONFIG_LP_LITTLE_ENDIAN=y
CONFIG_LP_IO_ADDRESS_SPACE=y
CONFIG_LP_ARCH_SPECIFIC_OPTIONS=y