There are two instructions to interact with the operating system:
- ecall for system calls
- ebreak for calling a debugger
Control and Status Registers (CSRs) provide a general facility for system control and I/O. There is a CSR address space for up to 212 registers.
The instructions to modify CSRs are:
|instr using rs1||instr using imm||description|
|csrrw rd, csr, rs1||csrrwi rd, csr, imm||atomically copy a value from csr to rd and |
overwrite csr with the value in rs1 or imm
|csrrc rd, csr, rs1||csrrci rd, csr, imm||atomically copy a value from csr to rd and |
clear bits in csr 1
|csrrs rd, csr, rs1||csrrsi rd, csr, imm||atomically copy a value from csr to rd and |
set bits in a csr 1
csrrs x1, csr, x0 can be used to read from
csr without modifying it.
It is abbreviated as a pseudoinstruciton csrr rd, csr.
|upper 32 bit of cycle counter|
|upper 32 bit of real-time clock|
|instructions retired counter|
|upper 32 bit of instret|
All of the following are in I-format:
1 TODO: according to the mask in rs1/imm ?