summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/Kconfig2
-rw-r--r--lib/efi_loader/efi_bootmgr.c2
-rw-r--r--lib/efi_loader/efi_fdt.c33
-rw-r--r--lib/zlib/inffast.c51
-rw-r--r--lib/zlib/zlib.h1
5 files changed, 61 insertions, 28 deletions
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 2fb24d7af9a..38e64af2531 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -67,7 +67,7 @@ config EFI_RT_VOLATILE_STORE
depends on EFI_VARIABLE_FILE_STORE
help
When EFI variables are stored on file we don't allow SetVariableRT,
- since the OS doesn't know how to write that file. At he same time
+ since the OS doesn't know how to write that file. At the same time
we copy runtime variables in DRAM and support GetVariableRT
Enable this option to allow SetVariableRT on the RAM backend of
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 304ed43595c..589d3996b68 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -1277,7 +1277,7 @@ efi_status_t efi_bootmgr_run(void *fdt)
if (fdt_lo)
fdt = fdt_lo;
if (!fdt) {
- efi_load_distro_fdt(&fdt_distro, &fdt_size);
+ efi_load_distro_fdt(handle, &fdt_distro, &fdt_size);
fdt = fdt_distro;
}
}
diff --git a/lib/efi_loader/efi_fdt.c b/lib/efi_loader/efi_fdt.c
index 86ba00c2bdd..4ccf2055be3 100644
--- a/lib/efi_loader/efi_fdt.c
+++ b/lib/efi_loader/efi_fdt.c
@@ -75,28 +75,34 @@ int efi_get_distro_fdt_name(char *fname, int size, int seq)
/**
* efi_load_distro_fdt() - load distro device-tree
*
+ * @handle: handle of loaded image
* @fdt: on return device-tree, must be freed via efi_free_pages()
* @fdt_size: buffer size
*/
-void efi_load_distro_fdt(void **fdt, efi_uintn_t *fdt_size)
+void efi_load_distro_fdt(efi_handle_t handle, void **fdt, efi_uintn_t *fdt_size)
{
- struct efi_device_path *rem, *dp;
+ struct efi_device_path *dp;
efi_status_t ret;
+ struct efi_handler *handler;
+ struct efi_loaded_image *loaded_image;
efi_handle_t device;
*fdt = NULL;
- dp = efi_get_dp_from_boot(NULL);
- if (!dp)
+ /* Get boot device from loaded image protocol */
+ ret = efi_search_protocol(handle, &efi_guid_loaded_image, &handler);
+ if (ret != EFI_SUCCESS)
return;
- device = efi_dp_find_obj(dp, NULL, &rem);
- ret = efi_search_protocol(device, &efi_simple_file_system_protocol_guid,
- NULL);
+ loaded_image = handler->protocol_interface;
+ device = loaded_image->device_handle;
+
+ /* Get device path of boot device */
+ ret = efi_search_protocol(device, &efi_guid_device_path, &handler);
if (ret != EFI_SUCCESS)
- goto err;
- memcpy(rem, &END, sizeof(END));
+ return;
+ dp = handler->protocol_interface;
- /* try the various available names */
+ /* Try the various available names */
for (int seq = 0; ; ++seq) {
struct efi_device_path *file;
char buf[255];
@@ -108,10 +114,9 @@ void efi_load_distro_fdt(void **fdt, efi_uintn_t *fdt_size)
break;
ret = efi_load_image_from_path(true, file, fdt, fdt_size);
efi_free_pool(file);
- if (ret == EFI_SUCCESS)
+ if (ret == EFI_SUCCESS) {
+ log_debug("Fdt %pD loaded\n", file);
break;
+ }
}
-
-err:
- efi_free_pool(dp);
}
diff --git a/lib/zlib/inffast.c b/lib/zlib/inffast.c
index 5e2a65ad4d2..b5a0adcce69 100644
--- a/lib/zlib/inffast.c
+++ b/lib/zlib/inffast.c
@@ -236,18 +236,47 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
else {
+ unsigned short *sout;
+ unsigned long loops;
+
from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- *out++ = *from++;
- *out++ = *from++;
- *out++ = *from++;
- len -= 3;
- } while (len > 2);
- if (len) {
- *out++ = *from++;
- if (len > 1)
- *out++ = *from++;
- }
+ /* minimum length is three */
+ /* Align out addr */
+ if (!((long)(out - 1) & 1)) {
+ *out++ = *from++;
+ len--;
+ }
+ sout = (unsigned short *)out;
+ if (dist > 2 ) {
+ unsigned short *sfrom;
+
+ sfrom = (unsigned short *)from;
+ loops = len >> 1;
+ do
+ *sout++ = get_unaligned(sfrom++);
+ while (--loops);
+ out = (unsigned char *)sout;
+ from = (unsigned char *)sfrom;
+ } else { /* dist == 1 or dist == 2 */
+ unsigned short pat16;
+
+ pat16 = *(sout - 1);
+ if (dist == 1)
+#if defined(__BIG_ENDIAN)
+ pat16 = (pat16 & 0xff) | ((pat16 & 0xff ) << 8);
+#elif defined(__LITTLE_ENDIAN)
+ pat16 = (pat16 & 0xff00) | ((pat16 & 0xff00 ) >> 8);
+#else
+#error __BIG_ENDIAN nor __LITTLE_ENDIAN is defined
+#endif
+ loops = len >> 1;
+ do
+ *sout++ = pat16;
+ while (--loops);
+ out = (unsigned char *)sout;
+ }
+ if (len & 1)
+ *out++ = *from++;
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
diff --git a/lib/zlib/zlib.h b/lib/zlib/zlib.h
index 560e7be97d3..f9b2f69ac02 100644
--- a/lib/zlib/zlib.h
+++ b/lib/zlib/zlib.h
@@ -10,7 +10,6 @@
/* avoid conflicts */
#undef OFF
#undef ASMINF
-#undef POSTINC
#undef NO_GZIP
#define GUNZIP
#undef STDC