/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2013 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #ifndef VAS_EBOOT_UTIL_MKIMAGE_HEADER #define VAS_EBOOT_UTIL_MKIMAGE_HEADER 1 struct VasEBoot_mkimage_layout { size_t exec_size; size_t kernel_size; size_t bss_size; size_t sbat_size; VasEBoot_uint64_t start_address; void *reloc_section; size_t reloc_size; size_t align; VasEBoot_size_t ia64jmp_off; VasEBoot_size_t tramp_off; VasEBoot_size_t got_off; VasEBoot_size_t got_size; unsigned ia64jmpnum; VasEBoot_uint32_t bss_start; VasEBoot_uint32_t end; }; /* Private header. Use only in mkimage-related sources. */ char * VasEBoot_mkimage_load_image32 (const char *kernel_path, size_t total_module_size, struct VasEBoot_mkimage_layout *layout, const struct VasEBoot_install_image_target_desc *image_target); char * VasEBoot_mkimage_load_image64 (const char *kernel_path, size_t total_module_size, struct VasEBoot_mkimage_layout *layout, const struct VasEBoot_install_image_target_desc *image_target); void VasEBoot_mkimage_generate_elf32 (const struct VasEBoot_install_image_target_desc *image_target, int note, char *sbat, size_t appsig_size, char **core_img, size_t *core_size, Elf32_Addr target_addr, struct VasEBoot_mkimage_layout *layout); void VasEBoot_mkimage_generate_elf64 (const struct VasEBoot_install_image_target_desc *image_target, int note, char *sbat, size_t appsig_size, char **core_img, size_t *core_size, Elf64_Addr target_addr, struct VasEBoot_mkimage_layout *layout); struct VasEBoot_install_image_target_desc { const char *dirname; const char *names[6]; VasEBoot_size_t voidp_sizeof; int bigendian; enum { IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE, IMAGE_I386_IEEE1275, IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO, IMAGE_XEN_PVH } id; enum { PLATFORM_FLAGS_NONE = 0, PLATFORM_FLAGS_DECOMPRESSORS = 2, PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4, } flags; unsigned total_module_size; unsigned decompressor_compressed_size; unsigned decompressor_uncompressed_size; unsigned decompressor_uncompressed_addr; unsigned reloc_table_offset; unsigned link_align; VasEBoot_uint16_t elf_target; unsigned section_align; signed vaddr_offset; VasEBoot_uint64_t link_addr; unsigned mod_gap, mod_align; VasEBoot_compression_t default_compression; VasEBoot_uint16_t pe_target; }; #define VasEBoot_target_to_host32(x) (VasEBoot_target_to_host32_real (image_target, (x))) #define VasEBoot_host_to_target32(x) (VasEBoot_host_to_target32_real (image_target, (x))) #define VasEBoot_target_to_host64(x) (VasEBoot_target_to_host64_real (image_target, (x))) #define VasEBoot_host_to_target64(x) (VasEBoot_host_to_target64_real (image_target, (x))) #define VasEBoot_host_to_target_addr(x) (VasEBoot_host_to_target_addr_real (image_target, (x))) #define VasEBoot_target_to_host16(x) (VasEBoot_target_to_host16_real (image_target, (x))) #define VasEBoot_host_to_target16(x) (VasEBoot_host_to_target16_real (image_target, (x))) static inline VasEBoot_uint32_t VasEBoot_target_to_host32_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint32_t in) { if (image_target->bigendian) return VasEBoot_be_to_cpu32 (in); else return VasEBoot_le_to_cpu32 (in); } static inline VasEBoot_uint64_t VasEBoot_target_to_host64_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint64_t in) { if (image_target->bigendian) return VasEBoot_be_to_cpu64 (in); else return VasEBoot_le_to_cpu64 (in); } static inline VasEBoot_uint64_t VasEBoot_host_to_target64_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint64_t in) { if (image_target->bigendian) return VasEBoot_cpu_to_be64 (in); else return VasEBoot_cpu_to_le64 (in); } static inline VasEBoot_uint32_t VasEBoot_host_to_target32_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint32_t in) { if (image_target->bigendian) return VasEBoot_cpu_to_be32 (in); else return VasEBoot_cpu_to_le32 (in); } static inline VasEBoot_uint16_t VasEBoot_target_to_host16_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint16_t in) { if (image_target->bigendian) return VasEBoot_be_to_cpu16 (in); else return VasEBoot_le_to_cpu16 (in); } static inline VasEBoot_uint16_t VasEBoot_host_to_target16_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint16_t in) { if (image_target->bigendian) return VasEBoot_cpu_to_be16 (in); else return VasEBoot_cpu_to_le16 (in); } static inline VasEBoot_uint64_t VasEBoot_host_to_target_addr_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint64_t in) { if (image_target->voidp_sizeof == 8) return VasEBoot_host_to_target64_real (image_target, in); else return VasEBoot_host_to_target32_real (image_target, in); } static inline VasEBoot_uint64_t VasEBoot_target_to_host_real (const struct VasEBoot_install_image_target_desc *image_target, VasEBoot_uint64_t in) { if (image_target->voidp_sizeof == 8) return VasEBoot_target_to_host64_real (image_target, in); else return VasEBoot_target_to_host32_real (image_target, in); } #define VasEBoot_target_to_host(val) VasEBoot_target_to_host_real(image_target, (val)) #endif