kvisc/vm/pc/regs.c

118 lines
2.6 KiB
C
Raw Normal View History

2019-05-15 20:06:45 +02:00
// The OS/K Team licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
2019-05-15 19:26:40 +02:00
2019-06-21 22:19:55 +02:00
#include <pc/device.h>
2019-05-15 19:26:40 +02:00
2019-06-16 12:48:30 +02:00
reg_t arch_r[] =
2019-05-15 19:26:40 +02:00
{
2019-06-18 12:58:26 +02:00
{ "inv", RES },
{ "rip", RES },
2019-06-23 21:12:25 +02:00
{ "rpc", RES },
2019-06-18 12:58:26 +02:00
{ "flg", RES },
{ "rx1", RES },
{ "rx2", RES },
2019-06-23 21:12:25 +02:00
{ "rbp", GPR },
{ "rsp", GPR },
2019-06-18 12:58:26 +02:00
{ "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 },
2019-05-15 19:26:40 +02:00
};
2019-06-14 13:34:24 +02:00
#define DUMPREGS(down, up) \
for (i = down; i <= up; i++) { \
if (i % 4 == 0) \
2019-06-19 21:41:22 +02:00
trace("\n"); \
2019-06-14 13:34:24 +02:00
r = &ctx->r[i]; \
2019-06-19 21:41:22 +02:00
trace("%s=0x%-16lX ", r->name, R(i)); \
2019-06-14 13:34:24 +02:00
} \
2019-05-29 16:57:22 +02:00
void dumpregs(ctx_t *ctx)
{
int i;
reg_t *r;
2019-05-30 12:44:56 +02:00
2019-06-21 22:19:55 +02:00
trace("Current RFRAME index: #%lu\n", rfs_current_idx);
2019-06-14 13:34:24 +02:00
2019-06-16 12:17:31 +02:00
DUMPREGS(RAX, RDI);
2019-06-23 21:12:25 +02:00
DUMPREGS(LX0, LX7);
trace("\n");
DUMPREGS(NX0, NX7);
DUMPREGS(AX0, AX7);
2019-06-14 13:34:24 +02:00
2019-06-19 21:41:22 +02:00
trace("\n");
2019-06-23 21:12:25 +02:00
DUMPREGS(SA0, SA7);
DUMPREGS(CR0, CR7);
2019-06-14 13:34:24 +02:00
2019-06-25 21:51:53 +02:00
trace("\n\nrip=0x%-16lX rpc=0x%-16lX rsp=0x%-16lX rbp=0x%-16lX",
rip, rpc, rsp, rbp);
2019-06-14 16:47:01 +02:00
2019-06-23 21:12:25 +02:00
trace("\nrx0=0d%-16lu rx1=0d%-16lu rx2=0d%-16lu flg=0x%-16lX",
rx0, rx1, rx2, flg);
2019-06-14 13:34:24 +02:00
2019-06-23 21:12:25 +02:00
trace("\n\nCF=%x OF=%x\n"
2019-06-19 21:41:22 +02:00
"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));
2019-06-18 22:56:41 +02:00
assert(inv == 0);
2019-05-29 16:57:22 +02:00
}