Skip to content

Commit 09cdf1f

Browse files
committed
Add Android loader type that automatically configures android.efi
Like the Linux boot type, this is just syntactic sugar for an EFI application (here: android-efi) that is expected to be present in the root directory of the ESP partition. For example: title Android android 80868086-8086-8086-8086-000000000100 initrd /intel-ucode.img options androidboot.mode=charger translates to title Android efi /android.efi options android 80868086-8086-8086-8086-000000000100 -- initrd=/intel-ucode.img androidboot.mode=charger
1 parent fc86263 commit 09cdf1f

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

boot.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum loader_type {
2727
LOADER_UNDEFINED,
2828
LOADER_EFI,
2929
LOADER_LINUX,
30+
LOADER_ANDROID,
3031
};
3132

3233
typedef struct {
@@ -1321,6 +1322,14 @@ static VOID config_entry_add_from_file(
13211322
continue;
13221323
}
13231324

1325+
if (strcmpa((CHAR8 *)"android", key) == 0) {
1326+
FreePool(entry->loader);
1327+
entry->type = LOADER_ANDROID;
1328+
entry->loader = stra_to_str(value);
1329+
entry->key = 'a';
1330+
continue;
1331+
}
1332+
13241333
if (strcmpa((CHAR8 *)"efi", key) == 0) {
13251334
entry->type = LOADER_EFI;
13261335
FreePool(entry->loader);
@@ -1395,7 +1404,7 @@ static VOID config_entry_add_from_file(
13951404
}
13961405

13971406
/* add initrd= to options */
1398-
if (entry->type == LOADER_LINUX && initrd) {
1407+
if ((entry->type == LOADER_LINUX || entry->type == LOADER_ANDROID) && initrd) {
13991408
if (entry->options) {
14001409
CHAR16 *s;
14011410

@@ -1415,6 +1424,24 @@ static VOID config_entry_add_from_file(
14151424
entry->id[len - 5] = '\0';
14161425
StrLwr(entry->id);
14171426

1427+
if (entry->type == LOADER_ANDROID) {
1428+
if (entry->loader) {
1429+
CHAR16 *s;
1430+
if (entry->options) {
1431+
s = PoolPrint(L"%s %s -- %s", entry->id,
1432+
entry->loader, entry->options);
1433+
FreePool(entry->options);
1434+
} else {
1435+
s = PoolPrint(L"%s %s",
1436+
entry->id, entry->loader);
1437+
}
1438+
entry->options = s;
1439+
FreePool(entry->loader);
1440+
}
1441+
1442+
entry->loader = L"" ANDROID_EFI_PATH;
1443+
}
1444+
14181445
config_add_entry(config, entry);
14191446

14201447
config_entry_parse_tries(entry, path, file, L".conf");

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ if have_gnu_efi
113113
efi_conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
114114
efi_conf.set10('ENABLE_TPM', get_option('tpm'))
115115
efi_conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
116+
efi_conf.set_quoted('ANDROID_EFI_PATH', '\\\\'.join(get_option('android-efi').split('/')))
116117

117118
efi_config_h = configure_file(
118119
output : 'efi_config.h',

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ option('efi-includedir', type : 'string', value : '/usr/include/efi',
1818
description : 'path to the EFI header directory')
1919
option('tpm-pcrindex', type : 'integer', value : 8,
2020
description : 'TPM PCR register number to use')
21+
option('android-efi', type : 'string', value : '/android.efi',
22+
description : 'Path to android.efi binary for booting Android images (optional)')
2123

2224
option('tests', type : 'combo', choices : ['true', 'false'],
2325
description : 'enable tests')

0 commit comments

Comments
 (0)