[coreboot-gerrit] Patch set updated for coreboot: e7e401f Intel 945, 5000, Sandy Bridge: Unify `udelay.c`

Paul Menzel (paulepanter@users.sourceforge.net) gerrit at coreboot.org
Sun May 12 11:05:23 CEST 2013


Paul Menzel (paulepanter at users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3220

-gerrit

commit e7e401f76d92673e3e711d116c87a69f606ac5e3
Author: Paul Menzel <paulepanter at users.sourceforge.net>
Date:   Wed May 8 17:08:55 2013 +0200

    Intel 945, 5000, Sandy Bridge: Unify `udelay.c`
    
    1. Change the comparison from < to <= as done for Sandy Bridge. This
       is quite controversial and is going to get split out, when Stefan
       enlightens us all, why he used <= instead of <.
    2. Use the same indentation and comment placement.
       (Run `indent -linux …` too.)
    3. Use the same spelling of words.
    
    Change-Id: Id5765c45b28058cdd50ee4c0a1fd9f645ad7f3f8
    Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>
---
 src/northbridge/intel/i5000/udelay.c       | 12 +++++++-----
 src/northbridge/intel/i945/udelay.c        | 13 +++++++------
 src/northbridge/intel/sandybridge/udelay.c | 16 ++++++++--------
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/src/northbridge/intel/i5000/udelay.c b/src/northbridge/intel/i5000/udelay.c
index 3768e16..d081acc 100644
--- a/src/northbridge/intel/i5000/udelay.c
+++ b/src/northbridge/intel/i5000/udelay.c
@@ -24,8 +24,10 @@
 #include <cpu/x86/msr.h>
 #include <cpu/intel/speedstep.h>
 
-/* Simple 32- to 64-bit multiplication. Uses 16-bit words to avoid overflow. */
-static inline void multiply_to_tsc(tsc_t *const tsc, const u32 a, const u32 b)
+/* Simple 32- to 64-bit multiplication. Uses 16-bit words to avoid overflow.
+ * This code is used to prevent use of libgcc's umoddi3.
+ */
+static inline void multiply_to_tsc(tsc_t * const tsc, const u32 a, const u32 b)
 {
 	tsc->lo = (a & 0xffff) * (b & 0xffff);
 	tsc->hi = ((tsc->lo >> 16)
@@ -36,7 +38,7 @@ static inline void multiply_to_tsc(tsc_t *const tsc, const u32 a, const u32 b)
 }
 
 /**
- * Intel Core(tm) cpus always run the TSC at the maximum possible CPU clock
+ * Intel Core(tm) CPUs always run the TSC at the maximum possible CPU clock
  */
 
 void udelay(u32 us)
@@ -75,7 +77,7 @@ void udelay(u32 us)
 	msr = rdmsr(0x198);
 	divisor = (msr.hi >> 8) & 0x1f;
 
-	d = (fsb * divisor) / 4; /* CPU clock is always a quarter. */
+	d = (fsb * divisor) / 4;	/* CPU clock is always a quarter. */
 
 	multiply_to_tsc(&tscd, us, d);
 
@@ -90,5 +92,5 @@ void udelay(u32 us)
 	do {
 		tsc = rdtsc();
 	} while ((tsc.hi < tsc1.hi)
-		 || ((tsc.hi == tsc1.hi) && (tsc.lo < tsc1.lo)));
+		 || ((tsc.hi == tsc1.hi) && (tsc.lo <= tsc1.lo)));
 }
diff --git a/src/northbridge/intel/i945/udelay.c b/src/northbridge/intel/i945/udelay.c
index 780c730..d081acc 100644
--- a/src/northbridge/intel/i945/udelay.c
+++ b/src/northbridge/intel/i945/udelay.c
@@ -24,8 +24,10 @@
 #include <cpu/x86/msr.h>
 #include <cpu/intel/speedstep.h>
 
-/* Simple 32- to 64-bit multiplication. Uses 16-bit words to avoid overflow. */
-static inline void multiply_to_tsc(tsc_t *const tsc, const u32 a, const u32 b)
+/* Simple 32- to 64-bit multiplication. Uses 16-bit words to avoid overflow.
+ * This code is used to prevent use of libgcc's umoddi3.
+ */
+static inline void multiply_to_tsc(tsc_t * const tsc, const u32 a, const u32 b)
 {
 	tsc->lo = (a & 0xffff) * (b & 0xffff);
 	tsc->hi = ((tsc->lo >> 16)
@@ -36,7 +38,7 @@ static inline void multiply_to_tsc(tsc_t *const tsc, const u32 a, const u32 b)
 }
 
 /**
- * Intel Core(tm) cpus always run the TSC at the maximum possible CPU clock
+ * Intel Core(tm) CPUs always run the TSC at the maximum possible CPU clock
  */
 
 void udelay(u32 us)
@@ -75,7 +77,7 @@ void udelay(u32 us)
 	msr = rdmsr(0x198);
 	divisor = (msr.hi >> 8) & 0x1f;
 
-	d = (fsb * divisor) / 4; /* CPU clock is always a quarter. */
+	d = (fsb * divisor) / 4;	/* CPU clock is always a quarter. */
 
 	multiply_to_tsc(&tscd, us, d);
 
@@ -90,6 +92,5 @@ void udelay(u32 us)
 	do {
 		tsc = rdtsc();
 	} while ((tsc.hi < tsc1.hi)
-		 || ((tsc.hi == tsc1.hi) && (tsc.lo < tsc1.lo)));
-
+		 || ((tsc.hi == tsc1.hi) && (tsc.lo <= tsc1.lo)));
 }
diff --git a/src/northbridge/intel/sandybridge/udelay.c b/src/northbridge/intel/sandybridge/udelay.c
index 5bbc383..10b4f7b 100644
--- a/src/northbridge/intel/sandybridge/udelay.c
+++ b/src/northbridge/intel/sandybridge/udelay.c
@@ -23,23 +23,23 @@
 #include <cpu/x86/tsc.h>
 #include <cpu/x86/msr.h>
 
-/**
- * Intel SandyBridge/IvyBridge CPUs always run the TSC at BCLK=100MHz
- */
-
 /* Simple 32- to 64-bit multiplication. Uses 16-bit words to avoid overflow.
  * This code is used to prevent use of libgcc's umoddi3.
  */
-static inline void multiply_to_tsc(tsc_t *const tsc, const u32 a, const u32 b)
+static inline void multiply_to_tsc(tsc_t * const tsc, const u32 a, const u32 b)
 {
 	tsc->lo = (a & 0xffff) * (b & 0xffff);
 	tsc->hi = ((tsc->lo >> 16)
-		+ ((a & 0xffff) * (b >> 16))
-		+ ((b & 0xffff) * (a >> 16)));
+		   + ((a & 0xffff) * (b >> 16))
+		   + ((b & 0xffff) * (a >> 16)));
 	tsc->lo = ((tsc->hi & 0xffff) << 16) | (tsc->lo & 0xffff);
 	tsc->hi = ((a >> 16) * (b >> 16)) + (tsc->hi >> 16);
 }
 
+/**
+ * Intel Sandy Bridge/Ivy Bridge CPUs always run the TSC at BCLK=100MHz
+ */
+
 void udelay(u32 us)
 {
 	u32 dword;
@@ -51,7 +51,7 @@ void udelay(u32 us)
 	msr = rdmsr(0xce);
 	divisor = (msr.lo >> 8) & 0xff;
 
-	d = fsb * divisor; /* On Core/Core2 this is divided by 4 */
+	d = fsb * divisor;	/* On Core/Core2 this is divided by 4 */
 	multiply_to_tsc(&tscd, us, d);
 
 	tsc1 = rdtsc();



More information about the coreboot-gerrit mailing list