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 vishal.bhoj@linaro.org Cc: haojian.zhuang@linaro.org Cc: guodong.xu@linaro.org Signed-off-by: John Stultz john.stultz@linaro.org --- .../HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 26 ++++++++++++++++++++++ HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c | 1 + 2 files changed, 27 insertions(+)
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
On 16 December 2015 at 06:22, John Stultz john.stultz@linaro.org wrote:
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 vishal.bhoj@linaro.org Cc: haojian.zhuang@linaro.org Cc: guodong.xu@linaro.org Signed-off-by: John Stultz john.stultz@linaro.org
.../HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 26 ++++++++++++++++++++++ HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c | 1 + 2 files changed, 27 insertions(+)
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
-- 1.9.1
Applied. Thanks
Regards Haojian
On Tue, Dec 15, 2015 at 10:18 PM, Haojian Zhuang haojian.zhuang@linaro.org wrote:
On 16 December 2015 at 06:22, John Stultz john.stultz@linaro.org wrote:
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 vishal.bhoj@linaro.org Cc: haojian.zhuang@linaro.org Cc: guodong.xu@linaro.org Signed-off-by: John Stultz john.stultz@linaro.org
.../HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 26 ++++++++++++++++++++++ HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c | 1 + 2 files changed, 27 insertions(+)
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
-- 1.9.1
Applied. Thanks
Eeerrr.. Ok. Is the direct access of physical memory actually correct here? I feel like there's probably a better way to do this, but I'm not familiar at all with the UEFI code base.
Its funny, because Ricardo suggested I submit the patch via merge request to get review feedback and I was worried someone might just merge it instead.
Now, I'm happy to have it merged, but I do want to make sure its right. :)
thanks -john
On 16 December 2015 at 14:30, John Stultz john.stultz@linaro.org wrote:
On Tue, Dec 15, 2015 at 10:18 PM, Haojian Zhuang haojian.zhuang@linaro.org wrote:
On 16 December 2015 at 06:22, John Stultz john.stultz@linaro.org wrote:
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 vishal.bhoj@linaro.org Cc: haojian.zhuang@linaro.org Cc: guodong.xu@linaro.org Signed-off-by: John Stultz john.stultz@linaro.org
.../HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 26 ++++++++++++++++++++++ HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c | 1 + 2 files changed, 27 insertions(+)
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
-- 1.9.1
Applied. Thanks
Eeerrr.. Ok. Is the direct access of physical memory actually correct here? I feel like there's probably a better way to do this, but I'm not familiar at all with the UEFI code base.
I assume that you already test this code. Is it right?
When you declare the memory in this table, it'll be reserved in kernel memory mapping. Since kernel will fetch the UEFI memory mapping directly.
Its funny, because Ricardo suggested I submit the patch via merge request to get review feedback and I was worried someone might just merge it instead.
Yes, all patches should be submitted from github. I merge it from github.
Now, I'm happy to have it merged, but I do want to make sure its right. :)
thanks -john
On Tue, Dec 15, 2015 at 10:49 PM, Haojian Zhuang haojian.zhuang@linaro.org wrote:
On 16 December 2015 at 14:30, John Stultz john.stultz@linaro.org wrote:
On Tue, Dec 15, 2015 at 10:18 PM, Haojian Zhuang haojian.zhuang@linaro.org wrote:
On 16 December 2015 at 06:22, John Stultz john.stultz@linaro.org wrote:
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 vishal.bhoj@linaro.org Cc: haojian.zhuang@linaro.org Cc: guodong.xu@linaro.org Signed-off-by: John Stultz john.stultz@linaro.org
.../HiKeyPkg/Drivers/HiKeyDxe/InstallBootMenu.c | 26 ++++++++++++++++++++++ HisiPkg/HiKeyPkg/Library/HiKeyLib/HiKeyMem.c | 1 + 2 files changed, 27 insertions(+)
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
-- 1.9.1
Applied. Thanks
Eeerrr.. Ok. Is the direct access of physical memory actually correct here? I feel like there's probably a better way to do this, but I'm not familiar at all with the UEFI code base.
I assume that you already test this code. Is it right?
Yes. I tested the code, and it works. But I'm just not sure what the rules are when there's no virtual addressing, or if there's some better way to reference a value stored at a physaddr.
thanks -john