Mercurial > ecos
changeset 1657:55f30b7a6e96
* src/fs/ide.c: make sure IDE_STAT_BSY is 0 before checking other
bits in the status register
| author | jlarmour |
|---|---|
| date | Thu, 27 May 2004 06:37:44 +0000 |
| parents | ea74d0ea9eb1 |
| children | 79f7073a7a00 |
| files | packages/redboot/current/ChangeLog packages/redboot/current/src/fs/ide.c |
| diffstat | 2 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,9 @@ +2004-05-16 Andrew Dyer <adyer@righthandtech.com> +2004-05-27 Jonathan Larmour <jifl@eCosCentric.com> + + * src/fs/ide.c: make sure IDE_STAT_BSY is 0 before checking other + bits in the status register + 2004-05-21 Ian Campbell <icampbell@arcom.com> * src/main.c: Make it build without CYGSEM_REDBOOT_FLASH_ALIASES.
--- a/packages/redboot/current/src/fs/ide.c +++ b/packages/redboot/current/src/fs/ide.c @@ -80,15 +80,18 @@ static inline int __wait_for_drq(int ctlr) { cyg_uint8 status; + cyg_ucount32 tries; CYGACC_CALL_IF_DELAY_US(10); - do { + for (tries=0; tries<1000000; tries++) { HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status); - if (status & IDE_STAT_DRQ) - return 1; - } while (status & IDE_STAT_BSY); - - return 0; + if (!(status & IDE_STAT_BSY)) { + if (status & IDE_STAT_DRQ) + return 1; + else + return 0; + } + } } static int @@ -102,16 +105,16 @@ ide_reset(int ctlr) HAL_IDE_WRITE_CONTROL(ctlr, 2); // polled mode, reset cleared CYGACC_CALL_IF_DELAY_US((cyg_uint32)50000); - // wait 30 seconds max for not busy + // wait 30 seconds max for not busy and drive ready for (delay = 0; delay < 300; ++delay) { CYGACC_CALL_IF_DELAY_US((cyg_uint32)100000); HAL_IDE_READ_UINT8(ctlr, IDE_REG_STATUS, status); - // bail out early on bogus status - if ((status & (IDE_STAT_BSY|IDE_STAT_DRDY)) == (IDE_STAT_BSY|IDE_STAT_DRDY)) - break; - if (!(status & IDE_STAT_BSY)) + if (!(status & IDE_STAT_BSY)) { + if (status & IDE_STAT_DRDY) { return 1; } + } + } return 0; }
