-
Notifications
You must be signed in to change notification settings - Fork 738
[lib][uefi] implement UEFI HII Database Protocol #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
338b7e5 to
da0571b
Compare
da0571b to
276fa18
Compare
Shell.efi from EDK2 requires this protocol to be existed. Otherwise it crashes. So we implemented a minimum set of UEFI HII Database Protocol to let the Shell.efi to run. Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>
276fa18 to
b33f350
Compare
|
I'm okay with this but @zhangxp1998 has generally been the maintainer of the UEFI stuff. What do you think Kelvin? |
|
|
||
| stbl = reinterpret_cast<struct efi_string_table *>(list_remove_head(&(hii->string_tables))); | ||
| if (!stbl) { | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break cause a memory leak? Is it OK that we don't free stbl ?
|
|
||
| static void remove_strings_package(struct efi_hii_packagelist *hii) { | ||
| while (true) { | ||
| struct efi_string_table *stbl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define and initialize in 1 step.
| while ((void *)package < end) { | ||
| switch (efi_hii_package_type(package)) { | ||
| case EFI_HII_PACKAGE_END: | ||
| goto out; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO goto statement in C++
| bool found = false; | ||
| list_for_every_entry(&efi_package_lists, hii, struct efi_hii_packagelist, node) { | ||
| if (hii == package_list) { | ||
| found = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just return true here?
| #include <uefi/protocols/hii_protocol.h> | ||
|
|
||
| namespace { | ||
| const int EFI_HII_PACKAGE_TYPE_SHIFT = 24; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constexpr
|
|
||
| namespace { | ||
| const int EFI_HII_PACKAGE_TYPE_SHIFT = 24; | ||
| const uint32_t EFI_HII_PACKAGE_TYPE_MASK = 0xff; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for all constants
| static uint32_t efi_hii_package_type(const EfiHiiPackageHeader *header) { | ||
| uint32_t fields; | ||
|
|
||
| fields = header->fields; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare variable and initialize in 1 step, same everywhere across the code
| return (fields >> EFI_HII_PACKAGE_TYPE_SHIFT) & EFI_HII_PACKAGE_TYPE_MASK; | ||
| } | ||
|
|
||
| static uint32_t efi_hii_package_len(const EfiHiiPackageHeader *header) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already inside an anonymous namespace, remove static keyword for all functions
| struct efi_hii_packagelist *hii; | ||
|
|
||
| hii = reinterpret_cast<struct efi_hii_packagelist *>(malloc(sizeof(struct efi_hii_packagelist))); | ||
| if (!hii) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not omit {}
Shell.efi from EDK2 requires this protocol to be existed. Otherwise it crashes. So we implemented a minimum set of UEFI HII Database Protocol to let the Shell.efi to run.