diff options
author | imp <imp@FreeBSD.org> | 2007-03-28 22:40:37 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2007-03-28 22:40:37 +0000 |
commit | fdf75b902074d70bcb83a0421e1e7a1ef8f5bed5 (patch) | |
tree | 507b2d214cf66e5e5c725d7626f0b447fdd7820e | |
parent | feacfb6fad7a2822ad94c01ac0ad86ac3d17786d (diff) | |
download | FreeBSD-src-fdf75b902074d70bcb83a0421e1e7a1ef8f5bed5.zip FreeBSD-src-fdf75b902074d70bcb83a0421e1e7a1ef8f5bed5.tar.gz |
RTC_TIMR's RTC_SEC field is BCD. That makes it unsuitable for
GetSeconds(). Instead, use CRTR register shifted right 15. This
gives us a range of 32 seconds we can do for timeout.
Shift to using == rather than < or > for calculating the timeout,
since if we can't read the ST_CTRT register twice in a second we have
even bigger problems to worry about, and == deals with the 'wrap'
issue.
This lets me type at the boot2 prompt again! Woo Hoo!
Bogusness noticed by: tisco
Pointy Hat to: That silly imp guy
-rw-r--r-- | sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c | 1 | ||||
-rw-r--r-- | sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h | 3 | ||||
-rw-r--r-- | sys/boot/arm/at91/libat91/emac.c | 11 | ||||
-rw-r--r-- | sys/boot/arm/at91/libat91/getc.c | 6 |
4 files changed, 13 insertions, 8 deletions
diff --git a/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c b/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c index 6ea79e7..192815d 100644 --- a/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c +++ b/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.c @@ -53,6 +53,7 @@ _init(void) register unsigned value; volatile sdram_size_t *p = (sdram_size_t *)SDRAM_BASE; + AT91C_BASE_ST->ST_RTMR = 1; #ifdef BOOT_TSC // For the TSC board, we turn ON the one LED we have while // early in boot. diff --git a/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h b/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h index 13edbec..c706247 100644 --- a/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h +++ b/sys/boot/arm/at91/libat91/at91rm9200_lowlevel.h @@ -58,7 +58,8 @@ typedef unsigned int sdram_size_t; /* Master clock frequency at power-up */ #define AT91C_MASTER_CLOCK 60000000 -#define GetSeconds() (AT91C_BASE_RTC->RTC_TIMR & AT91C_RTC_SEC) +/* #define GetSeconds() (AT91C_BASE_RTC->RTC_TIMR & AT91C_RTC_SEC) */ +#define GetSeconds() (AT91C_BASE_ST->ST_CRTR >> 15) extern void _init(void); diff --git a/sys/boot/arm/at91/libat91/emac.c b/sys/boot/arm/at91/libat91/emac.c index e82c613..392537c 100644 --- a/sys/boot/arm/at91/libat91/emac.c +++ b/sys/boot/arm/at91/libat91/emac.c @@ -412,7 +412,8 @@ MII_GetLinkSpeed(AT91PS_EMAC pEmac) break; printf("."); sec = GetSeconds(); - while (GetSeconds() <= sec) continue; + while (GetSeconds() == sec) + continue; } if (stat2 & MII_STS_LINK_STAT) break; @@ -541,7 +542,7 @@ TFTP_Download(unsigned address, char *filename) dlAddress = (char*)address; lastSize = 0; timeout = 10; - thisSeconds = GetSeconds() + 1; + thisSeconds = (GetSeconds() + 2) % 32; serverPort = SWAP16(69); ++localPort; ackBlock = -1; @@ -551,10 +552,10 @@ TFTP_Download(unsigned address, char *filename) if (ackBlock == -2) break; timeout = 10; - thisSeconds = GetSeconds() + 1; - } else if (GetSeconds() > thisSeconds) { + thisSeconds = (GetSeconds() + 2) % 32; + } else if (GetSeconds() == thisSeconds) { --timeout; - thisSeconds = GetSeconds() + 1; + thisSeconds = (GetSeconds() + 2) % 32; if (!serverMACSet) GetServerAddress(); else if (ackBlock == -1) diff --git a/sys/boot/arm/at91/libat91/getc.c b/sys/boot/arm/at91/libat91/getc.c index e0a43b9..59e27a4 100644 --- a/sys/boot/arm/at91/libat91/getc.c +++ b/sys/boot/arm/at91/libat91/getc.c @@ -50,13 +50,15 @@ getc(int seconds) AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU; unsigned thisSecond; + // Clamp to 20s + if (seconds > 20) + seconds = 20; thisSecond = GetSeconds(); seconds = thisSecond + seconds; - do { if ((pUSART->US_CSR & AT91C_US_RXRDY)) return (pUSART->US_RHR & 0xFF); thisSecond = GetSeconds(); - } while (thisSecond < seconds); + } while (thisSecond != seconds); return (-1); } |