Skip to content

Commit 358fe94

Browse files
committed
Prepare xccsr for s-mode bits
Split uccsr out to its own thing; remove mccsr and have accesses alias sccsr.
1 parent a241c8a commit 358fe94

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/cheri_regs.sail

-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ function ext_init_regs () = {
145145
x31 = null_cap;
146146

147147
misa->X() = 0b1;
148-
mccsr->d() = 0b1;
149-
mccsr->e() = 0b1;
150148
sccsr->d() = 0b1;
151149
sccsr->e() = 0b1;
152150
uccsr->d() = 0b1;

src/cheri_step_ext.sail

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
val ext_init : unit -> unit effect {wreg}
44
function ext_init () = {
55
misa->X() = 0b1;
6-
mccsr->d() = 0b1;
7-
mccsr->e() = 0b1;
86
sccsr->d() = 0b1;
97
sccsr->e() = 0b1;
108
uccsr->d() = 0b1;

src/cheri_sys_regs.sail

+16-10
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ bitfield ccsr : xlenbits = {
77
e : 0 /* enable */
88
}
99

10-
register mccsr : ccsr
11-
register sccsr : ccsr
10+
register sccsr : ccsr /* mccsr aliases sccsr */
1211
register uccsr : ccsr
1312

1413
/* access to CCSRs */
1514

16-
// for now, use a single privilege-independent legalizer
17-
function legalize_ccsr(c : ccsr, v : xlenbits) -> ccsr = {
15+
function legalize_uccsr(c : ccsr, v : xlenbits) -> ccsr = {
16+
// There are no defined bits in UCCSR, so ignore v
17+
18+
/* For now these bits are not really supported so hardwired to true */
19+
let c = update_d(c, 0b1);
20+
let c = update_e(c, 0b1);
21+
c
22+
}
23+
24+
function legalize_sccsr(c : ccsr, v : xlenbits) -> ccsr = {
1825
// write only the defined bits, leaving the other bits untouched
19-
// Technically, WPRI does not need a legalizer, since software is
20-
// assumed to legalize; so we could remove this function.
2126
let v = Mk_ccsr(v);
27+
2228
/* For now these bits are not really supported so hardwired to true */
2329
let c = update_d(c, 0b1);
2430
let c = update_e(c, 0b1);
@@ -32,11 +38,11 @@ function legalize_ccsr(c : ccsr, v : xlenbits) -> ccsr = {
3238

3339
function clause ext_read_CSR (0x8C0) = Some(uccsr.bits())
3440
function clause ext_read_CSR (0x9C0) = Some(sccsr.bits())
35-
function clause ext_read_CSR (0xBC0) = Some(mccsr.bits())
41+
function clause ext_read_CSR (0xBC0) = Some(sccsr.bits())
3642

37-
function clause ext_write_CSR (0x8C0, value) = { uccsr = legalize_ccsr(uccsr, value); Some(uccsr.bits()) }
38-
function clause ext_write_CSR (0x9C0, value) = { sccsr = legalize_ccsr(sccsr, value); Some(sccsr.bits()) }
39-
function clause ext_write_CSR (0xBC0, value) = { mccsr = legalize_ccsr(mccsr, value); Some(mccsr.bits()) }
43+
function clause ext_write_CSR (0x8C0, value) = { uccsr = legalize_uccsr(uccsr, value); Some(uccsr.bits()) }
44+
function clause ext_write_CSR (0x9C0, value) = { sccsr = legalize_sccsr(sccsr, value); Some(sccsr.bits()) }
45+
function clause ext_write_CSR (0xBC0, value) = { sccsr = legalize_sccsr(sccsr, value); Some(sccsr.bits()) }
4046

4147
function clause ext_is_CSR_defined (0x8C0, p) = haveUsrMode() // uccsr
4248
function clause ext_is_CSR_defined (0x9C0, p) = haveSupMode() & (p == Machine | p == Supervisor) // sccsr

0 commit comments

Comments
 (0)