17 Commits

Author SHA1 Message Date
Yi-Yo Chiang
e38bf65034 [lib][uefi] Default implementation of BootService.SetWatchdogTimer()
The platform_watchdog_ methods are optional features that the target
platform can choose to implement.
If they are implemented, then BootService.SetWatchdogTimer() would call
them to setup the hardware watchdog.
If they are not implemented (for example presubmit targets), then
BootService.SetWatchdogTimer() would test the WEAK symbol against a NULL
pointer and error out.

To use BootService.SetWatchdogTimer(), platforms can choose to either
implement platform_watchdog_init and platform_watchdog_set_enabled, or
override the entire BootService.SetWatchdogTimer() method.
2025-08-22 09:21:56 -07:00
Ying-Chun Liu (PaulLiu)
45d7da5640 lib: uefi: add volatile UEFI variable support
GBL needs to read an UEFI variable called "gbl_debug".
We add 2 commands. "uefi_set_var" to set an UEFI variable. And
"uefi_list_var" to list the UEFI variables.

For GBL, we can use "uefi_set_var gbl_debug 1" to enable its
debug mode.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-14 12:25:36 -04:00
Ying-Chun Liu (PaulLiu)
de3e831eae lib: uefi: add charset converting helper functions.
The UEFI variable names are in UTF-16. We add several helper
functions to convert US-ASCII to UTF-16.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-14 12:25:36 -04:00
Ying-Chun Liu (PaulLiu)
ea327d7242 lib: uefi: add EfiSystemTablePointer for debug
Add EfiSystemTablePointer structure for remote debugger to locate
the address of EfiSystemTable.

This feature is described in UEFI SPEC version 2.10. Section 18.4.2.
The implementation ensures support for hardware-assisted debugging and
provides a standardized mechanism for debuggers to discover the EFI
system table.

Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
2025-08-06 03:19:47 -04:00
Kelvin Zhang
f7d8f58cdc [lib][uefi] Support async blockio 2025-07-23 10:46:42 -07:00
Kelvin Zhang
e8cea74e9b [lib][uefi] Implement events API in UEFI
LK already has events APIs. To support events protocols in UEFI spec,
I created a wrapper object for LK events. This wrapper object keeps
additional data that are necessary to support UEFI events spec:

* Notification function, or callbacks
* Argument for the notification function
* Type of this UEFI event (which specifies when the callback should be
  called)

The events API is essential for supporting async I/O in UEFI. Intended
use case looks like:

* UEFI app creates an event object, attatch callback to this event
* UEFI app calls LK for asynchronous read/write on a block device, with
  the newly created events object
* LK executes IO operation in background, after IO finishes, signal the
  specified event object
* UEFI's callback gets executed
2025-07-16 14:00:00 -07:00
Kelvin Zhang
55e2d6f2aa [lib][uefi] Move platform dependent functions to a separate file 2025-04-29 14:17:10 -07:00
Kelvin Zhang
3fb0e31374 [app][uefi] Split memory and block io code into separate files 2025-02-25 01:05:22 -08:00
Kelvin Zhang
c7576472f2 [app][uefi] refactor relocation logic to a separate file 2025-02-25 01:05:22 -08:00
Kelvin Zhang
649d432b8a Move UEFI header files into private include namespace
This help reduce the risk of name collision. As MODULE_DIR/include is
automatically added to global includes.
2024-11-06 10:12:17 -08:00
Kelvin Zhang
1249e8a03b [app][uefi] Add configuration table 2024-11-06 10:12:17 -08:00
Kelvin Zhang
7d77e28430 [app][uefi] Enable mspace feature on dlmalloc
This allows us to use an identitiy mapped piece of memory as the heap
for UEFI app. UEFI app's allocation would go from this heap.
2024-11-06 10:12:17 -08:00
Kelvin Zhang
763ff7ce70 [app][uefi] Call kernel at an identity mapped stack 2024-11-06 10:12:17 -08:00
Kelvin Zhang
6a37823f71 [app][uefi] Add runtime service support 2024-11-06 10:12:17 -08:00
Kelvin Zhang
5ea19f1b0a [app][uefi] Setup skeleton for UEFI boot service 2024-11-06 10:12:16 -08:00
Kelvin Zhang
07b80bf495 Add section loading and entry point execution to UEFI loader
This loads all sections specified by PE header at the correct memory
location, and executes the entry point function. Only the
OutputString function of text output protocol is implemented,
so the only application we can run is hello world.

Test: th
Bug: 294283461
Change-Id: I786bc8b7db9e1c0a6019b8fe4ba5a8c8ab4f2936
2024-06-14 15:26:15 -07:00
Kelvin Zhang
c750ed0fa3 Add basic UEFI loader to lk
Thids adds a uefi_load <block dev name> command, which will
parse the PE header and do some basic validation checks.

Bug: 294283461
Test: uefi_load virtio0
Change-Id: I97393652526bda5be1b995e59647e239c64d31d6
2024-06-14 15:26:15 -07:00