From e5a014f403aabb9400f309a0bef08288d6421107 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 11 Nov 2009 16:05:34 -0800 Subject: [PATCH] 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 --- dos/syslinux.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/dos/syslinux.c b/dos/syslinux.c index d054c4c..ca2fd8e 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), -- 2.7.4