summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2014-12-12 02:17:10 +0100
committerWei Xu <xuwei5@huawei.com>2014-12-17 16:58:20 +0800
commitf9bbfcb9ee24e9d3540b03a3b10352c05d7b36ac (patch)
tree7353c724bd62e2bbd09d1139406077510b64518a
parentccdc4cc7e4e884a5a1eb25451363e38a3091c775 (diff)
HisiPkg: D01: Move bootwrapper to SRAM
Reserving DDR memory is a very tricky thing to do. We always need to make sure we don't overlap with memory regions the guest uncondionally uses. However, we need to keep the bootwrapper code resident in memory for CPU hotplug. So let's just move it into SRAM. There it can stay happily ever after. Unfortunately we need to make sure we only copy the bootwrapper to SRAM, not a full NAND block. So this patch also introduces a bounce buffer for NAND access. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Wei Xu <xuwei5@huawei.com>
-rw-r--r--HisiPkg/D01BoardPkg/Bds/Bds.c28
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BdsInternal.h4
-rw-r--r--HisiPkg/D01BoardPkg/Bds/BootMenu.c6
3 files changed, 26 insertions, 12 deletions
diff --git a/HisiPkg/D01BoardPkg/Bds/Bds.c b/HisiPkg/D01BoardPkg/Bds/Bds.c
index 4e2e34679..1792fccbc 100644
--- a/HisiPkg/D01BoardPkg/Bds/Bds.c
+++ b/HisiPkg/D01BoardPkg/Bds/Bds.c
@@ -80,8 +80,8 @@ BootGo (
#define FILESYSTEM_SIZE 0x1800000
//actual size of copying file to DDR, it should not bigger than estimate size
-#define TEXT_COPY_SIZE 0x20000
-#define MONITOR_COPY_SIZE 0x20000
+#define TEXT_COPY_SIZE 0x8000
+#define MONITOR_COPY_SIZE 0x8000
#define KERNEL_COPY_SIZE 0xa00000
#define FILESYSTEM_COPY_SIZE 0x1800000
@@ -552,26 +552,40 @@ EFI_STATUS CopyNandToMem(void* Dest, UINT32 StartBlockNum, UINT32 LengthCopy)
static void ReadBootwrapper(void)
{
- (VOID)AsciiPrint("\nCopy BootWrapper from FLASH to DDR...");
+ void *buf;
+ NAND_CMD_INFO_STRU ulNandCMDInfo = { 0 };
+ #ifdef NANDFLASHREAD
+ EFI_NAND_DRIVER_PROTOCOL *nandDriver = NULL;
+
+ gBS->LocateProtocol (&gNANDDriverProtocolGuid, NULL, (VOID *) &nandDriver);
+ ulNandCMDInfo = nandDriver->NandFlashGetCMDInfo(nandDriver);
+ #endif
+ buf = AllocatePool(ulNandCMDInfo.ulBlockSize);
+
+ (VOID)AsciiPrint("\nCopy Bootwrapper from FLASH to SRAM...");
#ifdef NANDFLASHREAD
- CopyNandToMem((void *)TEXT_DDR_BASE, TEXT_BLOCKNUM_NANDFLASH, TEXT_COPY_SIZE);
+ CopyNandToMem(buf, TEXT_BLOCKNUM_NANDFLASH, ulNandCMDInfo.ulBlockSize);
+ memcpy((void *)TEXT_SRAM_BASE, buf, TEXT_COPY_SIZE);
(VOID)AsciiPrint("\nThe .text file is transmitted ok!\n");
#else
/* copy.text */
- memcpy((void *)TEXT_DDR_BASE, (void *)TEXT_FLASH_BASE, TEXT_COPY_SIZE);
+ memcpy((void *)TEXT_SRAM_BASE, (void *)TEXT_FLASH_BASE, TEXT_COPY_SIZE);
(VOID)AsciiPrint("\nThe .text file is transmitted ok!\n");
#endif
#ifdef NANDFLASHREAD
/* copy .monitor */
- CopyNandToMem((void *)MONITOR_DDR_BASE, MONITOR_BLOCKNUM_NANDFLASH, MONITOR_COPY_SIZE);
+ CopyNandToMem(buf, MONITOR_BLOCKNUM_NANDFLASH, ulNandCMDInfo.ulBlockSize);
+ memcpy((void *)MONITOR_SRAM_BASE, buf, MONITOR_COPY_SIZE);
(VOID)AsciiPrint("The .monitor file is transmitted ok!\n");
#else
/* copy .monitor */
- memcpy((void *)MONITOR_DDR_BASE, (void *)MONITOR_FLASH_BASE, MONITOR_COPY_SIZE);
+ memcpy((void *)MONITOR_SRAM_BASE, (void *)MONITOR_FLASH_BASE, MONITOR_COPY_SIZE);
(VOID)AsciiPrint("The .monitor file is transmitted ok!\n");
#endif
+
+ gBS->FreePool(buf);
}
/**
diff --git a/HisiPkg/D01BoardPkg/Bds/BdsInternal.h b/HisiPkg/D01BoardPkg/Bds/BdsInternal.h
index 7481a8eaa..0b0d11ef4 100644
--- a/HisiPkg/D01BoardPkg/Bds/BdsInternal.h
+++ b/HisiPkg/D01BoardPkg/Bds/BdsInternal.h
@@ -38,8 +38,8 @@
#define BOOT_DEVICE_ADDRESS_MAX (sizeof(L"0x0000000000000000"))
//address of Linux in DDR
-#define TEXT_DDR_BASE 0x10c00000
-#define MONITOR_DDR_BASE 0x10c08000
+#define TEXT_SRAM_BASE 0xe00f0000
+#define MONITOR_SRAM_BASE 0xe00f8000
#define KERNEL_DDR_BASE 0x10008000
#define FILESYSTEM_DDR_BASE 0x10d00000
diff --git a/HisiPkg/D01BoardPkg/Bds/BootMenu.c b/HisiPkg/D01BoardPkg/Bds/BootMenu.c
index 4bc9cda82..c5380cb2b 100644
--- a/HisiPkg/D01BoardPkg/Bds/BootMenu.c
+++ b/HisiPkg/D01BoardPkg/Bds/BootMenu.c
@@ -772,14 +772,14 @@ BootLinuxAtagLoader (
EFI_STATUS LoadLinuxAtSecEnd()
{
- LinuxEntry entry = (LinuxEntry)(TEXT_DDR_BASE);
+ LinuxEntry entry = (LinuxEntry)(TEXT_SRAM_BASE);
EFI_STATUS Status = EFI_SUCCESS;
ArmDisableDataCache();
ArmCleanInvalidateDataCache();
ArmDisableInstructionCache ();
ArmInvalidateInstructionCache ();
ArmDisableMmu();
- DEBUG(( EFI_D_ERROR, "MOVE PC TEXT_DDR_BASE\n"));
+ DEBUG(( EFI_D_ERROR, "MOVE PC TEXT_SRAM_BASE\n"));
(void)entry();
return Status;
}
@@ -791,7 +791,7 @@ EFI_STATUS RunBootwrapper()
*(UINTN*)(UINTN)(0xe302b000 + 0x18) = 0;
*(UINTN*)(UINTN)(0xe302b000 + 0x1c) = 0;
- *(volatile UINT32 *)(0xe0000000 + 0x100) = TEXT_DDR_BASE;
+ *(volatile UINT32 *)(0xe0000000 + 0x100) = TEXT_SRAM_BASE;
ArmCleanDataCache();
*(UINT8*)(0xf4007000) = 'G';