blob: c88f6886c48c27354544d6560830af89287f80c0 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#include "sail.h"
#include "rts.h"
#include "riscv_prelude.h"
#include "riscv_platform_impl.h"
#include "riscv_sail.h"
/* This file contains the definitions of the C externs of Sail model. */
static mach_bits reservation = 0;
static bool reservation_valid = false;
bool sys_enable_rvc(unit u)
{ return rv_enable_rvc; }
bool sys_enable_writable_misa(unit u)
{ return rv_enable_writable_misa; }
bool plat_enable_dirty_update(unit u)
{ return rv_enable_dirty_update; }
bool plat_enable_misaligned_access(unit u)
{ return rv_enable_misaligned; }
bool plat_mtval_has_illegal_inst_bits(unit u)
{ return rv_mtval_has_illegal_inst_bits; }
bool plat_enable_pmp(unit u)
{ return rv_enable_pmp; }
mach_bits plat_ram_base(unit u)
{ return rv_ram_base; }
mach_bits plat_ram_size(unit u)
{ return rv_ram_size; }
mach_bits plat_rom_base(unit u)
{ return rv_rom_base; }
mach_bits plat_rom_size(unit u)
{ return rv_rom_size; }
mach_bits plat_clint_base(unit u)
{ return rv_clint_base; }
mach_bits plat_clint_size(unit u)
{ return rv_clint_size; }
unit load_reservation(mach_bits addr)
{
reservation = addr;
reservation_valid = true;
/* fprintf(stderr, "reservation <- %0" PRIx64 "\n", reservation); */
return UNIT;
}
bool speculate_conditional(unit u)
{ return true; }
static mach_bits check_mask(void)
{
return (zxlen_val == 32) ? 0x00000000FFFFFFFF : -1;
}
bool match_reservation(mach_bits addr)
{
mach_bits mask = check_mask();
bool ret = reservation_valid && (reservation & mask) == (addr & mask);
/*
fprintf(stderr, "reservation(%c): %0" PRIx64 ", key=%0" PRIx64 ": %s\n",
reservation_valid ? 'v' : 'i', reservation, addr, ret ? "ok" : "fail");
*/
return ret;
}
unit cancel_reservation(unit u)
{ /* fprintf(stderr, "reservation <- none\n"); */
reservation_valid = false;
return UNIT;
}
unit plat_term_write(mach_bits s)
{ char c = s & 0xff;
plat_term_write_impl(c);
return UNIT;
}
void plat_insns_per_tick(sail_int *rop, unit u)
{ }
mach_bits plat_htif_tohost(unit u)
{
return rv_htif_tohost;
}
unit memea(mach_bits len, sail_int n)
{
return UNIT;
}
|