|
|
|
@ -636,13 +636,19 @@ static void cpu_execute(rv32_cpu_t* cpu, instruction_t* instruction) |
|
|
|
|
case FUNC75_LRW: |
|
|
|
|
// Load-Reserved Word
|
|
|
|
|
cpu->regs.x[instruction->rd] = mem_read32(address); |
|
|
|
|
// TODO register reservation set that subsumes the bytes in word
|
|
|
|
|
cpu->load_reservation = address; |
|
|
|
|
break; |
|
|
|
|
case FUNC75_SCW: |
|
|
|
|
// Store-Conditional Word
|
|
|
|
|
// TODO succeed only if the reservation is still valid and the reservation set contains the bytes written
|
|
|
|
|
mem_write32(address, cpu->regs.x[instruction->rs2]); |
|
|
|
|
cpu->regs.x[instruction->rd] = 0; // TODO write 1 in rd on failure
|
|
|
|
|
if(cpu->load_reservation == address) |
|
|
|
|
{ |
|
|
|
|
mem_write32(address, cpu->regs.x[instruction->rs2]); |
|
|
|
|
cpu->regs.x[instruction->rd] = 0; // Write 0 in rd on success
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
cpu->regs.x[instruction->rd] = 1; // Write 1 in rd on failure
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case FUNC75_AMOSWAPW: |
|
|
|
|
// Atomic Memory Operation SWAP Word
|
|
|
|
|