| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| ## This file is part of the coreboot project. | ||
| ## | ||
| ## Copyright (C) 2017 Facebook 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. | ||
| ## | ||
|
|
||
| if PAYLOAD_LINUXBOOT | ||
|
|
||
| choice | ||
| prompt "Architecture" | ||
| default LINUXBOOT_X86_64 | ||
|
|
||
| config LINUXBOOT_X86_64 | ||
| bool "x86_64" | ||
| help | ||
| AMD64 kernel and initramfs | ||
|
|
||
| config LINUXBOOT_X86 | ||
| bool "x86" | ||
| help | ||
| X86 kernel and initramfs | ||
| endchoice | ||
|
|
||
| config LINUXBOOT_ARCH | ||
| string | ||
| default "amd64" if LINUXBOOT_X86_64 | ||
| default "386" if LINUXBOOT_X86 | ||
|
|
||
| choice | ||
| prompt "Kernel version" | ||
| default LINUXBOOT_KERNEL_STABLE | ||
|
|
||
| config LINUXBOOT_KERNEL_STABLE | ||
| bool "4.15.3" | ||
| help | ||
| Stable kernel version | ||
| endchoice | ||
|
|
||
| config LINUXBOOT_KERNEL_VERSION | ||
| string | ||
| default "4.15.3" if LINUXBOOT_KERNEL_STABLE | ||
|
|
||
| config LINUXBOOT_KERNEL_CONFIGFILE | ||
| string "Kernel config file" | ||
| default "" | ||
| help | ||
| Add your own kernel configuration file. Otherwise a default | ||
| minimal defconfig is used. | ||
|
|
||
| config LINUXBOOT_KERNEL_COMMANDLINE | ||
| string "Kernel command-line" | ||
| default "" | ||
| help | ||
| Add your own kernel command-line arguments. | ||
|
|
||
| config PAYLOAD_FILE | ||
| default "payloads/external/LinuxBoot/linuxboot/kernel-image" | ||
|
|
||
| choice | ||
| prompt "Payload Mode" | ||
| default LINUXBOOT_UROOT | ||
|
|
||
| config LINUXBOOT_UROOT | ||
| bool "u-root" | ||
| help | ||
| Enable u-root linuxboot mode. | ||
| See http://u-root.tk/ for more information. | ||
| endchoice | ||
|
|
||
| if LINUXBOOT_UROOT | ||
|
|
||
| choice | ||
| prompt "U-root version" | ||
| default LINUXBOOT_UROOT_MASTER | ||
|
|
||
| config LINUXBOOT_UROOT_MASTER | ||
| bool "master" | ||
| help | ||
| Latest u-root version | ||
| endchoice | ||
|
|
||
| config LINUXBOOT_UROOT_VERSION | ||
| string | ||
| default "master" if LINUXBOOT_UROOT_MASTER | ||
|
|
||
| config LINUXBOOT_UROOT_COMMANDS | ||
| string "Select u-root commands" | ||
| default "" | ||
| help | ||
| Comma separated list of additional modules to include. Otherwise all modules | ||
| of u-root are included. | ||
|
|
||
| config LINUXBOOT_UROOT_FILES | ||
| string "Add files to u-root base" | ||
| default "" | ||
| help | ||
| Path to directory containing root structure for embedding into the | ||
| initramfs. | ||
|
|
||
| config PAYLOAD_USERSPACE | ||
| string "" | ||
| default "payloads/external/LinuxBoot/linuxboot/initramfs.cpio.xz" | ||
|
|
||
| endif | ||
| endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ## This file is part of the coreboot project. | ||
| ## | ||
| ## Copyright (C) 2017 Facebook 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. | ||
| ## | ||
|
|
||
| config PAYLOAD_LINUXBOOT | ||
| bool "LinuxBoot" | ||
| depends on ARCH_X86 | ||
| help | ||
| Select this option if you want to build a coreboot image | ||
| with a LinuxBoot payload. If you don't know what this is | ||
| about, just leave it enabled. | ||
|
|
||
| See https://coreboot.org/Payloads for more information. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| ## This file is part of the coreboot project. | ||
| ## | ||
| ## Copyright (C) 2017 Facebook 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. | ||
| ## | ||
|
|
||
| kernel_tarball=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$(CONFIG_LINUXBOOT_KERNEL_VERSION).tar.xz | ||
| project_dir=linuxboot | ||
| kernel_dir=$(project_dir)/kernel | ||
|
|
||
| unexport $(COREBOOT_EXPORTS) | ||
|
|
||
| all: payload | ||
|
|
||
| $(kernel_dir)/.config: | ||
| echo " WWW Download Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)" | ||
| mkdir -p $(kernel_dir) | ||
| ifeq ("$(wildcard $(kernel_dir)/README)","") | ||
| wget -qO- $(kernel_tarball) | tar xJ -C $(kernel_dir) --strip 1 | ||
| endif | ||
|
|
||
| config: $(kernel_dir)/.config | ||
| echo " CONFIG Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)" | ||
| ifneq ($(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE),) | ||
| cp $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) $(kernel_dir)/.config | ||
| endif | ||
| ifeq ($(CONFIG_LINUXBOOT_ARCH),386) | ||
| cp x86/defconfig $(kernel_dir)/.config | ||
| else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64) | ||
| cp x86_64/defconfig $(kernel_dir)/.config | ||
| endif | ||
|
|
||
| $(project_dir)/kernel-image: config | ||
| echo " MAKE Kernel $(CONFIG_LINUXBOOT_KERNEL_VERSION)" | ||
| $(MAKE) -C $(kernel_dir) olddefconfig | ||
| $(MAKE) -C $(kernel_dir) -j $(CPUS) | ||
| ifeq ($(CONFIG_LINUXBOOT_ARCH),386) | ||
| cp $(kernel_dir)/arch/x86/boot/bzImage $(project_dir)/kernel-image | ||
| else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64) | ||
| cp $(kernel_dir)/arch/x86/boot/bzImage $(project_dir)/kernel-image | ||
| endif | ||
|
|
||
| payload: $(project_dir)/kernel-image | ||
| ifeq ($(CONFIG_LINUXBOOT_UROOT),y) | ||
| $(MAKE) -f targets/u-root.mk | ||
| endif | ||
|
|
||
| clean: | ||
| if [ -d "$(kernel_dir)" ]; then make -C $(kernel_dir) clean; fi | ||
| rm -f $(project_dir)/initramfs.cpio.xz | ||
|
|
||
| distclean: | ||
| rm -rf $(project_dir) | ||
|
|
||
| .PHONY: config patch payload clean distclean clone fetch all |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| ## This file is part of the coreboot project. | ||
| ## | ||
| ## Copyright (C) 2017 Facebook 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. | ||
| ## | ||
|
|
||
| uroot_git_repo=https://github.com/u-root/u-root.git | ||
| uroot_dir=$(project_dir)/go/src/github.com/u-root/u-root | ||
| go_check=$(shell command -v go 1>/dev/null 2>&1 && echo go) | ||
| project_dir=$(shell pwd)/linuxboot | ||
| project_name=u-root | ||
| go_path_dir=$(shell pwd)/linuxboot/go | ||
|
|
||
| all: build | ||
|
|
||
| check: | ||
| ifneq ($(go_check),go) | ||
| printf "\n<<Please install Golang >= 1.9 for u-root mode>>\n\n" | ||
| exit 1 | ||
| endif | ||
| mkdir -p $(project_dir)/go/src/github.com/u-root | ||
|
|
||
| $(uroot_dir)/.git: | ||
| echo " Git Cloning u-root $(CONFIG_LINUXBOOT_UROOT_VERSION)" | ||
| git clone $(uroot_git_repo) $(uroot_dir) | ||
|
|
||
| fetch: check $(uroot_dir)/.git | ||
| -cd "$(uroot_dir)" && git fetch origin | ||
|
|
||
| checkout: fetch | ||
| cd "$(uroot_dir)" && \ | ||
| if ! git diff --quiet _cb_checkout "$(CONFIG_LINUXBOOT_UROOT_VERSION)" -- 2>/dev/null; \ | ||
| then \ | ||
| printf " CHECKOUT $(project_name) [$(CONFIG_LINUXBOOT_UROOT_VERSION)]\n"; \ | ||
| git checkout $$(git rev-parse HEAD) >/dev/null 2>&1; \ | ||
| git branch -f _cb_checkout "$(CONFIG_LINUXBOOT_UROOT_VERSION)" && \ | ||
| git checkout _cb_checkout && \ | ||
| $(if $(project_patches), \ | ||
| for patch in $(project_patches); do \ | ||
| printf " PATCH $$patch\n"; \ | ||
| git am --keep-cr "$$patch" || \ | ||
| ( printf "Error when applying patches.\n"; \ | ||
| git am --abort; exit 1; ); \ | ||
| done;,true;) \ | ||
| fi | ||
|
|
||
| $(project_dir)/initramfs.cpio.xz: checkout | ||
| cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) go build u-root.go | ||
| echo " MAKE u-root $(CONFIG_LINUXBOOT_UROOT_VERSION)" | ||
| ifneq ($(CONFIG_LINUXBOOT_UROOT_COMMANDS),) | ||
| ifneq ($(CONFIG_LINUXBOOT_UROOT_FILES),) | ||
| cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ | ||
| -build=bb -files $(CONFIG_LINUXBOOT_UROOT_FILES) -o $(project_dir)/initramfs.cpio \ | ||
| ./cmds/{$(CONFIG_LINUXBOOT_UROOT_COMMANDS)} | ||
| else | ||
| cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ | ||
| -build=bb -o $(project_dir)/initramfs.cpio ./cmds/{$(CONFIG_LINUXBOOT_UROOT_COMMANDS)} | ||
| endif | ||
| else | ||
| ifneq ($(CONFIG_LINUXBOOT_UROOT_FILES),) | ||
| cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ | ||
| -build=bb -files $(CONFIG_LINUXBOOT_UROOT_FILES) -o $(project_dir)/initramfs.cpio | ||
| else | ||
| cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ | ||
| -build=bb -o $(project_dir)/initramfs.cpio | ||
| endif | ||
| endif | ||
| xz -f --check=crc32 -9 --lzma2=dict=1MiB --threads=$(CPUS) $(project_dir)/initramfs.cpio | ||
|
|
||
| build: $(project_dir)/initramfs.cpio.xz | ||
|
|
||
| .PHONY: build checkout fetch all check |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| From b652262ed0dd554c44e7b1bf7134d3458f5edef1 Mon Sep 17 00:00:00 2001 | ||
| From: Patrick Rudolph <siro@das-labor.org> | ||
| Date: Sun, 17 Jun 2018 08:44:51 +0200 | ||
| Subject: [PATCH] BaseTools: Fix building with -Werror=stringop-truncation | ||
|
|
||
| Signed-off-by: Patrick Rudolph <siro@das-labor.org> | ||
| --- | ||
| BaseTools/Source/C/GenVtf/GenVtf.c | 6 +++--- | ||
| 1 file changed, 3 insertions(+), 3 deletions(-) | ||
|
|
||
| diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c | ||
| index acc142a6d1..5d77016eba 100644 | ||
| --- a/BaseTools/Source/C/GenVtf/GenVtf.c | ||
| +++ b/BaseTools/Source/C/GenVtf/GenVtf.c | ||
| @@ -129,9 +129,9 @@ Returns: | ||
| } else { | ||
| Length = strlen(Str); | ||
| if (Length < 4) { | ||
| - strncpy (TemStr + 4 - Length, Str, Length); | ||
| + memcpy (TemStr + 4 - Length, Str, Length); | ||
| } else { | ||
| - strncpy (TemStr, Str + Length - 4, 4); | ||
| + memcpy (TemStr, Str + Length - 4, 4); | ||
| } | ||
|
|
||
| sscanf ( | ||
| @@ -1529,7 +1529,7 @@ Returns: | ||
| // | ||
| FitStartPtr = (FIT_TABLE *) RelativeAddress; | ||
|
|
||
| - strncpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "_FIT_ " | ||
| + memcpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "_FIT_ " | ||
| assert (((VtfInfo->CompSize & 0x00FFFFFF) % 16) == 0); | ||
| FitStartPtr->CompSize = (VtfInfo->CompSize & 0x00FFFFFF) / 16; | ||
| FitStartPtr->CompVersion = MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->MinorVer); | ||
| -- | ||
| 2.17.0 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| From 5546ab29b2c0c2fc3a963bc71221918dc77b6152 Mon Sep 17 00:00:00 2001 | ||
| From: Patrick Rudolph <siro@das-labor.org> | ||
| Date: Sun, 17 Jun 2018 08:53:25 +0200 | ||
| Subject: [PATCH] gcc7: Fix building with -fpermissive | ||
|
|
||
| Signed-off-by: Patrick Rudolph <siro@das-labor.org> | ||
| --- | ||
| BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 2 +- | ||
| MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 2 +- | ||
| 2 files changed, 2 insertions(+), 2 deletions(-) | ||
|
|
||
| diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | ||
| index 3ca57ed741..4fa066dd9f 100644 | ||
| --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | ||
| +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | ||
| @@ -3372,7 +3372,7 @@ CVfrStringDB::GetVarStoreNameFormStringId ( | ||
| UINT8 BlockType; | ||
| EFI_HII_STRING_PACKAGE_HDR *PkgHeader; | ||
|
|
||
| - if (mStringFileName == '\0' ) { | ||
| + if (mStringFileName == NULL ) { | ||
| return NULL; | ||
| } | ||
|
|
||
| diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c | ||
| index 857950118f..de0aa5f7bc 100644 | ||
| --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c | ||
| +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c | ||
| @@ -2181,7 +2181,7 @@ InternalHiiIfrValueAction ( | ||
|
|
||
| StringPtr = ConfigAltResp; | ||
|
|
||
| - while (StringPtr != L'\0') { | ||
| + while (StringPtr != NULL) { | ||
| // | ||
| // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=... | ||
| // | ||
| -- | ||
| 2.17.0 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| CONFIG_LP_CHROMEOS=y | ||
| CONFIG_LP_ARCH_ARM64=y | ||
| CONFIG_LP_TIMER_ARM64_ARCH=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * This file is part of the libpayload project. | ||
| * | ||
| * Copyright 2018 Google LLC. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions | ||
| * are met: | ||
| * 1. Redistributions of source code must retain the above copyright | ||
| * notice, this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright | ||
| * notice, this list of conditions and the following disclaimer in the | ||
| * documentation and/or other materials provided with the distribution. | ||
| * 3. The name of the author may not be used to endorse or promote products | ||
| * derived from this software without specific prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
| * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| * SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #ifndef __DRIVERS_I8042_I8042_H__ | ||
| #define __DRIVERS_I8042_I8042_H__ | ||
|
|
||
| /* Port 0x64 commands */ | ||
| #define I8042_CMD_RD_CMD_BYTE 0x20 | ||
| #define I8042_CMD_WR_CMD_BYTE 0x60 | ||
| #define I8042_CMD_DIS_AUX 0xa7 | ||
| #define I8042_CMD_EN_AUX 0xa8 | ||
| #define I8042_CMD_AUX_TEST 0xa9 | ||
| #define I8042_CMD_SELF_TEST 0xaa | ||
| #define I8042_SELF_TEST_RSP 0x55 | ||
| #define I8042_CMD_KB_TEST 0xab | ||
| #define I8042_CMD_DIAG_DUMP 0xac | ||
| #define I8042_CMD_DIS_KB 0xad | ||
| #define I8042_CMD_EN_KB 0xae | ||
| #define I8042_CMD_RD_INPUT_PORT 0xc0 | ||
| #define I8042_CMD_RD_OUTPUT_PORT 0xd0 | ||
| #define I8042_CMD_WR_OUTPUT_PORT 0xd1 | ||
| #define I8042_CMD_RD_TEST_INPUTS 0xe0 | ||
|
|
||
| /* Port 0x60 keyboard commands */ | ||
| #define I8042_KBCMD_SET_MODE_IND 0xed | ||
| #define I8042_MODE_CAPS_LOCK_ON (1 << 2) | ||
| #define I8042_MODE_CAPS_LOCK_OFF (0 << 2) | ||
| #define I8042_MODE_NUM_LOCK_ON (1 << 1) | ||
| #define I8042_MODE_NUM_LOCK_OFF (0 << 1) | ||
| #define I8042_MODE_SCROLL_LOCK_ON (1 << 0) | ||
| #define I8042_MODE_SCROLL_LOCK_OFF (0 << 0) | ||
| #define I8042_KBCMD_SET_SCANCODE 0xf0 | ||
| #define I8042_SCANCODE_SET_1 (1) | ||
| #define I8042_SCANCODE_SET_2 (2) | ||
| #define I8042_SCANCODE_SET_3 (3) | ||
| #define I8042_KBCMD_SET_TYPEMATIC 0xf3 | ||
| #define I8042_KBCMD_EN 0xf4 | ||
| #define I8042_KBCMD_DEFAULT_DIS 0xf5 | ||
| #define I8042_KBCMD_SET_DEFAULT 0xf6 | ||
| #define I8042_KBCMD_RESEND 0xfe | ||
| #define I8042_KBCMD_RESET 0xff | ||
|
|
||
| #endif /* __DRIVERS_I8042_I8042_H__ */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,17 +321,3 @@ void mmu_enable(void) | |
| raw_write_sctlr_el3(sctlr); | ||
| isb(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,262 @@ | ||
| /* | ||
| * Copyright 2013 Google Inc. | ||
| * Copyright 2018 Facebook, 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; either version 2 of | ||
| * the License, or (at your option) any later version. | ||
| * | ||
| * 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 <console/console.h> | ||
| #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> | ||
| #include <fit.h> | ||
| #include <endian.h> | ||
|
|
||
| #define MAX_KERNEL_SIZE (64*MiB) | ||
|
|
||
| struct arm64_kernel_header { | ||
| u32 code0; | ||
| u32 code1; | ||
| u64 text_offset; | ||
| u64 image_size; | ||
| u64 flags; | ||
| u64 res2; | ||
| u64 res3; | ||
| u64 res4; | ||
| u32 magic; | ||
| #define KERNEL_HEADER_MAGIC 0x644d5241 | ||
| u32 res5; | ||
| }; | ||
|
|
||
| static struct { | ||
| union { | ||
| struct arm64_kernel_header header; | ||
| u8 raw[sizeof(struct arm64_kernel_header) + 0x100]; | ||
| }; | ||
| #define SCRATCH_CANARY_VALUE 0xdeadbeef | ||
| u32 canary; | ||
| } scratch; | ||
|
|
||
| /* Returns true if decompressing was successful and it looks like a kernel. */ | ||
| static bool decompress_kernel_header(const struct fit_image_node *node) | ||
| { | ||
| /* Partially decompress to get text_offset. Can't check for errors. */ | ||
| scratch.canary = SCRATCH_CANARY_VALUE; | ||
| switch (node->compression) { | ||
| case CBFS_COMPRESS_NONE: | ||
| memcpy(scratch.raw, node->data, sizeof(scratch.raw)); | ||
| break; | ||
| case CBFS_COMPRESS_LZMA: | ||
| ulzman(node->data, node->size, | ||
| scratch.raw, sizeof(scratch.raw)); | ||
| break; | ||
| case CBFS_COMPRESS_LZ4: | ||
| ulz4fn(node->data, node->size, | ||
| scratch.raw, sizeof(scratch.raw)); | ||
| break; | ||
| default: | ||
| printk(BIOS_ERR, "ERROR: Unsupported compression algorithm!\n"); | ||
| return false; | ||
| } | ||
|
|
||
| /* Should never happen, but if it does we'll want to know. */ | ||
| if (scratch.canary != SCRATCH_CANARY_VALUE) | ||
| die("ERROR: Partial decompression ran over scratchbuf!\n"); | ||
|
|
||
| if (scratch.header.magic != KERNEL_HEADER_MAGIC) { | ||
| printk(BIOS_ERR, | ||
| "ERROR: Invalid kernel magic: %#.8x\n != %#.8x\n", | ||
| scratch.header.magic, KERNEL_HEADER_MAGIC); | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Prior to v3.17, the endianness of text_offset was not specified. In | ||
| * these cases image_size is zero and text_offset is 0x80000 in the | ||
| * endianness of the kernel. Where image_size is non-zero image_size is | ||
| * little-endian and must be respected. Where image_size is zero, | ||
| * text_offset can be assumed to be 0x80000. | ||
| */ | ||
| if (!scratch.header.image_size) | ||
| scratch.header.text_offset = cpu_to_le64(0x80000); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| static size_t get_kernel_size(const struct fit_image_node *node) | ||
| { | ||
| if (scratch.header.image_size) | ||
| return le64_to_cpu(scratch.header.image_size); | ||
|
|
||
| /** | ||
| * When image_size is zero, a bootloader should attempt to keep as much | ||
| * memory as possible free for use by the kernel immediately after the | ||
| * end of the kernel image. The amount of space required will vary | ||
| * depending on selected features, and is effectively unbound. | ||
| */ | ||
|
|
||
| printk(BIOS_WARNING, "FIT: image_size not set in kernel header.\n" | ||
| "Leaving additional %u MiB of free space after kernel.\n", | ||
| MAX_KERNEL_SIZE >> 20); | ||
|
|
||
| return node->size + MAX_KERNEL_SIZE; | ||
| } | ||
|
|
||
| static bool fit_place_kernel(const struct range_entry *r, void *arg) | ||
| { | ||
| struct region *region = arg; | ||
| resource_t start; | ||
|
|
||
| if (range_entry_tag(r) != BM_MEM_RAM) | ||
| return true; | ||
|
|
||
| /** | ||
| * The Image must be placed text_offset bytes from a 2MB aligned base | ||
| * address anywhere in usable system RAM and called there. The region | ||
| * between the 2 MB aligned base address and the start of the image has | ||
| * no special significance to the kernel, and may be used for other | ||
| * purposes. | ||
| * | ||
| * If the reserved memory (BL31 for example) is smaller than text_offset | ||
| * we can use the 2 MiB base address, otherwise use the next 2 MiB page. | ||
| * It's not mandatory, but wastes less memory below the kernel. | ||
| */ | ||
| start = ALIGN_DOWN(range_entry_base(r), 2 * MiB) + | ||
| le64_to_cpu(scratch.header.text_offset); | ||
|
|
||
| if (start < range_entry_base(r)) | ||
| start += 2 * MiB; | ||
| /** | ||
| * At least image_size bytes from the start of the image must be free | ||
| * for use by the kernel. | ||
| */ | ||
| if (start + region->size < range_entry_end(r)) { | ||
| region->offset = (size_t)start; | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Place the region in free memory range. | ||
| * | ||
| * The caller has to set region->offset to the minimum allowed address. | ||
| * The region->offset is usually 0 on kernel >v4.6 and kernel_base + kernel_size | ||
| * on kernel <v4.6. | ||
| */ | ||
| static bool fit_place_mem(const struct range_entry *r, void *arg) | ||
| { | ||
| struct region *region = arg; | ||
| resource_t start; | ||
|
|
||
| if (range_entry_tag(r) != BM_MEM_RAM) | ||
| return true; | ||
|
|
||
| /* Linux 4.15 doesn't like 4KiB alignment. Align to 1 MiB for now. */ | ||
| start = ALIGN_UP(MAX(region->offset, range_entry_base(r)), 1 * MiB); | ||
|
|
||
| if (start + region->size < range_entry_end(r)) { | ||
| region->offset = (size_t)start; | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool fit_payload_arch(struct prog *payload, struct fit_config_node *config, | ||
| struct region *kernel, | ||
| struct region *fdt, | ||
| struct region *initrd) | ||
| { | ||
| bool place_anywhere; | ||
| void *arg = NULL; | ||
|
|
||
| if (!config->fdt || !fdt) { | ||
| printk(BIOS_CRIT, "CRIT: Providing a valid FDT is mandatory to " | ||
| "boot an ARM64 kernel!\n"); | ||
| return false; | ||
| } | ||
|
|
||
| if (!decompress_kernel_header(config->kernel_node)) { | ||
| printk(BIOS_CRIT, "CRIT: Payload doesn't look like an ARM64" | ||
| " kernel Image.\n"); | ||
| return false; | ||
| } | ||
|
|
||
| /* Update kernel size from image header, if possible */ | ||
| kernel->size = get_kernel_size(config->kernel_node); | ||
| printk(BIOS_DEBUG, "FIT: Using kernel size of 0x%zx bytes\n", | ||
| kernel->size); | ||
|
|
||
| /** | ||
| * The code assumes that bootmem_walk provides a sorted list of memory | ||
| * regions, starting from the lowest address. | ||
| * The order of the calls here doesn't matter, as the placement is | ||
| * enforced in the called functions. | ||
| * For details check code on top. | ||
| */ | ||
|
|
||
| if (!bootmem_walk(fit_place_kernel, kernel)) | ||
| return false; | ||
|
|
||
| /* Mark as reserved for future allocations. */ | ||
| bootmem_add_range(kernel->offset, kernel->size, BM_MEM_PAYLOAD); | ||
|
|
||
| /** | ||
| * NOTE: versions prior to v4.6 cannot make use of memory below the | ||
| * physical offset of the Image so it is recommended that the Image be | ||
| * placed as close as possible to the start of system RAM. | ||
| * | ||
| * For kernel <v4.6 the INITRD and FDT can't be placed below the kernel. | ||
| * In that case set region offset to an address on top of kernel. | ||
| */ | ||
| place_anywhere = !!(le64_to_cpu(scratch.header.flags) & (1 << 3)); | ||
| printk(BIOS_DEBUG, "FIT: Placing FDT and INITRD %s\n", | ||
| place_anywhere ? "anywhere" : "on top of kernel"); | ||
|
|
||
| /* Place INITRD */ | ||
| if (config->ramdisk) { | ||
| if (place_anywhere) | ||
| initrd->offset = 0; | ||
| else | ||
| initrd->offset = kernel->offset + kernel->size; | ||
|
|
||
| if (!bootmem_walk(fit_place_mem, initrd)) | ||
| return false; | ||
| /* Mark as reserved for future allocations. */ | ||
| bootmem_add_range(initrd->offset, initrd->size, BM_MEM_PAYLOAD); | ||
| } | ||
|
|
||
| /* Place FDT */ | ||
| if (place_anywhere) | ||
| fdt->offset = 0; | ||
| else | ||
| fdt->offset = kernel->offset + kernel->size; | ||
|
|
||
| if (!bootmem_walk(fit_place_mem, fdt)) | ||
| return false; | ||
| /* Mark as reserved for future allocations. */ | ||
| bootmem_add_range(fdt->offset, fdt->size, BM_MEM_PAYLOAD); | ||
|
|
||
| /* Kernel expects FDT as argument */ | ||
| arg = (void *)fdt->offset; | ||
|
|
||
| prog_set_entry(payload, (void *)kernel->offset, arg); | ||
|
|
||
| bootmem_dump_ranges(); | ||
|
|
||
| return true; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,6 @@ | |
| */ | ||
|
|
||
| #include <stdlib.h> | ||
| #include <cbmem.h> | ||
| #include <compiler.h> | ||
| #include <arch/acpi.h> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * This file is part of the coreboot project. | ||
| * | ||
| * Copyright 2018 Google LLC | ||
| * | ||
| * 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 <stddef.h> | ||
| #include <stdint.h> | ||
| #include <cpu/x86/smm.h> | ||
|
|
||
| /* | ||
| * calls into SMM with the given cmd and subcmd in eax, and arg in ebx | ||
| * | ||
| * static inline because the resulting assembly is often smaller than | ||
| * the call sequence due to constant folding. | ||
| */ | ||
| static inline u32 call_smm(u8 cmd, u8 subcmd, void *arg) | ||
| { | ||
| u32 res = 0; | ||
| __asm__ __volatile__ ( | ||
| "outb %b0, %3" | ||
| : "=a" (res) | ||
| : "a" ((subcmd << 8) | cmd), "b" (arg), "i" (APM_CNT)); | ||
| return res; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ | |
| */ | ||
|
|
||
| #include <arch/cache.h> | ||
| #include "bouncebuf.h" | ||
| #include <halt.h> | ||
| #include "storage.h" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,6 @@ | |
| */ | ||
|
|
||
| #include <commonlib/storage.h> | ||
| #include <delay.h> | ||
| #include "sd_mmc.h" | ||
| #include "mmc.h" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| * GNU General Public License for more details. | ||
| */ | ||
|
|
||
| #include "sd_mmc.h" | ||
| #include "storage.h" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ if ARCH_X86 | |
|
|
||
| config CACHE_AS_RAM | ||
| bool | ||
| default y | ||
|
|
||
| config NO_CAR_GLOBAL_MIGRATION | ||
| bool | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,11 @@ | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_F_1207) += socket_F_1207 | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_AM2R2) += socket_AM2r2 | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_AM3) += socket_AM3 | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_ASB2) += socket_ASB2 | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_C32_NON_AGESA) += socket_C32 | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_FM2_NON_AGESA) += socket_FM2 | ||
| subdirs-$(CONFIG_CPU_AMD_SOCKET_G34_NON_AGESA) += socket_G34 | ||
| subdirs-$(CONFIG_CPU_AMD_GEODE_LX) += geode_lx | ||
|
|
||
| subdirs-$(CONFIG_CPU_AMD_AGESA) += agesa | ||
| subdirs-$(CONFIG_CPU_AMD_PI) += pi |