Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2717
-gerrit
commit 08469e965b4a5c9776acd56195e3f2f4a73a7bff
Author: Gabe Black <gabeblack(a)google.com>
Date: Fri Feb 22 16:38:53 2013 -0800
libpayload: Generalize and redistribute timekeeping code
The timekeeping code in libpayload was dependent on rdtsc, and when it was
split up by arch, that code was duplicated even though it was mostly the same.
This change factors out actually reading the count from the timer and the
speed of the timer and puts the definitions of ndelay, udelay, mdelay and
delay into generic code. Then, in x86, the timer_hz and timer_get_raw_value
functions which used to be in depthcharge were moved over to libpayload's
arch/x86/timer.c. In ARM where there isn't a single, canonical timer, those
functions are omitted with the intention that they'll be implemented by a
specific timer driver chosen elsewhere.
Change-Id: I9c919bed712ace941f417c1d58679d667b2d8269
Signed-off-by: Gabe Black <gabeblack(a)google.com>
---
payloads/libpayload/arch/armv7/timer.c | 47 --------------------
payloads/libpayload/arch/powerpc/timer.c | 76 +++-----------------------------
payloads/libpayload/arch/x86/timer.c | 52 +++-------------------
payloads/libpayload/include/libpayload.h | 6 ++-
payloads/libpayload/libc/time.c | 72 ++++++++++++++++++++++++------
5 files changed, 77 insertions(+), 176 deletions(-)
diff --git a/payloads/libpayload/arch/armv7/timer.c b/payloads/libpayload/arch/armv7/timer.c
index 24b0a0f..9449c9f 100644
--- a/payloads/libpayload/arch/armv7/timer.c
+++ b/payloads/libpayload/arch/armv7/timer.c
@@ -52,50 +52,3 @@ unsigned int get_cpu_speed(void)
return cpu_khz;
}
-
-static inline void _delay(unsigned long long delta)
-{
- /* FIXME */
-}
-
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000);
-}
-
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
- _delay((unsigned long long)m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
-{
- int i;
- for (i=0; i<1000; i++)
- _delay((unsigned long long)s * cpu_khz);
-}
diff --git a/payloads/libpayload/arch/powerpc/timer.c b/payloads/libpayload/arch/powerpc/timer.c
index ba824b0..fb181a4 100644
--- a/payloads/libpayload/arch/powerpc/timer.c
+++ b/payloads/libpayload/arch/powerpc/timer.c
@@ -33,7 +33,6 @@
*/
#include <libpayload.h>
-// #include <arch/rdtsc.h>
/**
* @ingroup arch
@@ -48,80 +47,19 @@ u32 cpu_khz;
*/
unsigned int get_cpu_speed(void)
{
-#if 0
- unsigned long long start, end;
-
- /* Set up the PPC port - disable the speaker, enable the T2 gate. */
- outb((inb(0x61) & ~0x02) | 0x01, 0x61);
-
- /* Set the PIT to Mode 0, counter 2, word access. */
- outb(0xB0, 0x43);
-
- /* Load the counter with 0xffff. */
- outb(0xff, 0x42);
- outb(0xff, 0x42);
-
- /* Read the number of ticks during the period. */
- start = rdtsc();
- while (!(inb(0x61) & 0x20)) ;
- end = rdtsc();
-
- /*
- * The clock rate is 1193180 Hz, the number of milliseconds for a
- * period of 0xffff is 1193180 / (0xFFFF * 1000) or .0182.
- * Multiply that by the number of measured clocks to get the kHz value.
- */
- cpu_khz = (unsigned int)((end - start) * 1193180U / (1000 * 0xffff));
-#else
+ /* FIXME */
cpu_khz = 200 * 1024;
-#endif
return cpu_khz;
}
-static inline void _delay(unsigned long long delta)
-{
-#if 0
- unsigned long long timeout = rdtsc() + delta;
- while (rdtsc() < timeout) ;
-#endif
-}
-
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
- _delay(n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
+uint64_t timer_hz(void)
{
- _delay(n * cpu_khz / 1000);
+ /* FIXME */
+ return 0;
}
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
- _delay(m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
+uint64_t timer_raw_value(void)
{
- _delay(s * cpu_khz * 1000);
+ /* FIXME */
+ return 0;
}
diff --git a/payloads/libpayload/arch/x86/timer.c b/payloads/libpayload/arch/x86/timer.c
index 40e81c4..e0cefb8 100644
--- a/payloads/libpayload/arch/x86/timer.c
+++ b/payloads/libpayload/arch/x86/timer.c
@@ -28,8 +28,8 @@
*/
/**
- * @file i386/timer.c
- * i386 specific timer routines
+ * @file x86/timer.c
+ * x86 specific timer routines
*/
#include <libpayload.h>
@@ -39,7 +39,7 @@
* @ingroup arch
* Global variable containing the speed of the processor in KHz.
*/
-u32 cpu_khz;
+uint32_t cpu_khz;
/**
* Calculate the speed of the processor for use in delays.
@@ -77,50 +77,12 @@ unsigned int get_cpu_speed(void)
return cpu_khz;
}
-static inline void _delay(unsigned long long delta)
+uint64_t timer_hz(void)
{
- unsigned long long timeout = rdtsc() + delta;
- while (rdtsc() < timeout) ;
+ return lib_sysinfo.cpu_khz * 1000;
}
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000);
-}
-
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
- _delay((unsigned long long)m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
+uint64_t timer_raw_value(void)
{
- int i;
- for (i=0; i<1000; i++)
- _delay((unsigned long long)s * cpu_khz);
+ return rdtsc();
}
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index eaa0d0d..f23fb87 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -407,8 +407,12 @@ int get_multiboot_info(struct sysinfo_t *info);
int lib_get_sysinfo(void);
-/* Timer functions - defined by each architecture. */
+/* Timer functions. */
+/* Defined by each architecture. */
unsigned int get_cpu_speed(void);
+uint64_t timer_hz(void);
+uint64_t timer_raw_value(void);
+/* Generic. */
void ndelay(unsigned int n);
void udelay(unsigned int n);
void mdelay(unsigned int n);
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index 1503c45..7b6bf47 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -46,21 +46,23 @@ static struct {
suseconds_t usecs;
} clock;
-#define TICKS_PER_SEC (cpu_khz * 1000)
-#define TICKS_PER_USEC (cpu_khz / 1000)
-
-#ifdef CONFIG_ARCH_X86
static void update_clock(void)
{
- u64 delta = rdtsc() - clock.ticks;
+ u64 delta = timer_raw_value() - clock.ticks;
int secs;
+ static uint64_t ticks_per_sec = 0;
+ static uint64_t ticks_per_usec = 0;
+ if (!ticks_per_sec) {
+ ticks_per_sec = timer_hz();
+ ticks_per_usec = timer_hz() / 1000000;
+ }
clock.ticks += delta;
- secs = (int) (delta / TICKS_PER_SEC);
+ secs = (int) (delta / ticks_per_sec);
clock.secs += secs;
- delta -= (secs * TICKS_PER_SEC);
- clock.usecs += (int) (delta / TICKS_PER_USEC);
+ delta -= (secs * ticks_per_sec);
+ clock.usecs += (int)(delta / ticks_per_usec);
if (clock.usecs > 1000000) {
clock.usecs -= 1000000;
@@ -110,15 +112,11 @@ static void gettimeofday_init(void)
clock.secs = (days * 86400) + (tm.tm_hour * 3600) +
(tm.tm_min * 60) + tm.tm_sec;
}
-#endif // CONFIG_NVRAM
-
#else
-static void update_clock(void)
-{
-}
-
static void gettimeofday_init(void)
{
+ /* Record the number of ticks */
+ clock.ticks = timer_raw_value();
}
#endif
@@ -145,3 +143,49 @@ int gettimeofday(struct timeval *tv, void *tz)
return 0;
}
+
+static inline void _delay(uint64_t delta)
+{
+ uint64_t start = timer_raw_value();
+ while (timer_raw_value() - start < delta) ;
+}
+
+/**
+ * Delay for a specified number of nanoseconds.
+ *
+ * @param n Number of nanoseconds to delay for.
+ */
+void ndelay(unsigned int n)
+{
+ _delay((uint64_t)n * timer_hz() / 1000000000);
+}
+
+/**
+ * Delay for a specified number of microseconds.
+ *
+ * @param n Number of microseconds to delay for.
+ */
+void udelay(unsigned int n)
+{
+ _delay((uint64_t)n * timer_hz() / 1000000);
+}
+
+/**
+ * Delay for a specified number of milliseconds.
+ *
+ * @param m Number of milliseconds to delay for.
+ */
+void mdelay(unsigned int m)
+{
+ _delay((uint64_t)m * timer_hz() / 1000);
+}
+
+/**
+ * Delay for a specified number of seconds.
+ *
+ * @param s Number of seconds to delay for.
+ */
+void delay(unsigned int s)
+{
+ _delay((uint64_t)s * timer_hz());
+}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2716
-gerrit
commit e71ac8fd5969f1d39c9d07955afdc1edf08eb534
Author: Gabe Black <gabeblack(a)google.com>
Date: Wed Jan 16 03:18:45 2013 -0800
libpayload: Put dump_td/dump_ed in ohci.c behind #ifdef USB_DEBUG
This function is static and not used in that file. To avoid the compiler
complaining about that fact, put the two functions and the call to dump_ed
(currently #if 0) behind #ifdef USB_DEBUG
Change-Id: Ic373313b5fff81f09800f286b32238350ab699c6
Signed-off-by: Gabe Black <gabeblack(a)google.com>
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
payloads/libpayload/drivers/usb/ohci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/payloads/libpayload/drivers/usb/ohci.c b/payloads/libpayload/drivers/usb/ohci.c
index c670373..44eba31 100644
--- a/payloads/libpayload/drivers/usb/ohci.c
+++ b/payloads/libpayload/drivers/usb/ohci.c
@@ -46,6 +46,7 @@ static void ohci_destroy_intr_queue (endpoint_t *ep, void *queue);
static u8* ohci_poll_intr_queue (void *queue);
static void ohci_process_done_queue(ohci_t *ohci, int spew_debug);
+#ifdef USB_DEBUG
static void
dump_td (td_t *cur)
{
@@ -116,6 +117,7 @@ dump_ed (ed_t *cur)
usb_debug("+---------------------------------------------------+\n");
}
}
+#endif
static void
ohci_reset (hci_t *controller)
@@ -429,7 +431,7 @@ ohci_control (usbdev_t *dev, direction_t dir, int drlen, void *devreq, int dalen
usb_debug("ohci_control(): doing transfer with %x. first_td at %x\n",
head->config & ED_FUNC_MASK, virt_to_phys(first_td));
-#if 0
+#ifdef USB_DEBUG
dump_ed(head);
#endif
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2718
-gerrit
commit 5e481ac120d8768b870fe80cd1286c6c4f16b07b
Author: Gabe Black <gabeblack(a)google.com>
Date: Sat Mar 2 03:32:19 2013 -0800
libpayload: Don't declare the loop counter within the for loop
'for' loop initial declarations are only allowed in C99 mode
I didn't realize we don't enable 14 year old features when building
libpayload, and I must have accidentally not rebuilt everything when making my
final tweaks to my earlier change.
Change-Id: I6caeeffad177b6d61fa30175f767e85084c061f4
Signed-off-by: Gabe Black <gabeblack(a)google.com>
---
payloads/libpayload/arch/armv7/exception.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/payloads/libpayload/arch/armv7/exception.c b/payloads/libpayload/arch/armv7/exception.c
index 8462b11..5e4e23d 100644
--- a/payloads/libpayload/arch/armv7/exception.c
+++ b/payloads/libpayload/arch/armv7/exception.c
@@ -45,11 +45,12 @@ void exception_fiq(uint32_t *);
static void print_regs(uint32_t *regs)
{
+ int i;
/* Don't print the link register and stack pointer since we don't have their
* actual value. They are hidden by the 'shadow' registers provided
* by the trap hardware.
*/
- for (int i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
if (i == 15)
printf("PC");
else if (i == 14)
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2717
-gerrit
commit 306842eebd4016413445cb0e636da46dade6b04e
Author: Gabe Black <gabeblack(a)google.com>
Date: Fri Feb 22 16:38:53 2013 -0800
libpayload: Generalize and redistribute timekeeping code
The timekeeping code in libpayload was dependent on rdtsc, and when it was
split up by arch, that code was duplicated even though it was mostly the same.
This change factors out actually reading the count from the timer and the
speed of the timer and puts the definitions of ndelay, udelay, mdelay and
delay into generic code. Then, in x86, the timer_hz and timer_get_raw_value
functions which used to be in depthcharge were moved over to libpayload's
arch/x86/timer.c. In ARM where there isn't a single, canonical timer, those
functions are omitted with the intention that they'll be implemented by a
specific timer driver chosen elsewhere.
Change-Id: I9c919bed712ace941f417c1d58679d667b2d8269
Signed-off-by: Gabe Black <gabeblack(a)google.com>
---
payloads/libpayload/arch/armv7/timer.c | 47 --------------------
payloads/libpayload/arch/powerpc/timer.c | 76 +++-----------------------------
payloads/libpayload/arch/x86/timer.c | 52 +++-------------------
payloads/libpayload/include/libpayload.h | 6 ++-
payloads/libpayload/libc/time.c | 72 ++++++++++++++++++++++++------
5 files changed, 77 insertions(+), 176 deletions(-)
diff --git a/payloads/libpayload/arch/armv7/timer.c b/payloads/libpayload/arch/armv7/timer.c
index 24b0a0f..9449c9f 100644
--- a/payloads/libpayload/arch/armv7/timer.c
+++ b/payloads/libpayload/arch/armv7/timer.c
@@ -52,50 +52,3 @@ unsigned int get_cpu_speed(void)
return cpu_khz;
}
-
-static inline void _delay(unsigned long long delta)
-{
- /* FIXME */
-}
-
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000);
-}
-
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
- _delay((unsigned long long)m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
-{
- int i;
- for (i=0; i<1000; i++)
- _delay((unsigned long long)s * cpu_khz);
-}
diff --git a/payloads/libpayload/arch/powerpc/timer.c b/payloads/libpayload/arch/powerpc/timer.c
index ba824b0..fb181a4 100644
--- a/payloads/libpayload/arch/powerpc/timer.c
+++ b/payloads/libpayload/arch/powerpc/timer.c
@@ -33,7 +33,6 @@
*/
#include <libpayload.h>
-// #include <arch/rdtsc.h>
/**
* @ingroup arch
@@ -48,80 +47,19 @@ u32 cpu_khz;
*/
unsigned int get_cpu_speed(void)
{
-#if 0
- unsigned long long start, end;
-
- /* Set up the PPC port - disable the speaker, enable the T2 gate. */
- outb((inb(0x61) & ~0x02) | 0x01, 0x61);
-
- /* Set the PIT to Mode 0, counter 2, word access. */
- outb(0xB0, 0x43);
-
- /* Load the counter with 0xffff. */
- outb(0xff, 0x42);
- outb(0xff, 0x42);
-
- /* Read the number of ticks during the period. */
- start = rdtsc();
- while (!(inb(0x61) & 0x20)) ;
- end = rdtsc();
-
- /*
- * The clock rate is 1193180 Hz, the number of milliseconds for a
- * period of 0xffff is 1193180 / (0xFFFF * 1000) or .0182.
- * Multiply that by the number of measured clocks to get the kHz value.
- */
- cpu_khz = (unsigned int)((end - start) * 1193180U / (1000 * 0xffff));
-#else
+ /* FIXME */
cpu_khz = 200 * 1024;
-#endif
return cpu_khz;
}
-static inline void _delay(unsigned long long delta)
-{
-#if 0
- unsigned long long timeout = rdtsc() + delta;
- while (rdtsc() < timeout) ;
-#endif
-}
-
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
- _delay(n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
+uint64_t timer_hz(void)
{
- _delay(n * cpu_khz / 1000);
+ /* FIXME */
+ return 0;
}
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
- _delay(m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
+uint64_t timer_raw_value(void)
{
- _delay(s * cpu_khz * 1000);
+ /* FIXME */
+ return 0;
}
diff --git a/payloads/libpayload/arch/x86/timer.c b/payloads/libpayload/arch/x86/timer.c
index 40e81c4..e0cefb8 100644
--- a/payloads/libpayload/arch/x86/timer.c
+++ b/payloads/libpayload/arch/x86/timer.c
@@ -28,8 +28,8 @@
*/
/**
- * @file i386/timer.c
- * i386 specific timer routines
+ * @file x86/timer.c
+ * x86 specific timer routines
*/
#include <libpayload.h>
@@ -39,7 +39,7 @@
* @ingroup arch
* Global variable containing the speed of the processor in KHz.
*/
-u32 cpu_khz;
+uint32_t cpu_khz;
/**
* Calculate the speed of the processor for use in delays.
@@ -77,50 +77,12 @@ unsigned int get_cpu_speed(void)
return cpu_khz;
}
-static inline void _delay(unsigned long long delta)
+uint64_t timer_hz(void)
{
- unsigned long long timeout = rdtsc() + delta;
- while (rdtsc() < timeout) ;
+ return lib_sysinfo.cpu_khz * 1000;
}
-/**
- * Delay for a specified number of nanoseconds.
- *
- * @param n Number of nanoseconds to delay for.
- */
-void ndelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000000);
-}
-
-/**
- * Delay for a specified number of microseconds.
- *
- * @param n Number of microseconds to delay for.
- */
-void udelay(unsigned int n)
-{
- _delay((unsigned long long)n * cpu_khz / 1000);
-}
-
-/**
- * Delay for a specified number of milliseconds.
- *
- * @param m Number of milliseconds to delay for.
- */
-void mdelay(unsigned int m)
-{
- _delay((unsigned long long)m * cpu_khz);
-}
-
-/**
- * Delay for a specified number of seconds.
- *
- * @param s Number of seconds to delay for.
- */
-void delay(unsigned int s)
+uint64_t timer_raw_value(void)
{
- int i;
- for (i=0; i<1000; i++)
- _delay((unsigned long long)s * cpu_khz);
+ return rdtsc();
}
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index eaa0d0d..f23fb87 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -407,8 +407,12 @@ int get_multiboot_info(struct sysinfo_t *info);
int lib_get_sysinfo(void);
-/* Timer functions - defined by each architecture. */
+/* Timer functions. */
+/* Defined by each architecture. */
unsigned int get_cpu_speed(void);
+uint64_t timer_hz(void);
+uint64_t timer_raw_value(void);
+/* Generic. */
void ndelay(unsigned int n);
void udelay(unsigned int n);
void mdelay(unsigned int n);
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index 1503c45..7b6bf47 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -46,21 +46,23 @@ static struct {
suseconds_t usecs;
} clock;
-#define TICKS_PER_SEC (cpu_khz * 1000)
-#define TICKS_PER_USEC (cpu_khz / 1000)
-
-#ifdef CONFIG_ARCH_X86
static void update_clock(void)
{
- u64 delta = rdtsc() - clock.ticks;
+ u64 delta = timer_raw_value() - clock.ticks;
int secs;
+ static uint64_t ticks_per_sec = 0;
+ static uint64_t ticks_per_usec = 0;
+ if (!ticks_per_sec) {
+ ticks_per_sec = timer_hz();
+ ticks_per_usec = timer_hz() / 1000000;
+ }
clock.ticks += delta;
- secs = (int) (delta / TICKS_PER_SEC);
+ secs = (int) (delta / ticks_per_sec);
clock.secs += secs;
- delta -= (secs * TICKS_PER_SEC);
- clock.usecs += (int) (delta / TICKS_PER_USEC);
+ delta -= (secs * ticks_per_sec);
+ clock.usecs += (int)(delta / ticks_per_usec);
if (clock.usecs > 1000000) {
clock.usecs -= 1000000;
@@ -110,15 +112,11 @@ static void gettimeofday_init(void)
clock.secs = (days * 86400) + (tm.tm_hour * 3600) +
(tm.tm_min * 60) + tm.tm_sec;
}
-#endif // CONFIG_NVRAM
-
#else
-static void update_clock(void)
-{
-}
-
static void gettimeofday_init(void)
{
+ /* Record the number of ticks */
+ clock.ticks = timer_raw_value();
}
#endif
@@ -145,3 +143,49 @@ int gettimeofday(struct timeval *tv, void *tz)
return 0;
}
+
+static inline void _delay(uint64_t delta)
+{
+ uint64_t start = timer_raw_value();
+ while (timer_raw_value() - start < delta) ;
+}
+
+/**
+ * Delay for a specified number of nanoseconds.
+ *
+ * @param n Number of nanoseconds to delay for.
+ */
+void ndelay(unsigned int n)
+{
+ _delay((uint64_t)n * timer_hz() / 1000000000);
+}
+
+/**
+ * Delay for a specified number of microseconds.
+ *
+ * @param n Number of microseconds to delay for.
+ */
+void udelay(unsigned int n)
+{
+ _delay((uint64_t)n * timer_hz() / 1000000);
+}
+
+/**
+ * Delay for a specified number of milliseconds.
+ *
+ * @param m Number of milliseconds to delay for.
+ */
+void mdelay(unsigned int m)
+{
+ _delay((uint64_t)m * timer_hz() / 1000);
+}
+
+/**
+ * Delay for a specified number of seconds.
+ *
+ * @param s Number of seconds to delay for.
+ */
+void delay(unsigned int s)
+{
+ _delay((uint64_t)s * timer_hz());
+}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2716
-gerrit
commit fbd0ee8a4ed861ed2c149203e512bc0edb2f97cd
Author: Gabe Black <gabeblack(a)google.com>
Date: Wed Jan 16 03:18:45 2013 -0800
libpayload: Put dump_td/dump_ed in ohci.c behind #ifdef USB_DEBUG
This function is static and not used in that file. To avoid the compiler
complaining about that fact, put the two functions and the call to dump_ed
(currently #if 0) behind #ifdef USB_DEBUG
Change-Id: Ic373313b5fff81f09800f286b32238350ab699c6
Signed-off-by: Gabe Black <gabeblack(a)google.com>
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
payloads/libpayload/drivers/usb/ohci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/payloads/libpayload/drivers/usb/ohci.c b/payloads/libpayload/drivers/usb/ohci.c
index c670373..44eba31 100644
--- a/payloads/libpayload/drivers/usb/ohci.c
+++ b/payloads/libpayload/drivers/usb/ohci.c
@@ -46,6 +46,7 @@ static void ohci_destroy_intr_queue (endpoint_t *ep, void *queue);
static u8* ohci_poll_intr_queue (void *queue);
static void ohci_process_done_queue(ohci_t *ohci, int spew_debug);
+#ifdef USB_DEBUG
static void
dump_td (td_t *cur)
{
@@ -116,6 +117,7 @@ dump_ed (ed_t *cur)
usb_debug("+---------------------------------------------------+\n");
}
}
+#endif
static void
ohci_reset (hci_t *controller)
@@ -429,7 +431,7 @@ ohci_control (usbdev_t *dev, direction_t dir, int drlen, void *devreq, int dalen
usb_debug("ohci_control(): doing transfer with %x. first_td at %x\n",
head->config & ED_FUNC_MASK, virt_to_phys(first_td));
-#if 0
+#ifdef USB_DEBUG
dump_ed(head);
#endif
Mike Loptien (mike.loptien(a)se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2715
-gerrit
commit 66dd14ee28486e81d2615f543a83f3b5b0675a14
Author: Mike Loptien <mike.loptien(a)se-eng.com>
Date: Wed Mar 13 17:12:01 2013 -0600
Remove 3rdparty directory from tree
Remove the 3rdparty directory from the coreboot
directory structure because we do not want it there
by default.
Change-Id: Ia560f81397def8961c8cdd0618723057d2107c70
Signed-off-by: Mike Loptien <mike.loptien(a)se-eng.com>
---
3rdparty | 1 -
1 file changed, 1 deletion(-)
diff --git a/3rdparty b/3rdparty
deleted file mode 160000
index dac1a18..0000000
--- a/3rdparty
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit dac1a18d184976e4447b98479f0b7a172054b98f
the following patch was just integrated into master:
commit 0f5a3fc36794fa23210ada7abf671495e4a98226
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Tue Mar 12 20:16:44 2013 -0700
exynos5250: add RAM resource beginning at physical address
The original code attempted to reserve a space in RAM for coreboot to
remain resident. This turns out not to be needed, and breaks things
for the kernel since the exynos5250-smdk5250 kernel device tree starts
RAM at 0x40000000.
(This patch was originally by Gabe, I'm just uploading it)
Change-Id: I4536edaf8785d81a3ea008216a2d57549ce5edfb
Signed-off-by: Gabe Black <gabeblack(a)chromium.org>
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
Reviewed-on: http://review.coreboot.org/2698
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
Tested-by: build bot (Jenkins)
Build-Tested: build bot (Jenkins) at Thu Mar 14 00:03:51 2013, giving +1
See http://review.coreboot.org/2698 for details.
-gerrit
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2698
-gerrit
commit 89e859b28fb3ce3b4e8ddd31550763bb8962cbf2
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Tue Mar 12 20:16:44 2013 -0700
exynos5250: add RAM resource beginning at physical address
The original code attempted to reserve a space in RAM for coreboot to
remain resident. This turns out not to be needed, and breaks things
for the kernel since the exynos5250-smdk5250 kernel device tree starts
RAM at 0x40000000.
(This patch was originally by Gabe, I'm just uploading it)
Change-Id: I4536edaf8785d81a3ea008216a2d57549ce5edfb
Signed-off-by: Gabe Black <gabeblack(a)chromium.org>
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/cpu/samsung/exynos5250/cpu.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/cpu/samsung/exynos5250/cpu.c b/src/cpu/samsung/exynos5250/cpu.c
index 0a49e1e..bcf4d22 100644
--- a/src/cpu/samsung/exynos5250/cpu.c
+++ b/src/cpu/samsung/exynos5250/cpu.c
@@ -1,13 +1,12 @@
#include <console/console.h>
#include <device/device.h>
-#define RAM_BASE ((CONFIG_SYS_SDRAM_BASE >> 10) + (CONFIG_COREBOOT_ROMSIZE_KB))
-#define RAM_SIZE (((CONFIG_DRAM_SIZE_MB << 10UL) * CONFIG_NR_DRAM_BANKS) \
- - CONFIG_COREBOOT_ROMSIZE_KB)
+#define RAM_BASE_KB (CONFIG_SYS_SDRAM_BASE >> 10)
+#define RAM_SIZE_KB (CONFIG_DRAM_SIZE_MB << 10UL)
static void domain_read_resources(device_t dev)
{
- ram_resource(dev, 0, RAM_BASE, RAM_SIZE);
+ ram_resource(dev, 0, RAM_BASE_KB, RAM_SIZE_KB);
}
static void domain_set_resources(device_t dev)
the following patch was just integrated into master:
commit 7bc153c6aef0f2615e3dadb274b9fed56ed15732
Author: Mike Loptien <mike.loptien(a)se-eng.com>
Date: Wed Mar 13 16:28:16 2013 -0600
Eagleheights DSDT: Grant OS control through OSC
Change the OSC method to actually grant control of
PCIe capabilities to the OS instead of granting no
control. I believe the logic was backwards in the
original commit. Bits should be set when granting
control and cleared when not granting control. By
setting the return value to 0x00, we effectively
tell the OS that it cannot control any PCIe
capability. See section 6.2.9 of the ACPI spec
version 3.0 for more information.
This edit is a duplication of the OSC method that
is in the src/southbridge/intel/bd82x6x/pch.asl
file.
Change-Id: Id2462ab12203afceb9033f24d06b4dfbf2236d2e
Signed-off-by: Mike Loptien <mike.loptien(a)se-eng.com>
Reviewed-on: http://review.coreboot.org/2714
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
Build-Tested: build bot (Jenkins) at Wed Mar 13 23:43:11 2013, giving +1
Reviewed-By: Ronald G. Minnich <rminnich(a)gmail.com> at Wed Mar 13 23:44:00 2013, giving +2
See http://review.coreboot.org/2714 for details.
-gerrit
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2698
-gerrit
commit 025f863183c3770766319572d86b306efda9b0bd
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Tue Mar 12 20:16:44 2013 -0700
exynos5250: add RAM resource beginning at physical address
The original code attempted to reserve a space in RAM for coreboot to
remain resident. This turns out not to be needed, and breaks things
for the kernel since the exynos5250-smdk5250 kernel device tree starts
RAM at 0x40000000.
(This patch was originally by Gabe, I'm just uploading it)
Change-Id: I4536edaf8785d81a3ea008216a2d57549ce5edfb
Signed-off-by: Gabe Black <gabeblack(a)chromium.org>
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/cpu/samsung/exynos5250/cpu.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/cpu/samsung/exynos5250/cpu.c b/src/cpu/samsung/exynos5250/cpu.c
index 0a49e1e..14aa9e2 100644
--- a/src/cpu/samsung/exynos5250/cpu.c
+++ b/src/cpu/samsung/exynos5250/cpu.c
@@ -1,13 +1,12 @@
#include <console/console.h>
#include <device/device.h>
-#define RAM_BASE ((CONFIG_SYS_SDRAM_BASE >> 10) + (CONFIG_COREBOOT_ROMSIZE_KB))
-#define RAM_SIZE (((CONFIG_DRAM_SIZE_MB << 10UL) * CONFIG_NR_DRAM_BANKS) \
- - CONFIG_COREBOOT_ROMSIZE_KB)
+#define RAM_BASE (CONFIG_SYS_SDRAM_BASE >> 10)
+#define RAM_SIZE_KB (CONFIG_DRAM_SIZE_MB << 10UL)
static void domain_read_resources(device_t dev)
{
- ram_resource(dev, 0, RAM_BASE, RAM_SIZE);
+ ram_resource(dev, 0, RAM_BASE, RAM_SIZE_KB);
}
static void domain_set_resources(device_t dev)