Annotation of /tags/mkinitrd-6_1_1/isolinux/loadhigh.inc
Parent Directory | Revision Log
Revision 532 -
(hide annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years, 1 month ago) by niro
Original Path: trunk/mkinitrd-magellan/isolinux/loadhigh.inc
File size: 2694 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years, 1 month ago) by niro
Original Path: trunk/mkinitrd-magellan/isolinux/loadhigh.inc
File size: 2694 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | niro | 532 | ;; $Id: loadhigh.inc,v 1.1 2007-09-01 22:44:05 niro Exp $ |
2 | ;; ----------------------------------------------------------------------- | ||
3 | ;; | ||
4 | ;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved | ||
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 | ; The input address (EDI) should be dword aligned, and the final | ||
30 | ; stretch is padded with zeroes if necessary. | ||
31 | ; | ||
32 | ; Inputs: SI = file handle/cluster pointer | ||
33 | ; EDI = target address in high memory | ||
34 | ; EAX = size of remaining file in bytes | ||
35 | ; DX = zero-padding mask (e.g. 0003h for pad to dword) | ||
36 | ; | ||
37 | ; Outputs: SI = file handle/cluster pointer | ||
38 | ; EDI = first untouched address (not including padding) | ||
39 | ; | ||
40 | load_high: | ||
41 | push es | ||
42 | |||
43 | mov bx,xfer_buf_seg | ||
44 | mov es,bx | ||
45 | |||
46 | .read_loop: | ||
47 | and si,si ; If SI == 0 then we have end of file | ||
48 | jz .eof | ||
49 | push si | ||
50 | mov si,dot_msg | ||
51 | call cwritestr | ||
52 | pop si | ||
53 | call abort_check | ||
54 | |||
55 | push eax ; <A> Total bytes to transfer | ||
56 | cmp eax,(1 << 16) ; Max 64K in one transfer | ||
57 | jna .size_ok | ||
58 | mov eax,(1 << 16) | ||
59 | .size_ok: | ||
60 | push eax ; <B> Bytes transferred this chunk | ||
61 | add eax,SECTOR_SIZE-1 | ||
62 | shr eax,SECTOR_SHIFT ; Convert to sectors | ||
63 | |||
64 | ; Now (e)ax contains the number of sectors to get | ||
65 | push edi ; <C> Target buffer | ||
66 | mov cx,ax | ||
67 | xor bx,bx ; ES:0 | ||
68 | call getfssec ; Load the data into xfer_buf_seg | ||
69 | pop edi ; <C> Target buffer | ||
70 | pop ecx ; <B> Byte count this round | ||
71 | push ecx ; <B> Byte count this round | ||
72 | push edi ; <C> Target buffer | ||
73 | .fix_slop: | ||
74 | test cx,dx | ||
75 | jz .noslop | ||
76 | ; The last dword fractional - pad with zeroes | ||
77 | ; Zero-padding is critical for multi-file initramfs. | ||
78 | mov byte [es:ecx],0 | ||
79 | inc ecx | ||
80 | jmp short .fix_slop | ||
81 | .noslop: | ||
82 | push esi ; <D> File handle/cluster pointer | ||
83 | mov esi,(xfer_buf_seg << 4) ; Source address | ||
84 | call bcopy ; Copy to high memory | ||
85 | pop esi ; <D> File handle/cluster pointer | ||
86 | pop edi ; <C> Target buffer | ||
87 | pop ecx ; <B> Byte count this round | ||
88 | pop eax ; <A> Total bytes to transfer | ||
89 | add edi,ecx | ||
90 | sub eax,ecx | ||
91 | jnz .read_loop ; More to read... | ||
92 | |||
93 | .eof: | ||
94 | pop es | ||
95 | ret | ||
96 |