/*1* Copyright 2010 Tilera Corporation. All Rights Reserved.2*3* This program is free software; you can redistribute it and/or4* modify it under the terms of the GNU General Public License5* as published by the Free Software Foundation, version 2.6*7* This program is distributed in the hope that it will be useful, but8* WITHOUT ANY WARRANTY; without even the implied warranty of9* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or10* NON INFRINGEMENT. See the GNU General Public License for11* more details.12*/1314#ifndef _ASM_TILE_ELF_H15#define _ASM_TILE_ELF_H1617/*18* ELF register definitions.19*/2021#include <arch/chip.h>2223#include <linux/ptrace.h>24#include <asm/byteorder.h>25#include <asm/page.h>2627typedef unsigned long elf_greg_t;2829#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))30typedef elf_greg_t elf_gregset_t[ELF_NGREG];3132#define EM_TILE64 18733#define EM_TILEPRO 18834#define EM_TILEGX 1913536/* Provide a nominal data structure. */37#define ELF_NFPREG 038typedef double elf_fpreg_t;39typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];4041#ifdef __tilegx__42#define ELF_CLASS ELFCLASS6443#else44#define ELF_CLASS ELFCLASS3245#endif46#define ELF_DATA ELFDATA2LSB4748/*49* There seems to be a bug in how compat_binfmt_elf.c works: it50* #undefs ELF_ARCH, but it is then used in binfmt_elf.c for fill_note_info().51* Hack around this by providing an enum value of ELF_ARCH.52*/53enum { ELF_ARCH = CHIP_ELF_TYPE() };54#define ELF_ARCH ELF_ARCH5556/*57* This is used to ensure we don't load something for the wrong architecture.58*/59#define elf_check_arch(x) \60((x)->e_ident[EI_CLASS] == ELF_CLASS && \61(x)->e_machine == CHIP_ELF_TYPE())6263/* The module loader only handles a few relocation types. */64#ifndef __tilegx__65#define R_TILE_32 166#define R_TILE_JOFFLONG_X1 1567#define R_TILE_IMM16_X0_LO 2568#define R_TILE_IMM16_X1_LO 2669#define R_TILE_IMM16_X0_HA 2970#define R_TILE_IMM16_X1_HA 3071#else72#define R_TILEGX_64 173#define R_TILEGX_JUMPOFF_X1 2174#define R_TILEGX_IMM16_X0_HW0 3675#define R_TILEGX_IMM16_X1_HW0 3776#define R_TILEGX_IMM16_X0_HW1 3877#define R_TILEGX_IMM16_X1_HW1 3978#define R_TILEGX_IMM16_X0_HW2_LAST 4879#define R_TILEGX_IMM16_X1_HW2_LAST 4980#endif8182/* Use standard page size for core dumps. */83#define ELF_EXEC_PAGESIZE PAGE_SIZE8485/*86* This is the location that an ET_DYN program is loaded if exec'ed. Typical87* use of this is to invoke "./ld.so someprog" to test out a new version of88* the loader. We need to make sure that it is out of the way of the program89* that it will "exec", and that there is sufficient room for the brk.90*/91#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)9293#define ELF_CORE_COPY_REGS(_dest, _regs) \94memcpy((char *) &_dest, (char *) _regs, \95sizeof(struct pt_regs));9697/* No additional FP registers to copy. */98#define ELF_CORE_COPY_FPREGS(t, fpu) 099100/*101* This yields a mask that user programs can use to figure out what102* instruction set this CPU supports. This could be done in user space,103* but it's not easy, and we've already done it here.104*/105#define ELF_HWCAP (0)106107/*108* This yields a string that ld.so will use to load implementation109* specific libraries for optimization. This is more specific in110* intent than poking at uname or /proc/cpuinfo.111*/112#define ELF_PLATFORM (NULL)113114extern void elf_plat_init(struct pt_regs *regs, unsigned long load_addr);115116#define ELF_PLAT_INIT(_r, load_addr) elf_plat_init(_r, load_addr)117118extern int dump_task_regs(struct task_struct *, elf_gregset_t *);119#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)120121/* Tilera Linux has no personalities currently, so no need to do anything. */122#define SET_PERSONALITY(ex) do { } while (0)123124#define ARCH_HAS_SETUP_ADDITIONAL_PAGES125/* Support auto-mapping of the user interrupt vectors. */126struct linux_binprm;127extern int arch_setup_additional_pages(struct linux_binprm *bprm,128int executable_stack);129#ifdef CONFIG_COMPAT130131#define COMPAT_ELF_PLATFORM "tilegx-m32"132133/*134* "Compat" binaries have the same machine type, but 32-bit class,135* since they're not a separate machine type, but just a 32-bit136* variant of the standard 64-bit architecture.137*/138#define compat_elf_check_arch(x) \139((x)->e_ident[EI_CLASS] == ELFCLASS32 && \140(x)->e_machine == CHIP_ELF_TYPE())141142#define compat_start_thread(regs, ip, usp) do { \143regs->pc = ptr_to_compat_reg((void *)(ip)); \144regs->sp = ptr_to_compat_reg((void *)(usp)); \145} while (0)146147/*148* Use SET_PERSONALITY to indicate compatibility via TS_COMPAT.149*/150#undef SET_PERSONALITY151#define SET_PERSONALITY(ex) \152do { \153current->personality = PER_LINUX; \154current_thread_info()->status &= ~TS_COMPAT; \155} while (0)156#define COMPAT_SET_PERSONALITY(ex) \157do { \158current->personality = PER_LINUX_32BIT; \159current_thread_info()->status |= TS_COMPAT; \160} while (0)161162#define COMPAT_ELF_ET_DYN_BASE (0xffffffff / 3 * 2)163164#endif /* CONFIG_COMPAT */165166#endif /* _ASM_TILE_ELF_H */167168169