strreplace: clean up and simplify
[profile/ivi/syslinux.git] / core / loadhigh.inc
1 ;; -----------------------------------------------------------------------
2 ;;
3 ;;   Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4 ;;   Copyright 2009-2010 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 .text16
21
22 ;
23 ; load_high:    loads (the remainder of) a file into high memory.
24 ;
25 ;               Assumes CS == DS.
26 ;
27 ; Inputs:       SI  = file handle/cluster pointer
28 ;               EDI = target address in high memory
29 ;               EAX = maximum number of bytes to load
30 ;               DX  = zero-padding mask (e.g. 0003h for pad to dword)
31 ;               BX  = subroutine to call at the top of each loop
32 ;                     (to print status and check for abort)
33 ;               [MyHighMemSize] = maximum load address
34 ;
35 ; Outputs:      SI  = file handle/cluster pointer
36 ;               EBX = first untouched address (not including padding)
37 ;               EDI = first untouched address (including padding)
38 ;               CF  = reached EOF
39 ;
40                 extern pm_load_high
41 load_high:
42                 push ebp
43                 mov ebp,[MyHighMemSize]
44                 pm_call pm_load_high
45                 pop ebp
46                 jo .overflow
47                 ret
48
49 .overflow:      mov si,err_nohighmem
50                 jmp abort_load
51
52                 section .data16
53 err_nohighmem   db CR, LF
54                 db 'Not enough memory to load specified image.', CR, LF, 0
55
56                 section .bss16
57                 alignb 2
58 PauseBird       resw 1
59
60                 section .text16