diff options
author | marcel <marcel@FreeBSD.org> | 2002-12-10 06:22:25 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2002-12-10 06:22:25 +0000 |
commit | 2b58aefd52a6386b1c0856e55a718966b9adb8a1 (patch) | |
tree | 94b8f0b58d4709b442bd9ffc80891c80059a5483 /sys/boot/efi/include | |
parent | f4623ed8677c37348f599d913b06a9f803722b93 (diff) | |
download | FreeBSD-src-2b58aefd52a6386b1c0856e55a718966b9adb8a1.zip FreeBSD-src-2b58aefd52a6386b1c0856e55a718966b9adb8a1.tar.gz |
Change the startup code to fix a memory leak and to allow us to
accept load options (=command line options).
The call graph changes from *entry*->efi_main->efi_init, where
efi_main is the EFI equivalent of main to *entry*->efi_main->main,
where main is what you'd expect. efi_main now is what efi_init was.
The prototype of main follows that of C. The first argument is argc
and the second is argv. There is no third argument.
Allocation of heap pages is now handled by the EFI library and it
now deallocates the pages when main() returns or when exit() is
called. This allows us to safely return to the boot manager (or
EFI shell) without leaks. EFI applications are responsible to free
all memory themselves.
Handling of the load options is a bit tricky. There are either no
load options, load options in ASCII or load options in Unicode.
The EFI library will translate the ASCII options to Unicode options
as to simplify user code. Since the load options are passed as a
single string (if present) and main() accepts argc and argv, the
startup code also has to split the string into words and build the
argv vector. Here the trickiness starts. When the loader is started
from the EFI shell, argv[0] will automaticly load the program name.
In all other cases (ie through the boot manager), this is not the
case. Unfortunately, there's no trivial way to check. Hence, a
set of conditions is checked to determine if we need to fill in
argv[0] ourselves or not. This checking is not perfect. There are
known cases where it fails to do the right thing. The logic works
for most expected cases, though. This includes the case where no
options are given.
Approved by: re (blanket)
Diffstat (limited to 'sys/boot/efi/include')
-rw-r--r-- | sys/boot/efi/include/efilib.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/boot/efi/include/efilib.h b/sys/boot/efi/include/efilib.h index 9d79939..695f334 100644 --- a/sys/boot/efi/include/efilib.h +++ b/sys/boot/efi/include/efilib.h @@ -31,4 +31,7 @@ extern EFI_SYSTEM_TABLE *ST; extern EFI_BOOT_SERVICES *BS; extern EFI_RUNTIME_SERVICES *RS; -void efi_init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table); +void efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table); + +EFI_STATUS main(int argc, CHAR16 *argv[]); +void exit(EFI_STATUS status); |