Magellan Linux

Contents of /trunk/mkinitrd-magellan/isolinux/loadhigh.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (show annotations) (download)
Thu Aug 19 09:50:43 2010 UTC (13 years, 8 months ago) by niro
File size: 3166 byte(s)
-updated to isolinux-3.86
1 ;; -----------------------------------------------------------------------
2 ;;
3 ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin
5 ;;
6 ;; This program is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ;; Boston MA 02111-1307, USA; either version 2 of the License, or
10 ;; (at your option) any later version; incorporated herein by reference.
11 ;;
12 ;; -----------------------------------------------------------------------
13
14 ;;
15 ;; loadhigh.inc
16 ;;
17 ;; Load a file into high memory
18 ;;
19
20 section .text
21
22 ;
23 ; load_high: loads (the remainder of) a file into high memory.
24 ; This routine prints dots for each 64K transferred, and
25 ; calls abort_check periodically.
26 ;
27 ; The xfer_buf_seg is used as a bounce buffer.
28 ;
29 ; Assumes CS == DS.
30 ;
31 ; The input address (EDI) should be dword aligned, and the final
32 ; stretch is padded with zeroes if necessary.
33 ;
34 ; Inputs: SI = file handle/cluster pointer
35 ; EDI = target address in high memory
36 ; EAX = maximum number of bytes to load
37 ; DX = zero-padding mask (e.g. 0003h for pad to dword)
38 ; BX = subroutine to call at the top of each loop
39 ; (to print status and check for abort)
40 ; MyHighMemSize = maximum load address
41 ;
42 ; Outputs: SI = file handle/cluster pointer
43 ; EBX = first untouched address (not including padding)
44 ; EDI = first untouched address (including padding)
45 ; CF = reached EOF
46 ;
47 load_high:
48 push es ; <AAA> ES
49
50 mov cx,xfer_buf_seg
51 mov es,cx
52 mov [PauseBird],bx
53
54 .read_loop:
55 and si,si ; If SI == 0 then we have end of file
56 jz .eof
57 call [PauseBird]
58
59 push eax ; <A> Total bytes to transfer
60 cmp eax,(1 << 16) ; Max 64K in one transfer
61 jna .size_ok
62 mov eax,(1 << 16)
63 .size_ok:
64 push eax ; <B> Bytes transferred this chunk
65 add eax,SECTOR_SIZE-1
66 shr eax,SECTOR_SHIFT ; Convert to sectors
67
68 ; Now (e)ax contains the number of sectors to get
69 push edi ; <C> Target buffer
70 mov cx,ax
71 xor bx,bx ; ES:0
72 call getfssec ; Load the data into xfer_buf_seg
73 pop edi ; <C> Target buffer
74 pushf ; <C> EOF status
75 lea ebx,[edi+ecx] ; End of data
76 .fix_slop:
77 test cx,dx
78 jz .noslop
79 ; The last dword fractional - pad with zeroes
80 ; Zero-padding is critical for multi-file initramfs.
81 mov byte [es:ecx],0
82 inc cx
83 jmp short .fix_slop
84 .noslop:
85 lea eax,[edi+ecx]
86 cmp eax,[MyHighMemSize]
87 ja .overflow
88
89 push esi ; <D> File handle/cluster pointer
90 mov esi,(xfer_buf_seg << 4) ; Source address
91 call bcopy ; Copy to high memory
92 pop esi ; <D> File handle/cluster pointer
93 popf ; <C> EOF status
94 pop ecx ; <B> Byte count this round
95 pop eax ; <A> Total bytes to transfer
96 jc .eof
97 sub eax,ecx
98 jnz .read_loop ; More to read... (if ZF=1 then CF=0)
99 .eof:
100 pop es ; <AAA> ES
101 ret
102
103 .overflow: mov si,err_nohighmem
104 jmp abort_load
105
106 section .data
107 err_nohighmem db CR, LF
108 db 'Not enough memory to load specified image.', CR, LF, 0
109
110 section .bss
111 alignb 2
112 PauseBird resw 1
113
114 section .text