From patchwork Tue Dec 15 22:22:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 58468 Delivered-To: patches@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp327864lbb; Tue, 15 Dec 2015 14:22:36 -0800 (PST) X-Received: by 10.98.13.134 with SMTP id 6mr461770pfn.48.1450218155850; Tue, 15 Dec 2015 14:22:35 -0800 (PST) Return-Path: Received: from mail-pa0-x232.google.com (mail-pa0-x232.google.com. [2607:f8b0:400e:c03::232]) by mx.google.com with ESMTPS id ra2si4355916pab.209.2015.12.15.14.22.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Dec 2015 14:22:35 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c03::232 as permitted sender) client-ip=2607:f8b0:400e:c03::232; Authentication-Results: mx.google.com; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c03::232 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-pa0-x232.google.com with SMTP id wq6so12157136pac.1 for ; Tue, 15 Dec 2015 14:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3lzGSpBYKRpqlYd2XFeX26h4EKmGwzc4QIGxkTrDvy4=; b=j/lSslYDLi4pZb8D8NuadPqtP2URsXG7mQMdaxQnXNMW/Xo5uwAKsGQiiEZ9TIOpbb aTq+d7uz/OYrtY3t5D2Dpjg3WyrFWd2QhcAyRQGt/xIGkJ1yGOQ4/OphLzYBEj9hS4FL Lqc6YowGg+rQOYRxA3HhwCLht26aKMxz4mQTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3lzGSpBYKRpqlYd2XFeX26h4EKmGwzc4QIGxkTrDvy4=; b=LOr9aKqJ2FyXqK2NMsfqU0JO8CHiUUi8laoJvUHdROmL9ioL+E+I87vH32G9YUl1wE fdGb2LeOshHlfK+vcLwXCsnqEekYKM3BDw9FwX5UHtA9EGjYrPuW4z6Jltj36rvWRNDu xM5TkIhDh7dycL8r6eIGq5p89biF2y6a0LfPgTVL/snB+56oblBXelzH71Nris29SehZ HQe3KzCvrnnq2W+LFmSbfdhyooJ1KC04JV59xOFuf8Q6YRRh1E3+BIR554vgfbXkbwH4 ehY/uCnKqjkMcyyI+QCFweLCy8f1CpJYKhUagjNDnBzuSn2nDfbSUNY7u10GeOOCYOtR kWCA== X-Gm-Message-State: ALoCoQlpJlorzJwoPj+xtpRziBv9cAvnEArJN22IVQerDaujyu/bJ/VphX9vw/DV1atCO3QJZXieAVH+Q01rqi5TPEZ4oe2CsA== X-Received: by 10.66.90.194 with SMTP id by2mr58155703pab.2.1450218155441; Tue, 15 Dec 2015 14:22:35 -0800 (PST) Return-Path: Received: from localhost.localdomain (c-76-115-103-22.hsd1.or.comcast.net. [76.115.103.22]) by smtp.gmail.com with ESMTPSA id q14sm160031pfa.45.2015.12.15.14.22.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Dec 2015 14:22:34 -0800 (PST) From: John Stultz To: dev@lists.96boards.org Cc: John Stultz , Vishal Bhoj , haojian.zhuang@linaro.org, guodong.xu@linaro.org Subject: [RFC][PATCH] linaro-edk2: Enable "adb reboot bootloader" support Date: Tue, 15 Dec 2015 14:22:26 -0800 Message-Id: <1450218146-8447-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 This allows the bootloader to user a reserved page to read if the kernel requested we boot into fastboot mode or normal bootup. This allows users to reboot into fastboot mode w/o having to modify jumpers on J15 This change requires the kernel to support the communication of the reboot reason to the bootloader. I'm really not sure the method I'm using here is right (ie: setting a pointer to a physaddr and reading/writing to it). So any extra feedback or review would be appreciated! Cc: Vishal Bhoj Cc: haojian.zhuang@linaro.org Cc: guodong.xu@linaro.org Signed-off-by: John Stultz --- .../HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 26 ++++++++++++++++++++++ HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c | 1 + 2 files changed, 27 insertions(+) -- 1.9.1 diff --git a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c index 84fdea1..90507d2 100644 --- a/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c +++ b/HisiPkg/HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c @@ -375,6 +375,31 @@ HiKeyTestLed ( } } + +#define REBOOT_REASON_ADDR 0x05F01000 +#define REBOOT_REASON_BOOTLOADER 0x77665500 +#define REBOOT_REASON_NONE 0x77665501 +STATIC +VOID +EFIAPI +HiKeyDetectRebootReason ( + IN VOID + ) +{ + UINT32 *addr = (UINT32*)REBOOT_REASON_ADDR; + UINT32 val; + + val = *addr; + /* Check to see if "reboot booloader" was specified */ + if (val == REBOOT_REASON_BOOTLOADER) { + mBootIndex = 0; + } + /* Write NONE to the reason address to clear the state */ + *addr = REBOOT_REASON_NONE; + + return; +} + STATIC VOID EFIAPI @@ -540,6 +565,7 @@ HiKeyOnEndOfDxe ( } HiKeyDetectJumper (); + HiKeyDetectRebootReason (); // Check boot device. // If boot device is eMMC, it's always higher priority. diff --git a/HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c b/HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c index d7d15b5..e0ae73f 100644 --- a/HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c +++ b/HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c @@ -37,6 +37,7 @@ STATIC struct HiKeyReservedMemory { EFI_PHYSICAL_ADDRESS Size; } HiKeyReservedMemoryBuffer [] = { { 0x05E00000, 0x00100000 }, // MCU + { 0x05F01000, 0x00001000 }, // ADB REBOOT "REASON" { 0x06DFF000, 0x00001000 }, // MAILBOX { 0x0740F000, 0x00001000 }, // MAILBOX { 0x3E000000, 0x02000000 } // TEE OS