diff --git a/src/loader/elf/mod.rs b/src/loader/elf/mod.rs index d7bf51a..10d3745 100644 --- a/src/loader/elf/mod.rs +++ b/src/loader/elf/mod.rs @@ -141,14 +141,14 @@ impl Elf { /// Verifies that magic numbers are present in the Elf header. fn validate_header(ehdr: &elf::Elf64_Ehdr) -> std::result::Result<(), Error> { // Sanity checks - if ehdr.e_ident[elf::EI_MAG0 as usize] != elf::ELFMAG0 as u8 - || ehdr.e_ident[elf::EI_MAG1 as usize] != elf::ELFMAG1 - || ehdr.e_ident[elf::EI_MAG2 as usize] != elf::ELFMAG2 - || ehdr.e_ident[elf::EI_MAG3 as usize] != elf::ELFMAG3 + if ehdr.e_ident[elf::EI_MAG0] != elf::ELFMAG0 + || ehdr.e_ident[elf::EI_MAG1] != elf::ELFMAG1 + || ehdr.e_ident[elf::EI_MAG2] != elf::ELFMAG2 + || ehdr.e_ident[elf::EI_MAG3] != elf::ELFMAG3 { return Err(Error::InvalidElfMagicNumber); } - if ehdr.e_ident[elf::EI_DATA as usize] != elf::ELFDATA2LSB as u8 { + if ehdr.e_ident[elf::EI_DATA] != elf::ELFDATA2LSB { return Err(Error::BigEndianElfOnLittle); } if ehdr.e_phentsize as usize != mem::size_of::() { diff --git a/src/loader_gen/x86_64/bootparam.rs b/src/loader_gen/x86_64/bootparam.rs index 12921cd..fb0f8bd 100644 --- a/src/loader_gen/x86_64/bootparam.rs +++ b/src/loader_gen/x86_64/bootparam.rs @@ -1,48 +1,10 @@ -// Copyright (c) 2019 Intel Corporation. All rights reserved. -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// -// Portions Copyright 2017 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-BSD-3-Clause file. -// -// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause +// Rust translation of arch/x86/include/uapi/asm/bootparam.h and its dependencies. +// All structs use #[repr(C, packed)] to match the kernel's binary layout exactly. -/* - * automatically generated by rust-bindgen 0.65.1 * - * From upstream linux arch/x86/include/uapi/asm/bootparam.h at commit: - * 48b1320a674e1ff5de2fad8606bee38f724594dc - */ +#![allow(non_camel_case_types, non_snake_case)] + +// --- setup_data.h constants --- -#[repr(C)] -#[derive(Default)] -pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); -impl __IncompleteArrayField { - #[inline] - pub const fn new() -> Self { - __IncompleteArrayField(::std::marker::PhantomData, []) - } - #[inline] - pub fn as_ptr(&self) -> *const T { - self as *const _ as *const T - } - #[inline] - pub fn as_mut_ptr(&mut self) -> *mut T { - self as *mut _ as *mut T - } - #[inline] - pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::std::slice::from_raw_parts(self.as_ptr(), len) - } - #[inline] - pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) - } -} -impl ::std::fmt::Debug for __IncompleteArrayField { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - fmt.write_str("__IncompleteArrayField") - } -} pub const SETUP_NONE: u32 = 0; pub const SETUP_E820_EXT: u32 = 1; pub const SETUP_DTB: u32 = 2; @@ -53,3997 +15,373 @@ pub const SETUP_JAILHOUSE: u32 = 6; pub const SETUP_CC_BLOB: u32 = 7; pub const SETUP_IMA: u32 = 8; pub const SETUP_RNG_SEED: u32 = 9; -pub const SETUP_ENUM_MAX: u32 = 9; -pub const SETUP_INDIRECT: u32 = 2147483648; -pub const SETUP_TYPE_MAX: u32 = 2147483657; -pub const RAMDISK_IMAGE_START_MASK: u32 = 2047; -pub const RAMDISK_PROMPT_FLAG: u32 = 32768; -pub const RAMDISK_LOAD_FLAG: u32 = 16384; -pub const LOADED_HIGH: u32 = 1; -pub const KASLR_FLAG: u32 = 2; -pub const QUIET_FLAG: u32 = 32; -pub const KEEP_SEGMENTS: u32 = 64; -pub const CAN_USE_HEAP: u32 = 128; -pub const XLF_KERNEL_64: u32 = 1; -pub const XLF_CAN_BE_LOADED_ABOVE_4G: u32 = 2; -pub const XLF_EFI_HANDOVER_32: u32 = 4; -pub const XLF_EFI_HANDOVER_64: u32 = 8; -pub const XLF_EFI_KEXEC: u32 = 16; -pub const XLF_5LEVEL: u32 = 32; -pub const XLF_5LEVEL_ENABLED: u32 = 64; -pub const __BITS_PER_LONG: u32 = 64; -pub const __FD_SETSIZE: u32 = 1024; -pub const VIDEO_TYPE_MDA: u32 = 16; -pub const VIDEO_TYPE_CGA: u32 = 17; -pub const VIDEO_TYPE_EGAM: u32 = 32; -pub const VIDEO_TYPE_EGAC: u32 = 33; -pub const VIDEO_TYPE_VGAC: u32 = 34; -pub const VIDEO_TYPE_VLFB: u32 = 35; -pub const VIDEO_TYPE_PICA_S3: u32 = 48; -pub const VIDEO_TYPE_MIPS_G364: u32 = 49; -pub const VIDEO_TYPE_SGI: u32 = 51; -pub const VIDEO_TYPE_TGAC: u32 = 64; -pub const VIDEO_TYPE_SUN: u32 = 80; -pub const VIDEO_TYPE_SUNPCI: u32 = 81; -pub const VIDEO_TYPE_PMAC: u32 = 96; -pub const VIDEO_TYPE_EFI: u32 = 112; -pub const VIDEO_FLAGS_NOCURSOR: u32 = 1; -pub const VIDEO_CAPABILITY_SKIP_QUIRKS: u32 = 1; -pub const VIDEO_CAPABILITY_64BIT_BASE: u32 = 2; -pub const APM_STATE_READY: u32 = 0; -pub const APM_STATE_STANDBY: u32 = 1; -pub const APM_STATE_SUSPEND: u32 = 2; -pub const APM_STATE_OFF: u32 = 3; -pub const APM_STATE_BUSY: u32 = 4; -pub const APM_STATE_REJECT: u32 = 5; -pub const APM_STATE_OEM_SYS: u32 = 32; -pub const APM_STATE_OEM_DEV: u32 = 64; -pub const APM_STATE_DISABLE: u32 = 0; -pub const APM_STATE_ENABLE: u32 = 1; -pub const APM_STATE_DISENGAGE: u32 = 0; -pub const APM_STATE_ENGAGE: u32 = 1; -pub const APM_SYS_STANDBY: u32 = 1; -pub const APM_SYS_SUSPEND: u32 = 2; -pub const APM_NORMAL_RESUME: u32 = 3; -pub const APM_CRITICAL_RESUME: u32 = 4; -pub const APM_LOW_BATTERY: u32 = 5; -pub const APM_POWER_STATUS_CHANGE: u32 = 6; -pub const APM_UPDATE_TIME: u32 = 7; -pub const APM_CRITICAL_SUSPEND: u32 = 8; -pub const APM_USER_STANDBY: u32 = 9; -pub const APM_USER_SUSPEND: u32 = 10; -pub const APM_STANDBY_RESUME: u32 = 11; -pub const APM_CAPABILITY_CHANGE: u32 = 12; -pub const APM_USER_HIBERNATION: u32 = 13; -pub const APM_HIBERNATION_RESUME: u32 = 14; -pub const APM_SUCCESS: u32 = 0; -pub const APM_DISABLED: u32 = 1; -pub const APM_CONNECTED: u32 = 2; -pub const APM_NOT_CONNECTED: u32 = 3; -pub const APM_16_CONNECTED: u32 = 5; -pub const APM_16_UNSUPPORTED: u32 = 6; -pub const APM_32_CONNECTED: u32 = 7; -pub const APM_32_UNSUPPORTED: u32 = 8; -pub const APM_BAD_DEVICE: u32 = 9; -pub const APM_BAD_PARAM: u32 = 10; -pub const APM_NOT_ENGAGED: u32 = 11; -pub const APM_BAD_FUNCTION: u32 = 12; -pub const APM_RESUME_DISABLED: u32 = 13; -pub const APM_NO_ERROR: u32 = 83; -pub const APM_BAD_STATE: u32 = 96; -pub const APM_NO_EVENTS: u32 = 128; -pub const APM_NOT_PRESENT: u32 = 134; -pub const APM_DEVICE_BIOS: u32 = 0; -pub const APM_DEVICE_ALL: u32 = 1; -pub const APM_DEVICE_DISPLAY: u32 = 256; -pub const APM_DEVICE_STORAGE: u32 = 512; -pub const APM_DEVICE_PARALLEL: u32 = 768; -pub const APM_DEVICE_SERIAL: u32 = 1024; -pub const APM_DEVICE_NETWORK: u32 = 1280; -pub const APM_DEVICE_PCMCIA: u32 = 1536; -pub const APM_DEVICE_BATTERY: u32 = 32768; -pub const APM_DEVICE_OEM: u32 = 57344; -pub const APM_DEVICE_OLD_ALL: u32 = 65535; -pub const APM_DEVICE_CLASS: u32 = 255; -pub const APM_DEVICE_MASK: u32 = 65280; -pub const APM_MAX_BATTERIES: u32 = 2; -pub const APM_CAP_GLOBAL_STANDBY: u32 = 1; -pub const APM_CAP_GLOBAL_SUSPEND: u32 = 2; -pub const APM_CAP_RESUME_STANDBY_TIMER: u32 = 4; -pub const APM_CAP_RESUME_SUSPEND_TIMER: u32 = 8; -pub const APM_CAP_RESUME_STANDBY_RING: u32 = 16; -pub const APM_CAP_RESUME_SUSPEND_RING: u32 = 32; -pub const APM_CAP_RESUME_STANDBY_PCMCIA: u32 = 64; -pub const APM_CAP_RESUME_SUSPEND_PCMCIA: u32 = 128; -pub const _IOC_NRBITS: u32 = 8; -pub const _IOC_TYPEBITS: u32 = 8; -pub const _IOC_SIZEBITS: u32 = 14; -pub const _IOC_DIRBITS: u32 = 2; -pub const _IOC_NRMASK: u32 = 255; -pub const _IOC_TYPEMASK: u32 = 255; -pub const _IOC_SIZEMASK: u32 = 16383; -pub const _IOC_DIRMASK: u32 = 3; -pub const _IOC_NRSHIFT: u32 = 0; -pub const _IOC_TYPESHIFT: u32 = 8; -pub const _IOC_SIZESHIFT: u32 = 16; -pub const _IOC_DIRSHIFT: u32 = 30; -pub const _IOC_NONE: u32 = 0; -pub const _IOC_WRITE: u32 = 1; -pub const _IOC_READ: u32 = 2; -pub const IOC_IN: u32 = 1073741824; -pub const IOC_OUT: u32 = 2147483648; -pub const IOC_INOUT: u32 = 3221225472; -pub const IOCSIZE_MASK: u32 = 1073676288; -pub const IOCSIZE_SHIFT: u32 = 16; -pub const EDDNR: u32 = 489; -pub const EDDBUF: u32 = 3328; -pub const EDDMAXNR: u32 = 6; -pub const EDDEXTSIZE: u32 = 8; -pub const EDDPARMSIZE: u32 = 74; -pub const CHECKEXTENSIONSPRESENT: u32 = 65; -pub const GETDEVICEPARAMETERS: u32 = 72; -pub const LEGACYGETDEVICEPARAMETERS: u32 = 8; -pub const EDDMAGIC1: u32 = 21930; -pub const EDDMAGIC2: u32 = 43605; -pub const READ_SECTORS: u32 = 2; -pub const EDD_MBR_SIG_OFFSET: u32 = 440; -pub const EDD_MBR_SIG_BUF: u32 = 656; -pub const EDD_MBR_SIG_MAX: u32 = 16; -pub const EDD_MBR_SIG_NR_BUF: u32 = 490; -pub const EDD_EXT_FIXED_DISK_ACCESS: u32 = 1; -pub const EDD_EXT_DEVICE_LOCKING_AND_EJECTING: u32 = 2; -pub const EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT: u32 = 4; -pub const EDD_EXT_64BIT_EXTENSIONS: u32 = 8; -pub const EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT: u32 = 1; -pub const EDD_INFO_GEOMETRY_VALID: u32 = 2; -pub const EDD_INFO_REMOVABLE: u32 = 4; -pub const EDD_INFO_WRITE_VERIFY: u32 = 8; -pub const EDD_INFO_MEDIA_CHANGE_NOTIFICATION: u32 = 16; -pub const EDD_INFO_LOCKABLE: u32 = 32; -pub const EDD_INFO_NO_MEDIA_PRESENT: u32 = 64; -pub const EDD_INFO_USE_INT13_FN50: u32 = 128; -pub const E820_MAX_ENTRIES_ZEROPAGE: u32 = 128; +pub const SETUP_KEXEC_KHO: u32 = 10; +pub const SETUP_ENUM_MAX: u32 = SETUP_KEXEC_KHO; +pub const SETUP_INDIRECT: u32 = 1 << 31; +pub const SETUP_TYPE_MAX: u32 = SETUP_ENUM_MAX | SETUP_INDIRECT; + +// --- bootparam.h constants --- + +pub const RAMDISK_IMAGE_START_MASK: u16 = 0x07FF; +pub const RAMDISK_PROMPT_FLAG: u16 = 0x8000; +pub const RAMDISK_LOAD_FLAG: u16 = 0x4000; + +pub const LOADED_HIGH: u8 = 1 << 0; +pub const KASLR_FLAG: u8 = 1 << 1; +pub const QUIET_FLAG: u8 = 1 << 5; +pub const KEEP_SEGMENTS: u8 = 1 << 6; +pub const CAN_USE_HEAP: u8 = 1 << 7; + +pub const XLF_KERNEL_64: u16 = 1 << 0; +pub const XLF_CAN_BE_LOADED_ABOVE_4G: u16 = 1 << 1; +pub const XLF_EFI_HANDOVER_32: u16 = 1 << 2; +pub const XLF_EFI_HANDOVER_64: u16 = 1 << 3; +pub const XLF_EFI_KEXEC: u16 = 1 << 4; +pub const XLF_5LEVEL: u16 = 1 << 5; +pub const XLF_5LEVEL_ENABLED: u16 = 1 << 6; +pub const XLF_MEM_ENCRYPTION: u16 = 1 << 7; + +pub const E820_MAX_ENTRIES_ZEROPAGE: usize = 128; pub const JAILHOUSE_SETUP_REQUIRED_VERSION: u32 = 1; -pub type __s8 = ::std::os::raw::c_schar; -pub type __u8 = ::std::os::raw::c_uchar; -pub type __s16 = ::std::os::raw::c_short; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __s32 = ::std::os::raw::c_int; -pub type __u32 = ::std::os::raw::c_uint; -pub type __s64 = ::std::os::raw::c_longlong; -pub type __u64 = ::std::os::raw::c_ulonglong; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct __kernel_fd_set { - pub fds_bits: [::std::os::raw::c_ulong; 16usize], -} -#[test] -fn bindgen_test_layout___kernel_fd_set() { - const UNINIT: ::std::mem::MaybeUninit<__kernel_fd_set> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__kernel_fd_set>(), - 128usize, - concat!("Size of: ", stringify!(__kernel_fd_set)) - ); - assert_eq!( - ::std::mem::align_of::<__kernel_fd_set>(), - 8usize, - concat!("Alignment of ", stringify!(__kernel_fd_set)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__kernel_fd_set), - "::", - stringify!(fds_bits) - ) - ); -} -pub type __kernel_sighandler_t = - ::std::option::Option; -pub type __kernel_key_t = ::std::os::raw::c_int; -pub type __kernel_mqd_t = ::std::os::raw::c_int; -pub type __kernel_old_uid_t = ::std::os::raw::c_ushort; -pub type __kernel_old_gid_t = ::std::os::raw::c_ushort; -pub type __kernel_old_dev_t = ::std::os::raw::c_ulong; -pub type __kernel_long_t = ::std::os::raw::c_long; -pub type __kernel_ulong_t = ::std::os::raw::c_ulong; -pub type __kernel_ino_t = __kernel_ulong_t; -pub type __kernel_mode_t = ::std::os::raw::c_uint; -pub type __kernel_pid_t = ::std::os::raw::c_int; -pub type __kernel_ipc_pid_t = ::std::os::raw::c_int; -pub type __kernel_uid_t = ::std::os::raw::c_uint; -pub type __kernel_gid_t = ::std::os::raw::c_uint; -pub type __kernel_suseconds_t = __kernel_long_t; -pub type __kernel_daddr_t = ::std::os::raw::c_int; -pub type __kernel_uid32_t = ::std::os::raw::c_uint; -pub type __kernel_gid32_t = ::std::os::raw::c_uint; -pub type __kernel_size_t = __kernel_ulong_t; -pub type __kernel_ssize_t = __kernel_long_t; -pub type __kernel_ptrdiff_t = __kernel_long_t; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct __kernel_fsid_t { - pub val: [::std::os::raw::c_int; 2usize], -} -#[test] -fn bindgen_test_layout___kernel_fsid_t() { - const UNINIT: ::std::mem::MaybeUninit<__kernel_fsid_t> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__kernel_fsid_t>(), - 8usize, - concat!("Size of: ", stringify!(__kernel_fsid_t)) - ); - assert_eq!( - ::std::mem::align_of::<__kernel_fsid_t>(), - 4usize, - concat!("Alignment of ", stringify!(__kernel_fsid_t)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__kernel_fsid_t), - "::", - stringify!(val) - ) - ); -} -pub type __kernel_off_t = __kernel_long_t; -pub type __kernel_loff_t = ::std::os::raw::c_longlong; -pub type __kernel_old_time_t = __kernel_long_t; -pub type __kernel_time_t = __kernel_long_t; -pub type __kernel_time64_t = ::std::os::raw::c_longlong; -pub type __kernel_clock_t = __kernel_long_t; -pub type __kernel_timer_t = ::std::os::raw::c_int; -pub type __kernel_clockid_t = ::std::os::raw::c_int; -pub type __kernel_caddr_t = *mut ::std::os::raw::c_char; -pub type __kernel_uid16_t = ::std::os::raw::c_ushort; -pub type __kernel_gid16_t = ::std::os::raw::c_ushort; -pub type __le16 = __u16; -pub type __be16 = __u16; -pub type __le32 = __u32; -pub type __be32 = __u32; -pub type __le64 = __u64; -pub type __be64 = __u64; -pub type __sum16 = __u16; -pub type __wsum = __u32; -pub type __poll_t = ::std::os::raw::c_uint; + +// --- edd.h constants --- + +pub const EDDNR: u16 = 0x1e9; +pub const EDDBUF: u16 = 0xd00; +pub const EDDMAXNR: usize = 6; +pub const EDDEXTSIZE: usize = 8; +pub const EDDPARMSIZE: usize = 74; +pub const CHECKEXTENSIONSPRESENT: u8 = 0x41; +pub const GETDEVICEPARAMETERS: u8 = 0x48; +pub const LEGACYGETDEVICEPARAMETERS: u8 = 0x08; +pub const EDDMAGIC1: u16 = 0x55AA; +pub const EDDMAGIC2: u16 = 0xAA55; + +pub const READ_SECTORS: u8 = 0x02; +pub const EDD_MBR_SIG_OFFSET: u16 = 0x1B8; +pub const EDD_MBR_SIG_BUF: u16 = 0x290; +pub const EDD_MBR_SIG_MAX: usize = 16; +pub const EDD_MBR_SIG_NR_BUF: u16 = 0x1ea; + +pub const EDD_EXT_FIXED_DISK_ACCESS: u16 = 1 << 0; +pub const EDD_EXT_DEVICE_LOCKING_AND_EJECTING: u16 = 1 << 1; +pub const EDD_EXT_ENHANCED_DISK_DRIVE_SUPPORT: u16 = 1 << 2; +pub const EDD_EXT_64BIT_EXTENSIONS: u16 = 1 << 3; + +pub const EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT: u16 = 1 << 0; +pub const EDD_INFO_GEOMETRY_VALID: u16 = 1 << 1; +pub const EDD_INFO_REMOVABLE: u16 = 1 << 2; +pub const EDD_INFO_WRITE_VERIFY: u16 = 1 << 3; +pub const EDD_INFO_MEDIA_CHANGE_NOTIFICATION: u16 = 1 << 4; +pub const EDD_INFO_LOCKABLE: u16 = 1 << 5; +pub const EDD_INFO_NO_MEDIA_PRESENT: u16 = 1 << 6; +pub const EDD_INFO_USE_INT13_FN50: u16 = 1 << 7; + +// --- screen_info.h constants --- + +pub const VIDEO_TYPE_MDA: u8 = 0x10; +pub const VIDEO_TYPE_CGA: u8 = 0x11; +pub const VIDEO_TYPE_EGAM: u8 = 0x20; +pub const VIDEO_TYPE_EGAC: u8 = 0x21; +pub const VIDEO_TYPE_VGAC: u8 = 0x22; +pub const VIDEO_TYPE_VLFB: u8 = 0x23; +pub const VIDEO_TYPE_PICA_S3: u8 = 0x30; +pub const VIDEO_TYPE_MIPS_G364: u8 = 0x31; +pub const VIDEO_TYPE_SGI: u8 = 0x33; +pub const VIDEO_TYPE_TGAC: u8 = 0x40; +pub const VIDEO_TYPE_SUN: u8 = 0x50; +pub const VIDEO_TYPE_SUNPCI: u8 = 0x51; +pub const VIDEO_TYPE_PMAC: u8 = 0x60; +pub const VIDEO_TYPE_EFI: u8 = 0x70; + +pub const VIDEO_FLAGS_NOCURSOR: u8 = 1 << 0; +pub const VIDEO_CAPABILITY_SKIP_QUIRKS: u32 = 1 << 0; +pub const VIDEO_CAPABILITY_64BIT_BASE: u32 = 1 << 1; + +// ============================================================================ +// Struct definitions +// ============================================================================ + +/// From include/uapi/linux/screen_info.h #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct screen_info { - pub orig_x: __u8, - pub orig_y: __u8, - pub ext_mem_k: __u16, - pub orig_video_page: __u16, - pub orig_video_mode: __u8, - pub orig_video_cols: __u8, - pub flags: __u8, - pub unused2: __u8, - pub orig_video_ega_bx: __u16, - pub unused3: __u16, - pub orig_video_lines: __u8, - pub orig_video_isVGA: __u8, - pub orig_video_points: __u16, - pub lfb_width: __u16, - pub lfb_height: __u16, - pub lfb_depth: __u16, - pub lfb_base: __u32, - pub lfb_size: __u32, - pub cl_magic: __u16, - pub cl_offset: __u16, - pub lfb_linelength: __u16, - pub red_size: __u8, - pub red_pos: __u8, - pub green_size: __u8, - pub green_pos: __u8, - pub blue_size: __u8, - pub blue_pos: __u8, - pub rsvd_size: __u8, - pub rsvd_pos: __u8, - pub vesapm_seg: __u16, - pub vesapm_off: __u16, - pub pages: __u16, - pub vesa_attributes: __u16, - pub capabilities: __u32, - pub ext_lfb_base: __u32, - pub _reserved: [__u8; 2usize], -} -#[test] -fn bindgen_test_layout_screen_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(screen_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(screen_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_y) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_mem_k) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(ext_mem_k) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_page) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_page) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_mode) as usize - ptr as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_mode) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_cols) as usize - ptr as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_cols) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).unused2) as usize - ptr as usize }, - 9usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(unused2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_ega_bx) as usize - ptr as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_ega_bx) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).unused3) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(unused3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_lines) as usize - ptr as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_lines) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_isVGA) as usize - ptr as usize }, - 15usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_isVGA) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).orig_video_points) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(orig_video_points) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lfb_width) as usize - ptr as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(lfb_width) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lfb_height) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(lfb_height) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lfb_depth) as usize - ptr as usize }, - 22usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(lfb_depth) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lfb_base) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(lfb_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lfb_size) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(lfb_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cl_magic) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(cl_magic) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cl_offset) as usize - ptr as usize }, - 34usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(cl_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lfb_linelength) as usize - ptr as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(lfb_linelength) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).red_size) as usize - ptr as usize }, - 38usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(red_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).red_pos) as usize - ptr as usize }, - 39usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(red_pos) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).green_size) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(green_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).green_pos) as usize - ptr as usize }, - 41usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(green_pos) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).blue_size) as usize - ptr as usize }, - 42usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(blue_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).blue_pos) as usize - ptr as usize }, - 43usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(blue_pos) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rsvd_size) as usize - ptr as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(rsvd_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rsvd_pos) as usize - ptr as usize }, - 45usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(rsvd_pos) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vesapm_seg) as usize - ptr as usize }, - 46usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(vesapm_seg) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vesapm_off) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(vesapm_off) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pages) as usize - ptr as usize }, - 50usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(pages) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vesa_attributes) as usize - ptr as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(vesa_attributes) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).capabilities) as usize - ptr as usize }, - 54usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(capabilities) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_lfb_base) as usize - ptr as usize }, - 58usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(ext_lfb_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._reserved) as usize - ptr as usize }, - 62usize, - concat!( - "Offset of field: ", - stringify!(screen_info), - "::", - stringify!(_reserved) - ) - ); -} -pub type apm_event_t = ::std::os::raw::c_ushort; -pub type apm_eventinfo_t = ::std::os::raw::c_ushort; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct apm_bios_info { - pub version: __u16, - pub cseg: __u16, - pub offset: __u32, - pub cseg_16: __u16, - pub dseg: __u16, - pub flags: __u16, - pub cseg_len: __u16, - pub cseg_16_len: __u16, - pub dseg_len: __u16, -} -#[test] -fn bindgen_test_layout_apm_bios_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 20usize, - concat!("Size of: ", stringify!(apm_bios_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(apm_bios_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cseg) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(cseg) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cseg_16) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(cseg_16) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dseg) as usize - ptr as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(dseg) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cseg_len) as usize - ptr as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(cseg_len) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cseg_16_len) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(cseg_16_len) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dseg_len) as usize - ptr as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(apm_bios_info), - "::", - stringify!(dseg_len) - ) - ); -} -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct edd_device_params { - pub length: __u16, - pub info_flags: __u16, - pub num_default_cylinders: __u32, - pub num_default_heads: __u32, - pub sectors_per_track: __u32, - pub number_of_sectors: __u64, - pub bytes_per_sector: __u16, - pub dpte_ptr: __u32, - pub key: __u16, - pub device_path_info_length: __u8, - pub reserved2: __u8, - pub reserved3: __u16, - pub host_bus_type: [__u8; 4usize], - pub interface_type: [__u8; 8usize], - pub interface_path: edd_device_params__bindgen_ty_1, - pub device_path: edd_device_params__bindgen_ty_2, - pub reserved4: __u8, - pub checksum: __u8, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union edd_device_params__bindgen_ty_1 { - pub isa: edd_device_params__bindgen_ty_1__bindgen_ty_1, - pub pci: edd_device_params__bindgen_ty_1__bindgen_ty_2, - pub ibnd: edd_device_params__bindgen_ty_1__bindgen_ty_3, - pub xprs: edd_device_params__bindgen_ty_1__bindgen_ty_4, - pub htpt: edd_device_params__bindgen_ty_1__bindgen_ty_5, - pub unknown: edd_device_params__bindgen_ty_1__bindgen_ty_6, -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_1__bindgen_ty_1 { - pub base_address: __u16, - pub reserved1: __u16, - pub reserved2: __u32, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).base_address) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(base_address) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_1), - "::", - stringify!(reserved2) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_1__bindgen_ty_2 { - pub bus: __u8, - pub slot: __u8, - pub function: __u8, - pub channel: __u8, - pub reserved: __u32, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bus) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(bus) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).slot) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(slot) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).function) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(function) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).channel) as usize - ptr as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(channel) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_2), - "::", - stringify!(reserved) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_1__bindgen_ty_3 { - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_3() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_3) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_3), - "::", - stringify!(reserved) - ) - ); + pub orig_x: u8, + pub orig_y: u8, + pub ext_mem_k: u16, + pub orig_video_page: u16, + pub orig_video_mode: u8, + pub orig_video_cols: u8, + pub flags: u8, + pub unused2: u8, + pub orig_video_ega_bx: u16, + pub unused3: u16, + pub orig_video_lines: u8, + pub orig_video_isVGA: u8, + pub orig_video_points: u16, + pub lfb_width: u16, + pub lfb_height: u16, + pub lfb_depth: u16, + pub lfb_base: u32, + pub lfb_size: u32, + pub cl_magic: u16, + pub cl_offset: u16, + pub lfb_linelength: u16, + pub red_size: u8, + pub red_pos: u8, + pub green_size: u8, + pub green_pos: u8, + pub blue_size: u8, + pub blue_pos: u8, + pub rsvd_size: u8, + pub rsvd_pos: u8, + pub vesapm_seg: u16, + pub vesapm_off: u16, + pub pages: u16, + pub vesa_attributes: u16, + pub capabilities: u32, + pub ext_lfb_base: u32, + pub _reserved: [u8; 2], } + +/// From include/uapi/linux/apm_bios.h #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_1__bindgen_ty_4 { - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_4() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_4) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_4) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_4), - "::", - stringify!(reserved) - ) - ); +pub struct apm_bios_info { + pub version: u16, + pub cseg: u16, + pub offset: u32, + pub cseg_16: u16, + pub dseg: u16, + pub flags: u16, + pub cseg_len: u16, + pub cseg_16_len: u16, + pub dseg_len: u16, } + +/// From arch/x86/include/uapi/asm/ist.h #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_1__bindgen_ty_5 { - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_5() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_5) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_5) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_5), - "::", - stringify!(reserved) - ) - ); +pub struct ist_info { + pub signature: u32, + pub command: u32, + pub event: u32, + pub perf_level: u32, } + +/// From include/uapi/video/edid.h #[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_1__bindgen_ty_6 { - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1__bindgen_ty_6() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_6) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_6) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1__bindgen_ty_6), - "::", - stringify!(reserved) - ) - ); -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(edd_device_params__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(edd_device_params__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).isa) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1), - "::", - stringify!(isa) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pci) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1), - "::", - stringify!(pci) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ibnd) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1), - "::", - stringify!(ibnd) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).xprs) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1), - "::", - stringify!(xprs) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).htpt) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1), - "::", - stringify!(htpt) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).unknown) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_1), - "::", - stringify!(unknown) - ) - ); +#[derive(Debug, Copy, Clone, PartialEq)] +pub struct edid_info { + pub dummy: [u8; 128], } -impl Default for edd_device_params__bindgen_ty_1 { + +impl Default for edid_info { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } + unsafe { core::mem::zeroed() } } } -#[repr(C)] -#[derive(Copy, Clone)] -pub union edd_device_params__bindgen_ty_2 { - pub ata: edd_device_params__bindgen_ty_2__bindgen_ty_1, - pub atapi: edd_device_params__bindgen_ty_2__bindgen_ty_2, - pub scsi: edd_device_params__bindgen_ty_2__bindgen_ty_3, - pub usb: edd_device_params__bindgen_ty_2__bindgen_ty_4, - pub i1394: edd_device_params__bindgen_ty_2__bindgen_ty_5, - pub fibre: edd_device_params__bindgen_ty_2__bindgen_ty_6, - pub i2o: edd_device_params__bindgen_ty_2__bindgen_ty_7, - pub raid: edd_device_params__bindgen_ty_2__bindgen_ty_8, - pub sata: edd_device_params__bindgen_ty_2__bindgen_ty_9, - pub unknown: edd_device_params__bindgen_ty_2__bindgen_ty_10, -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_1 { - pub device: __u8, - pub reserved1: __u8, - pub reserved2: __u16, - pub reserved3: __u32, - pub reserved4: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1), - "::", - stringify!(reserved2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1), - "::", - stringify!(reserved3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_1), - "::", - stringify!(reserved4) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_2 { - pub device: __u8, - pub lun: __u8, - pub reserved1: __u8, - pub reserved2: __u8, - pub reserved3: __u32, - pub reserved4: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2), - "::", - stringify!(lun) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2), - "::", - stringify!(reserved2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2), - "::", - stringify!(reserved3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_2), - "::", - stringify!(reserved4) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_3 { - pub id: __u16, - pub lun: __u64, - pub reserved1: __u16, - pub reserved2: __u32, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_3() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_3) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_3), - "::", - stringify!(id) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_3), - "::", - stringify!(lun) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_3), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_3), - "::", - stringify!(reserved2) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_4 { - pub serial_number: __u64, - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_4() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_4) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_4) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).serial_number) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_4), - "::", - stringify!(serial_number) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_4), - "::", - stringify!(reserved) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_5 { - pub eui: __u64, - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_5() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_5) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_5) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).eui) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_5), - "::", - stringify!(eui) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_5), - "::", - stringify!(reserved) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_6 { - pub wwid: __u64, - pub lun: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_6() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_6) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_6) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).wwid) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_6), - "::", - stringify!(wwid) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).lun) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_6), - "::", - stringify!(lun) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_7 { - pub identity_tag: __u64, - pub reserved: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_7() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_7) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_7) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).identity_tag) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_7), - "::", - stringify!(identity_tag) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_7), - "::", - stringify!(reserved) - ) - ); -} + +/// From arch/x86/include/uapi/asm/setup_data.h #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_8 { - pub array_number: __u32, - pub reserved1: __u32, - pub reserved2: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_8() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_8) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_8) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).array_number) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_8), - "::", - stringify!(array_number) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_8), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_8), - "::", - stringify!(reserved2) - ) - ); +pub struct boot_e820_entry { + pub addr: u64, + pub size: u64, + pub r#type: u32, } + +/// From include/uapi/linux/edd.h +/// +/// The `interface_path` and `device_path` fields are unions in C. They are +/// represented here as fixed-size byte arrays (8 and 16 bytes respectively) +/// for simplicity. Transmute or use `ptr::read_unaligned` to access a +/// specific variant. #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_9 { - pub device: __u8, - pub reserved1: __u8, - pub reserved2: __u16, - pub reserved3: __u32, - pub reserved4: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_9() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9), - "::", - stringify!(reserved2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9), - "::", - stringify!(reserved3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_9), - "::", - stringify!(reserved4) - ) - ); +pub struct edd_device_params { + pub length: u16, + pub info_flags: u16, + pub num_default_cylinders: u32, + pub num_default_heads: u32, + pub sectors_per_track: u32, + pub number_of_sectors: u64, + pub bytes_per_sector: u16, + pub dpte_ptr: u32, + pub key: u16, + pub device_path_info_length: u8, + pub reserved2: u8, + pub reserved3: u16, + pub host_bus_type: [u8; 4], + pub interface_type: [u8; 8], + pub interface_path: [u8; 8], + pub device_path: [u8; 16], + pub reserved4: u8, + pub checksum: u8, } + +/// From include/uapi/linux/edd.h #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct edd_device_params__bindgen_ty_2__bindgen_ty_10 { - pub reserved1: __u64, - pub reserved2: __u64, -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2__bindgen_ty_10() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!( - "Size of: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_10) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_10) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved1) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_10), - "::", - stringify!(reserved1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2__bindgen_ty_10), - "::", - stringify!(reserved2) - ) - ); -} -#[test] -fn bindgen_test_layout_edd_device_params__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(edd_device_params__bindgen_ty_2)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(edd_device_params__bindgen_ty_2)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ata) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(ata) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).atapi) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(atapi) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).scsi) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(scsi) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).usb) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(usb) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).i1394) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(i1394) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fibre) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(fibre) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).i2o) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(i2o) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).raid) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(raid) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sata) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(sata) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).unknown) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params__bindgen_ty_2), - "::", - stringify!(unknown) - ) - ); -} -impl Default for edd_device_params__bindgen_ty_2 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[test] -fn bindgen_test_layout_edd_device_params() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 74usize, - concat!("Size of: ", stringify!(edd_device_params)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(edd_device_params)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).info_flags) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(info_flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).num_default_cylinders) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(num_default_cylinders) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).num_default_heads) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(num_default_heads) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sectors_per_track) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(sectors_per_track) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).number_of_sectors) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(number_of_sectors) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bytes_per_sector) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(bytes_per_sector) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dpte_ptr) as usize - ptr as usize }, - 26usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(dpte_ptr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, - 30usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(key) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).device_path_info_length) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(device_path_info_length) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved2) as usize - ptr as usize }, - 33usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(reserved2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved3) as usize - ptr as usize }, - 34usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(reserved3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).host_bus_type) as usize - ptr as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(host_bus_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).interface_type) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(interface_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).interface_path) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(interface_path) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).device_path) as usize - ptr as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(device_path) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved4) as usize - ptr as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(reserved4) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).checksum) as usize - ptr as usize }, - 73usize, - concat!( - "Offset of field: ", - stringify!(edd_device_params), - "::", - stringify!(checksum) - ) - ); -} -impl Default for edd_device_params { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C, packed)] -#[derive(Copy, Clone)] pub struct edd_info { - pub device: __u8, - pub version: __u8, - pub interface_support: __u16, - pub legacy_max_cylinder: __u16, - pub legacy_max_head: __u8, - pub legacy_sectors_per_track: __u8, + pub device: u8, + pub version: u8, + pub interface_support: u16, + pub legacy_max_cylinder: u16, + pub legacy_max_head: u8, + pub legacy_sectors_per_track: u8, pub params: edd_device_params, } -#[test] -fn bindgen_test_layout_edd_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 82usize, - concat!("Size of: ", stringify!(edd_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(edd_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).device) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(device) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).interface_support) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(interface_support) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).legacy_max_cylinder) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(legacy_max_cylinder) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).legacy_max_head) as usize - ptr as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(legacy_max_head) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).legacy_sectors_per_track) as usize - ptr as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(legacy_sectors_per_track) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).params) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(edd_info), - "::", - stringify!(params) - ) - ); -} -impl Default for edd_info { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct edd { - pub mbr_signature: [::std::os::raw::c_uint; 16usize], - pub edd_info: [edd_info; 6usize], - pub mbr_signature_nr: ::std::os::raw::c_uchar, - pub edd_info_nr: ::std::os::raw::c_uchar, -} -#[test] -fn bindgen_test_layout_edd() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 560usize, - concat!("Size of: ", stringify!(edd)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(edd)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mbr_signature) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edd), - "::", - stringify!(mbr_signature) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).edd_info) as usize - ptr as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(edd), - "::", - stringify!(edd_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mbr_signature_nr) as usize - ptr as usize }, - 556usize, - concat!( - "Offset of field: ", - stringify!(edd), - "::", - stringify!(mbr_signature_nr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).edd_info_nr) as usize - ptr as usize }, - 557usize, - concat!( - "Offset of field: ", - stringify!(edd), - "::", - stringify!(edd_info_nr) - ) - ); -} -impl Default for edd { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct ist_info { - pub signature: __u32, - pub command: __u32, - pub event: __u32, - pub perf_level: __u32, -} -#[test] -fn bindgen_test_layout_ist_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(ist_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(ist_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).signature) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(ist_info), - "::", - stringify!(signature) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).command) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(ist_info), - "::", - stringify!(command) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).event) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(ist_info), - "::", - stringify!(event) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).perf_level) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(ist_info), - "::", - stringify!(perf_level) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct edid_info { - pub dummy: [::std::os::raw::c_uchar; 128usize], -} -#[test] -fn bindgen_test_layout_edid_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 128usize, - concat!("Size of: ", stringify!(edid_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(edid_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).dummy) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(edid_info), - "::", - stringify!(dummy) - ) - ); -} -impl Default for edid_info { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C)] -#[derive(Debug, Default)] -pub struct setup_data { - pub next: __u64, - pub type_: __u32, - pub len: __u32, - pub data: __IncompleteArrayField<__u8>, -} -#[test] -fn bindgen_test_layout_setup_data() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(setup_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(setup_data)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(setup_data), - "::", - stringify!(next) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(setup_data), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(setup_data), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(setup_data), - "::", - stringify!(data) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct setup_indirect { - pub type_: __u32, - pub reserved: __u32, - pub len: __u64, - pub addr: __u64, -} -#[test] -fn bindgen_test_layout_setup_indirect() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(setup_indirect)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(setup_indirect)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(setup_indirect), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(setup_indirect), - "::", - stringify!(reserved) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).len) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(setup_indirect), - "::", - stringify!(len) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(setup_indirect), - "::", - stringify!(addr) - ) - ); -} + +/// From arch/x86/include/uapi/asm/bootparam.h #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct setup_header { - pub setup_sects: __u8, - pub root_flags: __u16, - pub syssize: __u32, - pub ram_size: __u16, - pub vid_mode: __u16, - pub root_dev: __u16, - pub boot_flag: __u16, - pub jump: __u16, - pub header: __u32, - pub version: __u16, - pub realmode_swtch: __u32, - pub start_sys_seg: __u16, - pub kernel_version: __u16, - pub type_of_loader: __u8, - pub loadflags: __u8, - pub setup_move_size: __u16, - pub code32_start: __u32, - pub ramdisk_image: __u32, - pub ramdisk_size: __u32, - pub bootsect_kludge: __u32, - pub heap_end_ptr: __u16, - pub ext_loader_ver: __u8, - pub ext_loader_type: __u8, - pub cmd_line_ptr: __u32, - pub initrd_addr_max: __u32, - pub kernel_alignment: __u32, - pub relocatable_kernel: __u8, - pub min_alignment: __u8, - pub xloadflags: __u16, - pub cmdline_size: __u32, - pub hardware_subarch: __u32, - pub hardware_subarch_data: __u64, - pub payload_offset: __u32, - pub payload_length: __u32, - pub setup_data: __u64, - pub pref_address: __u64, - pub init_size: __u32, - pub handover_offset: __u32, - pub kernel_info_offset: __u32, -} -#[test] -fn bindgen_test_layout_setup_header() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 123usize, - concat!("Size of: ", stringify!(setup_header)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(setup_header)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).setup_sects) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(setup_sects) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).root_flags) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(root_flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).syssize) as usize - ptr as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(syssize) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ram_size) as usize - ptr as usize }, - 7usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(ram_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).vid_mode) as usize - ptr as usize }, - 9usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(vid_mode) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).root_dev) as usize - ptr as usize }, - 11usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(root_dev) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).boot_flag) as usize - ptr as usize }, - 13usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(boot_flag) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).jump) as usize - ptr as usize }, - 15usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(jump) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).header) as usize - ptr as usize }, - 17usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(header) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 21usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).realmode_swtch) as usize - ptr as usize }, - 23usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(realmode_swtch) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).start_sys_seg) as usize - ptr as usize }, - 27usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(start_sys_seg) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).kernel_version) as usize - ptr as usize }, - 29usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(kernel_version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_of_loader) as usize - ptr as usize }, - 31usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(type_of_loader) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).loadflags) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(loadflags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).setup_move_size) as usize - ptr as usize }, - 33usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(setup_move_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).code32_start) as usize - ptr as usize }, - 35usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(code32_start) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ramdisk_image) as usize - ptr as usize }, - 39usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(ramdisk_image) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ramdisk_size) as usize - ptr as usize }, - 43usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(ramdisk_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).bootsect_kludge) as usize - ptr as usize }, - 47usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(bootsect_kludge) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).heap_end_ptr) as usize - ptr as usize }, - 51usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(heap_end_ptr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_loader_ver) as usize - ptr as usize }, - 53usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(ext_loader_ver) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_loader_type) as usize - ptr as usize }, - 54usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(ext_loader_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cmd_line_ptr) as usize - ptr as usize }, - 55usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(cmd_line_ptr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).initrd_addr_max) as usize - ptr as usize }, - 59usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(initrd_addr_max) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).kernel_alignment) as usize - ptr as usize }, - 63usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(kernel_alignment) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).relocatable_kernel) as usize - ptr as usize }, - 67usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(relocatable_kernel) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).min_alignment) as usize - ptr as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(min_alignment) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).xloadflags) as usize - ptr as usize }, - 69usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(xloadflags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cmdline_size) as usize - ptr as usize }, - 71usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(cmdline_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hardware_subarch) as usize - ptr as usize }, - 75usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(hardware_subarch) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hardware_subarch_data) as usize - ptr as usize }, - 79usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(hardware_subarch_data) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).payload_offset) as usize - ptr as usize }, - 87usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(payload_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).payload_length) as usize - ptr as usize }, - 91usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(payload_length) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).setup_data) as usize - ptr as usize }, - 95usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(setup_data) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pref_address) as usize - ptr as usize }, - 103usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(pref_address) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).init_size) as usize - ptr as usize }, - 111usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(init_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).handover_offset) as usize - ptr as usize }, - 115usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(handover_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).kernel_info_offset) as usize - ptr as usize }, - 119usize, - concat!( - "Offset of field: ", - stringify!(setup_header), - "::", - stringify!(kernel_info_offset) - ) - ); + pub setup_sects: u8, + pub root_flags: u16, + pub syssize: u32, + pub ram_size: u16, + pub vid_mode: u16, + pub root_dev: u16, + pub boot_flag: u16, + pub jump: u16, + pub header: u32, + pub version: u16, + pub realmode_swtch: u32, + pub start_sys_seg: u16, + pub kernel_version: u16, + pub type_of_loader: u8, + pub loadflags: u8, + pub setup_move_size: u16, + pub code32_start: u32, + pub ramdisk_image: u32, + pub ramdisk_size: u32, + pub bootsect_kludge: u32, + pub heap_end_ptr: u16, + pub ext_loader_ver: u8, + pub ext_loader_type: u8, + pub cmd_line_ptr: u32, + pub initrd_addr_max: u32, + pub kernel_alignment: u32, + pub relocatable_kernel: u8, + pub min_alignment: u8, + pub xloadflags: u16, + pub cmdline_size: u32, + pub hardware_subarch: u32, + pub hardware_subarch_data: u64, + pub payload_offset: u32, + pub payload_length: u32, + pub setup_data: u64, + pub pref_address: u64, + pub init_size: u32, + pub handover_offset: u32, + pub kernel_info_offset: u32, } -#[repr(C)] + +#[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct sys_desc_table { - pub length: __u16, - pub table: [__u8; 14usize], -} -#[test] -fn bindgen_test_layout_sys_desc_table() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(sys_desc_table)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(sys_desc_table)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).length) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(sys_desc_table), - "::", - stringify!(length) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).table) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(sys_desc_table), - "::", - stringify!(table) - ) - ); + pub length: u16, + pub table: [u8; 14], } + #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct olpc_ofw_header { - pub ofw_magic: __u32, - pub ofw_version: __u32, - pub cif_handler: __u32, - pub irq_desc_table: __u32, -} -#[test] -fn bindgen_test_layout_olpc_ofw_header() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(olpc_ofw_header)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(olpc_ofw_header)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ofw_magic) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(olpc_ofw_header), - "::", - stringify!(ofw_magic) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ofw_version) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(olpc_ofw_header), - "::", - stringify!(ofw_version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cif_handler) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(olpc_ofw_header), - "::", - stringify!(cif_handler) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).irq_desc_table) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(olpc_ofw_header), - "::", - stringify!(irq_desc_table) - ) - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct efi_info { - pub efi_loader_signature: __u32, - pub efi_systab: __u32, - pub efi_memdesc_size: __u32, - pub efi_memdesc_version: __u32, - pub efi_memmap: __u32, - pub efi_memmap_size: __u32, - pub efi_systab_hi: __u32, - pub efi_memmap_hi: __u32, -} -#[test] -fn bindgen_test_layout_efi_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(efi_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(efi_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_loader_signature) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_loader_signature) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_systab) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_systab) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_memdesc_size) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_memdesc_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_memdesc_version) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_memdesc_version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_memmap) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_memmap) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_memmap_size) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_memmap_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_systab_hi) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_systab_hi) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_memmap_hi) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(efi_info), - "::", - stringify!(efi_memmap_hi) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct boot_e820_entry { - pub addr: __u64, - pub size: __u64, - pub type_: __u32, -} -#[test] -fn bindgen_test_layout_boot_e820_entry() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 20usize, - concat!("Size of: ", stringify!(boot_e820_entry)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(boot_e820_entry)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(boot_e820_entry), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(boot_e820_entry), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(boot_e820_entry), - "::", - stringify!(type_) - ) - ); -} -#[repr(C, packed)] -#[derive(Debug, Copy, Clone, PartialEq)] -pub struct jailhouse_setup_data { - pub hdr: jailhouse_setup_data__bindgen_ty_1, - pub v1: jailhouse_setup_data__bindgen_ty_2, - pub v2: jailhouse_setup_data__bindgen_ty_3, + pub ofw_magic: u32, + pub ofw_version: u32, + pub cif_handler: u32, + pub irq_desc_table: u32, } + #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct jailhouse_setup_data__bindgen_ty_1 { - pub version: __u16, - pub compatible_version: __u16, -} -#[test] -fn bindgen_test_layout_jailhouse_setup_data__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(jailhouse_setup_data__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(jailhouse_setup_data__bindgen_ty_1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_1), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).compatible_version) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_1), - "::", - stringify!(compatible_version) - ) - ); +pub struct efi_info { + pub efi_loader_signature: u32, + pub efi_systab: u32, + pub efi_memdesc_size: u32, + pub efi_memdesc_version: u32, + pub efi_memmap: u32, + pub efi_memmap_size: u32, + pub efi_systab_hi: u32, + pub efi_memmap_hi: u32, } + +/// The x86 "zeropage" — exactly 4096 bytes. +/// +/// `_pad7` size is `0x290 - 0x1f1 - sizeof(setup_header)` = 36 bytes. #[repr(C, packed)] #[derive(Debug, Copy, Clone, PartialEq)] -pub struct jailhouse_setup_data__bindgen_ty_2 { - pub pm_timer_address: __u16, - pub num_cpus: __u16, - pub pci_mmconfig_base: __u64, - pub tsc_khz: __u32, - pub apic_khz: __u32, - pub standard_ioapic: __u8, - pub cpu_ids: [__u8; 255usize], -} -#[test] -fn bindgen_test_layout_jailhouse_setup_data__bindgen_ty_2() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 276usize, - concat!("Size of: ", stringify!(jailhouse_setup_data__bindgen_ty_2)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(jailhouse_setup_data__bindgen_ty_2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pm_timer_address) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(pm_timer_address) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).num_cpus) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(num_cpus) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).pci_mmconfig_base) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(pci_mmconfig_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tsc_khz) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(tsc_khz) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).apic_khz) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(apic_khz) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).standard_ioapic) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(standard_ioapic) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cpu_ids) as usize - ptr as usize }, - 21usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_2), - "::", - stringify!(cpu_ids) - ) - ); -} -impl Default for jailhouse_setup_data__bindgen_ty_2 { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct jailhouse_setup_data__bindgen_ty_3 { - pub flags: __u32, -} -#[test] -fn bindgen_test_layout_jailhouse_setup_data__bindgen_ty_3() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(jailhouse_setup_data__bindgen_ty_3)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(jailhouse_setup_data__bindgen_ty_3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data__bindgen_ty_3), - "::", - stringify!(flags) - ) - ); -} -#[test] -fn bindgen_test_layout_jailhouse_setup_data() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 284usize, - concat!("Size of: ", stringify!(jailhouse_setup_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(jailhouse_setup_data)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data), - "::", - stringify!(hdr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).v1) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data), - "::", - stringify!(v1) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).v2) as usize - ptr as usize }, - 280usize, - concat!( - "Offset of field: ", - stringify!(jailhouse_setup_data), - "::", - stringify!(v2) - ) - ); -} -impl Default for jailhouse_setup_data { - fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } - } -} -#[repr(C, packed)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct ima_setup_data { - pub addr: __u64, - pub size: __u64, -} -#[test] -fn bindgen_test_layout_ima_setup_data() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(ima_setup_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(ima_setup_data)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(ima_setup_data), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(ima_setup_data), - "::", - stringify!(size) - ) - ); -} -#[repr(C, packed)] -#[derive(Copy, Clone)] pub struct boot_params { - pub screen_info: screen_info, - pub apm_bios_info: apm_bios_info, - pub _pad2: [__u8; 4usize], - pub tboot_addr: __u64, - pub ist_info: ist_info, - pub acpi_rsdp_addr: __u64, - pub _pad3: [__u8; 8usize], - pub hd0_info: [__u8; 16usize], - pub hd1_info: [__u8; 16usize], - pub sys_desc_table: sys_desc_table, - pub olpc_ofw_header: olpc_ofw_header, - pub ext_ramdisk_image: __u32, - pub ext_ramdisk_size: __u32, - pub ext_cmd_line_ptr: __u32, - pub _pad4: [__u8; 112usize], - pub cc_blob_address: __u32, - pub edid_info: edid_info, - pub efi_info: efi_info, - pub alt_mem_k: __u32, - pub scratch: __u32, - pub e820_entries: __u8, - pub eddbuf_entries: __u8, - pub edd_mbr_sig_buf_entries: __u8, - pub kbd_status: __u8, - pub secure_boot: __u8, - pub _pad5: [__u8; 2usize], - pub sentinel: __u8, - pub _pad6: [__u8; 1usize], - pub hdr: setup_header, - pub _pad7: [__u8; 36usize], - pub edd_mbr_sig_buffer: [__u32; 16usize], - pub e820_table: [boot_e820_entry; 128usize], - pub _pad8: [__u8; 48usize], - pub eddbuf: [edd_info; 6usize], - pub _pad9: [__u8; 276usize], + pub screen_info: screen_info, // 0x000 + pub apm_bios_info: apm_bios_info, // 0x040 + pub _pad2: [u8; 4], // 0x054 + pub tboot_addr: u64, // 0x058 + pub ist_info: ist_info, // 0x060 + pub acpi_rsdp_addr: u64, // 0x070 + pub _pad3: [u8; 8], // 0x078 + pub hd0_info: [u8; 16], // 0x080 + pub hd1_info: [u8; 16], // 0x090 + pub sys_desc_table: sys_desc_table, // 0x0a0 + pub olpc_ofw_header: olpc_ofw_header, // 0x0b0 + pub ext_ramdisk_image: u32, // 0x0c0 + pub ext_ramdisk_size: u32, // 0x0c4 + pub ext_cmd_line_ptr: u32, // 0x0c8 + pub _pad4: [u8; 112], // 0x0cc + pub cc_blob_address: u32, // 0x13c + pub edid_info: edid_info, // 0x140 + pub efi_info: efi_info, // 0x1c0 + pub alt_mem_k: u32, // 0x1e0 + pub scratch: u32, // 0x1e4 + pub e820_entries: u8, // 0x1e8 + pub eddbuf_entries: u8, // 0x1e9 + pub edd_mbr_sig_buf_entries: u8, // 0x1ea + pub kbd_status: u8, // 0x1eb + pub secure_boot: u8, // 0x1ec + pub _pad5: [u8; 2], // 0x1ed + pub sentinel: u8, // 0x1ef + pub _pad6: [u8; 1], // 0x1f0 + pub hdr: setup_header, // 0x1f1 + pub _pad7: [u8; 36], // 0x26c + pub edd_mbr_sig_buffer: [u32; EDD_MBR_SIG_MAX], // 0x290 + pub e820_table: [boot_e820_entry; E820_MAX_ENTRIES_ZEROPAGE], // 0x2d0 + pub _pad8: [u8; 48], // 0xcd0 + pub eddbuf: [edd_info; EDDMAXNR], // 0xd00 + pub _pad9: [u8; 276], // 0xeec } -#[test] -fn bindgen_test_layout_boot_params() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4096usize, - concat!("Size of: ", stringify!(boot_params)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(boot_params)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).screen_info) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(screen_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).apm_bios_info) as usize - ptr as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(apm_bios_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad2) as usize - ptr as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).tboot_addr) as usize - ptr as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(tboot_addr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ist_info) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(ist_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).acpi_rsdp_addr) as usize - ptr as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(acpi_rsdp_addr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad3) as usize - ptr as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad3) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hd0_info) as usize - ptr as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(hd0_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hd1_info) as usize - ptr as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(hd1_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sys_desc_table) as usize - ptr as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(sys_desc_table) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).olpc_ofw_header) as usize - ptr as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(olpc_ofw_header) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_ramdisk_image) as usize - ptr as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(ext_ramdisk_image) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_ramdisk_size) as usize - ptr as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(ext_ramdisk_size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ext_cmd_line_ptr) as usize - ptr as usize }, - 200usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(ext_cmd_line_ptr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad4) as usize - ptr as usize }, - 204usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad4) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cc_blob_address) as usize - ptr as usize }, - 316usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(cc_blob_address) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).edid_info) as usize - ptr as usize }, - 320usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(edid_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).efi_info) as usize - ptr as usize }, - 448usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(efi_info) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).alt_mem_k) as usize - ptr as usize }, - 480usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(alt_mem_k) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).scratch) as usize - ptr as usize }, - 484usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(scratch) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e820_entries) as usize - ptr as usize }, - 488usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(e820_entries) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).eddbuf_entries) as usize - ptr as usize }, - 489usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(eddbuf_entries) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).edd_mbr_sig_buf_entries) as usize - ptr as usize }, - 490usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(edd_mbr_sig_buf_entries) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).kbd_status) as usize - ptr as usize }, - 491usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(kbd_status) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).secure_boot) as usize - ptr as usize }, - 492usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(secure_boot) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad5) as usize - ptr as usize }, - 493usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad5) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).sentinel) as usize - ptr as usize }, - 495usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(sentinel) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad6) as usize - ptr as usize }, - 496usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad6) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).hdr) as usize - ptr as usize }, - 497usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(hdr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad7) as usize - ptr as usize }, - 620usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad7) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).edd_mbr_sig_buffer) as usize - ptr as usize }, - 656usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(edd_mbr_sig_buffer) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e820_table) as usize - ptr as usize }, - 720usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(e820_table) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad8) as usize - ptr as usize }, - 3280usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad8) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).eddbuf) as usize - ptr as usize }, - 3328usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(eddbuf) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._pad9) as usize - ptr as usize }, - 3820usize, - concat!( - "Offset of field: ", - stringify!(boot_params), - "::", - stringify!(_pad9) - ) - ); + +#[repr(u32)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)] +pub enum x86_hardware_subarch { + #[default] + X86_SUBARCH_PC = 0, + X86_SUBARCH_LGUEST = 1, + X86_SUBARCH_XEN = 2, + X86_SUBARCH_INTEL_MID = 3, + X86_SUBARCH_CE4100 = 4, } + +pub const X86_NR_SUBARCHS: u32 = 5; + impl Default for boot_params { fn default() -> Self { - let mut s = ::std::mem::MaybeUninit::::uninit(); - unsafe { - ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); - s.assume_init() - } + unsafe { core::mem::zeroed() } } } -pub const x86_hardware_subarch_X86_SUBARCH_PC: x86_hardware_subarch = 0; -pub const x86_hardware_subarch_X86_SUBARCH_LGUEST: x86_hardware_subarch = 1; -pub const x86_hardware_subarch_X86_SUBARCH_XEN: x86_hardware_subarch = 2; -pub const x86_hardware_subarch_X86_SUBARCH_INTEL_MID: x86_hardware_subarch = 3; -pub const x86_hardware_subarch_X86_SUBARCH_CE4100: x86_hardware_subarch = 4; -pub const x86_hardware_subarch_X86_NR_SUBARCHS: x86_hardware_subarch = 5; -#[doc = " enum x86_hardware_subarch - x86 hardware subarchitecture\n\n The x86 hardware_subarch and hardware_subarch_data were added as of the x86\n boot protocol 2.07 to help distinguish and support custom x86 boot\n sequences. This enum represents accepted values for the x86\n hardware_subarch. Custom x86 boot sequences (not X86_SUBARCH_PC) do not\n have or simply *cannot* make use of natural stubs like BIOS or EFI, the\n hardware_subarch can be used on the Linux entry path to revector to a\n subarchitecture stub when needed. This subarchitecture stub can be used to\n set up Linux boot parameters or for special care to account for nonstandard\n handling of page tables.\n\n These enums should only ever be used by x86 code, and the code that uses\n it should be well contained and compartmentalized.\n\n KVM and Xen HVM do not have a subarch as these are expected to follow\n standard x86 boot entries. If there is a genuine need for \"hypervisor\" type\n that should be considered separately in the future. Future guest types\n should seriously consider working with standard x86 boot stubs such as\n the BIOS or EFI boot stubs.\n\n WARNING: this enum is only used for legacy hacks, for platform features that\n\t are not easily enumerated or discoverable. You should not ever use\n\t this for new features.\n\n @X86_SUBARCH_PC: Should be used if the hardware is enumerable using standard\n\tPC mechanisms (PCI, ACPI) and doesn't need a special boot flow.\n @X86_SUBARCH_LGUEST: Used for x86 hypervisor demo, lguest, deprecated\n @X86_SUBARCH_XEN: Used for Xen guest types which follow the PV boot path,\n \twhich start at asm startup_xen() entry point and later jump to the C\n \txen_start_kernel() entry point. Both domU and dom0 type of guests are\n \tcurrently supported through this PV boot path.\n @X86_SUBARCH_INTEL_MID: Used for Intel MID (Mobile Internet Device) platform\n\tsystems which do not have the PCI legacy interfaces.\n @X86_SUBARCH_CE4100: Used for Intel CE media processor (CE4100) SoC\n \tfor settop boxes and media devices, the use of a subarch for CE4100\n \tis more of a hack..."] -pub type x86_hardware_subarch = ::std::os::raw::c_uint; + +// ============================================================================ +// Compile-time layout assertions +// ============================================================================ + +const _: () = assert!(core::mem::size_of::() == 0x40); +const _: () = assert!(core::mem::size_of::() == 0x14); +const _: () = assert!(core::mem::size_of::() == 0x10); +const _: () = assert!(core::mem::size_of::() == 0x80); +const _: () = assert!(core::mem::size_of::() == 20); +const _: () = assert!(core::mem::size_of::() == EDDPARMSIZE); +const _: () = assert!(core::mem::size_of::() == EDDEXTSIZE + EDDPARMSIZE); +const _: () = assert!(core::mem::size_of::() == 0x10); +const _: () = assert!(core::mem::size_of::() == 0x10); +const _: () = assert!(core::mem::size_of::() == 0x20); +const _: () = assert!(core::mem::size_of::() == 123); +const _: () = assert!(core::mem::size_of::() == 4096); diff --git a/src/loader_gen/x86_64/elf.rs b/src/loader_gen/x86_64/elf.rs index 3932e94..9ca917e 100644 --- a/src/loader_gen/x86_64/elf.rs +++ b/src/loader_gen/x86_64/elf.rs @@ -1,63 +1,651 @@ -// Copyright © 2020, Oracle and/or its affiliates. -// -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// -// Portions Copyright 2017 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-BSD-3-Clause file. -// -// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause - -/* - * automatically generated by rust-bindgen using: - * - * # bindgen --with-derive-default elf.h > elf.rs - * - * From upstream linux include/uapi/linux/elf.h at commit: - * 48b1320a674e1ff5de2fad8606bee38f724594dc - * and then edited to eliminate unnecessary definitions, add comments, - * and relocate definitions and tests for clarity. - */ +// Rust translation of include/uapi/linux/elf.h and include/uapi/linux/elf-em.h. +// All structs use #[repr(C)] to match the standard ELF ABI layout. +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] + +// ============================================================================ +// ELF base type aliases +// ============================================================================ + +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; +pub type Elf32_Versym = u16; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_SHalf = i16; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; +pub type Elf64_Sxword = i64; +pub type Elf64_Versym = u16; + +// ============================================================================ +// ELF machine types (elf-em.h) +// ============================================================================ + +pub const EM_NONE: u16 = 0; +pub const EM_M32: u16 = 1; +pub const EM_SPARC: u16 = 2; +pub const EM_386: u16 = 3; +pub const EM_68K: u16 = 4; +pub const EM_88K: u16 = 5; +pub const EM_486: u16 = 6; +pub const EM_860: u16 = 7; +pub const EM_MIPS: u16 = 8; +pub const EM_MIPS_RS3_LE: u16 = 10; +pub const EM_MIPS_RS4_BE: u16 = 10; +pub const EM_PARISC: u16 = 15; +pub const EM_SPARC32PLUS: u16 = 18; +pub const EM_PPC: u16 = 20; +pub const EM_PPC64: u16 = 21; +pub const EM_SPU: u16 = 23; +pub const EM_ARM: u16 = 40; +pub const EM_SH: u16 = 42; +pub const EM_SPARCV9: u16 = 43; +pub const EM_H8_300: u16 = 46; +pub const EM_IA_64: u16 = 50; +pub const EM_X86_64: u16 = 62; +pub const EM_S390: u16 = 22; +pub const EM_CRIS: u16 = 76; +pub const EM_M32R: u16 = 88; +pub const EM_MN10300: u16 = 89; +pub const EM_OPENRISC: u16 = 92; +pub const EM_ARCOMPACT: u16 = 93; +pub const EM_XTENSA: u16 = 94; +pub const EM_BLACKFIN: u16 = 106; +pub const EM_UNICORE: u16 = 110; +pub const EM_ALTERA_NIOS2: u16 = 113; +pub const EM_TI_C6000: u16 = 140; +pub const EM_HEXAGON: u16 = 164; +pub const EM_NDS32: u16 = 167; +pub const EM_AARCH64: u16 = 183; +pub const EM_TILEPRO: u16 = 188; +pub const EM_MICROBLAZE: u16 = 189; +pub const EM_TILEGX: u16 = 191; +pub const EM_ARCV2: u16 = 195; +pub const EM_RISCV: u16 = 243; +pub const EM_BPF: u16 = 247; +pub const EM_CSKY: u16 = 252; +pub const EM_LOONGARCH: u16 = 258; +pub const EM_FRV: u16 = 0x5441; +pub const EM_ALPHA: u16 = 0x9026; +pub const EM_CYGNUS_M32R: u16 = 0x9041; +pub const EM_S390_OLD: u16 = 0xA390; +pub const EM_CYGNUS_MN10300: u16 = 0xbeef; + +// ============================================================================ +// Segment types (p_type) +// ============================================================================ + +pub const PT_NULL: u32 = 0; pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_HIOS: u32 = 0x6fffffff; +pub const PT_LOPROC: u32 = 0x70000000; +pub const PT_HIPROC: u32 = 0x7fffffff; +pub const PT_GNU_EH_FRAME: u32 = PT_LOOS + 0x474e550; +pub const PT_GNU_STACK: u32 = PT_LOOS + 0x474e551; +pub const PT_GNU_RELRO: u32 = PT_LOOS + 0x474e552; +pub const PT_GNU_PROPERTY: u32 = PT_LOOS + 0x474e553; + +pub const PT_AARCH64_MEMTAG_MTE: u32 = PT_LOPROC + 0x2; + +pub const PN_XNUM: u16 = 0xffff; + +// ============================================================================ +// ELF file types (e_type) +// ============================================================================ + +pub const ET_NONE: u16 = 0; +pub const ET_REL: u16 = 1; +pub const ET_EXEC: u16 = 2; +pub const ET_DYN: u16 = 3; +pub const ET_CORE: u16 = 4; +pub const ET_LOPROC: u16 = 0xff00; +pub const ET_HIPROC: u16 = 0xffff; + +// ============================================================================ +// Dynamic section tags (d_tag) +// ============================================================================ + +pub const DT_NULL: i64 = 0; +pub const DT_NEEDED: i64 = 1; +pub const DT_PLTRELSZ: i64 = 2; +pub const DT_PLTGOT: i64 = 3; +pub const DT_HASH: i64 = 4; +pub const DT_STRTAB: i64 = 5; +pub const DT_SYMTAB: i64 = 6; +pub const DT_RELA: i64 = 7; +pub const DT_RELASZ: i64 = 8; +pub const DT_RELAENT: i64 = 9; +pub const DT_STRSZ: i64 = 10; +pub const DT_SYMENT: i64 = 11; +pub const DT_INIT: i64 = 12; +pub const DT_FINI: i64 = 13; +pub const DT_SONAME: i64 = 14; +pub const DT_RPATH: i64 = 15; +pub const DT_SYMBOLIC: i64 = 16; +pub const DT_REL: i64 = 17; +pub const DT_RELSZ: i64 = 18; +pub const DT_RELENT: i64 = 19; +pub const DT_PLTREL: i64 = 20; +pub const DT_DEBUG: i64 = 21; +pub const DT_TEXTREL: i64 = 22; +pub const DT_JMPREL: i64 = 23; +pub const DT_ENCODING: i64 = 32; +pub const OLD_DT_LOOS: i64 = 0x60000000; +pub const DT_LOOS: i64 = 0x6000000d; +pub const DT_HIOS: i64 = 0x6ffff000; +pub const DT_VALRNGLO: i64 = 0x6ffffd00; +pub const DT_VALRNGHI: i64 = 0x6ffffdff; +pub const DT_ADDRRNGLO: i64 = 0x6ffffe00; +pub const DT_GNU_HASH: i64 = 0x6ffffef5; +pub const DT_ADDRRNGHI: i64 = 0x6ffffeff; +pub const DT_VERSYM: i64 = 0x6ffffff0; +pub const DT_RELACOUNT: i64 = 0x6ffffff9; +pub const DT_RELCOUNT: i64 = 0x6ffffffa; +pub const DT_FLAGS_1: i64 = 0x6ffffffb; +pub const DT_VERDEF: i64 = 0x6ffffffc; +pub const DT_VERDEFNUM: i64 = 0x6ffffffd; +pub const DT_VERNEED: i64 = 0x6ffffffe; +pub const DT_VERNEEDNUM: i64 = 0x6fffffff; +pub const OLD_DT_HIOS: i64 = 0x6fffffff; +pub const DT_LOPROC: i64 = 0x70000000; +pub const DT_HIPROC: i64 = 0x7fffffff; + +// ============================================================================ +// Symbol binding and type +// ============================================================================ + +pub const STB_LOCAL: u8 = 0; +pub const STB_GLOBAL: u8 = 1; +pub const STB_WEAK: u8 = 2; -pub const EI_MAG0: u32 = 0; -pub const EI_MAG1: u32 = 1; -pub const EI_MAG2: u32 = 2; -pub const EI_MAG3: u32 = 3; -pub const EI_DATA: u32 = 5; +pub const STN_UNDEF: u32 = 0; + +pub const STT_NOTYPE: u8 = 0; +pub const STT_OBJECT: u8 = 1; +pub const STT_FUNC: u8 = 2; +pub const STT_SECTION: u8 = 3; +pub const STT_FILE: u8 = 4; +pub const STT_COMMON: u8 = 5; +pub const STT_TLS: u8 = 6; + +pub const VER_FLG_BASE: u16 = 0x1; +pub const VER_FLG_WEAK: u16 = 0x2; + +#[inline] +pub const fn ELF_ST_BIND(info: u8) -> u8 { + info >> 4 +} + +#[inline] +pub const fn ELF_ST_TYPE(info: u8) -> u8 { + info & 0xf +} + +#[inline] +pub const fn ELF32_ST_BIND(info: u8) -> u8 { + ELF_ST_BIND(info) +} + +#[inline] +pub const fn ELF32_ST_TYPE(info: u8) -> u8 { + ELF_ST_TYPE(info) +} + +#[inline] +pub const fn ELF64_ST_BIND(info: u8) -> u8 { + ELF_ST_BIND(info) +} + +#[inline] +pub const fn ELF64_ST_TYPE(info: u8) -> u8 { + ELF_ST_TYPE(info) +} -pub const ELFMAG0: u32 = 127; +// ============================================================================ +// Relocation helpers +// ============================================================================ -// The values for the following definitions have been edited -// to use their equivalent byte literal representations. +#[inline] +pub const fn ELF32_R_SYM(info: u32) -> u32 { + info >> 8 +} + +#[inline] +pub const fn ELF32_R_TYPE(info: u32) -> u8 { + (info & 0xff) as u8 +} + +#[inline] +pub const fn ELF64_R_SYM(info: u64) -> u32 { + (info >> 32) as u32 +} + +#[inline] +pub const fn ELF64_R_TYPE(info: u64) -> u32 { + (info & 0xffffffff) as u32 +} + +// ============================================================================ +// Segment permission flags (p_flags) +// ============================================================================ + +pub const PF_R: u32 = 0x4; +pub const PF_W: u32 = 0x2; +pub const PF_X: u32 = 0x1; + +// ============================================================================ +// Section header types (sh_type) +// ============================================================================ + +pub const SHT_NULL: u32 = 0; +pub const SHT_PROGBITS: u32 = 1; +pub const SHT_SYMTAB: u32 = 2; +pub const SHT_STRTAB: u32 = 3; +pub const SHT_RELA: u32 = 4; +pub const SHT_HASH: u32 = 5; +pub const SHT_DYNAMIC: u32 = 6; +pub const SHT_NOTE: u32 = 7; +pub const SHT_NOBITS: u32 = 8; +pub const SHT_REL: u32 = 9; +pub const SHT_SHLIB: u32 = 10; +pub const SHT_DYNSYM: u32 = 11; +pub const SHT_NUM: u32 = 12; +pub const SHT_LOPROC: u32 = 0x70000000; +pub const SHT_HIPROC: u32 = 0x7fffffff; +pub const SHT_LOUSER: u32 = 0x80000000; +pub const SHT_HIUSER: u32 = 0xffffffff; + +// ============================================================================ +// Section header flags (sh_flags) +// ============================================================================ + +pub const SHF_WRITE: u64 = 0x1; +pub const SHF_ALLOC: u64 = 0x2; +pub const SHF_EXECINSTR: u64 = 0x4; +pub const SHF_MERGE: u64 = 0x10; +pub const SHF_STRINGS: u64 = 0x20; +pub const SHF_INFO_LINK: u64 = 0x40; +pub const SHF_LINK_ORDER: u64 = 0x80; +pub const SHF_OS_NONCONFORMING: u64 = 0x100; +pub const SHF_GROUP: u64 = 0x200; +pub const SHF_TLS: u64 = 0x400; +pub const SHF_RELA_LIVEPATCH: u64 = 0x00100000; +pub const SHF_RO_AFTER_INIT: u64 = 0x00200000; +pub const SHF_ORDERED: u64 = 0x04000000; +pub const SHF_EXCLUDE: u64 = 0x08000000; +pub const SHF_MASKOS: u64 = 0x0ff00000; +pub const SHF_MASKPROC: u64 = 0xf0000000; + +// ============================================================================ +// Special section indexes +// ============================================================================ + +pub const SHN_UNDEF: u16 = 0; +pub const SHN_LORESERVE: u16 = 0xff00; +pub const SHN_LOPROC: u16 = 0xff00; +pub const SHN_HIPROC: u16 = 0xff1f; +pub const SHN_LIVEPATCH: u16 = 0xff20; +pub const SHN_ABS: u16 = 0xfff1; +pub const SHN_COMMON: u16 = 0xfff2; +pub const SHN_HIRESERVE: u16 = 0xffff; + +// ============================================================================ +// e_ident[] indexes and values +// ============================================================================ + +pub const EI_MAG0: usize = 0; +pub const EI_MAG1: usize = 1; +pub const EI_MAG2: usize = 2; +pub const EI_MAG3: usize = 3; +pub const EI_CLASS: usize = 4; +pub const EI_DATA: usize = 5; +pub const EI_VERSION: usize = 6; +pub const EI_OSABI: usize = 7; +pub const EI_PAD: usize = 8; +pub const EI_NIDENT: usize = 16; + +pub const ELFMAG0: u8 = 0x7f; pub const ELFMAG1: u8 = b'E'; pub const ELFMAG2: u8 = b'L'; pub const ELFMAG3: u8 = b'F'; +pub const ELFMAG: &[u8; 4] = b"\x7fELF"; +pub const SELFMAG: usize = 4; + +pub const ELFCLASSNONE: u8 = 0; +pub const ELFCLASS32: u8 = 1; +pub const ELFCLASS64: u8 = 2; +pub const ELFCLASSNUM: u8 = 3; + +pub const ELFDATANONE: u8 = 0; +pub const ELFDATA2LSB: u8 = 1; +pub const ELFDATA2MSB: u8 = 2; + +pub const EV_NONE: u8 = 0; +pub const EV_CURRENT: u8 = 1; +pub const EV_NUM: u8 = 2; -pub const ELFDATA2LSB: u32 = 1; +pub const ELFOSABI_NONE: u8 = 0; +pub const ELFOSABI_LINUX: u8 = 3; -pub type __s8 = ::std::os::raw::c_schar; -pub type __u8 = ::std::os::raw::c_uchar; -pub type __s16 = ::std::os::raw::c_short; -pub type __u16 = ::std::os::raw::c_ushort; -pub type __s32 = ::std::os::raw::c_int; -pub type __u32 = ::std::os::raw::c_uint; -pub type __s64 = ::std::os::raw::c_longlong; -pub type __u64 = ::std::os::raw::c_ulonglong; +// ============================================================================ +// GNU property types +// ============================================================================ -pub type Elf64_Addr = __u64; -pub type Elf64_Half = __u16; -pub type Elf64_Off = __u64; -pub type Elf64_Sword = __s32; -pub type Elf64_Word = __u32; -pub type Elf64_Xword = __u64; +pub const GNU_PROPERTY_AARCH64_FEATURE_1_AND: u32 = 0xc0000000; +pub const GNU_PROPERTY_AARCH64_FEATURE_1_BTI: u32 = 1 << 0; + +// ============================================================================ +// Note types (NT_*) and note names (NN_*) +// ============================================================================ + +pub const NN_GNU_PROPERTY_TYPE_0: &str = "GNU"; +pub const NT_GNU_PROPERTY_TYPE_0: u32 = 5; + +pub const NN_PRSTATUS: &str = "CORE"; +pub const NT_PRSTATUS: u32 = 1; +pub const NN_PRFPREG: &str = "CORE"; +pub const NT_PRFPREG: u32 = 2; +pub const NN_PRPSINFO: &str = "CORE"; +pub const NT_PRPSINFO: u32 = 3; +pub const NN_TASKSTRUCT: &str = "CORE"; +pub const NT_TASKSTRUCT: u32 = 4; +pub const NN_AUXV: &str = "CORE"; +pub const NT_AUXV: u32 = 6; +pub const NN_SIGINFO: &str = "CORE"; +pub const NT_SIGINFO: u32 = 0x53494749; +pub const NN_FILE: &str = "CORE"; +pub const NT_FILE: u32 = 0x46494c45; +pub const NN_PRXFPREG: &str = "LINUX"; +pub const NT_PRXFPREG: u32 = 0x46e62b7f; +pub const NN_PPC_VMX: &str = "LINUX"; +pub const NT_PPC_VMX: u32 = 0x100; +pub const NN_PPC_SPE: &str = "LINUX"; +pub const NT_PPC_SPE: u32 = 0x101; +pub const NN_PPC_VSX: &str = "LINUX"; +pub const NT_PPC_VSX: u32 = 0x102; +pub const NN_PPC_TAR: &str = "LINUX"; +pub const NT_PPC_TAR: u32 = 0x103; +pub const NN_PPC_PPR: &str = "LINUX"; +pub const NT_PPC_PPR: u32 = 0x104; +pub const NN_PPC_DSCR: &str = "LINUX"; +pub const NT_PPC_DSCR: u32 = 0x105; +pub const NN_PPC_EBB: &str = "LINUX"; +pub const NT_PPC_EBB: u32 = 0x106; +pub const NN_PPC_PMU: &str = "LINUX"; +pub const NT_PPC_PMU: u32 = 0x107; +pub const NN_PPC_TM_CGPR: &str = "LINUX"; +pub const NT_PPC_TM_CGPR: u32 = 0x108; +pub const NN_PPC_TM_CFPR: &str = "LINUX"; +pub const NT_PPC_TM_CFPR: u32 = 0x109; +pub const NN_PPC_TM_CVMX: &str = "LINUX"; +pub const NT_PPC_TM_CVMX: u32 = 0x10a; +pub const NN_PPC_TM_CVSX: &str = "LINUX"; +pub const NT_PPC_TM_CVSX: u32 = 0x10b; +pub const NN_PPC_TM_SPR: &str = "LINUX"; +pub const NT_PPC_TM_SPR: u32 = 0x10c; +pub const NN_PPC_TM_CTAR: &str = "LINUX"; +pub const NT_PPC_TM_CTAR: u32 = 0x10d; +pub const NN_PPC_TM_CPPR: &str = "LINUX"; +pub const NT_PPC_TM_CPPR: u32 = 0x10e; +pub const NN_PPC_TM_CDSCR: &str = "LINUX"; +pub const NT_PPC_TM_CDSCR: u32 = 0x10f; +pub const NN_PPC_PKEY: &str = "LINUX"; +pub const NT_PPC_PKEY: u32 = 0x110; +pub const NN_PPC_DEXCR: &str = "LINUX"; +pub const NT_PPC_DEXCR: u32 = 0x111; +pub const NN_PPC_HASHKEYR: &str = "LINUX"; +pub const NT_PPC_HASHKEYR: u32 = 0x112; +pub const NN_386_TLS: &str = "LINUX"; +pub const NT_386_TLS: u32 = 0x200; +pub const NN_386_IOPERM: &str = "LINUX"; +pub const NT_386_IOPERM: u32 = 0x201; +pub const NN_X86_XSTATE: &str = "LINUX"; +pub const NT_X86_XSTATE: u32 = 0x202; +pub const NN_X86_SHSTK: &str = "LINUX"; +pub const NT_X86_SHSTK: u32 = 0x204; +pub const NN_X86_XSAVE_LAYOUT: &str = "LINUX"; +pub const NT_X86_XSAVE_LAYOUT: u32 = 0x205; +pub const NN_S390_HIGH_GPRS: &str = "LINUX"; +pub const NT_S390_HIGH_GPRS: u32 = 0x300; +pub const NN_S390_TIMER: &str = "LINUX"; +pub const NT_S390_TIMER: u32 = 0x301; +pub const NN_S390_TODCMP: &str = "LINUX"; +pub const NT_S390_TODCMP: u32 = 0x302; +pub const NN_S390_TODPREG: &str = "LINUX"; +pub const NT_S390_TODPREG: u32 = 0x303; +pub const NN_S390_CTRS: &str = "LINUX"; +pub const NT_S390_CTRS: u32 = 0x304; +pub const NN_S390_PREFIX: &str = "LINUX"; +pub const NT_S390_PREFIX: u32 = 0x305; +pub const NN_S390_LAST_BREAK: &str = "LINUX"; +pub const NT_S390_LAST_BREAK: u32 = 0x306; +pub const NN_S390_SYSTEM_CALL: &str = "LINUX"; +pub const NT_S390_SYSTEM_CALL: u32 = 0x307; +pub const NN_S390_TDB: &str = "LINUX"; +pub const NT_S390_TDB: u32 = 0x308; +pub const NN_S390_VXRS_LOW: &str = "LINUX"; +pub const NT_S390_VXRS_LOW: u32 = 0x309; +pub const NN_S390_VXRS_HIGH: &str = "LINUX"; +pub const NT_S390_VXRS_HIGH: u32 = 0x30a; +pub const NN_S390_GS_CB: &str = "LINUX"; +pub const NT_S390_GS_CB: u32 = 0x30b; +pub const NN_S390_GS_BC: &str = "LINUX"; +pub const NT_S390_GS_BC: u32 = 0x30c; +pub const NN_S390_RI_CB: &str = "LINUX"; +pub const NT_S390_RI_CB: u32 = 0x30d; +pub const NN_S390_PV_CPU_DATA: &str = "LINUX"; +pub const NT_S390_PV_CPU_DATA: u32 = 0x30e; +pub const NN_ARM_VFP: &str = "LINUX"; +pub const NT_ARM_VFP: u32 = 0x400; +pub const NN_ARM_TLS: &str = "LINUX"; +pub const NT_ARM_TLS: u32 = 0x401; +pub const NN_ARM_HW_BREAK: &str = "LINUX"; +pub const NT_ARM_HW_BREAK: u32 = 0x402; +pub const NN_ARM_HW_WATCH: &str = "LINUX"; +pub const NT_ARM_HW_WATCH: u32 = 0x403; +pub const NN_ARM_SYSTEM_CALL: &str = "LINUX"; +pub const NT_ARM_SYSTEM_CALL: u32 = 0x404; +pub const NN_ARM_SVE: &str = "LINUX"; +pub const NT_ARM_SVE: u32 = 0x405; +pub const NN_ARM_PAC_MASK: &str = "LINUX"; +pub const NT_ARM_PAC_MASK: u32 = 0x406; +pub const NN_ARM_PACA_KEYS: &str = "LINUX"; +pub const NT_ARM_PACA_KEYS: u32 = 0x407; +pub const NN_ARM_PACG_KEYS: &str = "LINUX"; +pub const NT_ARM_PACG_KEYS: u32 = 0x408; +pub const NN_ARM_TAGGED_ADDR_CTRL: &str = "LINUX"; +pub const NT_ARM_TAGGED_ADDR_CTRL: u32 = 0x409; +pub const NN_ARM_PAC_ENABLED_KEYS: &str = "LINUX"; +pub const NT_ARM_PAC_ENABLED_KEYS: u32 = 0x40a; +pub const NN_ARM_SSVE: &str = "LINUX"; +pub const NT_ARM_SSVE: u32 = 0x40b; +pub const NN_ARM_ZA: &str = "LINUX"; +pub const NT_ARM_ZA: u32 = 0x40c; +pub const NN_ARM_ZT: &str = "LINUX"; +pub const NT_ARM_ZT: u32 = 0x40d; +pub const NN_ARM_FPMR: &str = "LINUX"; +pub const NT_ARM_FPMR: u32 = 0x40e; +pub const NN_ARM_POE: &str = "LINUX"; +pub const NT_ARM_POE: u32 = 0x40f; +pub const NN_ARM_GCS: &str = "LINUX"; +pub const NT_ARM_GCS: u32 = 0x410; +pub const NN_ARC_V2: &str = "LINUX"; +pub const NT_ARC_V2: u32 = 0x600; +pub const NN_VMCOREDD: &str = "LINUX"; +pub const NT_VMCOREDD: u32 = 0x700; +pub const NN_MIPS_DSP: &str = "LINUX"; +pub const NT_MIPS_DSP: u32 = 0x800; +pub const NN_MIPS_FP_MODE: &str = "LINUX"; +pub const NT_MIPS_FP_MODE: u32 = 0x801; +pub const NN_MIPS_MSA: &str = "LINUX"; +pub const NT_MIPS_MSA: u32 = 0x802; +pub const NN_RISCV_CSR: &str = "LINUX"; +pub const NT_RISCV_CSR: u32 = 0x900; +pub const NN_RISCV_VECTOR: &str = "LINUX"; +pub const NT_RISCV_VECTOR: u32 = 0x901; +pub const NN_RISCV_TAGGED_ADDR_CTRL: &str = "LINUX"; +pub const NT_RISCV_TAGGED_ADDR_CTRL: u32 = 0x902; +pub const NN_RISCV_USER_CFI: &str = "LINUX"; +pub const NT_RISCV_USER_CFI: u32 = 0x903; +pub const NN_LOONGARCH_CPUCFG: &str = "LINUX"; +pub const NT_LOONGARCH_CPUCFG: u32 = 0xa00; +pub const NN_LOONGARCH_CSR: &str = "LINUX"; +pub const NT_LOONGARCH_CSR: u32 = 0xa01; +pub const NN_LOONGARCH_LSX: &str = "LINUX"; +pub const NT_LOONGARCH_LSX: u32 = 0xa02; +pub const NN_LOONGARCH_LASX: &str = "LINUX"; +pub const NT_LOONGARCH_LASX: u32 = 0xa03; +pub const NN_LOONGARCH_LBT: &str = "LINUX"; +pub const NT_LOONGARCH_LBT: u32 = 0xa04; +pub const NN_LOONGARCH_HW_BREAK: &str = "LINUX"; +pub const NT_LOONGARCH_HW_BREAK: u32 = 0xa05; +pub const NN_LOONGARCH_HW_WATCH: &str = "LINUX"; +pub const NT_LOONGARCH_HW_WATCH: u32 = 0xa06; + +// ============================================================================ +// Struct definitions — 32-bit ELF +// ============================================================================ + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Ehdr { + pub e_ident: [u8; EI_NIDENT], + pub e_type: Elf32_Half, + pub e_machine: Elf32_Half, + pub e_version: Elf32_Word, + pub e_entry: Elf32_Addr, + pub e_phoff: Elf32_Off, + pub e_shoff: Elf32_Off, + pub e_flags: Elf32_Word, + pub e_ehsize: Elf32_Half, + pub e_phentsize: Elf32_Half, + pub e_phnum: Elf32_Half, + pub e_shentsize: Elf32_Half, + pub e_shnum: Elf32_Half, + pub e_shstrndx: Elf32_Half, +} #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct elf64_hdr { - pub e_ident: [::std::os::raw::c_uchar; 16usize], +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Shdr { + pub sh_name: Elf32_Word, + pub sh_type: Elf32_Word, + pub sh_flags: Elf32_Word, + pub sh_addr: Elf32_Addr, + pub sh_offset: Elf32_Off, + pub sh_size: Elf32_Word, + pub sh_link: Elf32_Word, + pub sh_info: Elf32_Word, + pub sh_addralign: Elf32_Word, + pub sh_entsize: Elf32_Word, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Sym { + pub st_name: Elf32_Word, + pub st_value: Elf32_Addr, + pub st_size: Elf32_Word, + pub st_info: u8, + pub st_other: u8, + pub st_shndx: Elf32_Half, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Rel { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Rela { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + pub r_addend: Elf32_Sword, +} + +/// Anonymous union in C; named here because Rust requires it. +/// Cannot derive Debug, Default, or PartialEq on unions. +#[repr(C)] +#[derive(Copy, Clone)] +pub union Elf32_Dyn_d_un { + pub d_val: Elf32_Sword, + pub d_ptr: Elf32_Addr, +} + +/// Contains a union field (d_un), so Debug, Default, and PartialEq +/// cannot be derived. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct Elf32_Dyn { + pub d_tag: Elf32_Sword, + pub d_un: Elf32_Dyn_d_un, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Nhdr { + pub n_namesz: Elf32_Word, + pub n_descsz: Elf32_Word, + pub n_type: Elf32_Word, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Verdef { + pub vd_version: Elf32_Half, + pub vd_flags: Elf32_Half, + pub vd_ndx: Elf32_Half, + pub vd_cnt: Elf32_Half, + pub vd_hash: Elf32_Word, + pub vd_aux: Elf32_Word, + pub vd_next: Elf32_Word, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf32_Verdaux { + pub vda_name: Elf32_Word, + pub vda_next: Elf32_Word, +} + +// ============================================================================ +// Struct definitions — 64-bit ELF +// ============================================================================ + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Ehdr { + pub e_ident: [u8; EI_NIDENT], pub e_type: Elf64_Half, pub e_machine: Elf64_Half, pub e_version: Elf64_Word, @@ -72,11 +660,10 @@ pub struct elf64_hdr { pub e_shnum: Elf64_Half, pub e_shstrndx: Elf64_Half, } -pub type Elf64_Ehdr = elf64_hdr; #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct elf64_phdr { +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Phdr { pub p_type: Elf64_Word, pub p_flags: Elf64_Word, pub p_offset: Elf64_Off, @@ -86,316 +673,114 @@ pub struct elf64_phdr { pub p_memsz: Elf64_Xword, pub p_align: Elf64_Xword, } -pub type Elf64_Phdr = elf64_phdr; #[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct elf64_note { +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Shdr { + pub sh_name: Elf64_Word, + pub sh_type: Elf64_Word, + pub sh_flags: Elf64_Xword, + pub sh_addr: Elf64_Addr, + pub sh_offset: Elf64_Off, + pub sh_size: Elf64_Xword, + pub sh_link: Elf64_Word, + pub sh_info: Elf64_Word, + pub sh_addralign: Elf64_Xword, + pub sh_entsize: Elf64_Xword, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Sym { + pub st_name: Elf64_Word, + pub st_info: u8, + pub st_other: u8, + pub st_shndx: Elf64_Half, + pub st_value: Elf64_Addr, + pub st_size: Elf64_Xword, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Rel { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Rela { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + pub r_addend: Elf64_Sxword, +} + +/// Anonymous union in C; named here because Rust requires it. +/// Cannot derive Debug, Default, or PartialEq on unions. +#[repr(C)] +#[derive(Copy, Clone)] +pub union Elf64_Dyn_d_un { + pub d_val: Elf64_Xword, + pub d_ptr: Elf64_Addr, +} + +/// Contains a union field (d_un), so Debug, Default, and PartialEq +/// cannot be derived. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct Elf64_Dyn { + pub d_tag: Elf64_Sxword, + pub d_un: Elf64_Dyn_d_un, +} + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Nhdr { pub n_namesz: Elf64_Word, pub n_descsz: Elf64_Word, pub n_type: Elf64_Word, } -pub type Elf64_Nhdr = elf64_note; - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn bindgen_test_layout_elf64_hdr() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(elf64_hdr)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(elf64_hdr)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_ident) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_ident) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_type) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_machine) as usize - ptr as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_machine) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_version) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_entry) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_entry) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_phoff) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_phoff) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_shoff) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_shoff) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_flags) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_ehsize) as usize - ptr as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_ehsize) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_phentsize) as usize - ptr as usize }, - 54usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_phentsize) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_phnum) as usize - ptr as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_phnum) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_shentsize) as usize - ptr as usize }, - 58usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_shentsize) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_shnum) as usize - ptr as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_shnum) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).e_shstrndx) as usize - ptr as usize }, - 62usize, - concat!( - "Offset of field: ", - stringify!(elf64_hdr), - "::", - stringify!(e_shstrndx) - ) - ); - } - - #[test] - fn bindgen_test_layout_elf64_phdr() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 56usize, - concat!("Size of: ", stringify!(elf64_phdr)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(elf64_phdr)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_type) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_flags) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_offset) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_vaddr) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_vaddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_paddr) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_filesz) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_filesz) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_memsz) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_memsz) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).p_align) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(elf64_phdr), - "::", - stringify!(p_align) - ) - ); - } - - #[test] - fn bindgen_test_layout_elf64_note() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(elf64_note)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(elf64_note)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).n_namesz) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(elf64_note), - "::", - stringify!(n_namesz) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).n_descsz) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(elf64_note), - "::", - stringify!(n_descsz) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).n_type) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(elf64_note), - "::", - stringify!(n_type) - ) - ); - } + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Verdef { + pub vd_version: Elf64_Half, + pub vd_flags: Elf64_Half, + pub vd_ndx: Elf64_Half, + pub vd_cnt: Elf64_Half, + pub vd_hash: Elf64_Word, + pub vd_aux: Elf64_Word, + pub vd_next: Elf64_Word, } + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] +pub struct Elf64_Verdaux { + pub vda_name: Elf64_Word, + pub vda_next: Elf64_Word, +} + +// ============================================================================ +// Compile-time layout assertions +// ============================================================================ + +const _: () = assert!(core::mem::size_of::() == 52); +const _: () = assert!(core::mem::size_of::() == 64); +const _: () = assert!(core::mem::size_of::() == 32); +const _: () = assert!(core::mem::size_of::() == 56); +const _: () = assert!(core::mem::size_of::() == 40); +const _: () = assert!(core::mem::size_of::() == 64); +const _: () = assert!(core::mem::size_of::() == 16); +const _: () = assert!(core::mem::size_of::() == 24); +const _: () = assert!(core::mem::size_of::() == 8); +const _: () = assert!(core::mem::size_of::() == 16); +const _: () = assert!(core::mem::size_of::() == 12); +const _: () = assert!(core::mem::size_of::() == 24); +const _: () = assert!(core::mem::size_of::() == 8); +const _: () = assert!(core::mem::size_of::() == 16); +const _: () = assert!(core::mem::size_of::() == 12); +const _: () = assert!(core::mem::size_of::() == 12); +const _: () = assert!(core::mem::size_of::() == 20); +const _: () = assert!(core::mem::size_of::() == 20); +const _: () = assert!(core::mem::size_of::() == 8); +const _: () = assert!(core::mem::size_of::() == 8); diff --git a/src/loader_gen/x86_64/mod.rs b/src/loader_gen/x86_64/mod.rs index 0d1a6c5..4c71acc 100644 --- a/src/loader_gen/x86_64/mod.rs +++ b/src/loader_gen/x86_64/mod.rs @@ -17,8 +17,6 @@ #![allow(non_snake_case)] #![allow(non_upper_case_globals)] -// Hide the autogenerated documentation for bindgen'ed sources. -#[doc(hidden)] pub mod bootparam; #[cfg(feature = "elf")] diff --git a/src/loader_gen/x86_64/start_info.rs b/src/loader_gen/x86_64/start_info.rs index 7960148..bc9ade0 100644 --- a/src/loader_gen/x86_64/start_info.rs +++ b/src/loader_gen/x86_64/start_info.rs @@ -1,128 +1,24 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Copyright (c) 2016, Citrix Systems, Inc. - */ +// Rust translation of xen/include/public/arch-x86/hvm/start_info.h -/* - * automatically generated by rust-bindgen using: - * - * # bindgen start_info.h -- -include stdint.h > start_info.rs - * - * From the canonical version in upstream Xen repository - * xen/include/public/arch-x86/hvm/start_info.h - * at commit: - * b4642c32c4d079916d5607ddda0232aae5e1690e - * - * The generated file has been edited to eliminate unnecessary - * definitions, add comments, and relocate definitions and tests for clarity. - * Added Default to the list of traits that are automatically derived. - * - * The definitions in this file are intended to be exported and used by a particular - * VMM implementation in order to boot a Linux guest using the PVH entry point as - * specified in the x86/HVM direct boot ABI. - * These structures contain all the required information (cmdline address, ACPI RSDP, - * memory maps, etc) that must be written to guest memory before starting guest - * execution by jumping to the PVH entry point address. - * A comparable set of definitions to hvm_start_info and hvm_memmap_table_entry in this - * file would be the boot_params and boot_e820_entry definitions used by the Linux - * 64-bit boot protocol. - * - * Start of day structure passed to PVH guests and to HVM guests in %ebx. - * - * NOTE: nothing will be loaded at physical address 0, so a 0 value in any - * of the address fields should be treated as not present. - * - * 0 +----------------+ - * | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE - * | | ("xEn3" with the 0x80 bit of the "E" set). - * 4 +----------------+ - * | version | Version of this structure. Current version is 1. New - * | | versions are guaranteed to be backwards-compatible. - * 8 +----------------+ - * | flags | SIF_xxx flags. - * 12 +----------------+ - * | nr_modules | Number of modules passed to the kernel. - * 16 +----------------+ - * | modlist_paddr | Physical address of an array of modules - * | | (layout of the structure below). - * 24 +----------------+ - * | cmdline_paddr | Physical address of the command line, - * | | a zero-terminated ASCII string. - * 32 +----------------+ - * | rsdp_paddr | Physical address of the RSDP ACPI data structure. - * 40 +----------------+ - * | memmap_paddr | Physical address of the (optional) memory map. Only - * | | present in version 1 and newer of the structure. - * 48 +----------------+ - * | memmap_entries | Number of entries in the memory map table. Zero - * | | if there is no memory map being provided. Only - * | | present in version 1 and newer of the structure. - * 52 +----------------+ - * | reserved | Version 1 and newer only. - * 56 +----------------+ - * - * The layout of each entry in the module structure is the following: - * - * 0 +----------------+ - * | paddr | Physical address of the module. - * 8 +----------------+ - * | size | Size of the module in bytes. - * 16 +----------------+ - * | cmdline_paddr | Physical address of the command line, - * | | a zero-terminated ASCII string. - * 24 +----------------+ - * | reserved | - * 32 +----------------+ - * - * The layout of each entry in the memory map table is as follows: - * - * 0 +----------------+ - * | addr | Base address - * 8 +----------------+ - * | size | Size of mapping in bytes - * 16 +----------------+ - * | type | Type of mapping as defined between the hypervisor - * | | and guest. See XEN_HVM_MEMMAP_TYPE_* values below. - * 20 +----------------| - * | reserved | - * 24 +----------------+ - * - * The address and sizes are always a 64bit little endian unsigned integer. - * - * NB: Xen on x86 will always try to place all the data below the 4GiB - * boundary. - * - * Version numbers of the hvm_start_info structure have evolved like this: - * - * Version 0: Initial implementation. - * - * Version 1: Added the memmap_paddr/memmap_entries fields (plus 4 bytes of - * padding) to the end of the hvm_start_info struct. These new - * fields can be used to pass a memory map to the guest. The - * memory map is optional and so guests that understand version 1 - * of the structure must check that memmap_entries is non-zero - * before trying to read the memory map. - */ +#![allow(non_camel_case_types)] +pub const XEN_HVM_START_MAGIC_VALUE: u32 = 0x336ec578; + +pub const XEN_HVM_MEMMAP_TYPE_RAM: u32 = 1; +pub const XEN_HVM_MEMMAP_TYPE_RESERVED: u32 = 2; +pub const XEN_HVM_MEMMAP_TYPE_ACPI: u32 = 3; +pub const XEN_HVM_MEMMAP_TYPE_NVS: u32 = 4; +pub const XEN_HVM_MEMMAP_TYPE_UNUSABLE: u32 = 5; +pub const XEN_HVM_MEMMAP_TYPE_DISABLED: u32 = 6; +pub const XEN_HVM_MEMMAP_TYPE_PMEM: u32 = 7; + +/// Start of day structure passed to PVH guests and to HVM guests in %ebx. +/// +/// A 0 value in any address field means not present. +/// Version 0 ends after `rsdp_paddr`; fields from `memmap_paddr` onward +/// are only present in version 1+. #[repr(C)] -#[derive(Debug, Copy, Clone, Default)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct hvm_start_info { pub magic: u32, pub version: u32, @@ -137,7 +33,7 @@ pub struct hvm_start_info { } #[repr(C)] -#[derive(Debug, Copy, Clone, Default)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct hvm_modlist_entry { pub paddr: u64, pub size: u64, @@ -146,7 +42,7 @@ pub struct hvm_modlist_entry { } #[repr(C)] -#[derive(Debug, Copy, Clone, Default)] +#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct hvm_memmap_table_entry { pub addr: u64, pub size: u64, @@ -154,237 +50,7 @@ pub struct hvm_memmap_table_entry { pub reserved: u32, } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn bindgen_test_layout_hvm_start_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 56usize, - concat!("Size of: ", stringify!(hvm_start_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(hvm_start_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).magic) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(magic) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).nr_modules) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(nr_modules) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).modlist_paddr) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(modlist_paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cmdline_paddr) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(cmdline_paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).rsdp_paddr) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(rsdp_paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).memmap_paddr) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(memmap_paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).memmap_entries) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(memmap_entries) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(hvm_start_info), - "::", - stringify!(reserved) - ) - ); - } - - #[test] - fn bindgen_test_layout_hvm_modlist_entry() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(hvm_modlist_entry)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(hvm_modlist_entry)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).paddr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(hvm_modlist_entry), - "::", - stringify!(paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(hvm_modlist_entry), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).cmdline_paddr) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(hvm_modlist_entry), - "::", - stringify!(cmdline_paddr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(hvm_modlist_entry), - "::", - stringify!(reserved) - ) - ); - } - - #[test] - fn bindgen_test_layout_hvm_memmap_table_entry() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(hvm_memmap_table_entry)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(hvm_memmap_table_entry)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(hvm_memmap_table_entry), - "::", - stringify!(addr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(hvm_memmap_table_entry), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(hvm_memmap_table_entry), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reserved) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(hvm_memmap_table_entry), - "::", - stringify!(reserved) - ) - ); - } -} +// Compile-time layout assertions (sizes from the spec comments) +const _: () = assert!(core::mem::size_of::() == 56); +const _: () = assert!(core::mem::size_of::() == 32); +const _: () = assert!(core::mem::size_of::() == 24);