mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
82 lines
1.6 KiB
C
82 lines
1.6 KiB
C
// The OS/K Team licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
#include "arch.h"
|
|
|
|
void dumpregs(ctx_t *ctx)
|
|
{
|
|
int i;
|
|
reg_t *r;
|
|
|
|
log("\nRegisters:\n");
|
|
log("rip=0x%016lX flg=0x%016lX", ctx->r[RIP].val, ctx->r[FLG].val);
|
|
|
|
for (i = 0; i < K00; i++) {
|
|
if (i % 4 == 0)
|
|
log("\n");
|
|
|
|
r = &ctx->r[i];
|
|
log("%s=0x%016lX ", r->name, r->val);
|
|
}
|
|
log("\n");
|
|
}
|
|
|
|
void dumpmem(ctx_t *ctx, ulong start, ulong size)
|
|
{
|
|
uint i;
|
|
for (i = 0; i < size/sizeof(ushort); i++) {
|
|
if (i % 4 == 0) {
|
|
if (i > 0) {
|
|
if (i % 8 == 0) log("\n");
|
|
else log(" ");
|
|
}
|
|
|
|
log("[0x%08lX]=0x", start + i * 2);
|
|
}
|
|
|
|
log("%04hX", ctx->mp[addr2real(start) + i]);
|
|
|
|
}
|
|
log("\n");
|
|
}
|
|
|
|
void dumpfwstack(ctx_t *ctx)
|
|
{
|
|
log("\nFirmware stack:\n");
|
|
dumpmem(ctx, FWSTACK, 128);
|
|
}
|
|
|
|
void dumpinstr(ctx_t *ctx, ulong rip, ushort c, acc_t *p1, acc_t *p2)
|
|
{
|
|
acc_t *p = 0;
|
|
instr_t *i = &ctx->i[c];
|
|
log("0x%016lX: %s", rip, i->name);
|
|
|
|
if (i->prm1 != NOPRM)
|
|
p = p1;
|
|
lp:
|
|
if (p != 0) {
|
|
if (p->mem) log(" [");
|
|
else log(" ");
|
|
|
|
if (p->type == A_REG)
|
|
log("%s", ctx->r[p->val].name);
|
|
else
|
|
log("0x%lX", p->val);
|
|
|
|
if (p->mem) {
|
|
if (p->off)
|
|
log("+%hd", p->off);
|
|
log("]");
|
|
}
|
|
|
|
if (p == p1 && i->prm2 != NOPRM) {
|
|
p = p2;
|
|
log(",");
|
|
goto lp;
|
|
}
|
|
}
|
|
|
|
log("\n");
|
|
}
|