summaryrefslogtreecommitdiffstats
path: root/common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch')
-rw-r--r--common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch55
1 files changed, 21 insertions, 34 deletions
diff --git a/common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch b/common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch
index ddad940b..e88012c3 100644
--- a/common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch
+++ b/common/recipes-bsp/systemd-boot/systemd-boot/0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch
@@ -1,4 +1,4 @@
1From f714cdc84b791d84099f7461c4f223677456720f Mon Sep 17 00:00:00 2001 1From a3c4fc8c2847fe289a617bcba1d905f580f0e18d Mon Sep 17 00:00:00 2001
2From: Jianxun Zhang <jianxun.zhang@linux.intel.com> 2From: Jianxun Zhang <jianxun.zhang@linux.intel.com>
3Date: Wed, 1 Jun 2016 16:32:22 -0700 3Date: Wed, 1 Jun 2016 16:32:22 -0700
4Subject: [PATCH 2/3] sd-boot: Load board-specific boot entries from RMC 4Subject: [PATCH 2/3] sd-boot: Load board-specific boot entries from RMC
@@ -39,23 +39,22 @@ Upstream-Status: Pending
39 39
40Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com> 40Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
41--- 41---
42 src/boot/efi/boot.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++- 42 src/boot/efi/boot.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++-
43 1 file changed, 158 insertions(+), 2 deletions(-) 43 1 file changed, 145 insertions(+), 2 deletions(-)
44 44
45diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c 45diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
46index 30c1ead..43b0793 100644 46index 30c1ead..d1b029b 100644
47--- a/src/boot/efi/boot.c 47--- a/src/boot/efi/boot.c
48+++ b/src/boot/efi/boot.c 48+++ b/src/boot/efi/boot.c
49@@ -15,6 +15,8 @@ 49@@ -15,6 +15,7 @@
50 50
51 #include <efi.h> 51 #include <efi.h>
52 #include <efilib.h> 52 #include <efilib.h>
53+#include <rmcl.h> 53+#include <rmc_api.h>
54+#include <rsmp.h>
55 54
56 #include "console.h" 55 #include "console.h"
57 #include "disk.h" 56 #include "disk.h"
58@@ -33,6 +35,9 @@ static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot 57@@ -33,6 +34,9 @@ static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot
59 58
60 static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE; 59 static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE;
61 60
@@ -65,7 +64,7 @@ index 30c1ead..43b0793 100644
65 enum loader_type { 64 enum loader_type {
66 LOADER_UNDEFINED, 65 LOADER_UNDEFINED,
67 LOADER_EFI, 66 LOADER_EFI,
68@@ -1702,6 +1707,148 @@ static VOID config_free(Config *config) { 67@@ -1702,6 +1706,136 @@ static VOID config_free(Config *config) {
69 FreePool(config->entry_oneshot); 68 FreePool(config->entry_oneshot);
70 } 69 }
71 70
@@ -123,13 +122,8 @@ index 30c1ead..43b0793 100644
123+ * this function returns 0. 122+ * this function returns 0.
124+ */ 123+ */
125+ 124+
126+static UINTN rmc_initialize(EFI_FILE *root_dir, CHAR8 **db, rmc_fingerprint_t **fp) { 125+static UINTN rmc_initialize(EFI_FILE *root_dir, EFI_SYSTEM_TABLE *sys_table, CHAR8 **db, rmc_fingerprint_t **fp) {
127+ UINTN len; 126+ UINTN len;
128+ EFI_GUID smbios_guid = SMBIOS_TABLE_GUID;
129+ EFI_GUID smbios3_guid = SMBIOS3_TABLE_GUID;
130+ VOID *smbios_entry = NULL;
131+ UINT64 smbios_struct_addr = 0;
132+ UINT16 smbios_struct_len = 0;
133+ UINTN ret = 1; 127+ UINTN ret = 1;
134+ 128+
135+ if (!db || !fp) 129+ if (!db || !fp)
@@ -144,18 +138,11 @@ index 30c1ead..43b0793 100644
144+ if (len <= 0) 138+ if (len <= 0)
145+ goto done; 139+ goto done;
146+ 140+
147+ /* locate smbios entry table, try both 32 and 64 bit */
148+ if (LibGetSystemConfigurationTable(&smbios3_guid, &smbios_entry) != EFI_SUCCESS
149+ && LibGetSystemConfigurationTable(&smbios_guid, &smbios_entry) != EFI_SUCCESS)
150+ goto done;
151+
152+ /* call rsmp to get fp */
153+ if (rsmp_get_smbios_strcut(smbios_entry, &smbios_struct_addr, &smbios_struct_len))
154+ goto done;
155+
156+ *fp = AllocateZeroPool(sizeof(rmc_fingerprint_t)); 141+ *fp = AllocateZeroPool(sizeof(rmc_fingerprint_t));
157+ 142+ /* call rmc to get fingerprint. We will use single-action rmc APIs to query multiple files.
158+ if (rsmp_get_fingerprint_from_smbios_struct((BYTE *) smbios_struct_addr, *fp)) 143+ * This should bring a better performance than calling double-action rmc API every time.
144+ */
145+ if (rmc_get_fingerprint(sys_table, *fp))
159+ goto done; 146+ goto done;
160+ 147+
161+ ret = 0; 148+ ret = 0;
@@ -174,7 +161,7 @@ index 30c1ead..43b0793 100644
174+static BOOLEAN config_load_rmc_entries(Config *config, EFI_HANDLE *device, CHAR16 *loaded_image_path, CHAR8 *db, rmc_fingerprint_t *fp) { 161+static BOOLEAN config_load_rmc_entries(Config *config, EFI_HANDLE *device, CHAR16 *loaded_image_path, CHAR8 *db, rmc_fingerprint_t *fp) {
175+ CHAR8 *boot_entry = NULL; 162+ CHAR8 *boot_entry = NULL;
176+ CHAR8 *boot_config = NULL; 163+ CHAR8 *boot_config = NULL;
177+ rmc_policy_file_t rp; 164+ rmc_file_t rp;
178+ CHAR8 *line; 165+ CHAR8 *line;
179+ UINT64 pos = 0; 166+ UINT64 pos = 0;
180+ BOOLEAN ret = FALSE; 167+ BOOLEAN ret = FALSE;
@@ -183,7 +170,7 @@ index 30c1ead..43b0793 100644
183+ return ret; 170+ return ret;
184+ 171+
185+ /* query boot entry config file */ 172+ /* query boot entry config file */
186+ if (query_policy_from_db(fp, db, RMC_POLICY_BLOB, "BOOTENTRY.CONFIG", &rp)) 173+ if (rmc_query_file_by_fp(fp, db, "BOOTENTRY.CONFIG", &rp))
187+ return ret; 174+ return ret;
188+ 175+
189+ /* file blob read from rmc db is not necessarily null-terminated, and we 176+ /* file blob read from rmc db is not necessarily null-terminated, and we
@@ -194,7 +181,7 @@ index 30c1ead..43b0793 100644
194+ boot_config[rp.blob_len] = '\0'; 181+ boot_config[rp.blob_len] = '\0';
195+ /* parse boot entry config */ 182+ /* parse boot entry config */
196+ while ((line = get_line(boot_config, &pos))) { 183+ while ((line = get_line(boot_config, &pos))) {
197+ if (query_policy_from_db(fp, db, RMC_POLICY_BLOB, (char *)line, &rp)) 184+ if (rmc_query_file_by_fp(fp, db, (char *)line, &rp))
198+ continue; 185+ continue;
199+ if (rp.blob_len > 0) { 186+ if (rp.blob_len > 0) {
200+ boot_entry = AllocatePool(rp.blob_len * sizeof(CHAR8) + 1); 187+ boot_entry = AllocatePool(rp.blob_len * sizeof(CHAR8) + 1);
@@ -214,7 +201,7 @@ index 30c1ead..43b0793 100644
214 EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { 201 EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
215 CHAR16 *s; 202 CHAR16 *s;
216 CHAR8 *b; 203 CHAR8 *b;
217@@ -1714,6 +1861,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { 204@@ -1714,6 +1848,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
218 UINT64 init_usec; 205 UINT64 init_usec;
219 BOOLEAN menu = FALSE; 206 BOOLEAN menu = FALSE;
220 CHAR16 uuid[37]; 207 CHAR16 uuid[37];
@@ -222,16 +209,16 @@ index 30c1ead..43b0793 100644
222 209
223 InitializeLib(image, sys_table); 210 InitializeLib(image, sys_table);
224 init_usec = time_usec(); 211 init_usec = time_usec();
225@@ -1745,6 +1893,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { 212@@ -1745,6 +1880,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
226 return EFI_LOAD_ERROR; 213 return EFI_LOAD_ERROR;
227 } 214 }
228 215
229+ /* Initialize rmc before loading any config */ 216+ /* Initialize rmc before loading any config */
230+ rmc_initialize(root_dir, &rmc_db, &rmc_fp); 217+ rmc_initialize(root_dir, sys_table, &rmc_db, &rmc_fp);
231 218
232 /* the filesystem path to this image, to prevent adding ourselves to the menu */ 219 /* the filesystem path to this image, to prevent adding ourselves to the menu */
233 loaded_image_path = DevicePathToStr(loaded_image->FilePath); 220 loaded_image_path = DevicePathToStr(loaded_image->FilePath);
234@@ -1753,11 +1903,15 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { 221@@ -1753,11 +1890,15 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
235 ZeroMem(&config, sizeof(Config)); 222 ZeroMem(&config, sizeof(Config));
236 config_load_defaults(&config, root_dir); 223 config_load_defaults(&config, root_dir);
237 224
@@ -249,7 +236,7 @@ index 30c1ead..43b0793 100644
249 236
250 /* sort entries after version number */ 237 /* sort entries after version number */
251 config_sort_entries(&config); 238 config_sort_entries(&config);
252@@ -1851,6 +2005,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { 239@@ -1851,6 +1992,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
253 out: 240 out:
254 FreePool(loaded_image_path); 241 FreePool(loaded_image_path);
255 config_free(&config); 242 config_free(&config);