diff options
Diffstat (limited to 'kernel/hd.c')
| -rw-r--r-- | kernel/hd.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/kernel/hd.c b/kernel/hd.c index 2f680d1..83108dd 100644 --- a/kernel/hd.c +++ b/kernel/hd.c @@ -40,7 +40,7 @@ static int read_sect(void *buf, uint32_t lba) { outb(0x1F7, 0x20); /* wait for the drive */ - while(1) { + for(;;) { /* poll the drive's status */ s = inb(0x1F7); if(s & ST_DF) { @@ -81,7 +81,7 @@ static int write_sect(void *buf, uint32_t lba) { outb(0x1F7, 0x30); /* wait for the drive */ - while(1) { + for(;;) { /* poll the drive's status */ s = inb(0x1F7); if(s & ST_DF) { @@ -102,15 +102,13 @@ static int write_sect(void *buf, uint32_t lba) { return 0; } -int hd_read_block(void *buf, size_t block) { +int hd_read_block(void *buf, uint16_t block) { int ret; size_t i; uint32_t s = SECTS(block); uint32_t e = SECTS(block + 1); - if(nblocks <= s) - return -1; - if(nblocks <= e) + if(nblocks <= s || nblocks <= e) return -1; for(i = 0; i < (e - s); i++) { @@ -125,15 +123,13 @@ int hd_read_block(void *buf, size_t block) { return 0; } -int hd_write_block(void *buf, size_t block) { +int hd_write_block(void *buf, uint16_t block) { int ret; size_t i; uint32_t s = SECTS(block); uint32_t e = SECTS(block + 1); - if(nblocks <= s) - return -1; - if(nblocks <= e) + if(nblocks <= s || nblocks <= e) return -1; for(i = 0; i < (e - s); i++) { @@ -158,7 +154,7 @@ int hd_init(void) { /* send the IDENTIFY command */ outb(0x1F7, 0xEC); - while(1) { + for(;;) { s = inb(0x1F7); if(!s) { printk("[hd] Master drive not detected on primary bus!\n"); |
