Add "show sysregs" command to ddb. On i386, this gives gdt, idt, ldt,
cr0-4, etc. Support should be added for other platforms that have a different set of registers for system use. Loosely based on: OpenBSD Approved by: re
This commit is contained in:
parent
c7f6197937
commit
3b3f28135f
@ -59,7 +59,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 27, 2006
|
||||
.Dd August 6, 2007
|
||||
.Dt DDB 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -522,6 +522,12 @@ The support of the
|
||||
modifier depends on the machine.
|
||||
If not supported, incorrect information will be displayed.
|
||||
.Pp
|
||||
.It Ic show Cm sysregs
|
||||
Show system registers (e.g.,
|
||||
.Li cr0-4
|
||||
on i386.)
|
||||
Not present on some platforms.
|
||||
.Pp
|
||||
.It Ic show Cm geom Op Ar addr
|
||||
If the
|
||||
.Ar addr
|
||||
|
@ -1587,6 +1587,25 @@ DB_SHOW_COMMAND(idt, db_show_idt)
|
||||
ip++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Show privileged registers. */
|
||||
DB_SHOW_COMMAND(sysregs, db_show_sysregs)
|
||||
{
|
||||
uint64_t idtr, gdtr;
|
||||
|
||||
idtr = ridt();
|
||||
db_printf("idtr\t0x%08x/%04x\n",
|
||||
(u_int)(idtr >> 16), (u_int)idtr & 0xffff);
|
||||
gdtr = rgdt();
|
||||
db_printf("gdtr\t0x%08x/%04x\n",
|
||||
(u_int)(gdtr >> 16), (u_int)gdtr & 0xffff);
|
||||
db_printf("ldtr\t0x%04x\n", rldt());
|
||||
db_printf("tr\t0x%04x\n", rtr());
|
||||
db_printf("cr0\t0x%08x\n", rcr0());
|
||||
db_printf("cr2\t0x%08x\n", rcr2());
|
||||
db_printf("cr3\t0x%08x\n", rcr3());
|
||||
db_printf("cr4\t0x%08x\n", rcr4());
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -326,28 +326,28 @@ read_eflags(void)
|
||||
return (ef);
|
||||
}
|
||||
|
||||
static __inline u_int64_t
|
||||
static __inline uint64_t
|
||||
rdmsr(u_int msr)
|
||||
{
|
||||
u_int64_t rv;
|
||||
uint64_t rv;
|
||||
|
||||
__asm __volatile("rdmsr" : "=A" (rv) : "c" (msr));
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static __inline u_int64_t
|
||||
static __inline uint64_t
|
||||
rdpmc(u_int pmc)
|
||||
{
|
||||
u_int64_t rv;
|
||||
uint64_t rv;
|
||||
|
||||
__asm __volatile("rdpmc" : "=A" (rv) : "c" (pmc));
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static __inline u_int64_t
|
||||
static __inline uint64_t
|
||||
rdtsc(void)
|
||||
{
|
||||
u_int64_t rv;
|
||||
uint64_t rv;
|
||||
|
||||
__asm __volatile("rdtsc" : "=A" (rv));
|
||||
return (rv);
|
||||
@ -366,7 +366,7 @@ write_eflags(u_int ef)
|
||||
}
|
||||
|
||||
static __inline void
|
||||
wrmsr(u_int msr, u_int64_t newval)
|
||||
wrmsr(u_int msr, uint64_t newval)
|
||||
{
|
||||
__asm __volatile("wrmsr" : : "A" (newval), "c" (msr));
|
||||
}
|
||||
@ -456,6 +456,14 @@ rfs(void)
|
||||
return (sel);
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
rgdt(void)
|
||||
{
|
||||
uint64_t gdtr;
|
||||
__asm __volatile("sgdt %0" : "=m" (gdtr));
|
||||
return (gdtr);
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
rgs(void)
|
||||
{
|
||||
@ -464,6 +472,22 @@ rgs(void)
|
||||
return (sel);
|
||||
}
|
||||
|
||||
static __inline uint64_t
|
||||
ridt(void)
|
||||
{
|
||||
uint64_t idtr;
|
||||
__asm __volatile("sidt %0" : "=m" (idtr));
|
||||
return (idtr);
|
||||
}
|
||||
|
||||
static __inline u_short
|
||||
rldt(void)
|
||||
{
|
||||
u_short ldtr;
|
||||
__asm __volatile("sldt %0" : "=g" (ldtr));
|
||||
return (ldtr);
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
rss(void)
|
||||
{
|
||||
@ -472,6 +496,14 @@ rss(void)
|
||||
return (sel);
|
||||
}
|
||||
|
||||
static __inline u_short
|
||||
rtr(void)
|
||||
{
|
||||
u_short tr;
|
||||
__asm __volatile("str %0" : "=g" (tr));
|
||||
return (tr);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
load_fs(u_int sel)
|
||||
{
|
||||
@ -677,8 +709,8 @@ u_int rcr0(void);
|
||||
u_int rcr2(void);
|
||||
u_int rcr3(void);
|
||||
u_int rcr4(void);
|
||||
u_int64_t rdmsr(u_int msr);
|
||||
u_int64_t rdpmc(u_int pmc);
|
||||
uint64_t rdmsr(u_int msr);
|
||||
uint64_t rdpmc(u_int pmc);
|
||||
u_int rdr0(void);
|
||||
u_int rdr1(void);
|
||||
u_int rdr2(void);
|
||||
@ -687,13 +719,17 @@ u_int rdr4(void);
|
||||
u_int rdr5(void);
|
||||
u_int rdr6(void);
|
||||
u_int rdr7(void);
|
||||
u_int64_t rdtsc(void);
|
||||
uint64_t rdtsc(void);
|
||||
u_int read_eflags(void);
|
||||
u_int rfs(void);
|
||||
uint64_t rgdt(void);
|
||||
u_int rgs(void);
|
||||
uint64_t ridt(void);
|
||||
u_short rldt(void);
|
||||
u_short rtr(void);
|
||||
void wbinvd(void);
|
||||
void write_eflags(u_int ef);
|
||||
void wrmsr(u_int msr, u_int64_t newval);
|
||||
void wrmsr(u_int msr, uint64_t newval);
|
||||
|
||||
#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user