From: Shao Miller Date: Mon, 28 Jun 2010 04:59:17 +0000 (-0400) Subject: chain.c32, libcom32: Move int13_retry() as disk_int13_retry() X-Git-Tag: syslinux-4.06-pre3~3^2~92^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f0f42100f43a52e957c7c6feec0d2fcb21d0b6e;p=profile%2Fivi%2Fsyslinux.git chain.c32, libcom32: Move int13_retry() as disk_int13_retry() Moving portions of chain.c32 into libcom32. Signed-off-by: Shao Miller --- diff --git a/com32/include/syslinux/disk.h b/com32/include/syslinux/disk.h index 482dece..83db05c 100644 --- a/com32/include/syslinux/disk.h +++ b/com32/include/syslinux/disk.h @@ -36,6 +36,10 @@ #ifndef _SYSLINUX_DISK_H #define _SYSLINUX_DISK_H +#include + #define SECTOR 512 /* bytes/sector */ +extern int disk_int13_retry(const com32sys_t * inreg, com32sys_t * outreg); + #endif /* _SYSLINUX_DISK_H */ diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c index 2a286e4..7be59f2 100644 --- a/com32/lib/syslinux/disk.c +++ b/com32/lib/syslinux/disk.c @@ -34,3 +34,26 @@ */ #include + +/** + * Call int 13h, but with retry on failure. Especially floppies need this. + * + * @v inreg CPU register settings upon INT call + * @v outreg CPU register settings returned by INT call + */ +int disk_int13_retry(const com32sys_t * inreg, com32sys_t * outreg) +{ + int retry = 6; /* Number of retries */ + com32sys_t tmpregs; + + if (!outreg) + outreg = &tmpregs; + + while (retry--) { + __intcall(0x13, inreg, outreg); + if (!(outreg->eflags.l & EFLAGS_CF)) + return 0; /* CF=0, OK */ + } + + return -1; /* Error */ +} diff --git a/com32/modules/chain.c b/com32/modules/chain.c index d6005e2..19afa05 100644 --- a/com32/modules/chain.c +++ b/com32/modules/chain.c @@ -146,26 +146,6 @@ static inline void error(const char *msg) } /* - * Call int 13h, but with retry on failure. Especially floppies need this. - */ -static int int13_retry(const com32sys_t * inreg, com32sys_t * outreg) -{ - int retry = 6; /* Number of retries */ - com32sys_t tmpregs; - - if (!outreg) - outreg = &tmpregs; - - while (retry--) { - __intcall(0x13, inreg, outreg); - if (!(outreg->eflags.l & EFLAGS_CF)) - return 0; /* CF=0, OK */ - } - - return -1; /* Error */ -} - -/* * Query disk parameters and EBIOS availability for a particular disk. */ struct diskinfo { @@ -287,7 +267,7 @@ static void *read_sectors(uint64_t lba, uint8_t count) inreg.es = SEG(buf); } - if (int13_retry(&inreg, NULL)) + if (disk_int13_retry(&inreg, NULL)) return NULL; data = malloc(count * SECTOR); @@ -347,7 +327,7 @@ static int write_sector(unsigned int lba, const void *data) inreg.es = SEG(buf); } - if (int13_retry(&inreg, NULL)) + if (disk_int13_retry(&inreg, NULL)) return -1; return 0; /* ok */