diff --git a/sys/amd64/amd64/efirt.c b/sys/amd64/amd64/efirt.c index 94229db1f9ee..ea940d771c51 100644 --- a/sys/amd64/amd64/efirt.c +++ b/sys/amd64/amd64/efirt.c @@ -420,13 +420,22 @@ efi_uninit(void) mtx_destroy(&efi_lock); } +int +efi_rt_ok(void) +{ + + if (efi_runtime == NULL) + return (ENXIO); + return (0); +} + int efi_get_table(struct uuid *uuid, void **ptr) { struct efi_cfgtbl *ct; u_long count; - if (efi_cfgtbl == NULL) + if (efi_cfgtbl == NULL || efi_systbl == NULL) return (ENXIO); count = efi_systbl->st_entries; ct = efi_cfgtbl; diff --git a/sys/amd64/include/efi.h b/sys/amd64/include/efi.h index a0a39b4056e9..c29a1a4d09a8 100644 --- a/sys/amd64/include/efi.h +++ b/sys/amd64/include/efi.h @@ -49,6 +49,7 @@ struct uuid; struct efi_tm; +int efi_rt_ok(void); int efi_get_table(struct uuid *uuid, void **ptr); int efi_get_time(struct efi_tm *tm); int efi_get_time_locked(struct efi_tm *tm); diff --git a/sys/dev/efidev/efidev.c b/sys/dev/efidev/efidev.c index d6e0e06468e5..1b83d55d511c 100644 --- a/sys/dev/efidev/efidev.c +++ b/sys/dev/efidev/efidev.c @@ -39,14 +39,27 @@ __FBSDID("$FreeBSD$"); #include #include +static d_open_t efidev_open; static d_ioctl_t efidev_ioctl; static struct cdevsw efi_cdevsw = { .d_name = "efi", .d_version = D_VERSION, + .d_open = efidev_open, .d_ioctl = efidev_ioctl, }; +static int +efidev_open(struct cdev *dev __unused, int oflags __unused, + int devtype __unused, struct thread *td __unused) +{ + /* + * Only return success when we have an actual runtime to call. + */ + + return efi_rt_ok(); +} + static int efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr, int flags __unused, struct thread *td __unused)