Path: blob/main/sys/compat/linuxkpi/common/include/linux/efi.h
39604 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2021 Vladimir Kondratyev <[email protected]>4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,19* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25*/2627#ifndef _LINUXKPI_LINUX_EFI_H_28#define _LINUXKPI_LINUX_EFI_H_2930#include <sys/param.h>31#include <sys/queue.h>32#include <sys/linker.h>33#include <sys/systm.h>3435#include <machine/md_var.h>36#include <machine/metadata.h>3738#define EFI_BOOT 03940static inline bool41__efi_enabled(int feature)42{43bool enabled = false;4445switch (feature) {46case EFI_BOOT:47#ifdef __amd64__48/* Use cached value on amd64 */49enabled = efi_boot;50#elif defined(MODINFOMD_EFI_MAP)51enabled = preload_search_info(preload_kmdp,52MODINFO_METADATA | MODINFOMD_EFI_MAP) != NULL;53#endif54break;55default:56break;57}5859return (enabled);60}6162#define efi_enabled(x) ({ \63_Static_assert((x) == EFI_BOOT, "unsupported feature"); \64__efi_enabled(x); \65})6667#endif /* _LINUXKPI_LINUX_EFI_H_ */686970