mirror of
https://github.com/clearlinux/clr-boot-manager.git
synced 2026-10-04 15:58:34 +00:00
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:
committed by
William Douglas
parent
224541dc7f
commit
fa155bc53e
@@ -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")))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user