Commit 9e62fd7f26d522f77f2a56bda6033c73bf286e07

Authored by bellard
1 parent 8977f3c1

ppc support (Jocelyn Mayer)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@546 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 63 additions and 0 deletions
gdbstub.c
@@ -359,6 +359,69 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) @@ -359,6 +359,69 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
359 #endif 359 #endif
360 } 360 }
361 361
  362 +#elif defined (TARGET_PPC)
  363 +static void to_le32(uint8_t *p, int v)
  364 +{
  365 + p[3] = v;
  366 + p[2] = v >> 8;
  367 + p[1] = v >> 16;
  368 + p[0] = v >> 24;
  369 +}
  370 +
  371 +static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
  372 +{
  373 + uint32_t tmp;
  374 + int i;
  375 +
  376 + /* fill in gprs */
  377 + for(i = 0; i < 8; i++) {
  378 + to_le32(mem_buf + i * 4, env->gpr[i]);
  379 + }
  380 + /* fill in fprs */
  381 + for (i = 0; i < 32; i++) {
  382 + to_le32(mem_buf + (i * 2) + 32, *((uint32_t *)&env->fpr[i]));
  383 + to_le32(mem_buf + (i * 2) + 33, *((uint32_t *)&env->fpr[i] + 1));
  384 + }
  385 + /* nip, msr, ccr, lnk, ctr, xer, mq */
  386 + to_le32(mem_buf + 96, tswapl(env->nip));
  387 + to_le32(mem_buf + 97, tswapl(_load_msr()));
  388 + to_le32(mem_buf + 98, 0);
  389 + tmp = 0;
  390 + for (i = 0; i < 8; i++)
  391 + tmp |= env->crf[i] << (32 - (i * 4));
  392 + to_le32(mem_buf + 98, tmp);
  393 + to_le32(mem_buf + 99, tswapl(env->lr));
  394 + to_le32(mem_buf + 100, tswapl(env->ctr));
  395 + to_le32(mem_buf + 101, tswapl(_load_xer()));
  396 + to_le32(mem_buf + 102, 0);
  397 +
  398 + return 102;
  399 +}
  400 +
  401 +static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
  402 +{
  403 + uint32_t *registers = (uint32_t *)mem_buf;
  404 + int i;
  405 +
  406 + /* fill in gprs */
  407 + for (i = 0; i < 32; i++) {
  408 + env->gpr[i] = tswapl(registers[i]);
  409 + }
  410 + /* fill in fprs */
  411 + for (i = 0; i < 32; i++) {
  412 + *((uint32_t *)&env->fpr[i]) = tswapl(registers[(i * 2) + 32]);
  413 + *((uint32_t *)&env->fpr[i] + 1) = tswapl(registers[(i * 2) + 33]);
  414 + }
  415 + /* nip, msr, ccr, lnk, ctr, xer, mq */
  416 + env->nip = tswapl(registers[96]);
  417 + _store_msr(tswapl(registers[97]));
  418 + registers[98] = tswapl(registers[98]);
  419 + for (i = 0; i < 8; i++)
  420 + env->crf[i] = (registers[98] >> (32 - (i * 4))) & 0xF;
  421 + env->lr = tswapl(registers[99]);
  422 + env->ctr = tswapl(registers[100]);
  423 + _store_xer(tswapl(registers[101]));
  424 +}
362 #else 425 #else
363 426
364 static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf) 427 static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)