提交 37ee75f4 创建 作者: Austin Clements's avatar Austin Clements

Rearrange for better page breaking

上级 7472b2b4
...@@ -90,23 +90,34 @@ readeflags(void) ...@@ -90,23 +90,34 @@ readeflags(void)
return eflags; return eflags;
} }
static inline uint static inline void
xchg(volatile uint *addr, uint newval) loadgs(ushort v)
{ {
uint result; asm volatile("movw %0, %%gs" : : "r" (v));
}
// The + in "+m" denotes a read-modify-write operand. static inline void lebp(uint val)
asm volatile("lock; xchgl %0, %1" : {
"+m" (*addr), "=a" (result) : asm volatile("movl %0,%%ebp" : : "r" (val));
"1" (newval) :
"cc");
return result;
} }
static inline void static inline uint rebp(void)
loadgs(ushort v)
{ {
asm volatile("movw %0, %%gs" : : "r" (v)); uint val;
asm volatile("movl %%ebp,%0" : "=r" (val));
return val;
}
static inline void lesp(uint val)
{
asm volatile("movl %0,%%esp" : : "r" (val));
}
static inline uint resp(void)
{
uint val;
asm volatile("movl %%esp,%0" : "=r" (val));
return val;
} }
static inline void static inline void
...@@ -121,6 +132,25 @@ sti(void) ...@@ -121,6 +132,25 @@ sti(void)
asm volatile("sti"); asm volatile("sti");
} }
static inline void nop_pause(void)
{
asm volatile("pause" : :);
}
//PAGEBREAK!
static inline uint
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) :
"1" (newval) :
"cc");
return result;
}
static inline void lcr0(uint val) static inline void lcr0(uint val)
{ {
asm volatile("movl %0,%%cr0" : : "r" (val)); asm volatile("movl %0,%%cr0" : : "r" (val));
...@@ -152,35 +182,6 @@ static inline uint rcr3(void) ...@@ -152,35 +182,6 @@ static inline uint rcr3(void)
return val; return val;
} }
static inline void lebp(uint val)
{
asm volatile("movl %0,%%ebp" : : "r" (val));
}
static inline uint rebp(void)
{
uint val;
asm volatile("movl %%ebp,%0" : "=r" (val));
return val;
}
static inline void lesp(uint val)
{
asm volatile("movl %0,%%esp" : : "r" (val));
}
static inline uint resp(void)
{
uint val;
asm volatile("movl %%esp,%0" : "=r" (val));
return val;
}
static inline void nop_pause(void)
{
asm volatile("pause" : :);
}
//PAGEBREAK: 36 //PAGEBREAK: 36
// Layout of the trap frame built on the stack by the // Layout of the trap frame built on the stack by the
// hardware and by trapasm.S, and passed to trap(). // hardware and by trapasm.S, and passed to trap().
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论