kvisc/vm/pc/regs.c

115 lines
2.5 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 <pc/device.h>
reg_t arch_r[] =
{
{ "inv", RES },
{ "rip", RES },
{ "flg", RES },
{ "rbp", GPR },
{ "rsp", GPR },
{ "rx0", RES },
{ "rx1", RES },
{ "rx2", RES },
{ "rax", GPR },
{ "rbx", GPR },
{ "rcx", GPR },
{ "rdx", GPR },
{ "rsx", GPR },
{ "rbi", GPR },
{ "rsi", GPR },
{ "rdi", GPR },
{ "nx0", GPR },
{ "nx1", GPR },
{ "nx2", GPR },
{ "nx3", GPR },
{ "nx4", GPR },
{ "nx5", GPR },
{ "nx6", GPR },
{ "nx7", GPR },
{ "ax0", GPR },
{ "ax1", GPR },
{ "ax2", GPR },
{ "ax3", GPR },
{ "ax4", GPR },
{ "ax5", GPR },
{ "ax6", GPR },
{ "ax7", GPR },
{ "lx0", GPR },
{ "lx1", GPR },
{ "lx2", GPR },
{ "lx3", GPR },
{ "lx4", GPR },
{ "lx5", GPR },
{ "lx6", GPR },
{ "lx7", GPR },
{ "cr0", CTL },
{ "cr1", CTL },
{ "cr2", CTL },
{ "cr3", CTL },
{ "cr4", CTL },
{ "cr5", CTL },
{ "cr6", CTL },
{ "cr7", CTL },
{ "sa0", SYS },
{ "sa1", SYS },
{ "sa2", SYS },
{ "sa3", SYS },
{ "sa4", SYS },
{ "sa5", SYS },
{ "sa6", SYS },
{ "sa7", SYS },
};
#define DUMPREGS(down, up) \
for (i = down; i <= up; i++) { \
if (i % 4 == 0) \
trace("\n"); \
r = &ctx->r[i]; \
trace("%s=0x%-16lX ", r->name, R(i)); \
} \
void dumpregs(ctx_t *ctx)
{
int i;
reg_t *r;
trace("Current RFRAME index: #%lu\n", rfs_current_idx);
DUMPREGS(RAX, RDI);
DUMPREGS(AX0, AX3);
DUMPREGS(LX0, LX3);
trace("\n");
DUMPREGS(NX0, NX3);
DUMPREGS(SA0, SA3);
DUMPREGS(CR0, CR3);
DUMPREGS(CR4, CR7);
trace("\n\nrip=0x%-16lX rsp=0x%-16lX rbp=0x%-16lX rx0=%-16lu\n\n",
rip, rsp, rbp, ctx->ninstrs);
trace("CF=%x OF=%x\n"
"ZF=%x SF=%x\n"
"PF=%x DF=%x\n"
"IF=%x UF=%x\n",
!!(flg&CF), !!(flg&OF),
!!(flg&ZF), !!(flg&SF),
!!(flg&PF), !!(flg&DF),
!!(cr0&IF), !!(cr0&UF));
assert(inv == 0);
}