aboutsummaryrefslogtreecommitdiffstats
path: root/dos
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-11-11 16:05:34 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-11-11 16:05:34 -0800
commite5a014f403aabb9400f309a0bef08288d6421107 (patch)
tree29d136a9460b22fe9fc4f1e6cf8c076ac4a9f934 /dos
parente79ba125c9c8eb3816d164d86b5264b21868f7af (diff)
downloadsyslinux-devel-e5a014f403aabb9400f309a0bef08288d6421107.tar.gz
syslinux-devel-e5a014f403aabb9400f309a0bef08288d6421107.tar.xz
syslinux-devel-e5a014f403aabb9400f309a0bef08288d6421107.zip
dos: always try the FAT32-aware direct I/O calls first
Always try the FAT32-aware direct I/O calls before trying the legacy raw I/O calls. The reason for doing this is that the FAT32 stuff may be implemented as an add-on. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'dos')
-rw-r--r--dos/syslinux.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/dos/syslinux.c b/dos/syslinux.c
index d054c4ce..ca2fd8e1 100644
--- a/dos/syslinux.c
+++ b/dos/syslinux.c
@@ -171,13 +171,15 @@ void write_device(int drive, const void *buf, size_t nsecs, unsigned int sector)
dio.bufoffs = (uintptr_t) buf;
dio.bufseg = data_segment();
- if (dos_version >= 0x070a) {
- asm volatile("int $0x21 ; setc %0"
- : "=bcdm" (err), "=a" (errnum)
- : "a" (0x7305), "b" (&dio), "c" (-1), "d" (drive),
- "S" (1), "m" (dio)
- : "memory");
- } else {
+ /* Try FAT32-aware system call first */
+ asm volatile("int $0x21 ; setc %0"
+ : "=bcdm" (err), "=a" (errnum)
+ : "a" (0x7305), "b" (&dio), "c" (-1), "d" (drive),
+ "S" (1), "m" (dio)
+ : "memory");
+
+ if (err && errnum == 0x0001) {
+ /* Try legacy system call */
asm volatile("int $0x26 ; setc %0 ; popfw"
: "=bcdm" (err), "=a" (errnum)
: "a" (drive-1), "b" (&dio), "c" (-1), "d" (buf),
@@ -204,12 +206,14 @@ void read_device(int drive, const void *buf, size_t nsecs, unsigned int sector)
dio.bufoffs = (uintptr_t) buf;
dio.bufseg = data_segment();
- if (dos_version >= 0x070a) {
- asm volatile("int $0x21 ; setc %0"
- : "=bcdm" (err), "=a" (errnum)
- : "a" (0x7305), "b" (&dio), "c" (-1), "d" (drive),
- "S" (0), "m" (dio));
- } else {
+ /* Try FAT32-aware system call first */
+ asm volatile("int $0x21 ; setc %0"
+ : "=bcdm" (err), "=a" (errnum)
+ : "a" (0x7305), "b" (&dio), "c" (-1), "d" (drive),
+ "S" (0), "m" (dio));
+
+ if (err && errnum == 0x0001) {
+ /* Try legacy system call */
asm volatile("int $0x25 ; setc %0 ; popfw"
: "=bcdm" (err), "=a" (errnum)
: "a" (drive-1), "b" (&dio), "c" (-1), "d" (buf),