summaryrefslogtreecommitdiff
path: root/Silicon/AMD/Styx/Applications
diff options
context:
space:
mode:
Diffstat (limited to 'Silicon/AMD/Styx/Applications')
-rw-r--r--Silicon/AMD/Styx/Applications/StyxFlashUefi/Scripts/GccBase.lds86
-rw-r--r--Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashImage.S25
-rw-r--r--Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.c96
-rw-r--r--Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.inf53
4 files changed, 260 insertions, 0 deletions
diff --git a/Silicon/AMD/Styx/Applications/StyxFlashUefi/Scripts/GccBase.lds b/Silicon/AMD/Styx/Applications/StyxFlashUefi/Scripts/GccBase.lds
new file mode 100644
index 0000000000..7a0c87c6e3
--- /dev/null
+++ b/Silicon/AMD/Styx/Applications/StyxFlashUefi/Scripts/GccBase.lds
@@ -0,0 +1,86 @@
+/** @file
+
+ Unified linker script for GCC based builds
+
+ Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2017, Linaro Ltd. All rights reserved.<BR>
+ (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+SECTIONS {
+
+ /*
+ * The PE/COFF binary consists of DOS and PE/COFF headers, and a sequence of
+ * section headers adding up to PECOFF_HEADER_SIZE bytes (which differs
+ * between 32-bit and 64-bit builds). The actual start of the .text section
+ * will be rounded up based on its actual alignment.
+ */
+ . = PECOFF_HEADER_SIZE;
+
+ .text : ALIGN(CONSTANT(COMMONPAGESIZE)) {
+ *(.text .text.* .stub .gnu.linkonce.t.*)
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ *(.got .got.*)
+
+ /*
+ * The contents of AutoGen.c files are mostly constant from the POV of the
+ * program, but most of it ends up in .data or .bss by default since few of
+ * the variable definitions that get emitted are declared as CONST.
+ * Unfortunately, we cannot pull it into the .text section entirely, since
+ * patchable PCDs are also emitted here, but we can at least move all of the
+ * emitted GUIDs here.
+ */
+ *:AutoGen.obj(.data.g*Guid)
+ }
+
+ /*
+ * The alignment of the .data section should be less than or equal to the
+ * alignment of the .text section. This ensures that the relative offset
+ * between these sections is the same in the ELF and the PE/COFF versions of
+ * this binary.
+ */
+ .data ALIGN(ALIGNOF(.text)) : ALIGN(CONSTANT(COMMONPAGESIZE)) {
+ *(.data .data.* .gnu.linkonce.d.*)
+ *(.bss .bss.*)
+ *(.payload)
+ }
+
+ .eh_frame ALIGN(CONSTANT(COMMONPAGESIZE)) : {
+ KEEP (*(.eh_frame))
+ }
+
+ .rela (INFO) : {
+ *(.rela .rela.*)
+ }
+
+ .hii : ALIGN(CONSTANT(COMMONPAGESIZE)) {
+ KEEP (*(.hii))
+ }
+
+ /*
+ * Retain the GNU build id but in a non-allocatable section so GenFw
+ * does not copy it into the PE/COFF image.
+ */
+ .build-id (INFO) : { *(.note.gnu.build-id) }
+
+ /DISCARD/ : {
+ *(.note.GNU-stack)
+ *(.gnu_debuglink)
+ *(.interp)
+ *(.dynsym)
+ *(.dynstr)
+ *(.dynamic)
+ *(.hash .gnu.hash)
+ *(.comment)
+ *(COMMON)
+ }
+}
diff --git a/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashImage.S b/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashImage.S
new file mode 100644
index 0000000000..041339ee9b
--- /dev/null
+++ b/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashImage.S
@@ -0,0 +1,25 @@
+/** @file
+
+ Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+ .section ".payload"
+ .align 12
+
+ASM_GLOBAL ASM_PFX(StyxFlashImageStart)
+ASM_PFX(StyxFlashImageStart):
+ .incbin "STYX_EFI.Fv"
+
+ .align 2
+ASM_GLOBAL ASM_PFX(StyxFlashImageSize)
+ASM_PFX(StyxFlashImageSize):
+ .long . - ASM_PFX(StyxFlashImageStart)
diff --git a/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.c b/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.c
new file mode 100644
index 0000000000..8f181bc2a5
--- /dev/null
+++ b/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.c
@@ -0,0 +1,96 @@
+/** @file
+
+ Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/ShellCEntryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/AmdIscpDxeProtocol.h>
+
+#define UEFI_IMAGE_OFFSET FixedPcdGet64 (PcdFvBaseAddress) - FixedPcdGet64 (PcdFdBaseAddress)
+#define BLOCK_SIZE SIZE_64KB
+
+STATIC AMD_ISCP_DXE_PROTOCOL *mIscpDxeProtocol;
+STATIC UINT8 Buffer[BLOCK_SIZE];
+
+extern CONST UINT8 StyxFlashImageStart[];
+extern CONST UINT32 StyxFlashImageSize;
+
+/***
+ Main entrypoint
+
+ Establishes the main structure of the application.
+
+ @retval 0 The application exited normally.
+ @retval Other An error occurred.
+***/
+INTN
+EFIAPI
+ShellAppMain (
+ IN UINTN Argc,
+ IN CHAR16 **Argv
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ INTN Remaining;
+
+ Print (L"StyxFlashUefi: firmware updater for AMD Seattle based boards.\n");
+
+ Status = gBS->LocateProtocol (&gAmdIscpDxeProtocolGuid, NULL,
+ (VOID **)&mIscpDxeProtocol);
+ if (EFI_ERROR (Status)) {
+ Print (L"Failed to locate ISCP communication protocol, terminating...\n");
+ return (INTN)Status;
+ }
+
+ Index = 0;
+ Remaining = StyxFlashImageSize;
+ do {
+ Status = mIscpDxeProtocol->AmdExecuteEraseFvBlockDxe (
+ mIscpDxeProtocol,
+ UEFI_IMAGE_OFFSET + Index * BLOCK_SIZE,
+ BLOCK_SIZE);
+ if (EFI_ERROR (Status)) {
+ Print (L"Erase failed!\n");
+ return (INTN)Status;
+ }
+
+ CopyMem (Buffer, StyxFlashImageStart + Index * BLOCK_SIZE,
+ MIN (Remaining, BLOCK_SIZE));
+
+ Status = mIscpDxeProtocol->AmdExecuteUpdateFvBlockDxe (
+ mIscpDxeProtocol,
+ UEFI_IMAGE_OFFSET + Index * BLOCK_SIZE,
+ Buffer,
+ MIN (Remaining, BLOCK_SIZE));
+
+ if (EFI_ERROR (Status)) {
+ Print (L"Update failed!\n");
+ return (INTN)Status;
+ }
+
+ Remaining -= BLOCK_SIZE;
+ Index++;
+
+ Print (L"Block %d of %d updated\n", Index, StyxFlashImageSize / BLOCK_SIZE);
+
+ } while (Remaining > 0);
+
+ Print (L"\nDone!\n");
+
+ return 0;
+}
diff --git a/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.inf b/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.inf
new file mode 100644
index 0000000000..582b57b2c8
--- /dev/null
+++ b/Silicon/AMD/Styx/Applications/StyxFlashUefi/StyxFlashUefi.inf
@@ -0,0 +1,53 @@
+#/** @file
+#
+# Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010019
+ BASE_NAME = StyxFlashUefi
+ FILE_GUID = 07b65d9d-b1a2-416e-bd04-0b61b775f924
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 0.1
+ ENTRY_POINT = ShellCEntryLib
+
+#
+# VALID_ARCHITECTURES = AARCH64
+#
+
+[Sources]
+ StyxFlashImage.S
+ StyxFlashUefi.c
+
+[Packages]
+ AmdModulePkg/AmdModulePkg.dec
+ ArmPkg/ArmPkg.dec
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ ShellCEntryLib
+ UefiBootServicesTableLib
+ UefiLib
+
+[Protocols]
+ gAmdIscpDxeProtocolGuid
+
+[FixedPcd]
+ gArmTokenSpaceGuid.PcdFdBaseAddress
+ gArmTokenSpaceGuid.PcdFvBaseAddress
+
+[BuildOptions]
+ *_*_*_CC_FLAGS = -mcmodel=small
+ *_*_*_DLINK_FLAGS = -z common-page-size=0x1000 -Wl,-T,$(MODULE_DIR)/Scripts/GccBase.lds
+ *_*_*_PLATFORM_FLAGS = -I$(BIN_DIR)/../FV