aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-21 09:51:28 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-21 09:51:28 -0700
commitd1890409251949b80c2026557b9b12ca00d55144 (patch)
tree118b44c1f72cbebca45d162730c468a2a6a8640e
parent075c25456b7c6f33248e8bcbe7ede17cf5e82781 (diff)
downloadsyslinux-d1890409251949b80c2026557b9b12ca00d55144.tar.gz
syslinux-d1890409251949b80c2026557b9b12ca00d55144.tar.xz
syslinux-d1890409251949b80c2026557b9b12ca00d55144.zip
gpllib: Move get_error from disk/util.c to disk/error.c
The get_error function is fairly big. It is worth creating a new file for it. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
-rw-r--r--com32/gplinclude/disk/error.h4
-rw-r--r--com32/gpllib/disk/error.c123
-rw-r--r--com32/gpllib/disk/util.c121
3 files changed, 127 insertions, 121 deletions
diff --git a/com32/gplinclude/disk/error.h b/com32/gplinclude/disk/error.h
new file mode 100644
index 00000000..3a7614e9
--- /dev/null
+++ b/com32/gplinclude/disk/error.h
@@ -0,0 +1,4 @@
+#ifndef _ERROR_H_
+#define _ERROR_H_
+void get_error(const int, char**);
+#endif /* _UTIL_H_ */
diff --git a/com32/gpllib/disk/error.c b/com32/gpllib/disk/error.c
new file mode 100644
index 00000000..469609b2
--- /dev/null
+++ b/com32/gpllib/disk/error.c
@@ -0,0 +1,123 @@
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * get_error - decode a disk error status
+ * @status: Error code
+ * @buffer_ptr: Pointer to set to the error message
+ *
+ * A buffer will be allocated to contain the error message.
+ * @buffer_ptr will point to it. The caller will need to free it.
+ **/
+void get_error(int status, char** buffer_ptr)
+{
+ int buffer_size = (80 * sizeof(char));
+ char* buffer = malloc(buffer_size);
+ *buffer_ptr = buffer;
+
+ switch (status) {
+ case 0x0:
+ strncpy(buffer, "successful completion", buffer_size);
+ break;
+ case 0x01:
+ strncpy(buffer, "invalid function in AH or invalid parameter", buffer_size);
+ break;
+ case 0x02:
+ strncpy(buffer, "address mark not found", buffer_size);
+ break;
+ case 0x03:
+ strncpy(buffer, "disk write-protected", buffer_size);
+ break;
+ case 0x04:
+ strncpy(buffer, "sector not found/read error", buffer_size);
+ break;
+ case 0x05:
+ strncpy(buffer, "reset failed (hard disk)", buffer_size);
+ //strncpy(buffer, "data did not verify correctly (TI Professional PC)", buffer_size);
+ break;
+ case 0x06:
+ strncpy(buffer, "disk changed (floppy)", buffer_size);
+ break;
+ case 0x07:
+ strncpy(buffer, "drive parameter activity failed (hard disk)", buffer_size);
+ break;
+ case 0x08:
+ strncpy(buffer, "DMA overrun", buffer_size);
+ break;
+ case 0x09:
+ strncpy(buffer, "data boundary error (attempted DMA across 64K boundary or >80h sectors)", buffer_size);
+ break;
+ case 0x0A:
+ strncpy(buffer, "bad sector detected (hard disk)", buffer_size);
+ break;
+ case 0x0B:
+ strncpy(buffer, "bad track detected (hard disk)", buffer_size);
+ break;
+ case 0x0C:
+ strncpy(buffer, "unsupported track or invalid media", buffer_size);
+ break;
+ case 0x0D:
+ strncpy(buffer, "invalid number of sectors on format (PS/2 hard disk)", buffer_size);
+ break;
+ case 0x0E:
+ strncpy(buffer, "control data address mark detected (hard disk)", buffer_size);
+ break;
+ case 0x0F:
+ strncpy(buffer, "DMA arbitration level out of range (hard disk)", buffer_size);
+ break;
+ case 0x10:
+ strncpy(buffer, "uncorrectable CRC or ECC error on read", buffer_size);
+ break;
+ case 0x11:
+ strncpy(buffer, "data ECC corrected (hard disk)", buffer_size);
+ break;
+ case 0x20:
+ strncpy(buffer, "controller failure", buffer_size);
+ break;
+ case 0x31:
+ strncpy(buffer, "no media in drive (IBM/MS INT 13 extensions)", buffer_size);
+ break;
+ case 0x32:
+ strncpy(buffer, "incorrect drive type stored in CMOS (Compaq)", buffer_size);
+ break;
+ case 0x40:
+ strncpy(buffer, "seek failed", buffer_size);
+ break;
+ case 0x80:
+ strncpy(buffer, "timeout (not ready)", buffer_size);
+ break;
+ case 0xAA:
+ strncpy(buffer, "drive not ready (hard disk)", buffer_size);
+ break;
+ case 0xB0:
+ strncpy(buffer, "volume not locked in drive (INT 13 extensions)", buffer_size);
+ break;
+ case 0xB1:
+ strncpy(buffer, "volume locked in drive (INT 13 extensions)", buffer_size);
+ break;
+ case 0xB2:
+ strncpy(buffer, "volume not removable (INT 13 extensions)", buffer_size);
+ break;
+ case 0xB3:
+ strncpy(buffer, "volume in use (INT 13 extensions)", buffer_size);
+ break;
+ case 0xB4:
+ strncpy(buffer, "lock count exceeded (INT 13 extensions)", buffer_size);
+ break;
+ case 0xB5:
+ strncpy(buffer, "valid eject request failed (INT 13 extensions)", buffer_size);
+ break;
+ case 0xBB:
+ strncpy(buffer, "undefined error (hard disk)", buffer_size);
+ break;
+ case 0xCC:
+ strncpy(buffer, "write fault (hard disk)", buffer_size);
+ break;
+ case 0xE0:
+ strncpy(buffer, "status register error (hard disk)", buffer_size);
+ break;
+ case 0xFF:
+ strncpy(buffer, "sense operation failed (hard disk)", buffer_size);
+ break;
+ }
+}
diff --git a/com32/gpllib/disk/util.c b/com32/gpllib/disk/util.c
index 7da8351d..c03ed37b 100644
--- a/com32/gpllib/disk/util.c
+++ b/com32/gpllib/disk/util.c
@@ -28,124 +28,3 @@ int int13_retry(const com32sys_t *inreg, com32sys_t *outreg)
/* If we get here: error */
return -1;
}
-
-/**
- * get_error - decode a disk error status
- * @status: Error code
- * @buffer_ptr: Pointer to set to the error message
- *
- * A buffer will be allocated to contain the error message.
- * @buffer_ptr will point to it. The caller will need to free it.
- **/
-void get_error(int status, char** buffer_ptr)
-{
- int buffer_size = (80 * sizeof(char));
- char* buffer = malloc(buffer_size);
- *buffer_ptr = buffer;
-
- switch (status) {
- case 0x0:
- strncpy(buffer, "successful completion", buffer_size);
- break;
- case 0x01:
- strncpy(buffer, "invalid function in AH or invalid parameter", buffer_size);
- break;
- case 0x02:
- strncpy(buffer, "address mark not found", buffer_size);
- break;
- case 0x03:
- strncpy(buffer, "disk write-protected", buffer_size);
- break;
- case 0x04:
- strncpy(buffer, "sector not found/read error", buffer_size);
- break;
- case 0x05:
- strncpy(buffer, "reset failed (hard disk)", buffer_size);
- //strncpy(buffer, "data did not verify correctly (TI Professional PC)", buffer_size);
- break;
- case 0x06:
- strncpy(buffer, "disk changed (floppy)", buffer_size);
- break;
- case 0x07:
- strncpy(buffer, "drive parameter activity failed (hard disk)", buffer_size);
- break;
- case 0x08:
- strncpy(buffer, "DMA overrun", buffer_size);
- break;
- case 0x09:
- strncpy(buffer, "data boundary error (attempted DMA across 64K boundary or >80h sectors)", buffer_size);
- break;
- case 0x0A:
- strncpy(buffer, "bad sector detected (hard disk)", buffer_size);
- break;
- case 0x0B:
- strncpy(buffer, "bad track detected (hard disk)", buffer_size);
- break;
- case 0x0C:
- strncpy(buffer, "unsupported track or invalid media", buffer_size);
- break;
- case 0x0D:
- strncpy(buffer, "invalid number of sectors on format (PS/2 hard disk)", buffer_size);
- break;
- case 0x0E:
- strncpy(buffer, "control data address mark detected (hard disk)", buffer_size);
- break;
- case 0x0F:
- strncpy(buffer, "DMA arbitration level out of range (hard disk)", buffer_size);
- break;
- case 0x10:
- strncpy(buffer, "uncorrectable CRC or ECC error on read", buffer_size);
- break;
- case 0x11:
- strncpy(buffer, "data ECC corrected (hard disk)", buffer_size);
- break;
- case 0x20:
- strncpy(buffer, "controller failure", buffer_size);
- break;
- case 0x31:
- strncpy(buffer, "no media in drive (IBM/MS INT 13 extensions)", buffer_size);
- break;
- case 0x32:
- strncpy(buffer, "incorrect drive type stored in CMOS (Compaq)", buffer_size);
- break;
- case 0x40:
- strncpy(buffer, "seek failed", buffer_size);
- break;
- case 0x80:
- strncpy(buffer, "timeout (not ready)", buffer_size);
- break;
- case 0xAA:
- strncpy(buffer, "drive not ready (hard disk)", buffer_size);
- break;
- case 0xB0:
- strncpy(buffer, "volume not locked in drive (INT 13 extensions)", buffer_size);
- break;
- case 0xB1:
- strncpy(buffer, "volume locked in drive (INT 13 extensions)", buffer_size);
- break;
- case 0xB2:
- strncpy(buffer, "volume not removable (INT 13 extensions)", buffer_size);
- break;
- case 0xB3:
- strncpy(buffer, "volume in use (INT 13 extensions)", buffer_size);
- break;
- case 0xB4:
- strncpy(buffer, "lock count exceeded (INT 13 extensions)", buffer_size);
- break;
- case 0xB5:
- strncpy(buffer, "valid eject request failed (INT 13 extensions)", buffer_size);
- break;
- case 0xBB:
- strncpy(buffer, "undefined error (hard disk)", buffer_size);
- break;
- case 0xCC:
- strncpy(buffer, "write fault (hard disk)", buffer_size);
- break;
- case 0xE0:
- strncpy(buffer, "status register error (hard disk)", buffer_size);
- break;
- case 0xFF:
- strncpy(buffer, "sense operation failed (hard disk)", buffer_size);
- break;
- }
-}