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

linld: multi initrd support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Nov 22 21:19:01 2016 +0100 (2016-11-22)
parents
children 7f92b23984dc
line source
1 ;***************************************************************
2 ;****** This file is distributed under GPL
3 ;***************************************************************
4 ideal
5 %crefref
6 %noincl
7 %nomacs
8 p386
10 group DGROUP _TEXT,_BSS
11 assume cs:DGROUP,ds:DGROUP
13 segment _BSS byte public use16 'BSS'
15 global _pm_high:byte
16 global _pm:dword
18 ends _BSS
21 segment _TEXT byte public use16 'CODE'
23 ;***************************************************************
24 ;void set_sregs_jump_seg_ofs(u32 csip, u32 sssp);
25 ;****** Never returns
26 ;***************************************************************
27 global _set_sregs_jump_seg_ofs:near
28 proc _set_sregs_jump_seg_ofs near
30 extrn dos_shutdown:near
32 pop ax ;caller return address
33 test [byte _pm_high],-1 ; load high ? clear CF
34 jne isbzimage
35 ; finish loading
36 extrn @last_ditch$qv:near
37 push cs
38 call @last_ditch$qv
39 mov bx,[word _pm+2+2] ; get pm->fallback high word
40 ; self move
41 cld
42 ; push 9940h ; 5120 bytes for cmdline
43 push 9820h ; 512 bytes for cmdline
44 pop es ; min 1024 bytes for stack
45 xor si,si ; A000 -9400 -0800(>movedend)
46 xor di,di ; set ZF
47 ; mov cx,offset movedend
48 global _bss_end:byte
49 mov cx,offset _bss_end
50 rep
51 movsb
52 push es
53 call near doretf ; mov cs,es
54 stc
55 isbzimage:
56 pop cx ; ip
57 pop dx ; cs
58 pop ax ; sp
59 pop ss ; ss
60 xchg sp,ax
61 push dx cx
62 jnc nomove
63 push cs
64 pop ds
65 call near dos_shutdown
66 ; move zImage pm
67 mov ax,8
68 cwd
69 cmp bx,ax
70 jnb bufhigh
71 sub ax,bx
72 inc ax
73 bufhigh:
74 push ax
75 push dx ; size=up to 512k
76 push bx ; src ofs= pm.fallback
77 push dx
78 push dx ; srcseg=0
79 push 1 ; dst
80 push dx ; ofs=64k
81 push dx ; dstseg=0
82 extrn _memcpy32:near
83 call _memcpy32
84 add sp,16
86 ifndef noelks
87 push ss
88 pop ds
89 ifndef NO386
90 cmp [dword 1E6h],'SKLE'
91 else
92 cmp [word 1E6h],'LE'
93 jne notelks
94 cmp [word 1E8h],'SK'
95 endif
96 jne notelks
97 push 100h
98 pop es
99 xor si,si
100 xor di,di
101 mov ch,05h
102 rep
103 movsw
104 push es
105 pop ss
106 push 120h
107 push 0
108 notelks:
109 endif
111 nomove:
112 push ss
113 pop ds
114 push ss
115 pop es
116 push ss
117 pop fs
118 push ss
119 pop gs
120 assume nothing
121 assume cs:DGROUP
123 doretf:
124 retf
126 movedend:
127 endp _set_sregs_jump_seg_ofs
129 ends _TEXT
131 end
133 ;###### END OF FILE ############################################