1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/pc/regs.c

125 lines
2.9 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-05 12:53:09 +02:00
#include <pc/arch.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-14 13:34:24 +02:00
// Invalid register
{ "inv", 0, RES },
// Instruction pointer
{ "rip", 0, RES },
// Flags register
{ "flg", 0, RES },
2019-05-29 16:57:22 +02:00
2019-05-30 11:19:16 +02:00
// Stack registers
2019-06-14 13:34:24 +02:00
{ "rbp", 0, GPR },
{ "rsp", 0, GPR },
// Reserved registers
{ "rx0", 0, RES },
{ "rx1", 0, RES },
{ "rx2", 0, RES },
2019-05-29 16:57:22 +02:00
2019-05-30 11:19:16 +02:00
// General-purpose volatile registers
2019-06-14 13:34:24 +02:00
{ "rax", 0, GPR },
{ "rbx", 0, GPR },
{ "rcx", 0, GPR },
{ "rdx", 0, GPR },
{ "rsx", 0, GPR },
{ "rbi", 0, GPR },
{ "rsi", 0, GPR },
2019-06-15 20:21:38 +02:00
{ "rdi", 0, GPR },
2019-05-29 16:57:22 +02:00
2019-05-30 11:19:16 +02:00
// General-purpose non-volatile registers
2019-06-14 13:34:24 +02:00
{ "nx0", 0, GPR },
{ "nx1", 0, GPR },
{ "nx2", 0, GPR },
{ "nx3", 0, GPR },
{ "nx4", 0, GPR },
{ "nx5", 0, GPR },
{ "nx6", 0, GPR },
{ "nx7", 0, GPR },
2019-05-30 11:19:16 +02:00
// Argument registers; volatile
2019-06-14 13:34:24 +02:00
{ "ax0", 0, GPR },
{ "ax1", 0, GPR },
{ "ax2", 0, GPR },
{ "ax3", 0, GPR },
{ "ax4", 0, GPR },
{ "ax5", 0, GPR },
{ "ax6", 0, GPR },
{ "ax7", 0, GPR },
// Leaf function registers; volatile
{ "lx0", 0, GPR },
{ "lx1", 0, GPR },
{ "lx2", 0, GPR },
{ "lx3", 0, GPR },
{ "lx4", 0, GPR },
{ "lx5", 0, GPR },
{ "lx6", 0, GPR },
{ "lx7", 0, GPR },
// Control register
{ "cr0", 0, CTL },
{ "cr1", 0, CTL },
{ "cr2", 0, CTL },
{ "cr3", 0, CTL },
{ "cr4", 0, CTL },
{ "cr5", 0, CTL },
{ "cr6", 0, CTL },
{ "cr7", 0, CTL },
2019-05-29 16:57:22 +02:00
2019-05-30 11:19:16 +02:00
// System-reserved
2019-06-14 13:34:24 +02:00
{ "sa0", 0, SYS },
{ "sa1", 0, SYS },
{ "sa2", 0, SYS },
{ "sa3", 0, SYS },
{ "sa4", 0, SYS },
{ "sa5", 0, SYS },
{ "sa6", 0, SYS },
{ "sa7", 0, 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) \
log("\n"); \
r = &ctx->r[i]; \
log("%s=0x%-16lX ", r->name, r->val); \
} \
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-14 13:34:24 +02:00
assert(inv == 0);
2019-06-16 12:17:31 +02:00
DUMPREGS(RAX, RDI);
2019-06-14 13:34:24 +02:00
DUMPREGS(AX0, AX3);
DUMPREGS(LX0, LX3);
log("\n");
DUMPREGS(NX0, NX3);
DUMPREGS(SA0, SA3);
DUMPREGS(CR0, CR3);
2019-06-14 16:47:01 +02:00
2019-06-16 20:31:55 +02:00
log("\n\nrip=0x%-16lX rsp=0x%-16lX rbp=0x%-16lX rx0=%-16lu\n\n",
rip, rsp, rbp, R(RX0));
2019-06-14 13:34:24 +02:00
2019-06-14 16:47:01 +02:00
log("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),
!!(flg&IF), !!(cr0&UF));
2019-05-29 16:57:22 +02:00
}