Importing mkelfimage from
ftp://ftp.lnxi.com/pub/mkelfImage/mkelfImage-2.7.tar.gz Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3103 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
committed by
Stefan Reinauer
parent
46fc14dcc8
commit
b34eea348c
226
util/mkelfImage/include/elf.h
Normal file
226
util/mkelfImage/include/elf.h
Normal file
@ -0,0 +1,226 @@
|
||||
#ifndef ELF_H
|
||||
#define ELF_H
|
||||
|
||||
#define EI_NIDENT 16 /* Size of e_ident array. */
|
||||
|
||||
/* Values for e_type. */
|
||||
#define ET_NONE 0 /* No file type */
|
||||
#define ET_REL 1 /* Relocatable file */
|
||||
#define ET_EXEC 2 /* Executable file */
|
||||
#define ET_DYN 3 /* Shared object file */
|
||||
#define ET_CORE 4 /* Core file */
|
||||
|
||||
/* Values for e_machine (architecute). */
|
||||
#define EM_NONE 0 /* No machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SUN SPARC */
|
||||
#define EM_386 3 /* Intel 80386+ */
|
||||
#define EM_68K 4 /* Motorola m68k family */
|
||||
#define EM_88K 5 /* Motorola m88k family */
|
||||
#define EM_486 6 /* Perhaps disused */
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS R3000 big-endian */
|
||||
#define EM_S370 9 /* IBM System/370 */
|
||||
#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
|
||||
|
||||
#define EM_PARISC 15 /* HPPA */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_PPC64 21 /* PowerPC 64-bit */
|
||||
#define EM_S390 22 /* IBM S390 */
|
||||
|
||||
#define EM_V800 36 /* NEC V800 series */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* ARM */
|
||||
#define EM_FAKE_ALPHA 41 /* Digital Alpha */
|
||||
#define EM_SH 42 /* Hitachi SH */
|
||||
#define EM_SPARCV9 43 /* SPARC v9 64-bit */
|
||||
#define EM_TRICORE 44 /* Siemens Tricore */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel Merced */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola Coldfire */
|
||||
#define EM_68HC12 53 /* Motorola M68HC12 */
|
||||
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
|
||||
#define EM_PCP 55 /* Siemens PCP */
|
||||
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
|
||||
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
|
||||
#define EM_STARCORE 58 /* Motorola Start*Core processor */
|
||||
#define EM_ME16 59 /* Toyota ME16 processor */
|
||||
#define EM_ST100 60 /* STMicroelectronic ST100 processor */
|
||||
#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
|
||||
#define EM_X86_64 62 /* AMD x86-64 architecture */
|
||||
#define EM_PDSP 63 /* Sony DSP Processor */
|
||||
|
||||
#define EM_FX66 66 /* Siemens FX66 microcontroller */
|
||||
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
|
||||
#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
|
||||
#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
|
||||
#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
|
||||
#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
|
||||
#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
|
||||
#define EM_SVX 73 /* Silicon Graphics SVx */
|
||||
#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
|
||||
#define EM_VAX 75 /* Digital VAX */
|
||||
#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
|
||||
#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
|
||||
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
|
||||
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
|
||||
#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
|
||||
#define EM_HUANY 81 /* Harvard University machine-independent object files */
|
||||
#define EM_PRISM 82 /* SiTera Prism */
|
||||
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
|
||||
#define EM_FR30 84 /* Fujitsu FR30 */
|
||||
#define EM_D10V 85 /* Mitsubishi D10V */
|
||||
#define EM_D30V 86 /* Mitsubishi D30V */
|
||||
#define EM_V850 87 /* NEC v850 */
|
||||
#define EM_M32R 88 /* Mitsubishi M32R */
|
||||
#define EM_MN10300 89 /* Matsushita MN10300 */
|
||||
#define EM_MN10200 90 /* Matsushita MN10200 */
|
||||
#define EM_PJ 91 /* picoJava */
|
||||
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
|
||||
#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
|
||||
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
|
||||
#define EM_NUM 95
|
||||
|
||||
/* Values for p_type. */
|
||||
#define PT_NULL 0 /* Unused entry. */
|
||||
#define PT_LOAD 1 /* Loadable segment. */
|
||||
#define PT_DYNAMIC 2 /* Dynamic linking information segment. */
|
||||
#define PT_INTERP 3 /* Pathname of interpreter. */
|
||||
#define PT_NOTE 4 /* Auxiliary information. */
|
||||
#define PT_SHLIB 5 /* Reserved (not used). */
|
||||
#define PT_PHDR 6 /* Location of program header itself. */
|
||||
|
||||
/* Values for p_flags. */
|
||||
#define PF_X 0x1 /* Executable. */
|
||||
#define PF_W 0x2 /* Writable. */
|
||||
#define PF_R 0x4 /* Readable. */
|
||||
|
||||
|
||||
#define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */
|
||||
|
||||
#define EI_MAG0 0
|
||||
#define ELFMAG0 0x7f
|
||||
|
||||
#define EI_MAG1 1
|
||||
#define ELFMAG1 'E'
|
||||
|
||||
#define EI_MAG2 2
|
||||
#define ELFMAG2 'L'
|
||||
|
||||
#define EI_MAG3 3
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
#define ELFMAG "\177ELF"
|
||||
|
||||
#define EI_CLASS 4 /* File class byte index */
|
||||
#define ELFCLASSNONE 0 /* Invalid class */
|
||||
#define ELFCLASS32 1 /* 32-bit objects */
|
||||
#define ELFCLASS64 2 /* 64-bit objects */
|
||||
|
||||
#define EI_DATA 5 /* Data encodeing byte index */
|
||||
#define ELFDATANONE 0 /* Invalid data encoding */
|
||||
#define ELFDATA2LSB 1 /* 2's complement little endian */
|
||||
#define ELFDATA2MSB 2 /* 2's complement big endian */
|
||||
|
||||
#define EI_VERSION 6 /* File version byte index */
|
||||
/* Value must be EV_CURRENT */
|
||||
|
||||
#define EV_NONE 0 /* Invalid ELF Version */
|
||||
#define EV_CURRENT 1 /* Current version */
|
||||
|
||||
#define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
/*
|
||||
* ELF definitions common to all 32-bit architectures.
|
||||
*/
|
||||
|
||||
typedef uint32_t Elf32_Addr;
|
||||
typedef uint16_t Elf32_Half;
|
||||
typedef uint32_t Elf32_Off;
|
||||
typedef int32_t Elf32_Sword;
|
||||
typedef uint32_t Elf32_Word;
|
||||
typedef uint32_t Elf32_Size;
|
||||
|
||||
typedef uint64_t Elf64_Addr;
|
||||
typedef uint16_t Elf64_Half;
|
||||
typedef uint64_t Elf64_Off;
|
||||
typedef int32_t Elf64_Sword;
|
||||
typedef uint32_t Elf64_Word;
|
||||
typedef uint64_t Elf64_Size;
|
||||
|
||||
/*
|
||||
* ELF header.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT]; /* File identification. */
|
||||
Elf32_Half e_type; /* File type. */
|
||||
Elf32_Half e_machine; /* Machine architecture. */
|
||||
Elf32_Word e_version; /* ELF format version. */
|
||||
Elf32_Addr e_entry; /* Entry point. */
|
||||
Elf32_Off e_phoff; /* Program header file offset. */
|
||||
Elf32_Off e_shoff; /* Section header file offset. */
|
||||
Elf32_Word e_flags; /* Architecture-specific flags. */
|
||||
Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
|
||||
Elf32_Half e_phentsize; /* Size of program header entry. */
|
||||
Elf32_Half e_phnum; /* Number of program header entries. */
|
||||
Elf32_Half e_shentsize; /* Size of section header entry. */
|
||||
Elf32_Half e_shnum; /* Number of section header entries. */
|
||||
Elf32_Half e_shstrndx; /* Section name strings section. */
|
||||
} Elf32_Ehdr;
|
||||
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT]; /* File identification. */
|
||||
Elf64_Half e_type; /* File type. */
|
||||
Elf64_Half e_machine; /* Machine architecture. */
|
||||
Elf64_Word e_version; /* ELF format version. */
|
||||
Elf64_Addr e_entry; /* Entry point. */
|
||||
Elf64_Off e_phoff; /* Program header file offset. */
|
||||
Elf64_Off e_shoff; /* Section header file offset. */
|
||||
Elf64_Word e_flags; /* Architecture-specific flags. */
|
||||
Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
|
||||
Elf64_Half e_phentsize; /* Size of program header entry. */
|
||||
Elf64_Half e_phnum; /* Number of program header entries. */
|
||||
Elf64_Half e_shentsize; /* Size of section header entry. */
|
||||
Elf64_Half e_shnum; /* Number of section header entries. */
|
||||
Elf64_Half e_shstrndx; /* Section name strings section. */
|
||||
} Elf64_Ehdr;
|
||||
|
||||
/*
|
||||
* Program header.
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word p_type; /* Entry type. */
|
||||
Elf32_Off p_offset; /* File offset of contents. */
|
||||
Elf32_Addr p_vaddr; /* Virtual address (not used). */
|
||||
Elf32_Addr p_paddr; /* Physical address. */
|
||||
Elf32_Size p_filesz; /* Size of contents in file. */
|
||||
Elf32_Size p_memsz; /* Size of contents in memory. */
|
||||
Elf32_Word p_flags; /* Access permission flags. */
|
||||
Elf32_Size p_align; /* Alignment in memory and file. */
|
||||
} Elf32_Phdr;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word p_type; /* Entry type. */
|
||||
Elf64_Word p_flags; /* Access permission flags. */
|
||||
Elf64_Off p_offset; /* File offset of contents. */
|
||||
Elf64_Addr p_vaddr; /* Virtual address (not used). */
|
||||
Elf64_Addr p_paddr; /* Physical address. */
|
||||
Elf64_Size p_filesz; /* Size of contents in file. */
|
||||
Elf64_Size p_memsz; /* Size of contents in memory. */
|
||||
Elf64_Size p_align; /* Alignment in memory and file. */
|
||||
} Elf64_Phdr;
|
||||
|
||||
#endif /* ASSEMBLY */
|
||||
|
||||
#endif /* ELF_H */
|
105
util/mkelfImage/include/elf_boot.h
Normal file
105
util/mkelfImage/include/elf_boot.h
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef ELF_BOOT_H
|
||||
#define ELF_BOOT_H
|
||||
|
||||
|
||||
/* This defines the structure of a table of parameters useful for ELF
|
||||
* bootable images. These parameters are all passed and generated
|
||||
* by the bootloader to the booted image. For simplicity and
|
||||
* consistency the Elf Note format is reused.
|
||||
*
|
||||
* All of the information must be Position Independent Data.
|
||||
* That is it must be safe to relocate the whole ELF boot parameter
|
||||
* block without changing the meaning or correctnes of the data.
|
||||
* Additionally it must be safe to permute the order of the ELF notes
|
||||
* to any possible permutation without changing the meaning or correctness
|
||||
* of the data.
|
||||
*
|
||||
*/
|
||||
|
||||
#define ELF_BHDR_MAGIC 0x0E1FB007
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
#include <stdint.h>
|
||||
typedef uint16_t Elf_Half;
|
||||
typedef uint32_t Elf_Word;
|
||||
|
||||
/*
|
||||
* Elf boot notes...
|
||||
*/
|
||||
|
||||
typedef struct Elf_Bhdr
|
||||
{
|
||||
Elf_Word b_signature; /* "0x0E1FB007" */
|
||||
Elf_Word b_size;
|
||||
Elf_Half b_checksum;
|
||||
Elf_Half b_records;
|
||||
} Elf_Bhdr;
|
||||
|
||||
/*
|
||||
* ELF Notes.
|
||||
*/
|
||||
|
||||
typedef struct Elf_Nhdr
|
||||
{
|
||||
Elf_Word n_namesz; /* Length of the note's name. */
|
||||
Elf_Word n_descsz; /* Length of the note's descriptor. */
|
||||
Elf_Word n_type; /* Type of the note. */
|
||||
} Elf_Nhdr;
|
||||
|
||||
#endif /* ASSEMBLY */
|
||||
|
||||
/* Standardized Elf image notes for booting... The name for all of these is ELFBoot */
|
||||
#define ELF_NOTE_BOOT "ELFBoot"
|
||||
|
||||
#define EIN_PROGRAM_NAME 0x00000001
|
||||
/* The program in this ELF file */
|
||||
#define EIN_PROGRAM_VERSION 0x00000002
|
||||
/* The version of the program in this ELF file */
|
||||
#define EIN_PROGRAM_CHECKSUM 0x00000003
|
||||
/* ip style checksum of the memory image. */
|
||||
|
||||
|
||||
/* Linux image notes for booting... The name for all of these is Linux */
|
||||
|
||||
#define LIN_COMMAND_LINE 0x00000001
|
||||
/* The command line to pass to the loaded kernel. */
|
||||
#define LIN_ROOT_DEV 0x00000002
|
||||
/* The root dev to pass to the loaded kernel. */
|
||||
#define LIN_RAMDISK_FLAGS 0x00000003
|
||||
/* Various old ramdisk flags */
|
||||
#define LIN_INITRD_START 0x00000004
|
||||
/* Start of the ramdisk in bytes */
|
||||
#define LIN_INITRD_SIZE 0x00000005
|
||||
/* Size of the ramdisk in bytes */
|
||||
|
||||
/* Notes that are passed to a loaded image */
|
||||
/* For the standard elf boot notes n_namesz must be zero */
|
||||
#define EBN_FIRMWARE_TYPE 0x00000001
|
||||
/* ASCIZ name of the platform firmware. */
|
||||
#define EBN_BOOTLOADER_NAME 0x00000002
|
||||
/* This specifies just the ASCIZ name of the bootloader */
|
||||
#define EBN_BOOTLOADER_VERSION 0x00000003
|
||||
/* This specifies the version of the bootloader as an ASCIZ string */
|
||||
#define EBN_COMMAND_LINE 0x00000004
|
||||
/* This specifies a command line that can be set by user interaction,
|
||||
* and is provided as a free form ASCIZ string to the loaded image.
|
||||
*/
|
||||
#define EBN_NOP 0x00000005
|
||||
/* A note nop note has no meaning, useful for inserting explicit padding */
|
||||
#define EBN_LOADED_IMAGE 0x00000006
|
||||
/* An ASCIZ string naming the loaded image */
|
||||
|
||||
|
||||
/* Etherboot specific notes */
|
||||
#define EB_PARAM_NOTE "Etherboot"
|
||||
#define EB_IA64_SYSTAB 0x00000001
|
||||
#define EB_IA64_MEMMAP 0x00000002
|
||||
#define EB_IA64_FPSWA 0x00000003
|
||||
#define EB_IA64_CONINFO 0x00000004
|
||||
#define EB_BOOTP_DATA 0x00000005
|
||||
#define EB_HEADER 0x00000006
|
||||
#define EB_IA64_IMAGE_HANDLE 0x00000007
|
||||
#define EB_I386_MEMMAP 0x00000008
|
||||
|
||||
|
||||
#endif /* ELF_BOOT_H */
|
82
util/mkelfImage/include/linuxbios_tables.h
Normal file
82
util/mkelfImage/include/linuxbios_tables.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef LINUXBIOS_TABLES_H
|
||||
#define LINUXBIOS_TABLES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* The linuxbios table information is for conveying information
|
||||
* from the firmware to the loaded OS image. Primarily this
|
||||
* is expected to be information that cannot be discovered by
|
||||
* other means, such as quering the hardware directly.
|
||||
*
|
||||
* All of the information should be Position Independent Data.
|
||||
* That is it should be safe to relocated any of the information
|
||||
* without it's meaning/correctnes changing. For table that
|
||||
* can reasonably be used on multiple architectures the data
|
||||
* size should be fixed. This should ease the transition between
|
||||
* 32 bit and 64 bit architectures etc.
|
||||
*
|
||||
* The completeness test for the information in this table is:
|
||||
* - Can all of the hardware be detected?
|
||||
* - Are the per motherboard constants available?
|
||||
* - Is there enough to allow a kernel to run that was written before
|
||||
* a particular motherboard is constructed? (Assuming the kernel
|
||||
* has drivers for all of the hardware but it does not have
|
||||
* assumptions on how the hardware is connected together).
|
||||
*
|
||||
* With this test it should be straight forward to determine if a
|
||||
* table entry is required or not. This should remove much of the
|
||||
* long term compatibility burden as table entries which are
|
||||
* irrelevant or have been replaced by better alternatives may be
|
||||
* dropped. Of course it is polite and expidite to include extra
|
||||
* table entries and be backwards compatible, but it is not required.
|
||||
*/
|
||||
|
||||
|
||||
struct lb_header
|
||||
{
|
||||
uint8_t signature[4]; /* LBIO */
|
||||
uint32_t header_bytes;
|
||||
uint32_t header_checksum;
|
||||
uint32_t table_bytes;
|
||||
uint32_t table_checksum;
|
||||
uint32_t table_entries;
|
||||
};
|
||||
|
||||
/* Every entry in the boot enviroment list will correspond to a boot
|
||||
* info record. Encoding both type and size. The type is obviously
|
||||
* so you can tell what it is. The size allows you to skip that
|
||||
* boot enviroment record if you don't know what it easy. This allows
|
||||
* forward compatibility with records not yet defined.
|
||||
*/
|
||||
struct lb_record {
|
||||
uint32_t tag; /* tag ID */
|
||||
uint32_t size; /* size of record (in bytes) */
|
||||
};
|
||||
|
||||
#define LB_TAG_UNUSED 0x0000
|
||||
|
||||
#define LB_TAG_MEMORY 0x0001
|
||||
|
||||
struct lb_memory_range {
|
||||
uint64_t start;
|
||||
uint64_t size;
|
||||
uint32_t type;
|
||||
#define LB_MEM_RAM 1
|
||||
#define LB_MEM_RESERVED 2
|
||||
|
||||
};
|
||||
|
||||
struct lb_memory {
|
||||
uint32_t tag;
|
||||
uint32_t size;
|
||||
struct lb_memory_range map[0];
|
||||
};
|
||||
|
||||
#define LB_TAG_HWRPB 0x0002
|
||||
struct lb_hwrpb {
|
||||
uint32_t tag;
|
||||
uint32_t size;
|
||||
uint64_t hwrpb;
|
||||
};
|
||||
|
||||
#endif /* LINUXBIOS_TABLES_H */
|
125
util/mkelfImage/include/mkelfImage.h
Normal file
125
util/mkelfImage/include/mkelfImage.h
Normal file
@ -0,0 +1,125 @@
|
||||
#ifndef MKELFIMAGE_H
|
||||
#define MKELFIMAGE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <byteswap.h>
|
||||
#define USE_BSD
|
||||
#include <endian.h>
|
||||
#define _GNU_SOURCE
|
||||
|
||||
struct memelfheader;
|
||||
struct memelfphdr;
|
||||
struct memelfnote;
|
||||
|
||||
extern void die(char *fmt, ...);
|
||||
extern void usage(void);
|
||||
extern void error(char *fmt, ...);
|
||||
extern uint16_t ipchksum(const void *data, unsigned long length);
|
||||
extern uint16_t add_ipchksums(unsigned long offset, uint16_t sum, uint16_t new);
|
||||
extern void *xmalloc(size_t size, const char *name);
|
||||
extern void *xrealloc(void *ptr, size_t size, const char *name);
|
||||
extern char *slurp_file(const char *filename, off_t *r_size);
|
||||
extern char *slurp_decompress_file(const char *filename, off_t *r_size);
|
||||
extern struct memelfphdr *add_program_headers(struct memelfheader *ehdr, int count);
|
||||
extern struct memelfnote *add_notes(struct memelfheader *ehdr, int count);
|
||||
|
||||
typedef char *(probe_t)(char *kernel_buf, off_t kernel_size);
|
||||
typedef int (mkelf_t)(int argc, char **argv,
|
||||
struct memelfheader *hdr, char *kernel_buf, off_t kernel_size);
|
||||
typedef void (usage_t)(void);
|
||||
struct file_type {
|
||||
const char *name;
|
||||
probe_t *probe;
|
||||
mkelf_t *mkelf;
|
||||
usage_t *usage;
|
||||
};
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define cpu_to_le16(val) (val)
|
||||
#define cpu_to_le32(val) (val)
|
||||
#define cpu_to_le64(val) (val)
|
||||
#define cpu_to_be16(val) bswap_16(val)
|
||||
#define cpu_to_be32(val) bswap_32(val)
|
||||
#define cpu_to_be64(val) bswap_64(val)
|
||||
#define le16_to_cpu(val) (val)
|
||||
#define le32_to_cpu(val) (val)
|
||||
#define le64_to_cpu(val) (val)
|
||||
#define be16_to_cpu(val) bswap_16(val)
|
||||
#define be32_to_cpu(val) bswap_32(val)
|
||||
#define be64_to_cpu(val) bswap_64(val)
|
||||
#endif
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define cpu_to_le16(val) bswap_16(val)
|
||||
#define cpu_to_le32(val) bswap_32(val)
|
||||
#define cpu_to_le64(val) bswap_64(val)
|
||||
#define cpu_to_be16(val) (val)
|
||||
#define cpu_to_be32(val) (val)
|
||||
#define cpu_to_be64(val) (val)
|
||||
#define le16_to_cpu(val) bswap_16(val)
|
||||
#define le32_to_cpu(val) bswap_32(val)
|
||||
#define le64_to_cpu(val) bswap_64(val)
|
||||
#define be16_to_cpu(val) (val)
|
||||
#define be32_to_cpu(val) (val)
|
||||
#define be64_to_cpu(val) (val)
|
||||
#endif
|
||||
|
||||
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
|
||||
|
||||
struct memelfheader {
|
||||
unsigned ei_class;
|
||||
unsigned ei_data;
|
||||
unsigned e_type;
|
||||
unsigned e_machine;
|
||||
unsigned e_flags;
|
||||
unsigned e_phnum;
|
||||
unsigned e_notenum;
|
||||
unsigned long e_entry;
|
||||
struct memelfphdr *e_phdr;
|
||||
struct memelfnote *e_notes;
|
||||
};
|
||||
|
||||
struct memelfphdr {
|
||||
uint64_t p_vaddr;
|
||||
uint64_t p_paddr;
|
||||
uint64_t p_filesz;
|
||||
uint64_t p_memsz;
|
||||
void *p_data;
|
||||
unsigned p_type;
|
||||
unsigned p_flags;
|
||||
};
|
||||
|
||||
struct memelfnote {
|
||||
unsigned n_type;
|
||||
char *n_name;
|
||||
void *n_desc;
|
||||
unsigned n_descsz;
|
||||
};
|
||||
|
||||
#define OPT_HELP 'h'
|
||||
#define OPT_VERSION 'v'
|
||||
#define OPT_TYPE 't'
|
||||
#define OPT_KERNEL 256
|
||||
#define OPT_OUTPUT 257
|
||||
#define OPT_MAX 258
|
||||
|
||||
#define MKELF_OPTIONS \
|
||||
{ "help", 0, 0, OPT_HELP }, \
|
||||
{ "version", 0, 0, OPT_VERSION }, \
|
||||
{ "kernel", 1, 0, OPT_KERNEL }, \
|
||||
{ "output", 1, 0, OPT_OUTPUT }, \
|
||||
{ "type", 1, 0, OPT_TYPE },
|
||||
|
||||
#define MKELF_OPT_STR "hvt:"
|
||||
|
||||
extern probe_t vmlinux_i386_probe;
|
||||
extern probe_t bzImage_i386_probe;
|
||||
extern probe_t linux_i386_probe;
|
||||
extern mkelf_t linux_i386_mkelf;
|
||||
extern usage_t linux_i386_usage;
|
||||
|
||||
extern probe_t linux_ia64_probe;
|
||||
extern mkelf_t linux_ia64_mkelf;
|
||||
extern usage_t linux_ia64_usage;
|
||||
|
||||
#endif /* MKELFIMAGE_H */
|
Reference in New Issue
Block a user