wok view linld/stuff/src/JUMP.ASM @ rev 19903

linld/tazboot: fix memcpy32
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 09 12:22:58 2017 +0200 (2017-04-09)
parents df6498976257
children e17c7b3f75a8
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 ifdef NO386
9 p8086
10 else
11 p386
12 endif
14 group DGROUP _TEXT,_DATA,_BSS
15 assume cs:DGROUP,ds:DGROUP
17 segment _DATA byte public use16 'DATA'
19 overflow db "Loaded too close to 9000:0",0
21 ends _DATA
23 segment _BSS byte public use16 'BSS'
25 global _imgs:dword
27 ends _BSS
30 segment _TEXT byte public use16 'CODE'
32 global _boot_kernel:near
33 _boot_kernel:
34 ; Shrink stack: we won't need much of it now and have no malloc() plans
35 extrn _heap_top:word
36 mov ax,[_heap_top]
37 inc ah
38 cmp ax,sp
39 ja samesp
40 xchg ax,sp
41 samesp:
42 ifdef NO386
43 extrn _topseg:near
44 call near _topseg
45 mov es,ax
46 xchg ax,bx
47 mov cl,4
48 mov ax,sp
49 shr ax,cl
50 else
51 mov bx,9000h
52 mov es,bx
53 mov ax,sp
54 shr ax,4
55 endif
56 mov dx,cs
57 add ax,dx
58 cmp ax,bx
59 jb nooverflow
60 ; Oops! We can stomp on our toes... better stop now
61 mov bx,offset overflow
62 extrn die:near
63 jmp near die
64 nooverflow:
65 ;***************************************************************
66 ;void set_sregs_jump_seg_ofs(u32 csip);
67 ;****** Never returns
68 ;***************************************************************
69 global _set_sregs_jump_seg_ofs:near
70 proc _set_sregs_jump_seg_ofs near
72 extrn dos_shutdown:near
74 cli ; we start doing destructive things to DOS
75 push es
76 pop ss
77 mov sp,0A000h
78 extrn _csip:dword
79 push [dword _csip]
80 extrn _rm_size:word
81 mov si,offset _rm_size ; _rm_size, _pm_high, _rm_buf
82 lodsw
83 xchg ax,cx ; _rm_size
84 lodsb ; _pm_high
85 mov si,[si] ; _rm_buf
86 xor di,di
87 ;cld
88 rep
89 movsb
90 extrn _cmdline:word
91 mov si,[_cmdline]
92 mov di,8000h
93 mov ch,10h ; 4k
94 rep
95 movsb
96 cmp al,cl ; load high ?
97 jne isbzimage
98 ifdef NO386
99 add bh,9
100 push bx ; topseg()+0x0900
101 else
102 push 9900h ; 4096 bytes for cmdline
103 ;push 9820h ; 512 bytes for cmdline
104 endif
105 ; finish loading
106 extrn @last_ditch$qv:near
107 push cs
108 call @last_ditch$qv
109 mov ax,[word _imgs+2+2] ; get pm->fallback high word
110 ; self move
111 ;cld
112 pop es ; min 2048 bytes for stack
113 xor si,si ; A000 -9000 -0800(>movedend)
114 xor di,di ; set ZF
115 mov cx,offset movedend
116 global _bss_end:byte
117 ;mov cx,offset _bss_end
118 rep
119 movsb
120 push es
121 call near doretf ; mov cs,es
122 push ss
123 pop es
124 push cs
125 pop ds
126 push ax
127 call near dos_shutdown
128 ;in al,70h
129 ;or al,80h ; disable NMI
130 ;out 70h,al
131 pop bx
132 ; move zImage pm
133 mov ax,8
134 cwd ; clear dx
135 cmp bx,ax
136 ja bufhigh
137 sub ax,bx
138 inc ax
139 bufhigh:
140 push ax
141 push dx ; size=up to 512k
142 push bx ; src ofs= pm.fallback
143 push dx
144 push dx ; srcseg=0
145 ifdef NO386
146 inc dx
147 push dx ; dst
148 dec dx
149 else
150 push 1 ; dst
151 endif
152 push dx ; ofs=64k
153 extrn _memcpy32:near
154 call _memcpy32
155 add sp,14
157 ifndef noelks
158 push ss
159 pop ds
160 ifndef NO386
161 cmp [dword 1E6h],'SKLE'
162 else
163 cmp [word 1E6h],'LE'
164 jne notelks
165 cmp [word 1E8h],'SK'
166 endif
167 jne notelks
168 ifdef NO386
169 mov cx,120h
170 push cx
171 mov cl,0h
172 push cx
173 else
174 push 120h
175 push 100h
176 endif
177 pop es
178 xor si,si
179 xor di,di
180 mov ch,05h
181 rep
182 movsw
183 push es
184 pop ss
185 push cx
186 notelks:
187 endif
189 isbzimage:
190 push ss
191 pop ds
192 ;push ss
193 ;pop es
194 ifndef NO386
195 push ss
196 pop fs
197 push ss
198 pop gs
199 endif
200 assume nothing
201 assume cs:DGROUP
203 doretf:
204 retf
206 movedend:
207 endp _set_sregs_jump_seg_ofs
209 ends _TEXT
211 end
213 ;###### END OF FILE ############################################