diff options
| author | Saul Wold <sgw@linux.intel.com> | 2017-11-07 10:32:26 -0800 |
|---|---|---|
| committer | Saul Wold <sgw@linux.intel.com> | 2017-11-20 15:33:02 -0800 |
| commit | d53dbb38c43da3fd04fed9a55e7b3b9e2c512b9a (patch) | |
| tree | fbe372dba00d45bbf9fbfbb3726708dc2590daeb /recipes-bsp/systemd-boot | |
| parent | 5adbf6df4fd89e7531ccccfb9cec7a5314d635f0 (diff) | |
| download | meta-intel-d53dbb38c43da3fd04fed9a55e7b3b9e2c512b9a.tar.gz | |
meta-intel: Reorganize the layout to remove common
Remove the concept of the common directory and move all the recipes-* dirs
to the top level as a normal layer would be. layer.conf is updated appropriately
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'recipes-bsp/systemd-boot')
9 files changed, 551 insertions, 0 deletions
diff --git a/recipes-bsp/systemd-boot/systemd-boot/0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch b/recipes-bsp/systemd-boot/systemd-boot/0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch new file mode 100644 index 00000000..8d0b6149 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | From 58669ad764767afea4de53f8a97357773b1855ef Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Saul Wold <sgw@linux.intel.com> | ||
| 3 | Date: Tue, 25 Oct 2016 12:54:08 -0700 | ||
| 4 | Subject: [PATCH] efi/boot.c: workaround for Joule BIOS hang | ||
| 5 | |||
| 6 | This patch should be removed when the BIOS is fixed | ||
| 7 | |||
| 8 | Authored-by: Steve Sakoman <steve@sakoman.com> | ||
| 9 | |||
| 10 | Upstream-Status: Inappropriate [machine specific workaround] | ||
| 11 | Signed-off-by: Saul Wold <sgw@linux.intel.com> | ||
| 12 | --- | ||
| 13 | src/boot/efi/boot.c | 2 +- | ||
| 14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 15 | |||
| 16 | diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c | ||
| 17 | index 3dcd9a5..3c6ed8c 100644 | ||
| 18 | --- a/src/boot/efi/boot.c | ||
| 19 | +++ b/src/boot/efi/boot.c | ||
| 20 | @@ -649,7 +649,7 @@ static BOOLEAN menu_run(Config *config, ConfigEntry **chosen_entry, CHAR16 *load | ||
| 21 | } | ||
| 22 | |||
| 23 | /* timeout disabled, wait for next key */ | ||
| 24 | - wait = TRUE; | ||
| 25 | + wait = FALSE; | ||
| 26 | continue; | ||
| 27 | } | ||
| 28 | |||
| 29 | -- | ||
| 30 | 2.7.4 | ||
| 31 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch b/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch new file mode 100644 index 00000000..2f248e21 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | From fe1c2fdfe81f2ac2b41fe8543ba07f1911770d26 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jianxun Zhang <jianxun.zhang@linux.intel.com> | ||
| 3 | Date: Sat, 21 May 2016 18:52:07 -0700 | ||
| 4 | Subject: [PATCH] sd-boot: Link RMC library into bootloader and stub | ||
| 5 | |||
| 6 | Add RMC library into bootloader binary and stub. | ||
| 7 | |||
| 8 | Upstream-Status: Pending | ||
| 9 | |||
| 10 | Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> | ||
| 11 | --- | ||
| 12 | Makefile.am | 4 ++-- | ||
| 13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
| 14 | |||
| 15 | diff --git a/Makefile.am b/Makefile.am | ||
| 16 | index 305099ab6..9fb6f9b7b 100644 | ||
| 17 | --- a/Makefile.am | ||
| 18 | +++ b/Makefile.am | ||
| 19 | @@ -2802,7 +2802,7 @@ $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(t | ||
| 20 | |||
| 21 | $(systemd_boot_solib): $(systemd_boot_objects) | ||
| 22 | $(AM_V_CCLD)$(LD) $(efi_ldflags) $(systemd_boot_objects) \ | ||
| 23 | - -o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \ | ||
| 24 | + -o $@ -lefi -lgnuefi -lrmcefi $(shell $(CC) -print-libgcc-file-name); \ | ||
| 25 | nm -D -u $@ | grep ' U ' && exit 1 || : | ||
| 26 | |||
| 27 | $(systemd_boot): $(systemd_boot_solib) | ||
| 28 | @@ -2852,7 +2852,7 @@ $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(t | ||
| 29 | |||
| 30 | $(stub_solib): $(stub_objects) | ||
| 31 | $(AM_V_CCLD)$(LD) $(efi_ldflags) $(stub_objects) \ | ||
| 32 | - -o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \ | ||
| 33 | + -o $@ -lefi -lgnuefi -lrmcefi $(shell $(CC) -print-libgcc-file-name); \ | ||
| 34 | nm -D -u $@ | grep ' U ' && exit 1 || : | ||
| 35 | |||
| 36 | $(stub): $(stub_solib) | ||
| 37 | -- | ||
| 38 | 2.11.0 | ||
| 39 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch b/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch new file mode 100644 index 00000000..69acc8f8 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-stub-check-LoadOptions-contains-data.patch | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | From 87cd5a5e0f06ceb7f9dbdcc4029e0c279a38e6ad Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mikko Ylinen <mikko.ylinen@linux.intel.com> | ||
| 3 | Date: Mon, 27 Feb 2017 10:04:03 +0200 | ||
| 4 | Subject: [PATCH] sd-boot: stub: check LoadOptions contains data | ||
| 5 | |||
| 6 | With some UEFI shells LoadOptionsSize is reported being > 0 | ||
| 7 | but the corresponding LoadOptions does not contain any data | ||
| 8 | (the first element has value 0). | ||
| 9 | |||
| 10 | When that happens, the stub feature that allows .cmdline to be | ||
| 11 | replaced by what's in LoadOptions ends up copying nothing/random | ||
| 12 | data to the kernel cmdline resulting in different kinds of boot | ||
| 13 | problems. | ||
| 14 | |||
| 15 | To fix this, add a check to see if LoadOptions contains data | ||
| 16 | before replacing the .cmdline. | ||
| 17 | |||
| 18 | Upstream-Status: Accepted [https://github.com/systemd/systemd/pull/5467] | ||
| 19 | |||
| 20 | Fixes [YOCTO #11078]. | ||
| 21 | |||
| 22 | Signed-off-by: Mikko Ylinen <mikko.ylinen@linux.intel.com> | ||
| 23 | --- | ||
| 24 | src/boot/efi/stub.c | 2 +- | ||
| 25 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 26 | |||
| 27 | diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c | ||
| 28 | index 7c1ffb1bc..b7d5d3cda 100644 | ||
| 29 | --- a/src/boot/efi/stub.c | ||
| 30 | +++ b/src/boot/efi/stub.c | ||
| 31 | @@ -87,7 +87,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 32 | cmdline_len = szs[0]; | ||
| 33 | |||
| 34 | /* if we are not in secure boot mode, accept a custom command line and replace the built-in one */ | ||
| 35 | - if (!secure && loaded_image->LoadOptionsSize > 0) { | ||
| 36 | + if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 *)loaded_image->LoadOptions != 0) { | ||
| 37 | CHAR16 *options; | ||
| 38 | CHAR8 *line; | ||
| 39 | UINTN i; | ||
| 40 | -- | ||
| 41 | 2.11.0 | ||
| 42 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch b/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch new file mode 100644 index 00000000..e88012c3 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch | |||
| @@ -0,0 +1,250 @@ | |||
| 1 | From a3c4fc8c2847fe289a617bcba1d905f580f0e18d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jianxun Zhang <jianxun.zhang@linux.intel.com> | ||
| 3 | Date: Wed, 1 Jun 2016 16:32:22 -0700 | ||
| 4 | Subject: [PATCH 2/3] sd-boot: Load board-specific boot entries from RMC | ||
| 5 | database | ||
| 6 | |||
| 7 | RMC provides a centralized database file on ESP. The DB contains | ||
| 8 | fingerprints and any file blobs associated to physical boards. | ||
| 9 | Callers can fetch board-specific data with fingerprint info | ||
| 10 | collected from board at runtime if there is any record matched | ||
| 11 | board's fingerprint. | ||
| 12 | |||
| 13 | To let bootloader know which file blob in RMC should be queried, | ||
| 14 | a special config file BOOTENTRY.CONFIG is defined as: | ||
| 15 | |||
| 16 | boot.conf | ||
| 17 | install.conf | ||
| 18 | |||
| 19 | Bootloader calls RMC APIs and other functions to perform these | ||
| 20 | tasks before it shows boot menu to user: | ||
| 21 | |||
| 22 | (1) Load RMC database file from ESP | ||
| 23 | (2) Collect fingerprint data from board | ||
| 24 | (3) Query BOOTENTRY.CONFIG from RMC DB with fingerprint | ||
| 25 | (4) Parse BOOTENTRY.CONFIG to know names of boot entry files | ||
| 26 | (5) Query boot entry files one by one from RMC DB, and add | ||
| 27 | them into sd-boot config data. | ||
| 28 | |||
| 29 | The final effect is that bootloader will show board-specific | ||
| 30 | boot entries in boot menu to user. User then can choose one | ||
| 31 | of them to boot system with the selected configuration. | ||
| 32 | |||
| 33 | If any of these steps fails, bootloader simply skips loading | ||
| 34 | RMC configs or any entry file not successfully fetched from | ||
| 35 | RMC DB. Once any entry is loaded successfully from RMC DB, | ||
| 36 | bootloader skips loading any boot entries from ESP. | ||
| 37 | |||
| 38 | Upstream-Status: Pending | ||
| 39 | |||
| 40 | Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> | ||
| 41 | --- | ||
| 42 | src/boot/efi/boot.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++- | ||
| 43 | 1 file changed, 145 insertions(+), 2 deletions(-) | ||
| 44 | |||
| 45 | diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c | ||
| 46 | index 30c1ead..d1b029b 100644 | ||
| 47 | --- a/src/boot/efi/boot.c | ||
| 48 | +++ b/src/boot/efi/boot.c | ||
| 49 | @@ -15,6 +15,7 @@ | ||
| 50 | |||
| 51 | #include <efi.h> | ||
| 52 | #include <efilib.h> | ||
| 53 | +#include <rmc_api.h> | ||
| 54 | |||
| 55 | #include "console.h" | ||
| 56 | #include "disk.h" | ||
| 57 | @@ -33,6 +34,9 @@ static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot | ||
| 58 | |||
| 59 | static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE; | ||
| 60 | |||
| 61 | +static CHAR8* rmc_db; | ||
| 62 | +static rmc_fingerprint_t *rmc_fp; | ||
| 63 | + | ||
| 64 | enum loader_type { | ||
| 65 | LOADER_UNDEFINED, | ||
| 66 | LOADER_EFI, | ||
| 67 | @@ -1702,6 +1706,136 @@ static VOID config_free(Config *config) { | ||
| 68 | FreePool(config->entry_oneshot); | ||
| 69 | } | ||
| 70 | |||
| 71 | +/* Derived from line_get_key_value(), we could consolidate two functions later */ | ||
| 72 | +static CHAR8 *get_line(CHAR8 *content, UINT64 *pos) { | ||
| 73 | + CHAR8 *line; | ||
| 74 | + UINT64 linelen; | ||
| 75 | + | ||
| 76 | +skip: | ||
| 77 | + line = content + *pos; | ||
| 78 | + if (*line == '\0') | ||
| 79 | + return NULL; | ||
| 80 | + | ||
| 81 | + linelen = 0; | ||
| 82 | + while (line[linelen] && !strchra((CHAR8 *)"\n\r", line[linelen])) | ||
| 83 | + linelen++; | ||
| 84 | + | ||
| 85 | + /* move pos to next line */ | ||
| 86 | + *pos += linelen; | ||
| 87 | + if (content[*pos]) | ||
| 88 | + (*pos)++; | ||
| 89 | + | ||
| 90 | + /* empty line */ | ||
| 91 | + if (linelen == 0) | ||
| 92 | + goto skip; | ||
| 93 | + | ||
| 94 | + /* terminate line */ | ||
| 95 | + line[linelen] = '\0'; | ||
| 96 | + | ||
| 97 | + /* remove leading whitespace */ | ||
| 98 | + while (strchra((CHAR8 *)" \t", *line)) { | ||
| 99 | + line++; | ||
| 100 | + linelen--; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /* remove trailing whitespace */ | ||
| 104 | + while (linelen > 0 && strchra((CHAR8 *)" \t", line[linelen-1])) | ||
| 105 | + linelen--; | ||
| 106 | + line[linelen] = '\0'; | ||
| 107 | + | ||
| 108 | + if (*line == '#') | ||
| 109 | + goto skip; | ||
| 110 | + | ||
| 111 | + return line; | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +/* load rmc database file from ESP and try to get fingerprint. These | ||
| 115 | + * are essential information indicating we could query rmc data for | ||
| 116 | + * this board at least | ||
| 117 | + * return 0 if both database file and fingerprint can be obtained, otherwise | ||
| 118 | + * non-zero value is returned. | ||
| 119 | + * | ||
| 120 | + * Note: db and fp hold valid values only when this function returns 0. | ||
| 121 | + * Caller is responsible to free allocated memory pointed by *db and *fp when | ||
| 122 | + * this function returns 0. | ||
| 123 | + */ | ||
| 124 | + | ||
| 125 | +static UINTN rmc_initialize(EFI_FILE *root_dir, EFI_SYSTEM_TABLE *sys_table, CHAR8 **db, rmc_fingerprint_t **fp) { | ||
| 126 | + UINTN len; | ||
| 127 | + UINTN ret = 1; | ||
| 128 | + | ||
| 129 | + if (!db || !fp) | ||
| 130 | + return ret; | ||
| 131 | + | ||
| 132 | + *db = NULL; | ||
| 133 | + *fp = NULL; | ||
| 134 | + | ||
| 135 | + /* load rmc database */ | ||
| 136 | + len = file_read(root_dir, L"\\rmc.db", 0, 0, db); | ||
| 137 | + | ||
| 138 | + if (len <= 0) | ||
| 139 | + goto done; | ||
| 140 | + | ||
| 141 | + *fp = AllocateZeroPool(sizeof(rmc_fingerprint_t)); | ||
| 142 | + /* call rmc to get fingerprint. We will use single-action rmc APIs to query multiple files. | ||
| 143 | + * This should bring a better performance than calling double-action rmc API every time. | ||
| 144 | + */ | ||
| 145 | + if (rmc_get_fingerprint(sys_table, *fp)) | ||
| 146 | + goto done; | ||
| 147 | + | ||
| 148 | + ret = 0; | ||
| 149 | +done: | ||
| 150 | + if (ret) { | ||
| 151 | + FreePool(*db); | ||
| 152 | + FreePool(*fp); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + return ret; | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +/* load RMC entries | ||
| 159 | + * return TRUE when at least one entry is loaded, otherwise, return FALSE | ||
| 160 | + */ | ||
| 161 | +static BOOLEAN config_load_rmc_entries(Config *config, EFI_HANDLE *device, CHAR16 *loaded_image_path, CHAR8 *db, rmc_fingerprint_t *fp) { | ||
| 162 | + CHAR8 *boot_entry = NULL; | ||
| 163 | + CHAR8 *boot_config = NULL; | ||
| 164 | + rmc_file_t rp; | ||
| 165 | + CHAR8 *line; | ||
| 166 | + UINT64 pos = 0; | ||
| 167 | + BOOLEAN ret = FALSE; | ||
| 168 | + | ||
| 169 | + if (!db || !fp) | ||
| 170 | + return ret; | ||
| 171 | + | ||
| 172 | + /* query boot entry config file */ | ||
| 173 | + if (rmc_query_file_by_fp(fp, db, "BOOTENTRY.CONFIG", &rp)) | ||
| 174 | + return ret; | ||
| 175 | + | ||
| 176 | + /* file blob read from rmc db is not necessarily null-terminated, and we | ||
| 177 | + * should keep mem where rmc db lives from change during parsing | ||
| 178 | + */ | ||
| 179 | + boot_config = AllocatePool(rp.blob_len * sizeof(CHAR8) + 1); | ||
| 180 | + CopyMem(boot_config, rp.blob, rp.blob_len); | ||
| 181 | + boot_config[rp.blob_len] = '\0'; | ||
| 182 | + /* parse boot entry config */ | ||
| 183 | + while ((line = get_line(boot_config, &pos))) { | ||
| 184 | + if (rmc_query_file_by_fp(fp, db, (char *)line, &rp)) | ||
| 185 | + continue; | ||
| 186 | + if (rp.blob_len > 0) { | ||
| 187 | + boot_entry = AllocatePool(rp.blob_len * sizeof(CHAR8) + 1); | ||
| 188 | + CopyMem(boot_entry, rp.blob, rp.blob_len); | ||
| 189 | + boot_entry[rp.blob_len] = '\0'; | ||
| 190 | + config_entry_add_from_file(config, device, | ||
| 191 | + stra_to_str(line), boot_entry, | ||
| 192 | + loaded_image_path); | ||
| 193 | + /* tell caller success when a RMC entry is loaded */ | ||
| 194 | + ret = TRUE; | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + return ret; | ||
| 199 | +} | ||
| 200 | + | ||
| 201 | EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 202 | CHAR16 *s; | ||
| 203 | CHAR8 *b; | ||
| 204 | @@ -1714,6 +1848,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 205 | UINT64 init_usec; | ||
| 206 | BOOLEAN menu = FALSE; | ||
| 207 | CHAR16 uuid[37]; | ||
| 208 | + BOOLEAN rmc_entry = FALSE; | ||
| 209 | |||
| 210 | InitializeLib(image, sys_table); | ||
| 211 | init_usec = time_usec(); | ||
| 212 | @@ -1745,6 +1880,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 213 | return EFI_LOAD_ERROR; | ||
| 214 | } | ||
| 215 | |||
| 216 | + /* Initialize rmc before loading any config */ | ||
| 217 | + rmc_initialize(root_dir, sys_table, &rmc_db, &rmc_fp); | ||
| 218 | |||
| 219 | /* the filesystem path to this image, to prevent adding ourselves to the menu */ | ||
| 220 | loaded_image_path = DevicePathToStr(loaded_image->FilePath); | ||
| 221 | @@ -1753,11 +1890,15 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 222 | ZeroMem(&config, sizeof(Config)); | ||
| 223 | config_load_defaults(&config, root_dir); | ||
| 224 | |||
| 225 | + if (rmc_db && rmc_fp) | ||
| 226 | + rmc_entry = config_load_rmc_entries(&config, loaded_image->DeviceHandle, loaded_image_path, rmc_db, rmc_fp); | ||
| 227 | + | ||
| 228 | /* scan /EFI/Linux/ directory */ | ||
| 229 | config_entry_add_linux(&config, loaded_image, root_dir); | ||
| 230 | |||
| 231 | - /* scan /loader/entries/\*.conf files */ | ||
| 232 | - config_load_entries(&config, loaded_image->DeviceHandle, root_dir, loaded_image_path); | ||
| 233 | + /* scan /loader/entries/\*.conf files only when no RMC entry is loaded */ | ||
| 234 | + if (rmc_entry == FALSE) | ||
| 235 | + config_load_entries(&config, loaded_image->DeviceHandle, root_dir, loaded_image_path); | ||
| 236 | |||
| 237 | /* sort entries after version number */ | ||
| 238 | config_sort_entries(&config); | ||
| 239 | @@ -1851,6 +1992,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 240 | out: | ||
| 241 | FreePool(loaded_image_path); | ||
| 242 | config_free(&config); | ||
| 243 | + FreePool(rmc_db); | ||
| 244 | + FreePool(rmc_fp); | ||
| 245 | uefi_call_wrapper(root_dir->Close, 1, root_dir); | ||
| 246 | uefi_call_wrapper(BS->CloseProtocol, 4, image, &LoadedImageProtocol, image, NULL); | ||
| 247 | return err; | ||
| 248 | -- | ||
| 249 | 2.7.4 | ||
| 250 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/0003-sd-boot-Support-global-kernel-command-line-fragment.patch b/recipes-bsp/systemd-boot/systemd-boot/0003-sd-boot-Support-global-kernel-command-line-fragment.patch new file mode 100644 index 00000000..a4b63557 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/0003-sd-boot-Support-global-kernel-command-line-fragment.patch | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | From 1e33f99e13a70c19c1f63f6ef1c5522a09adece6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jianxun Zhang <jianxun.zhang@linux.intel.com> | ||
| 3 | Date: Mon, 20 Jun 2016 13:08:20 -0700 | ||
| 4 | Subject: [PATCH 3/3] sd-boot: Support global kernel command line fragment | ||
| 5 | |||
| 6 | Query file blob KBOOTPARAM from RMC. If it exists, we append | ||
| 7 | it to the new linux boot entry's cmdline. A boot entry could | ||
| 8 | be read from a .conf file on ESP, RMC database, or embedded | ||
| 9 | linux image. content in KBOOTPARAM is effective in all of | ||
| 10 | these cases. | ||
| 11 | |||
| 12 | Upstream-Status: Pending | ||
| 13 | |||
| 14 | Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> | ||
| 15 | --- | ||
| 16 | src/boot/efi/boot.c | 34 ++++++++++++++++++++++++++++++++++ | ||
| 17 | 1 file changed, 34 insertions(+) | ||
| 18 | |||
| 19 | diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c | ||
| 20 | index d1b029b..8dffc48 100644 | ||
| 21 | --- a/src/boot/efi/boot.c | ||
| 22 | +++ b/src/boot/efi/boot.c | ||
| 23 | @@ -846,6 +846,40 @@ static VOID config_add_entry(Config *config, ConfigEntry *entry) { | ||
| 24 | config->entries = ReallocatePool(config->entries, | ||
| 25 | sizeof(VOID *) * config->entry_count, sizeof(VOID *) * i); | ||
| 26 | } | ||
| 27 | + | ||
| 28 | + /* rmc: a linux entry could be added from .conf file or an embedded linux image | ||
| 29 | + * we put appending global command line here to cover both of two cases. | ||
| 30 | + */ | ||
| 31 | + if (entry->type == LOADER_LINUX && rmc_db && rmc_fp) { | ||
| 32 | + rmc_file_t rmc_kp; | ||
| 33 | + | ||
| 34 | + if (!rmc_query_file_by_fp(rmc_fp, rmc_db, "KBOOTPARAM", &rmc_kp)) { | ||
| 35 | + CHAR8 *cmdline; | ||
| 36 | + CHAR16 *s; | ||
| 37 | + CHAR16 *t; | ||
| 38 | + CHAR16 *p; | ||
| 39 | + | ||
| 40 | + cmdline = AllocatePool(rmc_kp.blob_len * sizeof(CHAR8) + 1); | ||
| 41 | + CopyMem(cmdline, rmc_kp.blob, rmc_kp.blob_len); | ||
| 42 | + cmdline[rmc_kp.blob_len] = '\0'; | ||
| 43 | + p = stra_to_str(cmdline); | ||
| 44 | + t = p; | ||
| 45 | + | ||
| 46 | + while (*t) { | ||
| 47 | + if (*t == '\n') | ||
| 48 | + *t = '\0'; | ||
| 49 | + t++; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + s = PoolPrint(L"%s %s", entry->options, p); | ||
| 53 | + FreePool(entry->options); | ||
| 54 | + FreePool(p); | ||
| 55 | + FreePool(cmdline); | ||
| 56 | + | ||
| 57 | + entry->options = s; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | config->entries[config->entry_count++] = entry; | ||
| 62 | } | ||
| 63 | |||
| 64 | -- | ||
| 65 | 2.7.4 | ||
| 66 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch b/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch new file mode 100644 index 00000000..75082693 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | From 4cb9c65ea9c0eba3ba04d036dccd4a5ab3d2547b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mikko Ylinen <mikko.ylinen@intel.com> | ||
| 3 | Date: Fri, 27 Jan 2017 13:31:45 +0200 | ||
| 4 | Subject: [PATCH] sd-boot: support global kernel command line in EFI stub | ||
| 5 | |||
| 6 | This change integrates rmc into EFI stub and supports a | ||
| 7 | global fragment (RMC KBOOTPARAM) that is appended to the | ||
| 8 | cmdline at boot. | ||
| 9 | |||
| 10 | The fragment is board-specific and read from the database. | ||
| 11 | |||
| 12 | Implements [YOCTO #10924]. | ||
| 13 | |||
| 14 | Upstream-status: Pending | ||
| 15 | |||
| 16 | Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com> | ||
| 17 | --- | ||
| 18 | src/boot/efi/stub.c | 33 +++++++++++++++++++++++++++++++++ | ||
| 19 | 1 file changed, 33 insertions(+) | ||
| 20 | |||
| 21 | diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c | ||
| 22 | index 1e250f34f..f3865199f 100644 | ||
| 23 | --- a/src/boot/efi/stub.c | ||
| 24 | +++ b/src/boot/efi/stub.c | ||
| 25 | @@ -13,6 +13,7 @@ | ||
| 26 | |||
| 27 | #include <efi.h> | ||
| 28 | #include <efilib.h> | ||
| 29 | +#include <rmc_api.h> | ||
| 30 | |||
| 31 | #include "disk.h" | ||
| 32 | #include "graphics.h" | ||
| 33 | @@ -48,6 +49,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 34 | UINTN cmdline_len; | ||
| 35 | CHAR16 uuid[37]; | ||
| 36 | EFI_STATUS err; | ||
| 37 | + INTN len; | ||
| 38 | + CHAR8 *rmc_db = NULL; | ||
| 39 | + rmc_file_t rmc_file; | ||
| 40 | |||
| 41 | InitializeLib(image, sys_table); | ||
| 42 | |||
| 43 | @@ -112,6 +116,35 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { | ||
| 44 | #endif | ||
| 45 | } | ||
| 46 | |||
| 47 | + len = file_read(root_dir, L"\\rmc.db", 0, 0, &rmc_db); | ||
| 48 | + if (len <= 0) | ||
| 49 | + rmc_db = NULL; | ||
| 50 | + | ||
| 51 | + /* If the board has a fragment in rmc database, append it to the cmdline */ | ||
| 52 | + if (rmc_db && !rmc_gimme_file(sys_table, rmc_db, "KBOOTPARAM", &rmc_file)) { | ||
| 53 | + CHAR8 *line; | ||
| 54 | + UINTN i = 0; | ||
| 55 | + UINTN j; | ||
| 56 | + | ||
| 57 | + line = AllocatePool(rmc_file.blob_len + cmdline_len + 2); | ||
| 58 | + | ||
| 59 | + while (i < cmdline_len && cmdline[i] != '\0') { | ||
| 60 | + line[i] = cmdline[i]; | ||
| 61 | + i++; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + line[i++] = ' '; | ||
| 65 | + | ||
| 66 | + for (j=0; j < rmc_file.blob_len; j++) | ||
| 67 | + line[i+j] = rmc_file.blob[j]; | ||
| 68 | + line[i+j] = '\0'; | ||
| 69 | + | ||
| 70 | + cmdline = line; | ||
| 71 | + cmdline_len = i + j; | ||
| 72 | + | ||
| 73 | + FreePool(rmc_db); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | /* export the device path this image is started from */ | ||
| 77 | if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS) | ||
| 78 | efivar_set(L"LoaderDevicePartUUID", uuid, FALSE); | ||
| 79 | -- | ||
| 80 | 2.11.0 | ||
| 81 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/rmc-boot.inc b/recipes-bsp/systemd-boot/systemd-boot/rmc-boot.inc new file mode 100644 index 00000000..1172d53d --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/rmc-boot.inc | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | DEPENDS_append_intel-x86-common = " rmc rmc-efi" | ||
| 2 | |||
| 3 | EXTRA_OEMAKE_append_intel-x86-common = ' EFI_LDFLAGS="-L${STAGING_DIR_HOST}/usr/lib" EFI_CFLAGS="-I${STAGING_INCDIR}/rmc -DRMC_EFI"' | ||
| 4 | |||
| 5 | SRC_URI_append_intel-x86-common = " \ | ||
| 6 | file://0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch \ | ||
| 7 | file://0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch \ | ||
| 8 | file://0003-sd-boot-Support-global-kernel-command-line-fragment.patch \ | ||
| 9 | file://0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch \ | ||
| 10 | file://0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch \ | ||
| 11 | file://0001-sd-boot-stub-check-LoadOptions-contains-data.patch \ | ||
| 12 | " | ||
diff --git a/recipes-bsp/systemd-boot/systemd-boot/systemd-boot.inc b/recipes-bsp/systemd-boot/systemd-boot/systemd-boot.inc new file mode 100644 index 00000000..fcce6ce1 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot/systemd-boot.inc | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | EXTRA_OEMAKE_append_intel-x86-common = ' EFI_LDFLAGS="-L${STAGING_DIR_HOST}/usr/lib" ' | ||
| 2 | |||
| 3 | SRC_URI_append_intel-x86-common = " \ | ||
| 4 | file://0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch \ | ||
| 5 | file://0001-sd-boot-stub-check-LoadOptions-contains-data.patch \ | ||
| 6 | " | ||
| 7 | |||
diff --git a/recipes-bsp/systemd-boot/systemd-boot_%.bbappend b/recipes-bsp/systemd-boot/systemd-boot_%.bbappend new file mode 100644 index 00000000..557c0493 --- /dev/null +++ b/recipes-bsp/systemd-boot/systemd-boot_%.bbappend | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | FILESEXTRAPATHS_prepend_intel-x86-common := "${THISDIR}/systemd-boot:" | ||
| 2 | |||
| 3 | # Pin systemd revision down for systemd-boot recipe. | ||
| 4 | # Patches could not be applied cleanly when systemd in OE is updated, | ||
| 5 | # though we don't expect a lot of changes could happen in bootloader. | ||
| 6 | # RMC is designed to support a large number of types of boards, so we | ||
| 7 | # should do explicit update with validation to prevent regression even | ||
| 8 | # resolving conflicts for a new tip could be done in a short time. | ||
| 9 | |||
| 10 | # Revision: systemd v232 in OE | ||
| 11 | SRCREV_intel-x86-common = "a1e2ef7ec912902d8142e7cb5830cbfb47dba86c" | ||
| 12 | |||
| 13 | include systemd-boot/${EFI_PROVIDER}.inc | ||
| 14 | |||
| 15 | PACKAGE_ARCH_intel-x86-common = "${INTEL_COMMON_PACKAGE_ARCH}" | ||
| 16 | |||
| 17 | do_compile_append_intel-x86-common() { | ||
| 18 | oe_runmake linux${SYSTEMD_BOOT_EFI_ARCH}.efi.stub | ||
| 19 | } | ||
| 20 | |||
| 21 | do_deploy_append_intel-x86-common() { | ||
| 22 | install ${B}/linux*.efi.stub ${DEPLOYDIR} | ||
| 23 | } | ||
