From 28008967857a1f36a3171d064b318fe25dfc744b Mon Sep 17 00:00:00 2001 From: Federico Maria Morrone Date: Sun, 12 May 2024 14:56:13 +0200 Subject: [PATCH] Add arm64 image header bindings --- Cargo.toml | 3 +- gen/modules/image.h | 4 ++ gen/src/main.rs | 11 +++++- src/aarch64/image.rs | 79 ++++++++++++++++++++++++++++++++++++++++ src/arm/image.rs | 3 ++ src/csky/image.rs | 3 ++ src/lib.rs | 72 ++++++++++++++++++++++++++++++++++++ src/loongarch64/image.rs | 3 ++ src/mips/image.rs | 3 ++ src/mips32r6/image.rs | 3 ++ src/mips64/image.rs | 3 ++ src/mips64r6/image.rs | 3 ++ src/powerpc/image.rs | 3 ++ src/powerpc64/image.rs | 3 ++ src/riscv32/image.rs | 3 ++ src/riscv64/image.rs | 3 ++ src/s390x/image.rs | 3 ++ src/sparc/image.rs | 3 ++ src/sparc64/image.rs | 3 ++ src/x32/image.rs | 3 ++ src/x86/image.rs | 3 ++ src/x86_64/image.rs | 3 ++ 22 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 gen/modules/image.h create mode 100644 src/aarch64/image.rs create mode 100644 src/arm/image.rs create mode 100644 src/csky/image.rs create mode 100644 src/loongarch64/image.rs create mode 100644 src/mips/image.rs create mode 100644 src/mips32r6/image.rs create mode 100644 src/mips64/image.rs create mode 100644 src/mips64r6/image.rs create mode 100644 src/powerpc/image.rs create mode 100644 src/powerpc64/image.rs create mode 100644 src/riscv32/image.rs create mode 100644 src/riscv64/image.rs create mode 100644 src/s390x/image.rs create mode 100644 src/sparc/image.rs create mode 100644 src/sparc64/image.rs create mode 100644 src/x32/image.rs create mode 100644 src/x86/image.rs create mode 100644 src/x86_64/image.rs diff --git a/Cargo.toml b/Cargo.toml index 7657ac90..a30d0aa7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ static_assertions = "1.1.0" libc = "0.2.100" [package.metadata.docs.rs] -features = ["default", "bootparam", "ioctl", "netlink", "io_uring", "if_arp", "if_ether", "if_packet", "net", "prctl", "elf", "xdp", "mempolicy", "system", "loop_device"] +features = ["default", "bootparam", "image", "ioctl", "netlink", "io_uring", "if_arp", "if_ether", "if_packet", "net", "prctl", "elf", "xdp", "mempolicy", "system", "loop_device"] targets = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"] # The rest of this file is auto-generated! @@ -32,6 +32,7 @@ general = [] if_arp = [] if_ether = [] if_packet = [] +image = [] io_uring = [] ioctl = [] loop_device = [] diff --git a/gen/modules/image.h b/gen/modules/image.h new file mode 100644 index 00000000..79a63013 --- /dev/null +++ b/gen/modules/image.h @@ -0,0 +1,4 @@ +#if defined(__aarch64__) +#include +#include +#endif \ No newline at end of file diff --git a/gen/src/main.rs b/gen/src/main.rs index fef18f00..b2241fad 100644 --- a/gen/src/main.rs +++ b/gen/src/main.rs @@ -272,6 +272,14 @@ fn make_headers_install(linux_arch: &str, linux_headers: &Path) { .status() .unwrap() .success()); + + if linux_arch == "arm64" { + fs::copy( + "linux/arch/arm64/include/asm/image.h", + linux_headers.join("include/asm/image.h"), + ) + .expect("Missing headers"); + } } fn rust_arches(linux_arch: &str) -> &[&str] { @@ -291,8 +299,7 @@ fn rust_arches(linux_arch: &str) -> &[&str] { "x86" => &["x86", "x86_64", "x32"], "alpha" | "cris" | "h8300" | "m68k" | "microblaze" | "mn10300" | "score" | "blackfin" | "frv" | "ia64" | "m32r" | "m68knommu" | "parisc" | "sh" | "um" | "xtensa" - | "unicore32" | "c6x" | "nios2" | "openrisc" | "arc" | "nds32" | "metag" - | "tile" => &[], + | "unicore32" | "c6x" | "nios2" | "openrisc" | "arc" | "nds32" | "metag" | "tile" => &[], _ => panic!("unrecognized arch: {}", linux_arch), } } diff --git a/src/aarch64/image.rs b/src/aarch64/image.rs new file mode 100644 index 00000000..51bde97f --- /dev/null +++ b/src/aarch64/image.rs @@ -0,0 +1,79 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + +pub type __s8 = crate::ctypes::c_schar; +pub type __u8 = crate::ctypes::c_uchar; +pub type __s16 = crate::ctypes::c_short; +pub type __u16 = crate::ctypes::c_ushort; +pub type __s32 = crate::ctypes::c_int; +pub type __u32 = crate::ctypes::c_uint; +pub type __s64 = crate::ctypes::c_longlong; +pub type __u64 = crate::ctypes::c_ulonglong; +pub type __kernel_key_t = crate::ctypes::c_int; +pub type __kernel_mqd_t = crate::ctypes::c_int; +pub type __kernel_old_uid_t = crate::ctypes::c_ushort; +pub type __kernel_old_gid_t = crate::ctypes::c_ushort; +pub type __kernel_long_t = crate::ctypes::c_long; +pub type __kernel_ulong_t = crate::ctypes::c_ulong; +pub type __kernel_ino_t = __kernel_ulong_t; +pub type __kernel_mode_t = crate::ctypes::c_uint; +pub type __kernel_pid_t = crate::ctypes::c_int; +pub type __kernel_ipc_pid_t = crate::ctypes::c_int; +pub type __kernel_uid_t = crate::ctypes::c_uint; +pub type __kernel_gid_t = crate::ctypes::c_uint; +pub type __kernel_suseconds_t = __kernel_long_t; +pub type __kernel_daddr_t = crate::ctypes::c_int; +pub type __kernel_uid32_t = crate::ctypes::c_uint; +pub type __kernel_gid32_t = crate::ctypes::c_uint; +pub type __kernel_old_dev_t = crate::ctypes::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; +pub type __kernel_off_t = __kernel_long_t; +pub type __kernel_loff_t = crate::ctypes::c_longlong; +pub type __kernel_old_time_t = __kernel_long_t; +pub type __kernel_time_t = __kernel_long_t; +pub type __kernel_time64_t = crate::ctypes::c_longlong; +pub type __kernel_clock_t = __kernel_long_t; +pub type __kernel_timer_t = crate::ctypes::c_int; +pub type __kernel_clockid_t = crate::ctypes::c_int; +pub type __kernel_caddr_t = *mut crate::ctypes::c_char; +pub type __kernel_uid16_t = crate::ctypes::c_ushort; +pub type __kernel_gid16_t = crate::ctypes::c_ushort; +pub type __s128 = i128; +pub type __u128 = u128; +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 = crate::ctypes::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arm64_image_header { +pub code0: __le32, +pub code1: __le32, +pub text_offset: __le64, +pub image_size: __le64, +pub flags: __le64, +pub res2: __le64, +pub res3: __le64, +pub res4: __le64, +pub magic: __le32, +pub res5: __le32, +} +pub const ARM64_IMAGE_MAGIC: &[u8; 5] = b"ARMd\0"; +pub const ARM64_IMAGE_FLAG_BE_SHIFT: u32 = 0; +pub const ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT: u32 = 1; +pub const ARM64_IMAGE_FLAG_PHYS_BASE_SHIFT: u32 = 3; +pub const ARM64_IMAGE_FLAG_BE_MASK: u32 = 1; +pub const ARM64_IMAGE_FLAG_PAGE_SIZE_MASK: u32 = 3; +pub const ARM64_IMAGE_FLAG_PHYS_BASE_MASK: u32 = 1; +pub const ARM64_IMAGE_FLAG_LE: u32 = 0; +pub const ARM64_IMAGE_FLAG_BE: u32 = 1; +pub const ARM64_IMAGE_FLAG_PAGE_SIZE_4K: u32 = 1; +pub const ARM64_IMAGE_FLAG_PAGE_SIZE_16K: u32 = 2; +pub const ARM64_IMAGE_FLAG_PAGE_SIZE_64K: u32 = 3; +pub const ARM64_IMAGE_FLAG_PHYS_BASE: u32 = 1; diff --git a/src/arm/image.rs b/src/arm/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/arm/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/csky/image.rs b/src/csky/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/csky/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/lib.rs b/src/lib.rs index 7323c752..6e977e62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,6 +232,10 @@ pub mod if_ether; #[cfg(target_arch = "arm")] #[path = "arm/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "arm")] +#[path = "arm/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "arm")] #[path = "arm/io_uring.rs"] @@ -292,6 +296,10 @@ pub mod if_ether; #[cfg(target_arch = "aarch64")] #[path = "aarch64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "aarch64")] +#[path = "aarch64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "aarch64")] #[path = "aarch64/io_uring.rs"] @@ -352,6 +360,10 @@ pub mod if_ether; #[cfg(target_arch = "csky")] #[path = "csky/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "csky")] +#[path = "csky/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "csky")] #[path = "csky/io_uring.rs"] @@ -412,6 +424,10 @@ pub mod if_ether; #[cfg(target_arch = "loongarch64")] #[path = "loongarch64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "loongarch64")] +#[path = "loongarch64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "loongarch64")] #[path = "loongarch64/io_uring.rs"] @@ -472,6 +488,10 @@ pub mod if_ether; #[cfg(target_arch = "mips")] #[path = "mips/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "mips")] +#[path = "mips/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "mips")] #[path = "mips/io_uring.rs"] @@ -532,6 +552,10 @@ pub mod if_ether; #[cfg(target_arch = "mips64")] #[path = "mips64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "mips64")] +#[path = "mips64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "mips64")] #[path = "mips64/io_uring.rs"] @@ -592,6 +616,10 @@ pub mod if_ether; #[cfg(target_arch = "mips32r6")] #[path = "mips32r6/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "mips32r6")] +#[path = "mips32r6/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "mips32r6")] #[path = "mips32r6/io_uring.rs"] @@ -652,6 +680,10 @@ pub mod if_ether; #[cfg(target_arch = "mips64r6")] #[path = "mips64r6/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "mips64r6")] +#[path = "mips64r6/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "mips64r6")] #[path = "mips64r6/io_uring.rs"] @@ -712,6 +744,10 @@ pub mod if_ether; #[cfg(target_arch = "powerpc")] #[path = "powerpc/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "powerpc")] +#[path = "powerpc/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "powerpc")] #[path = "powerpc/io_uring.rs"] @@ -772,6 +808,10 @@ pub mod if_ether; #[cfg(target_arch = "powerpc64")] #[path = "powerpc64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "powerpc64")] +#[path = "powerpc64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "powerpc64")] #[path = "powerpc64/io_uring.rs"] @@ -832,6 +872,10 @@ pub mod if_ether; #[cfg(target_arch = "riscv32")] #[path = "riscv32/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "riscv32")] +#[path = "riscv32/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "riscv32")] #[path = "riscv32/io_uring.rs"] @@ -892,6 +936,10 @@ pub mod if_ether; #[cfg(target_arch = "riscv64")] #[path = "riscv64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "riscv64")] +#[path = "riscv64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "riscv64")] #[path = "riscv64/io_uring.rs"] @@ -952,6 +1000,10 @@ pub mod if_ether; #[cfg(target_arch = "s390x")] #[path = "s390x/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "s390x")] +#[path = "s390x/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "s390x")] #[path = "s390x/io_uring.rs"] @@ -1012,6 +1064,10 @@ pub mod if_ether; #[cfg(target_arch = "sparc")] #[path = "sparc/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "sparc")] +#[path = "sparc/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "sparc")] #[path = "sparc/io_uring.rs"] @@ -1072,6 +1128,10 @@ pub mod if_ether; #[cfg(target_arch = "sparc64")] #[path = "sparc64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "sparc64")] +#[path = "sparc64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "sparc64")] #[path = "sparc64/io_uring.rs"] @@ -1132,6 +1192,10 @@ pub mod if_ether; #[cfg(target_arch = "x86")] #[path = "x86/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(target_arch = "x86")] +#[path = "x86/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(target_arch = "x86")] #[path = "x86/io_uring.rs"] @@ -1192,6 +1256,10 @@ pub mod if_ether; #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[path = "x86_64/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +#[path = "x86_64/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[path = "x86_64/io_uring.rs"] @@ -1252,6 +1320,10 @@ pub mod if_ether; #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] #[path = "x32/if_packet.rs"] pub mod if_packet; +#[cfg(feature = "image")] +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +#[path = "x32/image.rs"] +pub mod image; #[cfg(feature = "io_uring")] #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] #[path = "x32/io_uring.rs"] diff --git a/src/loongarch64/image.rs b/src/loongarch64/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/loongarch64/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/mips/image.rs b/src/mips/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/mips/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/mips32r6/image.rs b/src/mips32r6/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/mips32r6/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/mips64/image.rs b/src/mips64/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/mips64/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/mips64r6/image.rs b/src/mips64r6/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/mips64r6/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/powerpc/image.rs b/src/powerpc/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/powerpc/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/powerpc64/image.rs b/src/powerpc64/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/powerpc64/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/riscv32/image.rs b/src/riscv32/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/riscv32/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/riscv64/image.rs b/src/riscv64/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/riscv64/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/s390x/image.rs b/src/s390x/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/s390x/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/sparc/image.rs b/src/sparc/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/sparc/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/sparc64/image.rs b/src/sparc64/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/sparc64/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/x32/image.rs b/src/x32/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/x32/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/x86/image.rs b/src/x86/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/x86/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + + diff --git a/src/x86_64/image.rs b/src/x86_64/image.rs new file mode 100644 index 00000000..286ed79e --- /dev/null +++ b/src/x86_64/image.rs @@ -0,0 +1,3 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + +