aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig7
-rw-r--r--lib/efi_loader/efi_boottime.c4
-rw-r--r--lib/efi_loader/efi_capsule.c6
-rw-r--r--lib/efi_loader/efi_device_path.c53
-rw-r--r--lib/efi_loader/efi_memory.c2
-rw-r--r--lib/efi_loader/efi_runtime.c2
-rw-r--r--lib/efi_loader/helloworld.c13
-rw-r--r--lib/efi_loader/initrddump.c5
-rw-r--r--lib/efi_selftest/efi_selftest_exitbootservices.c2
-rw-r--r--lib/efi_selftest/efi_selftest_load_file.c20
-rw-r--r--lib/fdtdec.c3
-rw-r--r--lib/lmb.c4
-rw-r--r--lib/vsprintf.c3
13 files changed, 74 insertions, 50 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 202a34ab41..d8dac09ea8 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1057,7 +1057,6 @@ config LMB
config LMB_USE_MAX_REGIONS
bool "Use a common number of memory and reserved regions in lmb lib"
- depends on LMB
default y
help
Define the number of supported memory regions in the library logical
@@ -1067,7 +1066,7 @@ config LMB_USE_MAX_REGIONS
config LMB_MAX_REGIONS
int "Number of memory and reserved regions in lmb lib"
- depends on LMB && LMB_USE_MAX_REGIONS
+ depends on LMB_USE_MAX_REGIONS
default 16
help
Define the number of supported regions, memory and reserved, in the
@@ -1075,7 +1074,7 @@ config LMB_MAX_REGIONS
config LMB_MEMORY_REGIONS
int "Number of memory regions in lmb lib"
- depends on LMB && !LMB_USE_MAX_REGIONS
+ depends on !LMB_USE_MAX_REGIONS
default 8
help
Define the number of supported memory regions in the library logical
@@ -1084,7 +1083,7 @@ config LMB_MEMORY_REGIONS
config LMB_RESERVED_REGIONS
int "Number of reserved regions in lmb lib"
- depends on LMB && !LMB_USE_MAX_REGIONS
+ depends on !LMB_USE_MAX_REGIONS
default 8
help
Define the number of supported reserved regions in the library logical
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index caaab685ee..d5065f296a 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -35,7 +35,7 @@ LIST_HEAD(efi_obj_list);
__efi_runtime_data LIST_HEAD(efi_events);
/* List of queued events */
-LIST_HEAD(efi_event_queue);
+static LIST_HEAD(efi_event_queue);
/* Flag to disable timer activity in ExitBootServices() */
static bool timers_enabled = true;
@@ -44,7 +44,7 @@ static bool timers_enabled = true;
bool efi_st_keep_devices;
/* List of all events registered by RegisterProtocolNotify() */
-LIST_HEAD(efi_register_notify_events);
+static LIST_HEAD(efi_register_notify_events);
/* Handle of the currently executing image */
static efi_handle_t current_image;
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index d5d3ede7ae..7a6f195cbc 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -404,12 +404,6 @@ out:
return status;
}
-#else
-efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size,
- void **image, efi_uintn_t *image_size)
-{
- return EFI_UNSUPPORTED;
-}
#endif /* CONFIG_EFI_CAPSULE_AUTHENTICATE */
static __maybe_unused bool fwu_empty_capsule(struct efi_capsule_header *capsule)
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index d5cc495830..e2e98a39be 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -21,6 +21,9 @@
#include <asm-generic/unaligned.h>
#include <linux/compat.h> /* U16_MAX */
+#ifdef CONFIG_BLKMAP
+const efi_guid_t efi_guid_blkmap_dev = U_BOOT_BLKMAP_DEV_GUID;
+#endif
#ifdef CONFIG_SANDBOX
const efi_guid_t efi_guid_host_dev = U_BOOT_HOST_DEV_GUID;
#endif
@@ -110,17 +113,13 @@ int efi_dp_match(const struct efi_device_path *a,
/**
* efi_dp_shorten() - shorten device-path
*
- * We can have device paths that start with a USB WWID or a USB Class node,
- * and a few other cases which don't encode the full device path with bus
- * hierarchy:
+ * When creating a short boot option we want to use a device-path that is
+ * independent of the location where the block device is plugged in.
*
- * * MESSAGING:USB_WWID
- * * MESSAGING:USB_CLASS
- * * MEDIA:FILE_PATH
- * * MEDIA:HARD_DRIVE
- * * MESSAGING:URI
+ * UsbWwi() nodes contain a serial number, hard drive paths a partition
+ * UUID. Both should be unique.
*
- * See UEFI spec (section 3.1.2, about short-form device-paths)
+ * See UEFI spec, section 3.1.2 for "short-form device path".
*
* @dp: original device-path
* @Return: shortened device-path or NULL
@@ -128,12 +127,7 @@ int efi_dp_match(const struct efi_device_path *a,
struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp)
{
while (dp) {
- /*
- * TODO: Add MESSAGING:USB_WWID and MESSAGING:URI..
- * in practice fallback.efi just uses MEDIA:HARD_DRIVE
- * so not sure when we would see these other cases.
- */
- if (EFI_DP_TYPE(dp, MESSAGING_DEVICE, MSG_USB) ||
+ if (EFI_DP_TYPE(dp, MESSAGING_DEVICE, MSG_USB_WWI) ||
EFI_DP_TYPE(dp, MEDIA_DEVICE, HARD_DRIVE_PATH) ||
EFI_DP_TYPE(dp, MEDIA_DEVICE, FILE_PATH))
return dp;
@@ -565,6 +559,16 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
return dp_size(dev->parent)
+ sizeof(struct efi_device_path_vendor) + 1;
#endif
+#ifdef CONFIG_BLKMAP
+ case UCLASS_BLKMAP:
+ /*
+ * blkmap devices will be represented as a vendor
+ * device node with an extra byte for the device
+ * number.
+ */
+ return dp_size(dev->parent)
+ + sizeof(struct efi_device_path_vendor) + 1;
+#endif
default:
return dp_size(dev->parent);
}
@@ -622,6 +626,23 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
#endif
case UCLASS_BLK:
switch (dev->parent->uclass->uc_drv->id) {
+#ifdef CONFIG_BLKMAP
+ case UCLASS_BLKMAP: {
+ struct efi_device_path_vendor *dp;
+ struct blk_desc *desc = dev_get_uclass_plat(dev);
+
+ dp_fill(buf, dev->parent);
+ dp = buf;
+ ++dp;
+ dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
+ dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
+ dp->dp.length = sizeof(*dp) + 1;
+ memcpy(&dp->guid, &efi_guid_blkmap_dev,
+ sizeof(efi_guid_t));
+ dp->vendor_data[0] = desc->devnum;
+ return &dp->vendor_data[1];
+ }
+#endif
#ifdef CONFIG_SANDBOX
case UCLASS_HOST: {
/* stop traversing parents at this point: */
@@ -735,7 +756,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
#endif
#if defined(CONFIG_USB)
case UCLASS_MASS_STORAGE: {
- struct blk_desc *desc = desc = dev_get_uclass_plat(dev);
+ struct blk_desc *desc = dev_get_uclass_plat(dev);
struct efi_device_path_controller *dp =
dp_fill(buf, dev->parent);
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 8f82496740..e2ca78d935 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -36,7 +36,7 @@ struct efi_mem_list {
#define EFI_CARVE_OVERLAPS_NONRAM -3
/* This list contains all memory map items */
-LIST_HEAD(efi_mem);
+static LIST_HEAD(efi_mem);
#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
void *efi_bounce_buffer;
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index cee96bfc7f..bf54d6ad87 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -32,7 +32,7 @@ struct efi_runtime_mmio_list {
};
/* This list contains all runtime available mmio regions */
-LIST_HEAD(efi_runtime_mmio);
+static LIST_HEAD(efi_runtime_mmio);
static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void);
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 49fa8cc2f0..6405f58ec3 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -197,8 +197,10 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
print_config_tables();
/* Get the loaded image protocol */
- ret = boottime->handle_protocol(handle, &loaded_image_guid,
- (void **)&loaded_image);
+ ret = boottime->open_protocol(handle, &loaded_image_guid,
+ (void **)&loaded_image, NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+
if (ret != EFI_SUCCESS) {
con_out->output_string
(con_out, u"Cannot open loaded image protocol\r\n");
@@ -219,9 +221,10 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
(con_out, u"Missing device handle\r\n");
goto out;
}
- ret = boottime->handle_protocol(loaded_image->device_handle,
- &device_path_guid,
- (void **)&device_path);
+ ret = boottime->open_protocol(loaded_image->device_handle,
+ &device_path_guid,
+ (void **)&device_path, NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (ret != EFI_SUCCESS) {
con_out->output_string
(con_out, u"Missing device path for device handle\r\n");
diff --git a/lib/efi_loader/initrddump.c b/lib/efi_loader/initrddump.c
index 971a3b6236..5b470f4819 100644
--- a/lib/efi_loader/initrddump.c
+++ b/lib/efi_loader/initrddump.c
@@ -291,8 +291,9 @@ static efi_status_t get_initrd(void **initrd, efi_uintn_t *initrd_size)
error(u"Load File2 protocol not found\r\n");
return ret;
}
- ret = bs->handle_protocol(handle, &load_file2_guid,
- (void **)&load_file2_prot);
+ ret = bs->open_protocol(handle, &load_file2_guid,
+ (void **)&load_file2_prot, NULL, NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL);
ret = load_file2_prot->load_file(load_file2_prot, dp, false,
initrd_size, NULL);
if (ret != EFI_BUFFER_TOO_SMALL) {
diff --git a/lib/efi_selftest/efi_selftest_exitbootservices.c b/lib/efi_selftest/efi_selftest_exitbootservices.c
index 11b43fdd90..b090ce74d2 100644
--- a/lib/efi_selftest/efi_selftest_exitbootservices.c
+++ b/lib/efi_selftest/efi_selftest_exitbootservices.c
@@ -27,7 +27,7 @@ struct notification_context {
static struct efi_boot_services *boottime;
static struct efi_event *efi_st_event_notify;
-struct notification_record record;
+static struct notification_record record;
struct notification_context context_before = {
.record = &record,
diff --git a/lib/efi_selftest/efi_selftest_load_file.c b/lib/efi_selftest/efi_selftest_load_file.c
index 8784a76172..14df761172 100644
--- a/lib/efi_selftest/efi_selftest_load_file.c
+++ b/lib/efi_selftest/efi_selftest_load_file.c
@@ -206,11 +206,11 @@ static efi_status_t decompress(u8 **image)
* @buffer_size: (required) buffer size
* @buffer: buffer to which the file is to be loaded
*/
-efi_status_t EFIAPI load_file(struct efi_load_file_protocol *this,
- struct efi_device_path *file_path,
- bool boot_policy,
- efi_uintn_t *buffer_size,
- void *buffer)
+static efi_status_t EFIAPI load_file(struct efi_load_file_protocol *this,
+ struct efi_device_path *file_path,
+ bool boot_policy,
+ efi_uintn_t *buffer_size,
+ void *buffer)
{
++load_file_call_count;
if (memcmp(file_path, dp_lf_file_remainder,
@@ -243,11 +243,11 @@ efi_status_t EFIAPI load_file(struct efi_load_file_protocol *this,
* @buffer_size: (required) buffer size
* @buffer: buffer to which the file is to be loaded
*/
-efi_status_t EFIAPI load_file2(struct efi_load_file_protocol *this,
- struct efi_device_path *file_path,
- bool boot_policy,
- efi_uintn_t *buffer_size,
- void *buffer)
+static efi_status_t EFIAPI load_file2(struct efi_load_file_protocol *this,
+ struct efi_device_path *file_path,
+ bool boot_policy,
+ efi_uintn_t *buffer_size,
+ void *buffer)
{
++load_file2_call_count;
if (memcmp(file_path, dp_lf2_file_remainder,
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 0827e16859..55cc95db5d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * NOTE: Please do not add new devicetree-reading functionality into this file.
+ * Add it to the ofnode API instead, since that is compatible with livetree.
*/
#ifndef USE_HOSTCC
diff --git a/lib/lmb.c b/lib/lmb.c
index 2444b2a621..b2c233edb6 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -27,7 +27,7 @@ static void lmb_dump_region(struct lmb_region *rgn, char *name)
enum lmb_flags flags;
int i;
- printf(" %s.cnt = 0x%lx\n", name, rgn->cnt);
+ printf(" %s.cnt = 0x%lx / max = 0x%lx\n", name, rgn->cnt, rgn->max);
for (i = 0; i < rgn->cnt; i++) {
base = rgn->region[i].base;
@@ -110,7 +110,7 @@ void lmb_init(struct lmb *lmb)
#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
lmb->memory.max = CONFIG_LMB_MAX_REGIONS;
lmb->reserved.max = CONFIG_LMB_MAX_REGIONS;
-#elif defined(CONFIG_LMB_MEMORY_REGIONS)
+#else
lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS;
lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS;
lmb->memory.region = lmb->memory_regions;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 2d13e68b57..e87503e41a 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -674,6 +674,7 @@ repeat:
case 'x':
flags |= SMALL;
+ /* fallthrough */
case 'X':
base = 16;
break;
@@ -681,8 +682,10 @@ repeat:
case 'd':
if (fmt[1] == 'E')
flags |= ERRSTR;
+ /* fallthrough */
case 'i':
flags |= SIGN;
+ /* fallthrough */
case 'u':
break;