@@ -69,18 +69,15 @@ bitfield ccsr : xlenbits = {
69
69
e : 0 /* enable */
70
70
}
71
71
72
- register mccsr : ccsr
73
- register sccsr : ccsr
72
+ register sccsr : ccsr /* mccsr aliases sccsr */
74
73
register uccsr : ccsr
75
74
76
75
/* access to CCSRs */
77
76
78
- // for now, use a single privilege-independent legalizer
79
- function legalize_ccsr (c : ccsr , v : xlenbits ) -> ccsr = {
77
+ function legalize_ccsr (csrp : Privilege , c : ccsr , v : xlenbits ) -> ccsr = {
80
78
// write only the defined bits, leaving the other bits untouched
81
- // Technically, WPRI does not need a legalizer, since software is
82
- // assumed to legalize; so we could remove this function.
83
79
let v = Mk_ccsr (v );
80
+
84
81
/* For now these bits are not really supported so hardwired to true */
85
82
let c = update_d (c , 0b1 );
86
83
let c = update_e (c , 0b1 );
@@ -94,11 +91,11 @@ function legalize_ccsr(c : ccsr, v : xlenbits) -> ccsr = {
94
91
95
92
function clause ext_read_CSR (0x8C0 ) = Some (uccsr . bits ())
96
93
function clause ext_read_CSR (0x9C0 ) = Some (sccsr . bits ())
97
- function clause ext_read_CSR (0xBC0 ) = Some (mccsr . bits ())
94
+ function clause ext_read_CSR (0xBC0 ) = Some (sccsr . bits ())
98
95
99
- function clause ext_write_CSR (0x8C0 , value ) = { uccsr = legalize_ccsr (uccsr , value ); Some (uccsr . bits ()) }
100
- function clause ext_write_CSR (0x9C0 , value ) = { sccsr = legalize_ccsr (sccsr , value ); Some (sccsr . bits ()) }
101
- function clause ext_write_CSR (0xBC0 , value ) = { mccsr = legalize_ccsr (mccsr , value ); Some (mccsr . bits ()) }
96
+ function clause ext_write_CSR (0x8C0 , value ) = { uccsr = legalize_ccsr (User , uccsr , value ); Some (uccsr . bits ()) }
97
+ function clause ext_write_CSR (0x9C0 , value ) = { sccsr = legalize_ccsr (Supervisor , sccsr , value ); Some (sccsr . bits ()) }
98
+ function clause ext_write_CSR (0xBC0 , value ) = { sccsr = legalize_ccsr (Machine , sccsr , value ); Some (sccsr . bits ()) }
102
99
103
100
function clause ext_is_CSR_defined (0x8C0 , p ) = haveUsrMode () // uccsr
104
101
function clause ext_is_CSR_defined (0x9C0 , p ) = haveSupMode () & (p == Machine | p == Supervisor ) // sccsr
0 commit comments