bootloaders: Introduce a very trivial capabilities system

This is used to describe in an obvious sense the purpose and application
for a given bootloader implementation. For now we'll use this to determine
whether a selected bootloader is being used in UEFI mode or not, and in the
future we can expand on this to dynamically select the correct bootloader
based on the system topology.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
This commit is contained in:
Ikey Doherty
2017-02-28 09:30:35 -06:00
committed by William Douglas
parent 224541dc7f
commit fa155bc53e
7 changed files with 37 additions and 6 deletions
+12 -2
View File
@@ -29,6 +29,15 @@ typedef bool (*boot_loader_install)(const BootManager *);
typedef bool (*boot_loader_update)(const BootManager *);
typedef bool (*boot_loader_remove)(const BootManager *);
typedef void (*boot_loader_destroy)(const BootManager *);
typedef int (*boot_loader_caps)(const BootManager *);
typedef enum {
BOOTLOADER_CAP_MIN = 1 << 0,
BOOTLOADER_CAP_UEFI = 1 << 1, /**<Bootloader supports UEFI */
BOOTLOADER_CAP_GPT = 1 << 2, /**<Bootloader supports GPT boot partition */
BOOTLOADER_CAP_LEGACY = 1 << 3, /**<Bootloader supports legacy boot */
BOOTLOADER_CAP_MAX = 1 << 4
} BootLoaderCapability;
/**
* Virtual BootLoader provider
@@ -43,8 +52,9 @@ typedef struct BootLoader {
boot_loader_needs_install needs_install; /**<Check if an install is required */
boot_loader_install install; /**<Install this bootloader */
boot_loader_update update; /**<Update this bootloader */
boot_loader_remove remove; /**<Remove this bootloader from the disk */
boot_loader_destroy destroy; /**<Perform necessary cleanups */
boot_loader_remove remove; /**<Remove this bootloader from the disk */
boot_loader_destroy destroy; /**<Perform necessary cleanups */
boot_loader_caps get_capabilities; /**<Check capabilities */
} BootLoader;
#define __cbm_export__ __attribute__((visibility("default")))
+3 -1
View File
@@ -34,7 +34,9 @@ __cbm_export__ const BootLoader goofiboot_bootloader = {.name = "goofiboot",
.install = sd_class_install,
.update = sd_class_update,
.remove = sd_class_remove,
.destroy = sd_class_destroy };
.destroy = sd_class_destroy,
.get_capabilities =
sd_class_get_capabilities };
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
+3 -1
View File
@@ -34,7 +34,9 @@ __cbm_export__ const BootLoader gummiboot_bootloader = {.name = "gummiboot",
.install = sd_class_install,
.update = sd_class_update,
.remove = sd_class_remove,
.destroy = sd_class_destroy };
.destroy = sd_class_destroy,
.get_capabilities =
sd_class_get_capabilities };
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
+8 -1
View File
@@ -278,6 +278,11 @@ static void syslinux_destroy(__cbm_unused__ const BootManager *manager)
}
}
static int syslinux_get_capabilities(__cbm_unused__ const BootManager *manager)
{
return BOOTLOADER_CAP_GPT | BOOTLOADER_CAP_LEGACY;
}
__cbm_export__ const BootLoader syslinux_bootloader = {.name = "syslinux",
.init = syslinux_init,
.install_kernel = syslinux_install_kernel,
@@ -289,7 +294,9 @@ __cbm_export__ const BootLoader syslinux_bootloader = {.name = "syslinux",
.install = syslinux_install,
.update = syslinux_update,
.remove = syslinux_remove,
.destroy = syslinux_destroy };
.destroy = syslinux_destroy,
.get_capabilities =
syslinux_get_capabilities };
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
+3 -1
View File
@@ -34,7 +34,9 @@ __cbm_export__ const BootLoader systemd_bootloader = {.name = "systemd",
.install = sd_class_install,
.update = sd_class_update,
.remove = sd_class_remove,
.destroy = sd_class_destroy };
.destroy = sd_class_destroy,
.get_capabilities =
sd_class_get_capabilities };
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
+6
View File
@@ -523,6 +523,12 @@ bool sd_class_remove(const BootManager *manager)
return true;
}
int sd_class_get_capabilities(__cbm_unused__ const BootManager *manager)
{
/* Very trivial bootloader, we support UEFI/GPT only */
return BOOTLOADER_CAP_GPT | BOOTLOADER_CAP_UEFI;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
+2
View File
@@ -49,6 +49,8 @@ bool sd_class_init(const BootManager *manager, BootLoaderConfig *config);
void sd_class_destroy(const BootManager *manager);
int sd_class_get_capabilities(const BootManager *manager);
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*