vaseboot/include/VasEBoot/loongarch64/reloc.h

114 lines
4.8 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2023 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_LOONGARCH64_RELOC_H
#define VAS_EBOOT_LOONGARCH64_RELOC_H 1
#include <VasEBoot/types.h>
#define LOONGARCH64_STACK_MAX 16
struct VasEBoot_loongarch64_stack
{
VasEBoot_uint64_t data[LOONGARCH64_STACK_MAX];
int count;
int top;
};
typedef struct VasEBoot_loongarch64_stack* VasEBoot_loongarch64_stack_t;
void VasEBoot_loongarch64_stack_init (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_push (VasEBoot_loongarch64_stack_t stack,
VasEBoot_int64_t offset);
void VasEBoot_loongarch64_sop_sub (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_sl (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_sr (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_add (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_and (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_if_else (VasEBoot_loongarch64_stack_t stack);
void VasEBoot_loongarch64_sop_32_s_10_5 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_u_10_12 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_s_10_12 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_s_10_16 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_s_10_16_s2 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_s_5_20 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_s_0_5_10_16_s2 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_sop_32_s_0_10_10_16_s2 (VasEBoot_loongarch64_stack_t stack,
VasEBoot_uint64_t *place);
void VasEBoot_loongarch64_b26 (VasEBoot_uint32_t *place, VasEBoot_int64_t offset);
void VasEBoot_loongarch64_xxx_hi20 (VasEBoot_uint32_t *place, VasEBoot_int64_t offset);
void VasEBoot_loongarch64_xxx_lo12 (VasEBoot_uint32_t *place, VasEBoot_int64_t offset);
void VasEBoot_loongarch64_abs64_hi12 (VasEBoot_uint32_t *place, VasEBoot_int64_t offset);
void VasEBoot_loongarch64_abs64_lo20 (VasEBoot_uint32_t *place, VasEBoot_int64_t offset);
#define VAS_EBOOT_LOONGARCH64_RELOCATION(STACK, PLACE, OFFSET) \
case R_LARCH_SOP_PUSH_ABSOLUTE: \
VasEBoot_loongarch64_sop_push (STACK, OFFSET); \
break; \
case R_LARCH_SOP_SUB: \
VasEBoot_loongarch64_sop_sub (STACK); \
break; \
case R_LARCH_SOP_SL: \
VasEBoot_loongarch64_sop_sl (STACK); \
break; \
case R_LARCH_SOP_SR: \
VasEBoot_loongarch64_sop_sr (STACK); \
break; \
case R_LARCH_SOP_ADD: \
VasEBoot_loongarch64_sop_add (STACK); \
break; \
case R_LARCH_SOP_AND: \
VasEBoot_loongarch64_sop_and (STACK); \
break; \
case R_LARCH_SOP_IF_ELSE: \
VasEBoot_loongarch64_sop_if_else (STACK); \
break; \
case R_LARCH_SOP_POP_32_S_10_5: \
VasEBoot_loongarch64_sop_32_s_10_5 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_U_10_12: \
VasEBoot_loongarch64_sop_32_u_10_12 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_S_10_12: \
VasEBoot_loongarch64_sop_32_s_10_12 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_S_10_16: \
VasEBoot_loongarch64_sop_32_s_10_16 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_S_10_16_S2: \
VasEBoot_loongarch64_sop_32_s_10_16_s2 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_S_5_20: \
VasEBoot_loongarch64_sop_32_s_5_20 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_S_0_5_10_16_S2: \
VasEBoot_loongarch64_sop_32_s_0_5_10_16_s2 (STACK, PLACE); \
break; \
case R_LARCH_SOP_POP_32_S_0_10_10_16_S2: \
VasEBoot_loongarch64_sop_32_s_0_10_10_16_s2 (STACK, PLACE); \
break;
#endif /* VAS_EBOOT_LOONGARCH64_RELOC_H */