18d7e7a98SRuslan Bukin /*- 28d7e7a98SRuslan Bukin * Copyright (c) 1996-1997 John D. Polstra. 38d7e7a98SRuslan Bukin * All rights reserved. 48d7e7a98SRuslan Bukin * 58d7e7a98SRuslan Bukin * Redistribution and use in source and binary forms, with or without 68d7e7a98SRuslan Bukin * modification, are permitted provided that the following conditions 78d7e7a98SRuslan Bukin * are met: 88d7e7a98SRuslan Bukin * 1. Redistributions of source code must retain the above copyright 98d7e7a98SRuslan Bukin * notice, this list of conditions and the following disclaimer. 108d7e7a98SRuslan Bukin * 2. Redistributions in binary form must reproduce the above copyright 118d7e7a98SRuslan Bukin * notice, this list of conditions and the following disclaimer in the 128d7e7a98SRuslan Bukin * documentation and/or other materials provided with the distribution. 138d7e7a98SRuslan Bukin * 148d7e7a98SRuslan Bukin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158d7e7a98SRuslan Bukin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168d7e7a98SRuslan Bukin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178d7e7a98SRuslan Bukin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188d7e7a98SRuslan Bukin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198d7e7a98SRuslan Bukin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208d7e7a98SRuslan Bukin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218d7e7a98SRuslan Bukin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228d7e7a98SRuslan Bukin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238d7e7a98SRuslan Bukin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248d7e7a98SRuslan Bukin * SUCH DAMAGE. 258d7e7a98SRuslan Bukin */ 268d7e7a98SRuslan Bukin 278d7e7a98SRuslan Bukin #ifndef _MACHINE_ELF_H_ 288d7e7a98SRuslan Bukin #define _MACHINE_ELF_H_ 298d7e7a98SRuslan Bukin 308d7e7a98SRuslan Bukin /* 318d7e7a98SRuslan Bukin * ELF definitions for the RISC-V architecture. 328d7e7a98SRuslan Bukin */ 338d7e7a98SRuslan Bukin 348d7e7a98SRuslan Bukin #include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 358d7e7a98SRuslan Bukin #include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */ 368d7e7a98SRuslan Bukin 378d7e7a98SRuslan Bukin #define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */ 388d7e7a98SRuslan Bukin #include <sys/elf_generic.h> 398d7e7a98SRuslan Bukin 408d7e7a98SRuslan Bukin /* 418d7e7a98SRuslan Bukin * Auxiliary vector entries for passing information to the interpreter. 428d7e7a98SRuslan Bukin */ 438d7e7a98SRuslan Bukin 448d7e7a98SRuslan Bukin typedef struct { /* Auxiliary vector entry on initial stack */ 458d7e7a98SRuslan Bukin int a_type; /* Entry type. */ 468d7e7a98SRuslan Bukin union { 478d7e7a98SRuslan Bukin int a_val; /* Integer value. */ 488d7e7a98SRuslan Bukin } a_un; 498d7e7a98SRuslan Bukin } Elf32_Auxinfo; 508d7e7a98SRuslan Bukin 518d7e7a98SRuslan Bukin typedef struct { /* Auxiliary vector entry on initial stack */ 528d7e7a98SRuslan Bukin long a_type; /* Entry type. */ 538d7e7a98SRuslan Bukin union { 548d7e7a98SRuslan Bukin long a_val; /* Integer value. */ 558d7e7a98SRuslan Bukin void *a_ptr; /* Address. */ 568d7e7a98SRuslan Bukin void (*a_fcn)(void); /* Function pointer (not used). */ 578d7e7a98SRuslan Bukin } a_un; 588d7e7a98SRuslan Bukin } Elf64_Auxinfo; 598d7e7a98SRuslan Bukin 608d7e7a98SRuslan Bukin __ElfType(Auxinfo); 618d7e7a98SRuslan Bukin 628d7e7a98SRuslan Bukin #define ELF_ARCH EM_RISCV 638d7e7a98SRuslan Bukin 648d7e7a98SRuslan Bukin #define ELF_MACHINE_OK(x) ((x) == (ELF_ARCH)) 658d7e7a98SRuslan Bukin 668d7e7a98SRuslan Bukin /* Define "machine" characteristics */ 678d7e7a98SRuslan Bukin #define ELF_TARG_CLASS ELFCLASS64 688d7e7a98SRuslan Bukin #define ELF_TARG_DATA ELFDATA2LSB 698d7e7a98SRuslan Bukin #define ELF_TARG_MACH EM_RISCV 708d7e7a98SRuslan Bukin #define ELF_TARG_VER 1 718d7e7a98SRuslan Bukin 728d7e7a98SRuslan Bukin /* TODO: set correct value */ 738d7e7a98SRuslan Bukin #define ET_DYN_LOAD_ADDR 0x100000 748d7e7a98SRuslan Bukin 75ffedb98bSMitchell Horne /* Flags passed in AT_HWCAP */ 76701923e2SMitchell Horne #define HWCAP_ISA_BIT(c) (1 << ((c) - 'a')) 77701923e2SMitchell Horne #define HWCAP_ISA_I HWCAP_ISA_BIT('i') 78701923e2SMitchell Horne #define HWCAP_ISA_M HWCAP_ISA_BIT('m') 79701923e2SMitchell Horne #define HWCAP_ISA_A HWCAP_ISA_BIT('a') 80701923e2SMitchell Horne #define HWCAP_ISA_F HWCAP_ISA_BIT('f') 81701923e2SMitchell Horne #define HWCAP_ISA_D HWCAP_ISA_BIT('d') 82701923e2SMitchell Horne #define HWCAP_ISA_C HWCAP_ISA_BIT('c') 83ffedb98bSMitchell Horne #define HWCAP_ISA_G \ 84ffedb98bSMitchell Horne (HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F | HWCAP_ISA_D) 85ffedb98bSMitchell Horne 868d7e7a98SRuslan Bukin #endif /* !_MACHINE_ELF_H_ */ 87