From e67aea1c0ccd3cc08a9110386d9b75b281941907 Mon Sep 17 00:00:00 2001 From: hpa Date: Sat, 14 Feb 1998 00:26:18 +0000 Subject: [PATCH] FAT16 support!!! --- NEWS | 3 +++ TODO | 10 +++++++++- ldlinux.asm | 36 ++++++++++++++++++++++++------------ syslinux.asm | 7 ------- syslinux.c | 6 ++++++ 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index ce73765..ff399e7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Changes in 1.32: + * FAT16 is now supported. + Changes in 1.31: * Now compiles under Linux, using NASM, rather than using Turbo Assembler under DOS. See http://www.cryogen.com/Nasm diff --git a/TODO b/TODO index a296aa3..3c05d9e 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,14 @@ Currently scheduled for inclusion in 1.40: -- FAT16 support (for LS120 floppies mainly). +- FAT16 support (for LS120 floppies mainly). DONE! - "Comboot" style boot files. - Booting DOS for a DOS/Linux dual rescue disk. - Cleaned up documentation, with a real man page. + +For a later release, perhaps: + +- Support for clusters larger than 16K. This would require changing + a lot of the SYSLINUX internals so we can read partial clusters; + change the current "cluster pointers" to become + "cluster:sector pointers". + diff --git a/ldlinux.asm b/ldlinux.asm index a6f04df..6e7328e 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -689,7 +689,8 @@ bootsignature dw 0AA55h ldlinux_magic db 'LDLINUX' missing_dot db ' ' db 'SYS ', version_str, ' ', date -magic_eof db 0, 0Dh, 0Ah, 01Ah +magic_eof db 0, +crlf db 0Dh, 0Ah, 0, 01Ah align 4 ldlinux_ent: @@ -822,8 +823,6 @@ load_rest: ; All loaded up ; all_read_jmp: - mov si,copyright_str - call writestr jmp all_read ; ; ----------------------------------------------------------------------------- @@ -945,13 +944,18 @@ nc_even: pop ax nc_return: ret +; +; FAT16 decoding routine. Note that a 16-bit FAT can be up to 128K, +; so we have to decide if we're in the "low" or the "high" 64K-segment... +; nextcluster_fat16: push ax push ds - mov ax,(fat_seg >> 12) + mov ax,fat_seg shl si,1 - adc ax,byte 0 - mov ds,ax + jnc .seg0 + mov ax,fat_seg+1000h +.seg0: mov ds,ax mov si,[si] cmp si,0FFF0h cmc @@ -968,12 +972,6 @@ safedumpregs: jmp dumpregs %endif -; -; Data that has to be in the first sector -; -copyright_str db ' Copyright (C) 1994-', year, ' H. Peter Anvin' -crlf db 0Dh, 0Ah, 0 - rl_checkpt equ $ ; Must be <= 400h ; ---------------------------------------------------------------------------- @@ -982,6 +980,12 @@ rl_checkpt equ $ ; Must be <= 400h all_read: ; +; Let the user (and programmer!) know we got this far. This used to be +; in Sector 1, but makes a lot more sense here. +; + mov si,copyright_str + call writestr +; ; Check that no moron is trying to boot Linux on a 286 or so. According ; to Intel, the way to check is to see if the high 4 bits of the FLAGS ; register are either all stuck at 1 (8086/8088) or all stuck at 0 @@ -1041,6 +1045,7 @@ skip_checks: ; We still need to check if this is a 486 or higher, and if it isn't, blank ; out the WBINVD subroutine ; +%if 0 pushfd pushfd pop eax @@ -1055,6 +1060,11 @@ skip_checks: jne is_486 ; Is a 486 or higher, assume WBINVD works mov word [flush_cache.wbinvd],09090h ; NOP out is_486: +%else + +%define wbinvd nop + +%endif ; ; Initialization that does not need to go into the any of the pre-load @@ -2862,6 +2872,8 @@ lcase_tab db 135, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138 ; ; Various initialized or semi-initialized variables ; +copyright_str db ' Copyright (C) 1994-', year, ' H. Peter Anvin' + db 0Dh, 0Ah, 0 boot_prompt db 'boot: ',0 wipe_char db 08h, ' ', 08h, 0 err_notfound db 'Could not find kernel image: ',0 diff --git a/syslinux.asm b/syslinux.asm index 92163b9..4082084 100644 --- a/syslinux.asm +++ b/syslinux.asm @@ -124,9 +124,6 @@ got_cmdline: and al,al jnz filesystem_error - cmp word [bx+dpbMaxCluster],4087 ; FAT16 not supported yet - ja fat16_error - cmp word [bx+dpbSectorSize],512 ; Sector size = 512 required jne sectorsize_error @@ -139,9 +136,6 @@ hugeclust_error: filesystem_error: mov dx,msg_filesystem_err jmp die -fat16_error: - mov dx,msg_fat16_err - jmp die sectorsize_error: mov dx,msg_sectorsize_err jmp die @@ -262,7 +256,6 @@ die: section .data msg_error: db 'ERROR: $' msg_filesystem_err: db 'Filesystem not found on disk', 0Dh, 0Ah, '$' -msg_fat16_err: db 'FAT16 filesystems not supported at this time', 0Dh, 0Ah, '$' msg_sectorsize_err: db 'Sector sizes other than 512 bytes not supported', 0Dh, 0Ah, '$' msg_hugeclust_err: db 'Clusters larger than 16K not supported', 0Dh, 0Ah, '$' msg_read_err: db 'Disk read failed', 0Dh, 0Ah, '$' diff --git a/syslinux.c b/syslinux.c index 0a5afcc..8874d48 100644 --- a/syslinux.c +++ b/syslinux.c @@ -177,6 +177,12 @@ int main(int argc, char *argv[]) device); exit(1); } + } else if ( !memcmp(sectbuf+bsFileSysType, "FAT16 ", 8) ) { + if ( clusters <= 4086 ) { + fprintf(stderr, "%s: ERROR: FAT16 but claims less than 4086 clusters\n", + device); + exit(1); + } } else { fprintf(stderr, "%s: filesystem type \"%8.8s\" not supported\n", device, sectbuf+bsFileSysType); -- 2.7.4