linux/include/linux/pe.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright 2011 Red Hat, Inc.
 * All rights reserved.
 *
 * Author(s): Peter Jones <[email protected]>
 */
#ifndef __LINUX_PE_H
#define __LINUX_PE_H

#include <linux/types.h>

/*
 * Starting from version v3.0, the major version field should be interpreted as
 * a bit mask of features supported by the kernel's EFI stub:
 * - 0x1: initrd loading from the LINUX_EFI_INITRD_MEDIA_GUID device path,
 * - 0x2: initrd loading using the initrd= command line option, where the file
 *        may be specified using device path notation, and is not required to
 *        reside on the same volume as the loaded kernel image.
 *
 * The recommended way of loading and starting v1.0 or later kernels is to use
 * the LoadImage() and StartImage() EFI boot services, and expose the initrd
 * via the LINUX_EFI_INITRD_MEDIA_GUID device path.
 *
 * Versions older than v1.0 may support initrd loading via the image load
 * options (using initrd=, limited to the volume from which the kernel itself
 * was loaded), or only via arch specific means (bootparams, DT, etc).
 *
 * The minor version field must remain 0x0.
 * (https://lore.kernel.org/all/[email protected]/)
 */
#define LINUX_EFISTUB_MAJOR_VERSION
#define LINUX_EFISTUB_MINOR_VERSION

/*
 * LINUX_PE_MAGIC appears at offset 0x38 into the MS-DOS header of EFI bootable
 * Linux kernel images that target the architecture as specified by the PE/COFF
 * header machine type field.
 */
#define LINUX_PE_MAGIC

#define MZ_MAGIC

#define PE_MAGIC
#define PE_OPT_MAGIC_PE32
#define PE_OPT_MAGIC_PE32_ROM
#define PE_OPT_MAGIC_PE32PLUS

/* machine type */
#define IMAGE_FILE_MACHINE_UNKNOWN
#define IMAGE_FILE_MACHINE_AM33
#define IMAGE_FILE_MACHINE_AMD64
#define IMAGE_FILE_MACHINE_ARM
#define IMAGE_FILE_MACHINE_ARMV7
#define IMAGE_FILE_MACHINE_ARM64
#define IMAGE_FILE_MACHINE_EBC
#define IMAGE_FILE_MACHINE_I386
#define IMAGE_FILE_MACHINE_IA64
#define IMAGE_FILE_MACHINE_M32R
#define IMAGE_FILE_MACHINE_MIPS16
#define IMAGE_FILE_MACHINE_MIPSFPU
#define IMAGE_FILE_MACHINE_MIPSFPU16
#define IMAGE_FILE_MACHINE_POWERPC
#define IMAGE_FILE_MACHINE_POWERPCFP
#define IMAGE_FILE_MACHINE_R4000
#define IMAGE_FILE_MACHINE_RISCV32
#define IMAGE_FILE_MACHINE_RISCV64
#define IMAGE_FILE_MACHINE_RISCV128
#define IMAGE_FILE_MACHINE_SH3
#define IMAGE_FILE_MACHINE_SH3DSP
#define IMAGE_FILE_MACHINE_SH3E
#define IMAGE_FILE_MACHINE_SH4
#define IMAGE_FILE_MACHINE_SH5
#define IMAGE_FILE_MACHINE_THUMB
#define IMAGE_FILE_MACHINE_WCEMIPSV2
#define IMAGE_FILE_MACHINE_LOONGARCH32
#define IMAGE_FILE_MACHINE_LOONGARCH64

/* flags */
#define IMAGE_FILE_RELOCS_STRIPPED
#define IMAGE_FILE_EXECUTABLE_IMAGE
#define IMAGE_FILE_LINE_NUMS_STRIPPED
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED
#define IMAGE_FILE_AGGRESSIVE_WS_TRIM
#define IMAGE_FILE_LARGE_ADDRESS_AWARE
#define IMAGE_FILE_16BIT_MACHINE
#define IMAGE_FILE_BYTES_REVERSED_LO
#define IMAGE_FILE_32BIT_MACHINE
#define IMAGE_FILE_DEBUG_STRIPPED
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP
#define IMAGE_FILE_NET_RUN_FROM_SWAP
#define IMAGE_FILE_SYSTEM
#define IMAGE_FILE_DLL
#define IMAGE_FILE_UP_SYSTEM_ONLY
#define IMAGE_FILE_BYTES_REVERSED_HI

#define IMAGE_FILE_OPT_ROM_MAGIC
#define IMAGE_FILE_OPT_PE32_MAGIC
#define IMAGE_FILE_OPT_PE32_PLUS_MAGIC

#define IMAGE_SUBSYSTEM_UNKNOWN
#define IMAGE_SUBSYSTEM_NATIVE
#define IMAGE_SUBSYSTEM_WINDOWS_GUI
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
#define IMAGE_SUBSYSTEM_POSIX_CUI
#define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI
#define IMAGE_SUBSYSTEM_EFI_APPLICATION
#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
#define IMAGE_SUBSYSTEM_EFI_ROM_IMAGE
#define IMAGE_SUBSYSTEM_XBOX

#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY
#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION
#define IMAGE_DLLCHARACTERISTICS_NO_SEH
#define IMAGE_DLLCHARACTERISTICS_NO_BIND
#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER
#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE

#define IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT
#define IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT

/* they actually defined 0x00000000 as well, but I think we'll skip that one. */
#define IMAGE_SCN_RESERVED_0
#define IMAGE_SCN_RESERVED_1
#define IMAGE_SCN_RESERVED_2
#define IMAGE_SCN_TYPE_NO_PAD
#define IMAGE_SCN_RESERVED_3
#define IMAGE_SCN_CNT_CODE
#define IMAGE_SCN_CNT_INITIALIZED_DATA
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA
#define IMAGE_SCN_LNK_OTHER
#define IMAGE_SCN_LNK_INFO
#define IMAGE_SCN_RESERVED_4
#define IMAGE_SCN_LNK_REMOVE
#define IMAGE_SCN_LNK_COMDAT
#define IMAGE_SCN_RESERVED_5
#define IMAGE_SCN_RESERVED_6
#define IMAGE_SCN_GPREL
/* spec lists 0x20000 twice, I suspect they meant 0x10000 for one of them */
#define IMAGE_SCN_MEM_PURGEABLE
#define IMAGE_SCN_16BIT
#define IMAGE_SCN_LOCKED
#define IMAGE_SCN_PRELOAD
/* and here they just stuck a 1-byte integer in the middle of a bitfield */
#define IMAGE_SCN_ALIGN_1BYTES
#define IMAGE_SCN_ALIGN_2BYTES
#define IMAGE_SCN_ALIGN_4BYTES
#define IMAGE_SCN_ALIGN_8BYTES
#define IMAGE_SCN_ALIGN_16BYTES
#define IMAGE_SCN_ALIGN_32BYTES
#define IMAGE_SCN_ALIGN_64BYTES
#define IMAGE_SCN_ALIGN_128BYTES
#define IMAGE_SCN_ALIGN_256BYTES
#define IMAGE_SCN_ALIGN_512BYTES
#define IMAGE_SCN_ALIGN_1024BYTES
#define IMAGE_SCN_ALIGN_2048BYTES
#define IMAGE_SCN_ALIGN_4096BYTES
#define IMAGE_SCN_ALIGN_8192BYTES
#define IMAGE_SCN_LNK_NRELOC_OVFL
#define IMAGE_SCN_MEM_DISCARDABLE
#define IMAGE_SCN_MEM_NOT_CACHED
#define IMAGE_SCN_MEM_NOT_PAGED
#define IMAGE_SCN_MEM_SHARED
#define IMAGE_SCN_MEM_EXECUTE
#define IMAGE_SCN_MEM_READ
#define IMAGE_SCN_MEM_WRITE

#define IMAGE_DEBUG_TYPE_CODEVIEW
#define IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS

#ifndef __ASSEMBLY__

struct mz_hdr {};

struct mz_reloc {};

struct pe_hdr {};

/* the fact that pe32 isn't padded where pe32+ is 64-bit means union won't
 * work right.  vomit. */
struct pe32_opt_hdr {};

struct pe32plus_opt_hdr {};

struct data_dirent {};

struct data_directory {};

struct section_header {};

enum x64_coff_reloc_type {};

enum arm_coff_reloc_type {};

enum sh_coff_reloc_type {};

enum ppc_coff_reloc_type {};

enum x86_coff_reloc_type {};

enum ia64_coff_reloc_type {};

struct coff_reloc {};

/*
 * Definitions for the contents of the certs data block
 */
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA
#define WIN_CERT_TYPE_EFI_OKCS115
#define WIN_CERT_TYPE_EFI_GUID

#define WIN_CERT_REVISION_1_0
#define WIN_CERT_REVISION_2_0

struct win_certificate {};

#endif /* !__ASSEMBLY__ */

#endif /* __LINUX_PE_H */