Newer
Older
// Routines to let C code use special x86 instructions.
asm volatile("in %1,%0" : "=a" (data) : "d" (port));
"=D" (addr), "=c" (cnt) :
"d" (port), "0" (addr), "1" (cnt) :
"memory", "cc");
asm volatile("out %0,%1" : : "a" (data), "d" (port));
asm volatile("out %0,%1" : : "a" (data), "d" (port));
"=S" (addr), "=c" (cnt) :
"d" (port), "0" (addr), "1" (cnt) :
"cc");
static inline uint
read_ebp(void)
{
uint ebp;
asm volatile("movl %%ebp, %0" : "=a" (ebp));
return ebp;
}
pd[0] = size-1;
pd[1] = (uint)p;
pd[2] = (uint)p >> 16;
pd[0] = size-1;
pd[1] = (uint)p;
pd[2] = (uint)p >> 16;
asm volatile("pushfl; popl %0" : "=r" (eflags));
asm volatile("pushl %0; popfl" : : "r" (eflags));
cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp)
asm volatile("cpuid" :
"=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) :
"a" (info));
{
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; cmpxchgl %2, %0" :
"+m" (*lock_addr), "=a" (result) :
"r"(newval), "1"(oldval) :
"cc");
return result;
}
// Layout of the trap frame built on the stack by the
// hardware and by trapasm.S, and passed to trap().
uint edi;
uint esi;
uint ebp;
uint ebx;
uint edx;
uint ecx;
uint eax;
ushort es;
ushort padding1;
ushort ds;
ushort padding2;
uint trapno;
uint err;
uint eip;
ushort cs;
ushort padding3;
uint eflags;
// below here only when crossing rings, such as from user to kernel
uint esp;
ushort ss;
ushort padding4;