return 0;
}
- /* better than nothing for SOFTMMU : we use physical addresses */
-#ifdef CONFIG_SOFTMMU
-static int memory_rw(uint8_t *buf, uint32_t addr, int len, int is_write)
-{
- uint8_t *ptr;
-
- if (addr >= phys_ram_size ||
- ((int64_t)addr + len > phys_ram_size))
- return -1;
- ptr = phys_ram_base + addr;
- if (is_write)
- memcpy(ptr, buf, len);
- else
- memcpy(buf, ptr, len);
- return 0;
-}
-#else
-static int memory_rw(uint8_t *buf, uint32_t addr, int len, int is_write)
-{
- int l, flags;
- uint32_t page;
-
- while (len > 0) {
- page = addr & TARGET_PAGE_MASK;
- l = (page + TARGET_PAGE_SIZE) - addr;
- if (l > len)
- l = len;
- flags = page_get_flags(page);
- if (!(flags & PAGE_VALID))
- return -1;
- if (is_write) {
- if (!(flags & PAGE_WRITE))
- return -1;
- memcpy((uint8_t *)addr, buf, l);
- } else {
- if (!(flags & PAGE_READ))
- return -1;
- memcpy(buf, (uint8_t *)addr, l);
- }
- len -= l;
- buf += l;
- addr += l;
- }
- return 0;
-}
-#endif
-
#if defined(TARGET_I386)
static void to_le32(uint8_t *p, int v)
#endif
}
+#elif defined (TARGET_PPC)
+static void to_le32(uint8_t *p, int v)
+{
+ p[3] = v;
+ p[2] = v >> 8;
+ p[1] = v >> 16;
+ p[0] = v >> 24;
+}
+
+static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
+{
+ uint32_t tmp;
+ int i;
+
+ /* fill in gprs */
+ for(i = 0; i < 8; i++) {
+ to_le32(mem_buf + i * 4, env->gpr[i]);
+ }
+ /* fill in fprs */
+ for (i = 0; i < 32; i++) {
+ to_le32(mem_buf + (i * 2) + 32, *((uint32_t *)&env->fpr[i]));
+ to_le32(mem_buf + (i * 2) + 33, *((uint32_t *)&env->fpr[i] + 1));
+ }
+ /* nip, msr, ccr, lnk, ctr, xer, mq */
+ to_le32(mem_buf + 96, tswapl(env->nip));
+ to_le32(mem_buf + 97, tswapl(_load_msr()));
+ to_le32(mem_buf + 98, 0);
+ tmp = 0;
+ for (i = 0; i < 8; i++)
+ tmp |= env->crf[i] << (32 - (i * 4));
+ to_le32(mem_buf + 98, tmp);
+ to_le32(mem_buf + 99, tswapl(env->lr));
+ to_le32(mem_buf + 100, tswapl(env->ctr));
+ to_le32(mem_buf + 101, tswapl(_load_xer()));
+ to_le32(mem_buf + 102, 0);
+
+ return 102;
+}
+
+static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
+{
+ uint32_t *registers = (uint32_t *)mem_buf;
+ int i;
+
+ /* fill in gprs */
+ for (i = 0; i < 32; i++) {
+ env->gpr[i] = tswapl(registers[i]);
+ }
+ /* fill in fprs */
+ for (i = 0; i < 32; i++) {
+ *((uint32_t *)&env->fpr[i]) = tswapl(registers[(i * 2) + 32]);
+ *((uint32_t *)&env->fpr[i] + 1) = tswapl(registers[(i * 2) + 33]);
+ }
+ /* nip, msr, ccr, lnk, ctr, xer, mq */
+ env->nip = tswapl(registers[96]);
+ _store_msr(tswapl(registers[97]));
+ registers[98] = tswapl(registers[98]);
+ for (i = 0; i < 8; i++)
+ env->crf[i] = (registers[98] >> (32 - (i * 4))) & 0xF;
+ env->lr = tswapl(registers[99]);
+ env->ctr = tswapl(registers[100]);
+ _store_xer(tswapl(registers[101]));
+}
#else
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
env = cpu_gdbstub_get_env(opaque);
#if defined(TARGET_I386)
env->eip = addr;
+#elif defined (TARGET_PPC)
+ env->nip = addr;
#endif
}
ret = main_loop(opaque);
addr = strtoul(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
+#elif defined (TARGET_PPC)
+ env->nip = addr;
#endif
}
cpu_single_step(env, 1);
put_packet("OK");
break;
case 'm':
+ env = cpu_gdbstub_get_env(opaque);
addr = strtoul(p, (char **)&p, 16);
if (*p == ',')
p++;
len = strtoul(p, NULL, 16);
- if (memory_rw(mem_buf, addr, len, 0) != 0)
+ if (cpu_memory_rw_debug(env, addr, mem_buf, len, 0) != 0)
memset(mem_buf, 0, len);
memtohex(buf, mem_buf, len);
put_packet(buf);
break;
case 'M':
+ env = cpu_gdbstub_get_env(opaque);
addr = strtoul(p, (char **)&p, 16);
if (*p == ',')
p++;
if (*p == ',')
p++;
hextomem(mem_buf, p, len);
- if (memory_rw(mem_buf, addr, len, 1) != 0)
+ if (cpu_memory_rw_debug(env, addr, mem_buf, len, 1) != 0)
put_packet("ENN");
else
put_packet("OK");