aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_driver/Makefile1
-rw-r--r--lib/efi_driver/efi_dm_integration.c36
-rw-r--r--lib/efi_loader/efi_boottime.c1
-rw-r--r--lib/efi_loader/efi_disk.c72
-rw-r--r--lib/efi_selftest/efi_selftest_tpl.c2
-rw-r--r--lib/smbios.c24
6 files changed, 98 insertions, 38 deletions
diff --git a/lib/efi_driver/Makefile b/lib/efi_driver/Makefile
index 83baa1c..f0d5fa5 100644
--- a/lib/efi_driver/Makefile
+++ b/lib/efi_driver/Makefile
@@ -5,6 +5,7 @@
# This file only gets included with CONFIG_EFI_LOADER set, so all
# object inclusion implicitly depends on it
+obj-y += efi_dm_integration.o
obj-y += efi_uclass.o
ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
obj-y += efi_block_device.o
diff --git a/lib/efi_driver/efi_dm_integration.c b/lib/efi_driver/efi_dm_integration.c
new file mode 100644
index 0000000..9c6c339
--- /dev/null
+++ b/lib/efi_driver/efi_dm_integration.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ */
+
+#define LOG_CATEGORY LOGC_EFI
+
+#include <common.h>
+#include <dm.h>
+#include <efi_loader.h>
+#include <log.h>
+
+/**
+ * efi_post_probe_device() - set up handle for probed device
+ *
+ * This function is called by device_probe(). After the UEFI sub-system is
+ * initialized this function adds handles for new devices.
+ *
+ * @dev: probed device
+ * Return: 0 on success
+ */
+int efi_post_probe_device(struct udevice *dev)
+{
+ if (!dev || !dev->uclass)
+ return -EINVAL;
+
+ switch (dev->uclass->uc_drv->id) {
+ case UCLASS_BLK:
+ if (efi_block_device_register(dev) != EFI_SUCCESS)
+ log_err("Failed to register %s\n", dev->name);
+ default:
+ break;
+ }
+
+ return 0;
+}
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 4777b35..f6d5ba0 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -264,7 +264,6 @@ efi_status_t is_valid_tpl(efi_uintn_t tpl)
case TPL_APPLICATION:
case TPL_CALLBACK:
case TPL_NOTIFY:
- case TPL_HIGH_LEVEL:
return EFI_SUCCESS;
default:
return EFI_INVALID_PARAMETER;
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 988907e..b798cab 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -10,6 +10,7 @@
#include <common.h>
#include <blk.h>
#include <dm.h>
+#include <dm/device-internal.h>
#include <efi_loader.h>
#include <fs.h>
#include <log.h>
@@ -536,6 +537,41 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
}
/**
+ * efi_block_device_register() - register a block device in the UEFI sub-system
+ *
+ * @dev: block device
+ * Return: status code
+ */
+efi_status_t efi_block_device_register(struct udevice *dev)
+{
+ struct blk_desc *desc = dev_get_uclass_plat(dev);
+ const char *if_typename = blk_get_if_type_name(desc->if_type);
+ struct efi_disk_obj *disk;
+ efi_status_t ret;
+
+ /* Add block device for the full device */
+ ret = device_probe(dev);
+ if (ret)
+ return EFI_NOT_FOUND;
+ log_info("Scanning disk %s...\n", dev->name);
+ ret = efi_disk_add_dev(NULL, NULL, if_typename,
+ desc, desc->devnum, NULL, 0, &disk);
+ if (ret == EFI_NOT_READY) {
+ log_notice("Disk %s not ready\n", dev->name);
+ return ret;
+ } else if (ret != EFI_SUCCESS) {
+ log_err("ERROR: failure to add disk device %s, r = %lu\n",
+ dev->name, ret & ~EFI_ERROR_MASK);
+ return ret;
+ }
+
+ /* Partitions show up as block devices in EFI */
+ efi_disk_create_partitions(&disk->header, desc, if_typename,
+ desc->devnum, dev->name);
+ return ret;
+}
+
+/**
* efi_disk_register() - register block devices
*
* U-Boot doesn't have a list of all online disk devices. So when running our
@@ -552,38 +588,16 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
*/
efi_status_t efi_disk_register(void)
{
- struct efi_disk_obj *disk;
- int disks = 0;
- efi_status_t ret;
#ifdef CONFIG_BLK
struct udevice *dev;
-
+ /* Probe all block devices */
for (uclass_first_device_check(UCLASS_BLK, &dev); dev;
- uclass_next_device_check(&dev)) {
- struct blk_desc *desc = dev_get_uclass_plat(dev);
- const char *if_typename = blk_get_if_type_name(desc->if_type);
-
- /* Add block device for the full device */
- log_info("Scanning disk %s...\n", dev->name);
- ret = efi_disk_add_dev(NULL, NULL, if_typename,
- desc, desc->devnum, NULL, 0, &disk);
- if (ret == EFI_NOT_READY) {
- log_notice("Disk %s not ready\n", dev->name);
- continue;
- }
- if (ret) {
- log_err("ERROR: failure to add disk device %s, r = %lu\n",
- dev->name, ret & ~EFI_ERROR_MASK);
- return ret;
- }
- disks++;
-
- /* Partitions show up as block devices in EFI */
- disks += efi_disk_create_partitions(
- &disk->header, desc, if_typename,
- desc->devnum, dev->name);
- }
+ uclass_next_device_check(&dev))
+ ;
#else
+ struct efi_disk_obj *disk;
+ int disks = 0;
+ efi_status_t ret;
int i, if_type;
/* Search for all available disk devices */
@@ -630,8 +644,8 @@ efi_status_t efi_disk_register(void)
if_typename, i, devname);
}
}
-#endif
log_info("Found %d disks\n", disks);
+#endif
return EFI_SUCCESS;
}
diff --git a/lib/efi_selftest/efi_selftest_tpl.c b/lib/efi_selftest/efi_selftest_tpl.c
index 70a355e..0c0e412 100644
--- a/lib/efi_selftest/efi_selftest_tpl.c
+++ b/lib/efi_selftest/efi_selftest_tpl.c
@@ -55,7 +55,7 @@ static int setup(const efi_handle_t handle,
return EFI_ST_FAILURE;
}
ret = boottime->create_event(EVT_TIMER | EVT_NOTIFY_WAIT,
- TPL_HIGH_LEVEL, notify, NULL, &event_wait);
+ TPL_NOTIFY, notify, NULL, &event_wait);
if (ret != EFI_SUCCESS) {
efi_st_error("could not create event\n");
return EFI_ST_FAILURE;
diff --git a/lib/smbios.c b/lib/smbios.c
index 9eb226e..b52e125 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -47,7 +47,7 @@ struct smbios_ctx {
* @addr: start address to write the structure
* @handle: the structure's handle, a unique 16-bit number
* @ctx: context for writing the tables
- * @return: size of the structure
+ * Return: size of the structure
*/
typedef int (*smbios_write_type)(ulong *addr, int handle,
struct smbios_ctx *ctx);
@@ -72,7 +72,7 @@ struct smbios_write_method {
*
* @ctx: SMBIOS context
* @str: string to add
- * @return: string number in the string area (1 or more)
+ * Return: string number in the string area (1 or more)
*/
static int smbios_add_string(struct smbios_ctx *ctx, const char *str)
{
@@ -111,7 +111,7 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str)
*
* @ctx: context for writing the tables
* @prop: property to write
- * @return 0 if not found, else SMBIOS string number (1 or more)
+ * Return: 0 if not found, else SMBIOS string number (1 or more)
*/
static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop,
int sysinfo_id)
@@ -139,7 +139,7 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop,
* smbios_add_prop() - Add a property from the devicetree
*
* @prop: property to write
- * @return 0 if not found, else SMBIOS string number (1 or more)
+ * Return: 0 if not found, else SMBIOS string number (1 or more)
*/
static int smbios_add_prop(struct smbios_ctx *ctx, const char *prop)
{
@@ -187,7 +187,7 @@ int smbios_update_version(const char *version)
* This computes the size of the string area including the string terminator.
*
* @ctx: SMBIOS context
- * @return: string area size
+ * Return: string area size
*/
static int smbios_string_table_len(const struct smbios_ctx *ctx)
{
@@ -229,9 +229,9 @@ static int smbios_write_type0(ulong *current, int handle,
t->bios_characteristics_ext1 = BIOS_CHARACTERISTICS_EXT1_ACPI;
#endif
#ifdef CONFIG_EFI_LOADER
- t->bios_characteristics_ext1 |= BIOS_CHARACTERISTICS_EXT1_UEFI;
+ t->bios_characteristics_ext2 |= BIOS_CHARACTERISTICS_EXT2_UEFI;
#endif
- t->bios_characteristics_ext2 = BIOS_CHARACTERISTICS_EXT2_TARGET;
+ t->bios_characteristics_ext2 |= BIOS_CHARACTERISTICS_EXT2_TARGET;
/* bios_major_release has only one byte, so drop century */
t->bios_major_release = U_BOOT_VERSION_NUM % 100;
@@ -258,7 +258,11 @@ static int smbios_write_type1(ulong *current, int handle,
fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
smbios_set_eos(ctx, t->eos);
t->manufacturer = smbios_add_prop(ctx, "manufacturer");
+ if (!t->manufacturer)
+ t->manufacturer = smbios_add_string(ctx, "Unknown");
t->product_name = smbios_add_prop(ctx, "product");
+ if (!t->product_name)
+ t->product_name = smbios_add_string(ctx, "Unknown Product");
t->version = smbios_add_prop_si(ctx, "version",
SYSINFO_ID_SMBIOS_SYSTEM_VERSION);
if (serial_str) {
@@ -288,7 +292,11 @@ static int smbios_write_type2(ulong *current, int handle,
fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
smbios_set_eos(ctx, t->eos);
t->manufacturer = smbios_add_prop(ctx, "manufacturer");
+ if (!t->manufacturer)
+ t->manufacturer = smbios_add_string(ctx, "Unknown");
t->product_name = smbios_add_prop(ctx, "product");
+ if (!t->product_name)
+ t->product_name = smbios_add_string(ctx, "Unknown Product");
t->version = smbios_add_prop_si(ctx, "version",
SYSINFO_ID_SMBIOS_BASEBOARD_VERSION);
t->asset_tag_number = smbios_add_prop(ctx, "asset-tag");
@@ -313,6 +321,8 @@ static int smbios_write_type3(ulong *current, int handle,
fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle);
smbios_set_eos(ctx, t->eos);
t->manufacturer = smbios_add_prop(ctx, "manufacturer");
+ if (!t->manufacturer)
+ t->manufacturer = smbios_add_string(ctx, "Unknown");
t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP;
t->bootup_state = SMBIOS_STATE_SAFE;
t->power_supply_state = SMBIOS_STATE_SAFE;