// Routines to let C code use special x86 instructions.
+// Syntax reminder: (instructions : output : input : clobber)
static inline uchar
inb(ushort port)
xchg(volatile uint *addr, uint newval)
{
uint result;
-
+
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
"+m" (*addr), "=a" (result) :
}
static inline void
-lcr3(uint val)
+lcr3(uint val)
{
asm volatile("movl %0,%%cr3" : : "r" (val));
}
+static inline void
+rdtsc(uint *hi, uint *lo)
+{
+ asm volatile("rdtscp" : "=d" (*hi), "=a" (*lo) : : "%ecx");
+}
+
//PAGEBREAK: 36
// Layout of the trap frame built on the stack by the
// hardware and by trapasm.S, and passed to trap().