Compare commits
2 Commits
43629abbd4
...
6b9e5c766b
Author | SHA1 | Date | |
---|---|---|---|
6b9e5c766b | |||
cb98752b67 |
@ -39,7 +39,7 @@ static void cpu_print_instruction(instruction_t* instruction);
|
|||||||
|
|
||||||
void cpu_init()
|
void cpu_init()
|
||||||
{
|
{
|
||||||
cpu0 = malloc(sizeof(rv32_cpu_t));
|
cpu0 = calloc(1, sizeof(rv32_cpu_t));
|
||||||
cpu0->regs.zero = 0;
|
cpu0->regs.zero = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ void gdbstub_thread_gdb()
|
|||||||
}
|
}
|
||||||
else if(packet[0] == 'g')
|
else if(packet[0] == 'g')
|
||||||
{
|
{
|
||||||
|
// g : read all registers -> send back all registers
|
||||||
char resp[32 * 8 + 8 + 1] = {0};
|
char resp[32 * 8 + 8 + 1] = {0};
|
||||||
|
|
||||||
// All general purpose registers in host byte order as chars
|
// All general purpose registers in host byte order as chars
|
||||||
@ -175,6 +176,28 @@ void gdbstub_thread_gdb()
|
|||||||
size_t size = 32 * 8 + 8;
|
size_t size = 32 * 8 + 8;
|
||||||
gdbstub_send_packet(resp, size);
|
gdbstub_send_packet(resp, size);
|
||||||
}
|
}
|
||||||
|
else if(packet[0] == 'G')
|
||||||
|
{
|
||||||
|
// G : write all registers -> read and set all registers
|
||||||
|
|
||||||
|
// All general purpose registers in host byte order as chars
|
||||||
|
for(size_t i = 1; i < 32; i++)
|
||||||
|
{
|
||||||
|
uint32_t value = 0;
|
||||||
|
sscanf(packet + 1 + i * 8, "%08x", &value);
|
||||||
|
value = ntohl(value);
|
||||||
|
|
||||||
|
cpu0->regs.x[i] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PC register
|
||||||
|
uint32_t pc = 0;
|
||||||
|
sscanf(packet + 1 + 32 * 8, "%08x", &pc);
|
||||||
|
pc = ntohl(pc);
|
||||||
|
cpu0->pc = pc;
|
||||||
|
|
||||||
|
gdbstub_send_packet("OK", 2);
|
||||||
|
}
|
||||||
else gdbstub_send_unsupported();
|
else gdbstub_send_unsupported();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user