summaryrefslogtreecommitdiff
path: root/ldlinux.asm
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-27 13:22:16 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-02-27 13:24:57 -0800
commitf4c12ad254d31eae619f38f7571e57e110745d66 (patch)
treea87fc262b7899c73ba240a5c4ad5558b04ba7f44 /ldlinux.asm
parent79c071f6ca6dc9bd5eafb33da8587b7873b5e270 (diff)
downloadsyslinux-3.70-pre1.tar.gz
SYSLINUX, EXTLINUX: support the new getfssec APIsyslinux-3.70-pre1
Support the new getfssec API which returns number of bytes read in SYSLINUX and EXTLINUX. Untested so far, but it's a reasonably easy change.
Diffstat (limited to 'ldlinux.asm')
-rw-r--r--ldlinux.asm23
1 files changed, 18 insertions, 5 deletions
diff --git a/ldlinux.asm b/ldlinux.asm
index c8e4aa81..4df94b73 100644
--- a/ldlinux.asm
+++ b/ldlinux.asm
@@ -88,7 +88,9 @@ comboot_seg equ real_mode_seg ; COMBOOT image loading zone
;
struc open_file_t
file_sector resd 1 ; Sector pointer (0 = structure free)
+file_bytesleft resd 1 ; Number of bytes left
file_left resd 1 ; Number of sectors left
+ resd 1 ; Unused
endstruc
%ifndef DEPEND
@@ -1089,6 +1091,7 @@ searchdir:
jnz .badfile ; If not a file, it's a bad thing
; SI and EAX are already set
+ mov [si+file_bytesleft],eax
and eax,eax ; EAX != 0
jz .badfile
ret ; Done!
@@ -1341,20 +1344,30 @@ getfssec_edx:
; CX -> Sector count (0FFFFh = until end of file)
; Must not exceed the ES segment
; Returns CF=1 on EOF (not necessarily error)
+; ECX returns number of bytes read.
; All arguments are advanced to reflect data read.
;
getfssec:
push edx
movzx edx,cx
- cmp edx,[si+4]
+ push edx ; Zero-extended CX
+ cmp edx,[si+file_left]
jbe .sizeok
- mov edx,[si+4]
+ mov edx,[si+file_left]
mov cx,dx
.sizeok:
- sub [si+4],edx
- mov edx,[si]
+ sub [si+file_left],edx
+ mov edx,[si+file_sector]
call getfssec_edx
- mov [si],edx
+ mov [si+file_sector],edx
+ pop ecx ; Sectors requested read
+ pushf ; Save CF from getfssec_edx
+ shl ecx,SECTOR_SHIFT
+ cmp ecx,[si+file_bytesleft]
+ jna .noteof
+ mov ecx,[si+file_bytesleft]
+.noteof: sub ecx,[si+file_bytesleft]
+ popf
pop edx
ret