From 37ee75f42e9d35a96b84fe0c95479178cd41efac Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 31 Aug 2010 16:42:05 -0400 Subject: Rearrange for better page breaking --- x86.h | 85 ++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) (limited to 'x86.h') diff --git a/x86.h b/x86.h index b9fa8b8..71427b3 100644 --- a/x86.h +++ b/x86.h @@ -90,25 +90,36 @@ readeflags(void) return eflags; } -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 loadgs(ushort v) { asm volatile("movw %0, %%gs" : : "r" (v)); } +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 cli(void) { @@ -121,6 +132,25 @@ sti(void) 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) { asm volatile("movl %0,%%cr0" : : "r" (val)); @@ -152,35 +182,6 @@ static inline uint rcr3(void) 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 // Layout of the trap frame built on the stack by the // hardware and by trapasm.S, and passed to trap(). -- cgit v1.2.3 From 92639b6ba95d1d960a9e808c7163f6d171b2e4a3 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 31 Aug 2010 16:43:41 -0400 Subject: Follow xv6 code style. Also fixes indexing for these functions --- x86.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'x86.h') diff --git a/x86.h b/x86.h index 71427b3..1f903b2 100644 --- a/x86.h +++ b/x86.h @@ -132,7 +132,8 @@ sti(void) asm volatile("sti"); } -static inline void nop_pause(void) +static inline void +nop_pause(void) { asm volatile("pause" : :); } @@ -151,31 +152,36 @@ xchg(volatile uint *addr, uint newval) return result; } -static inline void lcr0(uint val) +static inline void +lcr0(uint val) { asm volatile("movl %0,%%cr0" : : "r" (val)); } -static inline uint rcr0(void) +static inline uint +rcr0(void) { uint val; asm volatile("movl %%cr0,%0" : "=r" (val)); return val; } -static inline uint rcr2(void) +static inline uint +rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); return val; } -static inline void lcr3(uint val) +static inline void +lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); } -static inline uint rcr3(void) +static inline uint +rcr3(void) { uint val; asm volatile("movl %%cr3,%0" : "=r" (val)); -- cgit v1.2.3 From 29c054df817d55ae6e0fc3bd4c9e2343a2b4ca75 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 31 Aug 2010 17:07:54 -0400 Subject: We don't use lesp/lebp and using them at all from C would be fraught with peril. Keep resp/rebp, but fix their code style. --- x86.h | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'x86.h') diff --git a/x86.h b/x86.h index 1f903b2..33e240d 100644 --- a/x86.h +++ b/x86.h @@ -96,24 +96,16 @@ loadgs(ushort v) asm volatile("movw %0, %%gs" : : "r" (v)); } -static inline void lebp(uint val) -{ - asm volatile("movl %0,%%ebp" : : "r" (val)); -} - -static inline uint rebp(void) +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) +static inline uint +resp(void) { uint val; asm volatile("movl %%esp,%0" : "=r" (val)); @@ -132,13 +124,6 @@ sti(void) asm volatile("sti"); } -static inline void -nop_pause(void) -{ - asm volatile("pause" : :); -} - -//PAGEBREAK! static inline uint xchg(volatile uint *addr, uint newval) { @@ -152,6 +137,13 @@ xchg(volatile uint *addr, uint newval) return result; } +static inline void +nop_pause(void) +{ + asm volatile("pause" : :); +} + +//PAGEBREAK! static inline void lcr0(uint val) { -- cgit v1.2.3 From d599aa2e40fc116d84c609358a9fdc51824b621d Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 2 Sep 2010 14:08:45 -0400 Subject: Remove unused nop_pause function. --- x86.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'x86.h') diff --git a/x86.h b/x86.h index 33e240d..5a59cc2 100644 --- a/x86.h +++ b/x86.h @@ -137,12 +137,6 @@ xchg(volatile uint *addr, uint newval) return result; } -static inline void -nop_pause(void) -{ - asm volatile("pause" : :); -} - //PAGEBREAK! static inline void lcr0(uint val) -- cgit v1.2.3