aboutsummaryrefslogtreecommitdiff
path: root/src/target/riscv/asm.h
blob: 6ceb8c9bd2708a9109ee0beadeec7f48ef67682c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef TARGET__RISCV__ASM_H
#define TARGET__RISCV__ASM_H

#include "riscv.h"

/*** Version-independent functions that we don't want in the main address space. ***/

static uint32_t load(const struct target *target, unsigned int rd,
		unsigned int base, uint16_t offset) __attribute__ ((unused));
static uint32_t load(const struct target *target, unsigned int rd,
		unsigned int base, uint16_t offset)
{
	switch (riscv_xlen(target)) {
		case 32:
			return lw(rd, base, offset);
		case 64:
			return ld(rd, base, offset);
	}
	assert(0);
	return 0; /* Silence -Werror=return-type */
}

static uint32_t store(const struct target *target, unsigned int src,
		unsigned int base, uint16_t offset) __attribute__ ((unused));
static uint32_t store(const struct target *target, unsigned int src,
		unsigned int base, uint16_t offset)
{
	switch (riscv_xlen(target)) {
		case 32:
			return sw(src, base, offset);
		case 64:
			return sd(src, base, offset);
	}
	assert(0);
	return 0; /* Silence -Werror=return-type */
}

#endif