Annotation of /trunk/mkinitrd-magellan/isolinux/loadhigh.inc
Parent Directory | Revision Log
Revision 1133 -
(hide annotations)
(download)
Thu Aug 19 09:50:43 2010 UTC (14 years, 1 month ago) by niro
File size: 3166 byte(s)
Thu Aug 19 09:50:43 2010 UTC (14 years, 1 month ago) by niro
File size: 3166 byte(s)
-updated to isolinux-3.86
1 | niro | 532 | ;; ----------------------------------------------------------------------- |
2 | ;; | ||
3 | niro | 1133 | ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
4 | ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin | ||
5 | ;; | ||
6 | niro | 532 | ;; 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 | niro | 1133 | ;; |
17 | niro | 532 | ;; 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 | niro | 1133 | ; |
27 | niro | 532 | ; The xfer_buf_seg is used as a bounce buffer. |
28 | ; | ||
29 | niro | 1133 | ; Assumes CS == DS. |
30 | ; | ||
31 | niro | 532 | ; 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 | niro | 1133 | ; 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 | niro | 532 | ; |
42 | ; Outputs: SI = file handle/cluster pointer | ||
43 | niro | 1133 | ; EBX = first untouched address (not including padding) |
44 | ; EDI = first untouched address (including padding) | ||
45 | ; CF = reached EOF | ||
46 | niro | 532 | ; |
47 | load_high: | ||
48 | niro | 1133 | push es ; <AAA> ES |
49 | niro | 532 | |
50 | niro | 1133 | mov cx,xfer_buf_seg |
51 | mov es,cx | ||
52 | mov [PauseBird],bx | ||
53 | niro | 532 | |
54 | .read_loop: | ||
55 | and si,si ; If SI == 0 then we have end of file | ||
56 | jz .eof | ||
57 | niro | 1133 | call [PauseBird] |
58 | niro | 532 | |
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 | niro | 1133 | pushf ; <C> EOF status |
75 | lea ebx,[edi+ecx] ; End of data | ||
76 | niro | 532 | .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 | niro | 1133 | inc cx |
83 | niro | 532 | jmp short .fix_slop |
84 | .noslop: | ||
85 | niro | 1133 | lea eax,[edi+ecx] |
86 | cmp eax,[MyHighMemSize] | ||
87 | ja .overflow | ||
88 | |||
89 | niro | 532 | 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 | niro | 1133 | popf ; <C> EOF status |
94 | niro | 532 | pop ecx ; <B> Byte count this round |
95 | pop eax ; <A> Total bytes to transfer | ||
96 | niro | 1133 | jc .eof |
97 | niro | 532 | sub eax,ecx |
98 | niro | 1133 | jnz .read_loop ; More to read... (if ZF=1 then CF=0) |
99 | niro | 532 | .eof: |
100 | niro | 1133 | pop es ; <AAA> ES |
101 | niro | 532 | ret |
102 | |||
103 | niro | 1133 | .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 |