/*-1* Copyright (c) 1996-1997 John D. Polstra.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#ifndef _MACHINE_ELF_H_27#define _MACHINE_ELF_H_2829/*30* ELF definitions for the RISC-V architecture.31*/3233#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */34#include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */3536#define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */37#include <sys/elf_generic.h>3839/*40* Auxiliary vector entries for passing information to the interpreter.41*/4243typedef struct { /* Auxiliary vector entry on initial stack */44int a_type; /* Entry type. */45union {46int a_val; /* Integer value. */47} a_un;48} Elf32_Auxinfo;4950typedef struct { /* Auxiliary vector entry on initial stack */51long a_type; /* Entry type. */52union {53long a_val; /* Integer value. */54void *a_ptr; /* Address. */55void (*a_fcn)(void); /* Function pointer (not used). */56} a_un;57} Elf64_Auxinfo;5859__ElfType(Auxinfo);6061#define ELF_ARCH EM_RISCV6263#define ELF_MACHINE_OK(x) ((x) == (ELF_ARCH))6465/* Define "machine" characteristics */66#define ELF_TARG_CLASS ELFCLASS6467#define ELF_TARG_DATA ELFDATA2LSB68#define ELF_TARG_MACH EM_RISCV69#define ELF_TARG_VER 17071/* TODO: set correct value */72#define ET_DYN_LOAD_ADDR 0x1000007374/* Flags passed in AT_HWCAP */75#define HWCAP_ISA_BIT(c) (1 << ((c) - 'a'))76#define HWCAP_ISA_I HWCAP_ISA_BIT('i')77#define HWCAP_ISA_M HWCAP_ISA_BIT('m')78#define HWCAP_ISA_A HWCAP_ISA_BIT('a')79#define HWCAP_ISA_F HWCAP_ISA_BIT('f')80#define HWCAP_ISA_D HWCAP_ISA_BIT('d')81#define HWCAP_ISA_C HWCAP_ISA_BIT('c')82#define HWCAP_ISA_H HWCAP_ISA_BIT('h')83#define HWCAP_ISA_G \84(HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F | HWCAP_ISA_D)85#define HWCAP_ISA_B HWCAP_ISA_BIT('b')8687#endif /* !_MACHINE_ELF_H_ */888990