From 2902be86c1496244800ee15a148a4907bf9a3492 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:07 -0700 Subject: bootvx: x86: Prepare e820 related stuff from the given kernel memory base address At present two environment variables 'e820data'/'e820info' are required to boot a VxWorks x86 kernel, but this is superfluous. The offset of these two tables are actually at a fixed offset from the kernel memory base address and we can provide the kernel memory base address to U-Boot via only one variable 'vx_phys_mem_base'. Note as it name indicates, the physical address should be provided. Signed-off-by: Bin Meng Reviewed-by: Christian Gmeiner --- include/vxworks.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/vxworks.h b/include/vxworks.h index f69b0084ff..f600dfa337 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -8,10 +8,16 @@ #ifndef _VXWORKS_H_ #define _VXWORKS_H_ +/* + * Physical address of memory base for VxWorks x86 + * This is LOCAL_MEM_LOCAL_ADRS in the VxWorks kernel configuration. + */ +#define VXWORKS_PHYS_MEM_BASE 0x100000 + /* * VxWorks x86 E820 related stuff * - * VxWorks on x86 gets E820 information from pre-defined address @ + * VxWorks on x86 gets E820 information from pre-defined offset @ * 0x4a00 and 0x4000. At 0x4a00 it's an information table defined * by VxWorks and the actual E820 table entries starts from 0x4000. * As defined by the BIOS E820 spec, the maximum number of E820 table @@ -20,8 +26,8 @@ * information that is retrieved from the BIOS E820 call and saved * later for sanity test during the kernel boot-up. */ -#define VXWORKS_E820_DATA_ADDR 0x4000 -#define VXWORKS_E820_INFO_ADDR 0x4a00 +#define E820_DATA_OFFSET 0x4000 +#define E820_INFO_OFFSET 0x4a00 /* E820 info signatiure "SMAP" - System MAP */ #define E820_SIGNATURE 0x534d4150 -- cgit From 1351700cf2eec9fd928dace86de0aabdb34dfeb5 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:08 -0700 Subject: bootvx: x86: Explicitly clear the bootloader image size VxWorks bootloader stores its size at a pre-defined offset @ 0x5004. Later when VxWorks kernel boots up and system memory information is retrieved from the E820 table, the bootloader size will be subtracted from the total system memory size to calculate the size of available memory for the OS. Explicitly clear the bootloader image size otherwise if memory at this offset happens to contain some garbage data, the final available memory size for the kernel is insane. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/vxworks.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/vxworks.h b/include/vxworks.h index f600dfa337..d912076322 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -43,6 +43,15 @@ struct e820info { u32 error; /* must be zero */ }; +/* + * VxWorks bootloader stores its size at a pre-defined offset @ 0x5004. + * Later when VxWorks kernel boots up and system memory information is + * retrieved from the E820 table, the bootloader size will be subtracted + * from the total system memory size to calculate the size of available + * memory for the OS. + */ +#define BOOT_IMAGE_SIZE_OFFSET 0x5004 + int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); void boot_prep_vxworks(bootm_headers_t *images); void boot_jump_vxworks(bootm_headers_t *images); -- cgit From fa5e91f778fe8aba1fa9a7d0d7f64abdf3080ac9 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:09 -0700 Subject: vxworks: x86: Rename e820info to e820_info This changes 'struct e820info' to 'struct e820_info' to conform with the coding style. Signed-off-by: Bin Meng Reviewed-by: Christian Gmeiner --- include/vxworks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/vxworks.h b/include/vxworks.h index d912076322..4a83a34dfb 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -32,7 +32,7 @@ /* E820 info signatiure "SMAP" - System MAP */ #define E820_SIGNATURE 0x534d4150 -struct e820info { +struct e820_info { u32 sign; /* "SMAP" signature */ u32 x0; /* don't care, used by VxWorks */ u32 x1; /* don't care, used by VxWorks */ -- cgit From df635df2e0f2d7a54401377bbc59e98ec2fa8753 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:12 -0700 Subject: elf: Clean up the ELF header file Fix various style violations in elf.h - use correct comment format if the comment fits in just one line - remove the ending period for the one-line comment - use tab for the indention instead of space - put the opening brace at the same line of a typedef/union - remove in a 'typedef struct' for consistency Signed-off-by: Bin Meng Reviewed-by: Christian Gmeiner --- include/elf.h | 284 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 138 insertions(+), 146 deletions(-) (limited to 'include') diff --git a/include/elf.h b/include/elf.h index fe2128f378..4742597980 100644 --- a/include/elf.h +++ b/include/elf.h @@ -5,10 +5,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ -/* - * This is the ELF ABI header file - * formerly known as "elf_abi.h". - */ +/* This is the ELF ABI header file formerly known as "elf_abi.h" */ #ifndef _ELF_H #define _ELF_H @@ -16,20 +13,16 @@ #ifndef __ASSEMBLER__ #include "compiler.h" -/* - * This version doesn't work for 64-bit ABIs - Erik. - */ +/* This version doesn't work for 64-bit ABIs - Erik */ -/* - * These typedefs need to be handled better. - */ +/* These typedefs need to be handled better */ typedef uint32_t Elf32_Addr; /* Unsigned program address */ typedef uint32_t Elf32_Off; /* Unsigned file offset */ typedef int32_t Elf32_Sword; /* Signed large integer */ typedef uint32_t Elf32_Word; /* Unsigned large integer */ typedef uint16_t Elf32_Half; /* Unsigned medium integer */ -/* 64-bit ELF base types. */ +/* 64-bit ELF base types */ typedef uint64_t Elf64_Addr; typedef uint16_t Elf64_Half; typedef int16_t Elf64_SHalf; @@ -96,7 +89,7 @@ typedef int64_t Elf64_Sxword; (ehdr).e_ident[EI_MAG3] == ELFMAG3) /* ELF Header */ -typedef struct elfhdr{ +typedef struct { unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ Elf32_Half e_type; /* object file type */ Elf32_Half e_machine; /* machine */ @@ -122,9 +115,9 @@ typedef struct elfhdr{ #define ET_CORE 4 /* core file */ #define ET_NUM 5 /* number of types */ #define ET_LOOS 0xfe00 /* reserved range for operating */ -#define ET_HIOS 0xfeff /* system specific e_type */ +#define ET_HIOS 0xfeff /* system specific e_type */ #define ET_LOPROC 0xff00 /* reserved range for processor */ -#define ET_HIPROC 0xffff /* specific e_type */ +#define ET_HIPROC 0xffff /* specific e_type */ /* e_machine */ #define EM_NONE 0 /* No Machine */ @@ -235,9 +228,9 @@ typedef struct { #define SHN_UNDEF 0 /* undefined */ #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ #define SHN_LOPROC 0xff00 /* reserved range for processor */ -#define SHN_HIPROC 0xff1f /* specific section indexes */ +#define SHN_HIPROC 0xff1f /* specific section indexes */ #define SHN_LOOS 0xff20 /* reserved range for operating */ -#define SHN_HIOS 0xff3f /* specific semantics */ +#define SHN_HIOS 0xff3f /* specific semantics */ #define SHN_ABS 0xfff1 /* absolute value */ #define SHN_COMMON 0xfff2 /* common symbol */ #define SHN_XINDEX 0xffff /* Index is an extra table */ @@ -265,46 +258,46 @@ typedef struct { #define SHT_LOOS 0x60000000 /* Start OS-specific */ #define SHT_HIOS 0x6fffffff /* End OS-specific */ #define SHT_LOPROC 0x70000000 /* reserved range for processor */ -#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_HIPROC 0x7fffffff /* specific section header types */ #define SHT_LOUSER 0x80000000 /* reserved range for application */ -#define SHT_HIUSER 0xffffffff /* specific indexes */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ /* Section names */ -#define ELF_BSS ".bss" /* uninitialized data */ +#define ELF_BSS ".bss" /* uninitialized data */ #define ELF_COMMENT ".comment" /* version control information */ -#define ELF_DATA ".data" /* initialized data */ -#define ELF_DATA1 ".data1" /* initialized data */ -#define ELF_DEBUG ".debug" /* debug */ -#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ -#define ELF_DYNSTR ".dynstr" /* dynamic string table */ -#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ -#define ELF_FINI ".fini" /* termination code */ +#define ELF_DATA ".data" /* initialized data */ +#define ELF_DATA1 ".data1" /* initialized data */ +#define ELF_DEBUG ".debug" /* debug */ +#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ +#define ELF_DYNSTR ".dynstr" /* dynamic string table */ +#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ +#define ELF_FINI ".fini" /* termination code */ #define ELF_FINI_ARRAY ".fini_array" /* Array of destructors */ -#define ELF_GOT ".got" /* global offset table */ -#define ELF_HASH ".hash" /* symbol hash table */ -#define ELF_INIT ".init" /* initialization code */ +#define ELF_GOT ".got" /* global offset table */ +#define ELF_HASH ".hash" /* symbol hash table */ +#define ELF_INIT ".init" /* initialization code */ #define ELF_INIT_ARRAY ".init_array" /* Array of constuctors */ #define ELF_INTERP ".interp" /* Pathname of program interpreter */ #define ELF_LINE ".line" /* Symbolic line numnber information */ #define ELF_NOTE ".note" /* Contains note section */ #define ELF_PLT ".plt" /* Procedure linkage table */ #define ELF_PREINIT_ARRAY ".preinit_array" /* Array of pre-constructors */ -#define ELF_REL_DATA ".rel.data" /* relocation data */ -#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ -#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ -#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ -#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ -#define ELF_REL_TEXT ".rel.text" /* relocation code */ -#define ELF_RODATA ".rodata" /* read-only data */ -#define ELF_RODATA1 ".rodata1" /* read-only data */ -#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ -#define ELF_STRTAB ".strtab" /* string table */ -#define ELF_SYMTAB ".symtab" /* symbol table */ +#define ELF_REL_DATA ".rel.data" /* relocation data */ +#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ +#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ +#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ +#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ +#define ELF_REL_TEXT ".rel.text" /* relocation code */ +#define ELF_RODATA ".rodata" /* read-only data */ +#define ELF_RODATA1 ".rodata1" /* read-only data */ +#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ +#define ELF_STRTAB ".strtab" /* string table */ +#define ELF_SYMTAB ".symtab" /* symbol table */ #define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */ #define ELF_TBSS ".tbss" /* thread local uninit data */ #define ELF_TDATA ".tdata" /* thread local init data */ #define ELF_TDATA1 ".tdata1" /* thread local init data */ -#define ELF_TEXT ".text" /* code */ +#define ELF_TEXT ".text" /* code */ /* Section Attribute Flags - sh_flags */ #define SHF_WRITE 0x1 /* Writable */ @@ -319,7 +312,7 @@ typedef struct { #define SHF_TLS 0x400 /* Thread local storage */ #define SHF_MASKOS 0x0ff00000 /* OS specific */ #define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ - /* specific section attributes */ + /* specific section attributes */ /* Section Group Flags */ #define GRP_COMDAT 0x1 /* COMDAT group */ @@ -327,7 +320,7 @@ typedef struct { #define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags */ /* Symbol Table Entry */ -typedef struct elf32_sym { +typedef struct { Elf32_Word st_name; /* name - index into string table */ Elf32_Addr st_value; /* symbol value */ Elf32_Word st_size; /* symbol size */ @@ -351,9 +344,9 @@ typedef struct elf32_sym { #define STB_WEAK 2 /* like global - lower precedence */ #define STB_NUM 3 /* number of symbol bindings */ #define STB_LOOS 10 /* reserved range for operating */ -#define STB_HIOS 12 /* system specific symbol bindings */ +#define STB_HIOS 12 /* system specific symbol bindings */ #define STB_LOPROC 13 /* reserved range for processor */ -#define STB_HIPROC 15 /* specific symbol bindings */ +#define STB_HIPROC 15 /* specific symbol bindings */ /* Symbol type - ELF32_ST_TYPE - st_info */ #define STT_NOTYPE 0 /* not specified */ @@ -364,9 +357,9 @@ typedef struct elf32_sym { #define STT_NUM 5 /* number of symbol types */ #define STT_TLS 6 /* Thread local storage symbol */ #define STT_LOOS 10 /* reserved range for operating */ -#define STT_HIOS 12 /* system specific symbol types */ +#define STT_HIOS 12 /* system specific symbol types */ #define STT_LOPROC 13 /* reserved range for processor */ -#define STT_HIPROC 15 /* specific symbol types */ +#define STT_HIPROC 15 /* specific symbol types */ /* Symbol visibility - ELF32_ST_VISIBILITY - st_other */ #define STV_DEFAULT 0 /* Normal visibility rules */ @@ -374,17 +367,14 @@ typedef struct elf32_sym { #define STV_HIDDEN 2 /* Symbol unavailable in other mods */ #define STV_PROTECTED 3 /* Not preemptible, not exported */ - /* Relocation entry with implicit addend */ -typedef struct -{ +typedef struct { Elf32_Addr r_offset; /* offset of relocation */ Elf32_Word r_info; /* symbol table index and type */ } Elf32_Rel; /* Relocation entry with explicit addend */ -typedef struct -{ +typedef struct { Elf32_Addr r_offset; /* offset of relocation */ Elf32_Word r_info; /* symbol table index and type */ Elf32_Sword r_addend; @@ -396,9 +386,9 @@ typedef struct { } Elf64_Rel; typedef struct { - Elf64_Addr r_offset; /* Location at which to apply the action */ - Elf64_Xword r_info; /* index and type of relocation */ - Elf64_Sxword r_addend; /* Constant addend used to compute value */ + Elf64_Addr r_offset; /* Location at which to apply the action */ + Elf64_Xword r_info; /* index and type of relocation */ + Elf64_Sxword r_addend; /* Constant addend used to compute value */ } Elf64_Rela; /* Extract relocation info - r_info */ @@ -411,9 +401,9 @@ typedef struct { Elf32_Word p_type; /* segment type */ Elf32_Off p_offset; /* segment offset */ Elf32_Addr p_vaddr; /* virtual address of segment */ - Elf32_Addr p_paddr; /* physical address - ignored? */ - Elf32_Word p_filesz; /* number of bytes in file for seg. */ - Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ + Elf32_Addr p_paddr; /* physical address of segment */ + Elf32_Word p_filesz; /* number of bytes in file for seg */ + Elf32_Word p_memsz; /* number of bytes in mem. for seg */ Elf32_Word p_flags; /* flags */ Elf32_Word p_align; /* memory alignment */ } Elf32_Phdr; @@ -429,9 +419,9 @@ typedef struct { #define PT_TLS 7 /* Thread local storage template */ #define PT_NUM 8 /* Number of segment types */ #define PT_LOOS 0x60000000 /* reserved range for operating */ -#define PT_HIOS 0x6fffffff /* system specific segment types */ +#define PT_HIOS 0x6fffffff /* system specific segment types */ #define PT_LOPROC 0x70000000 /* reserved range for processor */ -#define PT_HIPROC 0x7fffffff /* specific segment types */ +#define PT_HIPROC 0x7fffffff /* specific segment types */ /* Segment flags - p_flags */ #define PF_X 0x1 /* Executable */ @@ -439,13 +429,11 @@ typedef struct { #define PF_R 0x4 /* Readable */ #define PF_MASKOS 0x0ff00000 /* OS specific segment flags */ #define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ - /* specific segment flags */ + /* specific segment flags */ /* Dynamic structure */ -typedef struct -{ +typedef struct { Elf32_Sword d_tag; /* controls meaning of d_val */ - union - { + union { Elf32_Word d_val; /* Multiple meanings - see d_tag */ Elf32_Addr d_ptr; /* program virtual address */ } d_un; @@ -477,12 +465,12 @@ typedef struct { #define DT_RELAENT 9 /* size of relocation entry */ #define DT_STRSZ 10 /* size of string table */ #define DT_SYMENT 11 /* size of symbol table entry */ -#define DT_INIT 12 /* address of initialization func. */ +#define DT_INIT 12 /* address of initialization func */ #define DT_FINI 13 /* address of termination function */ #define DT_SONAME 14 /* string table offset of shared obj */ #define DT_RPATH 15 /* string table offset of library search path */ -#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ +#define DT_SYMBOLIC 16 /* start sym search in shared obj */ #define DT_REL 17 /* address of rel. tbl. w addends */ #define DT_RELSZ 18 /* size of DT_REL relocation table */ #define DT_RELENT 19 /* size of DT_REL relocation entry */ @@ -500,11 +488,11 @@ typedef struct { #define DT_ENCODING 32 /* Start of encoded range */ #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used. */ +#define DT_NUM 34 /* Number used */ #define DT_LOOS 0x60000000 /* reserved range for OS */ -#define DT_HIOS 0x6fffffff /* specific dynamic array tags */ +#define DT_HIOS 0x6fffffff /* specific dynamic array tags */ #define DT_LOPROC 0x70000000 /* reserved range for processor */ -#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ +#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ /* Dynamic Tag Flags - d_un.d_val */ #define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */ @@ -525,93 +513,97 @@ unsigned long elf_hash(const unsigned char *name); * but we'll put them in for simplicity. */ -/* Values for Elf32/64_Ehdr.e_flags. */ -#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ +/* Values for Elf32/64_Ehdr.e_flags */ +#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ /* Cygnus local bits below */ -#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib +#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ +#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag */ /* PowerPC relocations defined by the ABIs */ -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 /* 32bit absolute address */ -#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ -#define R_PPC_ADDR16 3 /* 16bit absolute address */ -#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ -#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ -#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ -#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 /* PC relative 26 bit */ -#define R_PPC_REL14 11 /* PC relative 16 bit */ -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 -/* Keep this the last entry. */ -#define R_PPC_NUM 37 - -/* The remaining relocs are from the Embedded ELF ABI, and are not - in the SVR4 ELF ABI. */ -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ - -/* Diab tool relocations. */ -#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ -#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ -#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ -#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ -#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ -#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -/* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ -#define R_PPC_TOC16 255 +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 /* 32bit absolute address */ +#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored */ +#define R_PPC_ADDR16 3 /* 16bit absolute address */ +#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ +#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ +#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ +#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 /* PC relative 26 bit */ +#define R_PPC_REL14 11 /* PC relative 16 bit */ +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 +/* Keep this the last entry */ +#define R_PPC_NUM 37 + +/* + * The remaining relocs are from the Embedded ELF ABI, and are not + * in the SVR4 ELF ABI. + */ +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ + +/* Diab tool relocations */ +#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ +#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ +#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ +#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ +#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ +#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ + +/* + * This is a phony reloc to handle any old fashioned TOC16 references + * that may still be in object files. + */ +#define R_PPC_TOC16 255 /* ARM relocs */ #define R_ARM_NONE 0 /* No reloc */ #define R_ARM_RELATIVE 23 /* Adjust by program base */ /* AArch64 relocs */ -#define R_AARCH64_NONE 0 /* No relocation. */ -#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */ +#define R_AARCH64_NONE 0 /* No relocation */ +#define R_AARCH64_RELATIVE 1027 /* Adjust by program base */ /* RISC-V relocations */ #define R_RISCV_32 1 -- cgit From 2bce3f595d224fc620b07449d47fa2b08151a890 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:13 -0700 Subject: elf: Add ELF64 related structure defines This adds ELF header, program header and section header structure defines for the 64-bit ELF image. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/elf.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include') diff --git a/include/elf.h b/include/elf.h index 4742597980..248ba59cd6 100644 --- a/include/elf.h +++ b/include/elf.h @@ -107,6 +107,24 @@ typedef struct { header string table" entry offset */ } Elf32_Ehdr; +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ + Elf64_Half e_type; /* object file type */ + Elf64_Half e_machine; /* machine */ + Elf64_Word e_version; /* object file version */ + Elf64_Addr e_entry; /* virtual entry point */ + Elf64_Off e_phoff; /* program header table offset */ + Elf64_Off e_shoff; /* section header table offset */ + Elf64_Word e_flags; /* processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size */ + Elf64_Half e_phentsize; /* program header entry size */ + Elf64_Half e_phnum; /* number of program header entries */ + Elf64_Half e_shentsize; /* section header entry size */ + Elf64_Half e_shnum; /* number of section header entries */ + Elf64_Half e_shstrndx; /* section header table's "section + header string table" entry offset */ +} Elf64_Ehdr; + /* e_type */ #define ET_NONE 0 /* No file type */ #define ET_REL 1 /* relocatable file */ @@ -224,6 +242,20 @@ typedef struct { Elf32_Word sh_entsize; /* section entry size */ } Elf32_Shdr; +typedef struct { + Elf64_Word sh_name; /* name - index into section header + string table section */ + Elf64_Word sh_type; /* type */ + Elf64_Xword sh_flags; /* flags */ + Elf64_Addr sh_addr; /* address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Word sh_link; /* section header table index link */ + Elf64_Word sh_info; /* extra information */ + Elf64_Xword sh_addralign; /* address alignment */ + Elf64_Xword sh_entsize; /* section entry size */ +} Elf64_Shdr; + /* Special Section Indexes */ #define SHN_UNDEF 0 /* undefined */ #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ @@ -408,6 +440,17 @@ typedef struct { Elf32_Word p_align; /* memory alignment */ } Elf32_Phdr; +typedef struct { + Elf64_Word p_type; /* segment type */ + Elf64_Word p_flags; /* flags */ + Elf64_Off p_offset; /* segment offset */ + Elf64_Addr p_vaddr; /* virtual address of segment */ + Elf64_Addr p_paddr; /* physical address of segment */ + Elf64_Xword p_filesz; /* number of bytes in file for seg */ + Elf64_Xword p_memsz; /* number of bytes in mem. for seg */ + Elf64_Xword p_align; /* memory alignment */ +} Elf64_Phdr; + /* Segment types - p_type */ #define PT_NULL 0 /* unused */ #define PT_LOAD 1 /* loadable segment */ -- cgit From 447ae4f7adb2c667eec1e0861e2346694c57a2e0 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:19 -0700 Subject: bootvx: x86: Make VxWorks EFI console driver happy When booting from EFI BIOS, VxWorks bootloader stores the EFI GOP framebuffer info at a pre-defined offset @ 0x6100. When VxWorks kernel boots up, its EFI console driver tries to find such a block and if the signature matches, the framebuffer information will be used to initialize the driver. However it is not necessary to prepare an EFI environment for VxWorks's EFI console driver to function (eg: EFI loader in U-Boot). If U-Boot has already initialized the graphics card and set it to a VESA mode that is compatible with EFI GOP, we can simply prepare such a block for VxWorks. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/vxworks.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include') diff --git a/include/vxworks.h b/include/vxworks.h index 4a83a34dfb..b1b5096b90 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -8,6 +8,8 @@ #ifndef _VXWORKS_H_ #define _VXWORKS_H_ +#include + /* * Physical address of memory base for VxWorks x86 * This is LOCAL_MEM_LOCAL_ADRS in the VxWorks kernel configuration. @@ -52,6 +54,30 @@ struct e820_info { */ #define BOOT_IMAGE_SIZE_OFFSET 0x5004 +/* + * When booting from EFI BIOS, VxWorks bootloader stores the EFI GOP + * framebuffer info at a pre-defined offset @ 0x6100. When VxWorks kernel + * boots up, its EFI console driver tries to find such a block and if + * the signature matches, the framebuffer information will be used to + * initialize the driver. + * + * However it is not necessary to prepare an EFI environment for VxWorks's + * EFI console driver to function (eg: EFI loader in U-Boot). If U-Boot has + * already initialized the graphics card and set it to a VESA mode that is + * compatible with EFI GOP, we can simply prepare such a block for VxWorks. + */ +#define EFI_GOP_INFO_OFFSET 0x6100 + +/* EFI GOP info signatiure */ +#define EFI_GOP_INFO_MAGIC 0xfeedface + +struct efi_gop_info { + u32 magic; /* signature */ + struct efi_gop_mode_info info; /* EFI GOP mode info structure */ + phys_addr_t fb_base; /* framebuffer base address */ + u32 fb_size; /* framebuffer size */ +}; + int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); void boot_prep_vxworks(bootm_headers_t *images); void boot_jump_vxworks(bootm_headers_t *images); -- cgit From 79c584e5595458d58dc1cf47172abcb3748574f4 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 11 Apr 2018 22:02:22 -0700 Subject: bootvx: x86: Assign bootaddr based on kernel memory base On VxWorks x86 its bootline address is at a pre-defined offset @ 0x1200. If 'bootaddr' is not passed via environment variable, we assign its value based on the kernel memory base address. Signed-off-by: Bin Meng --- include/vxworks.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/vxworks.h b/include/vxworks.h index b1b5096b90..39f0a444a2 100644 --- a/include/vxworks.h +++ b/include/vxworks.h @@ -16,6 +16,9 @@ */ #define VXWORKS_PHYS_MEM_BASE 0x100000 +/* x86 bootline offset relative to LOCAL_MEM_LOCAL_ADRS in VxWorks */ +#define X86_BOOT_LINE_OFFSET 0x1200 + /* * VxWorks x86 E820 related stuff * -- cgit