wok-6.x annotate linld/stuff/src/JUMP.ASM @ rev 22176

linld: spare up to 30k more for zImage
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 08 20:55:40 2019 +0100 (2019-11-08)
parents 306a4bbdee7d
children 65ea21135647
rev   line source
pascal@19515 1 ;***************************************************************
pascal@19515 2 ;****** This file is distributed under GPL
pascal@19515 3 ;***************************************************************
pascal@19515 4 ideal
pascal@21984 5 %PAGESIZE 1000
pascal@19515 6 %crefref
pascal@19515 7 %noincl
pascal@19515 8 %nomacs
pascal@19636 9 ifdef NO386
pascal@19636 10 p8086
pascal@19636 11 else
pascal@19515 12 p386
pascal@19636 13 endif
pascal@19515 14
pascal@21757 15 group DGROUP _TEXT,_BSS
pascal@19515 16 assume cs:DGROUP,ds:DGROUP
pascal@19515 17
pascal@19515 18 segment _BSS byte public use16 'BSS'
pascal@19515 19
pascal@19899 20 global _imgs:dword
pascal@19515 21
pascal@19515 22 ends _BSS
pascal@19515 23
pascal@19515 24
pascal@19515 25 segment _TEXT byte public use16 'CODE'
pascal@19515 26
pascal@19905 27 ;***************************************************************
pascal@20473 28 ;void dos_shutdown()
pascal@20473 29 ;***************************************************************
pascal@20473 30
pascal@20473 31 macro dos_shutdown
pascal@21342 32 xor si,si
pascal@21342 33 mov ds,si
pascal@20473 34 ifndef NO386
pascal@21342 35 push [dword si+4] ; save step
pascal@21342 36 mov [word si+4],offset step19
pascal@20473 37 else
pascal@20473 38 mov ax,offset step19
pascal@21342 39 xchg ax,[word si+4]
pascal@21342 40 push [word si+6]
pascal@20473 41 push ax ; save step
pascal@20473 42 endif
pascal@20473 43 mov [word cs:sssp],sp
pascal@21342 44 ;cmp [byte si+7],0F0h
pascal@20473 45 ;jnc notdos
pascal@21342 46 mov [si+6],cs
pascal@20473 47 pushf
pascal@20473 48 pushf
pascal@20473 49 pop ax
pascal@20473 50 inc ah ; set TF
pascal@20473 51 push ax
pascal@20473 52 popf
pascal@21342 53 call [dword si+4*19h]
pascal@20473 54 notdos:
pascal@20473 55 ifndef NO386
pascal@20473 56 lss sp,[dword cs:sssp]
pascal@20473 57 else
pascal@20473 58 lds ax,[dword cs:sssp]
pascal@20473 59 push ds
pascal@20473 60 pop ss
pascal@20473 61 xchg ax,sp
pascal@20473 62 endif
pascal@21342 63 xor si,si
pascal@21342 64 mov ds,si
pascal@21342 65 pop [dword si+4] ; restore step
pascal@20473 66 endm
pascal@20473 67 macro step19code
pascal@20473 68 step19:
pascal@21342 69 push si
pascal@20473 70 push ds
pascal@21342 71 mov si,sp
pascal@21342 72 lds si,[dword ss:si+4] ; read cs:ip
pascal@21342 73 cmp [word si],19CDh ; int 19h ?
pascal@20473 74 pop ds
pascal@21342 75 pop si
pascal@20473 76 je notdos
pascal@20473 77 iret
pascal@20473 78 endm
pascal@20473 79
pascal@20473 80
pascal@20473 81 ;***************************************************************
pascal@19905 82 ;void boot_kernel();
pascal@19905 83 ;****** Never returns
pascal@19905 84 ;***************************************************************
pascal@19903 85 global _boot_kernel:near
pascal@19905 86 proc _boot_kernel near
pascal@19905 87
pascal@21757 88 ifdef NO386
pascal@20142 89 p8086
pascal@19903 90 else
pascal@20142 91 p386
pascal@19903 92 endif
pascal@20473 93 ;cli ; we start doing destructive things to DOS
pascal@21757 94 extrn sssp:word
pascal@21757 95 mov es,[sssp+2]
pascal@19571 96 push es
pascal@19571 97 pop ss
pascal@19571 98 mov sp,0A000h
pascal@19636 99 extrn _rm_size:word
pascal@20745 100 ifdef NO386
pascal@22019 101 mov si,offset _rm_size-4 ; _rm_size, _pm_high, _rm_buf
pascal@22019 102 lodsw
pascal@22019 103 xchg ax,bx
pascal@20745 104 lodsw
pascal@20745 105 push ax ; _csip high
pascal@22019 106 push bx ; _csip low
pascal@22019 107 lodsw ; skip _rm_size
pascal@20745 108 else
pascal@21757 109 mov si,offset _rm_size+2 ; _rm_size, _pm_high, _rm_buf
pascal@21757 110 push [dword si-6] ; _csip
pascal@20745 111 endif
pascal@19636 112 lodsb ; _pm_high
pascal@22019 113
pascal@22019 114 ifdef NO386
pascal@22019 115 mov cx,ss
pascal@22019 116 add ch,9
pascal@22019 117 push cx ; topseg()+0x0900
pascal@22019 118 else
pascal@22019 119 push 9800h+(4096/16) ; 4096 bytes for cmdline
pascal@22019 120 endif
pascal@22019 121
pascal@19571 122 extrn _cmdline:word
pascal@19571 123 mov si,[_cmdline]
pascal@19571 124 mov di,8000h
pascal@19571 125 mov ch,10h ; 4k
pascal@19571 126 rep
pascal@19571 127 movsb
pascal@22019 128
pascal@22019 129 or cl,al ; load high ?
pascal@22019 130 inc cx
pascal@22019 131 push cx
pascal@22019 132 mov ax,[word ss:024Ch]
pascal@22019 133 xor ax,2b30h ; ipxe ?
pascal@22019 134 loopne @@notipxe
pascal@22019 135
pascal@22019 136 ; finish loading
pascal@22019 137 extrn @last_ditch$qv:near
pascal@22008 138 push cs
pascal@22008 139 call @last_ditch$qv
pascal@22152 140 dos_shutdown ; clear si; ds=0; kill VCPI
pascal@22152 141 push cs
pascal@22152 142 pop ds
pascal@22019 143
pascal@22019 144 @@notipxe:
pascal@22019 145 pop cx
pascal@22019 146 pop es ; min 2048 bytes for stack
pascal@22019 147 loop @@isbzimage
pascal@22019 148
pascal@19515 149 ; self move
pascal@19571 150 ;cld
pascal@20534 151 extrn gdt_data
pascal@20534 152 mov cx,offset gdt_data+8
pascal@21342 153 xor di,di ; A000 -9000 -0800(>movedend)
pascal@19515 154 rep
pascal@19515 155 movsb
pascal@21628 156 mov si,offset _imgs+2
pascal@21628 157 lodsw
pascal@21628 158 xchg ax,bx ; get pm->fallback low word
pascal@21628 159 lodsw ; get pm->fallback high word
pascal@22176 160 ifdef MOVE_SETUP
pascal@22176 161 mov si,0
pascal@22176 162 global _rm_offset:word
pascal@22176 163 org $-2
pascal@22176 164 _rm_offset dw ?
pascal@22176 165 endif
pascal@20484 166 push es
pascal@20484 167 call near @@isbzimage ; pop cs ; ds=es=ss
pascal@20477 168
pascal@20477 169 ; prepare memcpy32 size & srcofs param to move zImage pm
pascal@21781 170 ifndef NO386
pascal@21781 171 push 8 ; size hi
pascal@21781 172 else
pascal@20477 173 mov dx,8
pascal@20477 174 push dx ; size hi
pascal@21781 175 endif
pascal@20477 176 push cx ; size lo=up to 512k
pascal@21628 177 push ax ; src ofs hi = pm.fallback
pascal@20477 178
pascal@19538 179 ;in al,70h
pascal@19538 180 ;or al,80h ; disable NMI
pascal@19538 181 ;out 70h,al
pascal@20477 182
pascal@21628 183 push bx ; src ofs lo
pascal@20485 184 xor di,di
pascal@20481 185 push di ; src seg=0
pascal@21628 186 inc cx
pascal@21628 187 push cx ; dst ofs hi
pascal@20481 188 push di ; dst ofs lo : 64k
pascal@20528 189 extrn memcpy32:near
pascal@20528 190 call memcpy32
pascal@19515 191
pascal@22176 192 ifdef MOVE_SETUP
pascal@22176 193 ;xor di,di
pascal@22176 194 mov cx,8000h
pascal@22176 195 ;sub cx,si
pascal@22176 196 rep
pascal@22176 197 movsb
pascal@22176 198 endif
pascal@22176 199
pascal@19515 200 ifndef noelks
pascal@19515 201 ifndef NO386
pascal@19515 202 cmp [dword 1E6h],'SKLE'
pascal@20473 203 jne @@notelks
pascal@20481 204 xor si,si
pascal@19515 205 else
pascal@20481 206 mov si,1E6h
pascal@20481 207 lodsw
pascal@20481 208 cmp ax,'LE'
pascal@19905 209 jne @@notelks
pascal@20481 210 lodsw
pascal@20481 211 xor ax,'SK'
pascal@20473 212 jne @@notelks
pascal@20481 213 xchg ax,si
pascal@19515 214 endif
pascal@21988 215 mov cx,100h ; DS=ES=SS=0100
pascal@21988 216 mov ss,cx
pascal@21988 217 mov es,cx
pascal@21998 218 mov cl,20h ; CS=0120
pascal@21998 219 push cx
pascal@20481 220 push si ; IP=0000
pascal@21998 221 mov ch,3Fh ; 05h min, 3Fh max
pascal@19515 222 rep
pascal@19515 223 movsw
pascal@19905 224 @@notelks:
pascal@19515 225 endif
pascal@19905 226 @@isbzimage:
pascal@19515 227 push ss
pascal@19515 228 pop ds
pascal@20475 229 push ss
pascal@20475 230 pop es
pascal@19636 231 ifndef NO386
pascal@19515 232 push ss
pascal@19515 233 pop fs
pascal@19515 234 push ss
pascal@19515 235 pop gs
pascal@19636 236 endif
pascal@19515 237 assume nothing
pascal@19515 238 assume cs:DGROUP
pascal@19515 239 retf
pascal@19515 240
pascal@20473 241 step19code
pascal@20477 242
pascal@20477 243 endp _boot_kernel
pascal@20477 244
pascal@19515 245 movedend:
pascal@19515 246
pascal@19515 247 ends _TEXT
pascal@19515 248
pascal@19515 249 end
pascal@19515 250
pascal@19515 251 ;###### END OF FILE ############################################