18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef __ASM_CSKY_ELF_H
58c2ecf20Sopenharmony_ci#define __ASM_CSKY_ELF_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
88c2ecf20Sopenharmony_ci#include <abi/regdef.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define ELF_ARCH EM_CSKY
118c2ecf20Sopenharmony_ci#define EM_CSKY_OLD 39
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* CSKY Relocations */
148c2ecf20Sopenharmony_ci#define R_CSKY_NONE               0
158c2ecf20Sopenharmony_ci#define R_CSKY_32                 1
168c2ecf20Sopenharmony_ci#define R_CSKY_PCIMM8BY4          2
178c2ecf20Sopenharmony_ci#define R_CSKY_PCIMM11BY2         3
188c2ecf20Sopenharmony_ci#define R_CSKY_PCIMM4BY2          4
198c2ecf20Sopenharmony_ci#define R_CSKY_PC32               5
208c2ecf20Sopenharmony_ci#define R_CSKY_PCRELJSR_IMM11BY2  6
218c2ecf20Sopenharmony_ci#define R_CSKY_GNU_VTINHERIT      7
228c2ecf20Sopenharmony_ci#define R_CSKY_GNU_VTENTRY        8
238c2ecf20Sopenharmony_ci#define R_CSKY_RELATIVE           9
248c2ecf20Sopenharmony_ci#define R_CSKY_COPY               10
258c2ecf20Sopenharmony_ci#define R_CSKY_GLOB_DAT           11
268c2ecf20Sopenharmony_ci#define R_CSKY_JUMP_SLOT          12
278c2ecf20Sopenharmony_ci#define R_CSKY_ADDR_HI16          24
288c2ecf20Sopenharmony_ci#define R_CSKY_ADDR_LO16          25
298c2ecf20Sopenharmony_ci#define R_CSKY_PCRELJSR_IMM26BY2  40
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_citypedef unsigned long elf_greg_t;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_citypedef struct user_fp elf_fpregset_t;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/*
368c2ecf20Sopenharmony_ci * In gdb/bfd elf32-csky.c, csky_elf_grok_prstatus() use fixed size of
378c2ecf20Sopenharmony_ci * elf_prstatus. It's 148 for abiv1 and 220 for abiv2, the size is enough
388c2ecf20Sopenharmony_ci * for coredump and no need full sizeof(struct pt_regs).
398c2ecf20Sopenharmony_ci */
408c2ecf20Sopenharmony_ci#define ELF_NGREG ((sizeof(struct pt_regs) / sizeof(elf_greg_t)) - 2)
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_citypedef elf_greg_t elf_gregset_t[ELF_NGREG];
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/*
458c2ecf20Sopenharmony_ci * This is used to ensure we don't load something for the wrong architecture.
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_ci#define elf_check_arch(x) (((x)->e_machine == ELF_ARCH) || \
488c2ecf20Sopenharmony_ci			   ((x)->e_machine == EM_CSKY_OLD))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/*
518c2ecf20Sopenharmony_ci * These are used to set parameters in the core dumps.
528c2ecf20Sopenharmony_ci */
538c2ecf20Sopenharmony_ci#define USE_ELF_CORE_DUMP
548c2ecf20Sopenharmony_ci#define ELF_EXEC_PAGESIZE		4096
558c2ecf20Sopenharmony_ci#define ELF_CLASS			ELFCLASS32
568c2ecf20Sopenharmony_ci#define ELF_PLAT_INIT(_r, load_addr)	{ _r->a0 = 0; }
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#ifdef __cskyBE__
598c2ecf20Sopenharmony_ci#define ELF_DATA	ELFDATA2MSB
608c2ecf20Sopenharmony_ci#else
618c2ecf20Sopenharmony_ci#define ELF_DATA	ELFDATA2LSB
628c2ecf20Sopenharmony_ci#endif
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/*
658c2ecf20Sopenharmony_ci * This is the location that an ET_DYN program is loaded if exec'ed. Typical
668c2ecf20Sopenharmony_ci * use of this is to invoke "./ld.so someprog" to test out a new version of
678c2ecf20Sopenharmony_ci * the loader.  We need to make sure that it is out of the way of the program
688c2ecf20Sopenharmony_ci * that it will "exec", and that there is sufficient room for the brk.
698c2ecf20Sopenharmony_ci */
708c2ecf20Sopenharmony_ci#define ELF_ET_DYN_BASE	0x0UL
718c2ecf20Sopenharmony_ci#include <abi/elf.h>
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/* Similar, but for a thread other than current. */
748c2ecf20Sopenharmony_cistruct task_struct;
758c2ecf20Sopenharmony_ciextern int dump_task_regs(struct task_struct *tsk, elf_gregset_t *elf_regs);
768c2ecf20Sopenharmony_ci#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define ELF_HWCAP	(0)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci/*
818c2ecf20Sopenharmony_ci * This yields a string that ld.so will use to load implementation specific
828c2ecf20Sopenharmony_ci * libraries for optimization. This is more specific in intent than poking
838c2ecf20Sopenharmony_ci * at uname or /proc/cpuinfo.
848c2ecf20Sopenharmony_ci */
858c2ecf20Sopenharmony_ci#define ELF_PLATFORM		(NULL)
868c2ecf20Sopenharmony_ci#define SET_PERSONALITY(ex)	set_personality(PER_LINUX)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
898c2ecf20Sopenharmony_cistruct linux_binprm;
908c2ecf20Sopenharmony_ciextern int arch_setup_additional_pages(struct linux_binprm *bprm,
918c2ecf20Sopenharmony_ci				       int uses_interp);
928c2ecf20Sopenharmony_ci#endif /* __ASM_CSKY_ELF_H */
93