chain.c32, libcom32: Move int13_retry() as disk_int13_retry()
authorShao Miller <shao.miller@yrdsb.edu.on.ca>
Mon, 28 Jun 2010 04:59:17 +0000 (00:59 -0400)
committerShao Miller <shao.miller@yrdsb.edu.on.ca>
Sat, 10 Jul 2010 05:00:47 +0000 (01:00 -0400)
Moving portions of chain.c32 into libcom32.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
com32/include/syslinux/disk.h
com32/lib/syslinux/disk.c
com32/modules/chain.c

index 482dece..83db05c 100644 (file)
 #ifndef _SYSLINUX_DISK_H
 #define _SYSLINUX_DISK_H
 
+#include <com32.h>
+
 #define SECTOR 512             /* bytes/sector */
 
+extern int disk_int13_retry(const com32sys_t * inreg, com32sys_t * outreg);
+
 #endif /* _SYSLINUX_DISK_H */
index 2a286e4..7be59f2 100644 (file)
  */
 
 #include <syslinux/disk.h>
+
+/**
+ * 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 */
+}
index d6005e2..19afa05 100644 (file)
@@ -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 */