wok diff linld/stuff/src/VCPI.ASM @ rev 24013
linld: add quick boot switch
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Feb 18 08:56:43 2021 +0000 (2021-02-18) |
parents | 5c1ce90eb1d6 |
children | c1844f1c4954 |
line diff
1.1 --- a/linld/stuff/src/VCPI.ASM Tue Jan 12 07:47:12 2021 +0000 1.2 +++ b/linld/stuff/src/VCPI.ASM Thu Feb 18 08:56:43 2021 +0000 1.3 @@ -102,21 +102,21 @@ 1.4 ;mov ax,0DE01h ;get vcpi pm interface 1.5 int 67h 1.6 xchg [si+vcpi_pm_entry-gdt_vcpi],ebx ; bx=((640*1024) shr 12) 1.7 - ;xor bx,bx 1.8 1.9 ; Check that mapping for low 640k is 1:1 1.10 pop si ; [page0_ofs] 1.11 ;cld 1.12 - mov cx,bx 1.13 + mov cx,bx 1.14 @@map_chk: 1.15 - lodsd 1.16 - shr eax,12 1.17 - add al,cl 1.18 - cmp al,((640*1024) shr 12) 1.19 - loope @@map_chk 1.20 -; Return 1.21 -@@bad: 1.22 + lodsd 1.23 + shr eax,12 1.24 + add ax,cx 1.25 + ;cmp eax,ebx ; ((640*1024) shr 12) 1.26 + cmp ax,bx ; ((640*1024) shr 12) 1.27 + loope @@map_chk 1.28 + ;pop di si 1.29 ret 1.30 + 1.31 endp _get_vcpi_interface 1.32 1.33 1.34 @@ -137,7 +137,7 @@ 1.35 ; Fix up base of some gdt descriptors 1.36 ; Note: 'add [dword xx.base0],edx' actually updates 24 bit quantity! 1.37 ; Do NOT replace with mov! 1.38 - mov ebx,10000h-28h 1.39 + mov bx,10000h-28h 1.40 add [dword si+sw2pm_addr-gdt_vcpi],edx 1.41 add [dword si+sw2pm_idtr_ptr-gdt_vcpi],edx 1.42 @@fixup: 1.43 @@ -146,11 +146,12 @@ 1.44 js @@fixup 1.45 mov bh,10h 1.46 extrn _heap_top:word 1.47 - movzx eax,[_heap_top] 1.48 + ;movzx eax,[_heap_top] 1.49 + mov ax,[_heap_top] 1.50 + add ax,bx ; assume _heap_top < 0f000h 1.51 add eax,edx 1.52 and ax,0f000h ;eax = 4k aligned linear addr of pagebuf 1.53 - add eax,ebx ;eax=page0 linear addr 1.54 - add [si+sw2pm_cr3-gdt_vcpi],eax 1.55 + add [si+sw2pm_cr3-gdt_vcpi],eax ;eax=page0 linear addr 1.56 mov edi,eax 1.57 sub edi,edx 1.58 mov al,3 ;add present+writable bits 1.59 @@ -181,7 +182,7 @@ 1.60 gdt_vcpi3 descr <?> ;0018 1.61 org $-8 1.62 global gdt_memcpy:descr 1.63 -gdt_memcpy descr <?> 1.64 +gdt_memcpy descr <?> ;null + gdt_abs 1.65 descriptor gdt_abs ,(data_seg+writable),priv0,is_present,0fffffh,(gran_page+use_32),0 1.66 ;Note: code/data segs must be flagged use16 (i.e. use ip/sp, not eip/esp) 1.67 ;Note: base addrs will be fixed up in prepare_vcpi() 1.68 @@ -208,7 +209,7 @@ 1.69 sw2pm_idtr_ptr dw offset idtr,0 1.70 sw2pm_ldtr dw 0 ;we don't need it 1.71 sw2pm_tr dw SEL_TSS ;vcpi thinks we need it... can't set to 0 1.72 -sw2pm_jumpaddr dd 0 1.73 +sw2pm_jumpaddr dw offset pmode,0 1.74 dw SEL_CODE 1.75 1.76 vcpi_pm_entry dd ((640*1024) shr 12) 1.77 @@ -218,20 +219,6 @@ 1.78 idt_lim dw 03ffh ;we won't enable ints, 1.79 idt_base dd 0 ; so let's leave it the same as for rm 1.80 1.81 -;*************************************************************** 1.82 -switch_to_pm: 1.83 - assume cs:DGROUP,ds:DGROUP 1.84 - mov edx,esi 1.85 - movzx_e si,<offset sw2pm_params> 1.86 - org $-4 1.87 -sw2pm_addr dd ? 1.88 - pop [word sw2pm_jumpaddr] ; CS:EIP of protected mode entry-point 1.89 - ;mov [word sw2pm_jumpaddr+2],0 1.90 - ;mov [word sw2pm_jumpaddr+4],SEL_CODE 1.91 - mov ax,0DE0Ch ; vcpi: switch to pm 1.92 - cli ; load GDTR LDTR TR need 16 bytes in SS:ESP 1.93 - int 67h ; EAX, ESI, DS, ES, FS, GS destroyed 1.94 - 1.95 1.96 ;*************************************************************** 1.97 ;void memcpy_vcpi(u32 dstofs,u16 srcseg,u32 srcofs); 1.98 @@ -270,14 +257,26 @@ 1.99 push bx ;\eip 1.100 push offset vcpi_ret ;/ 1.101 1.102 - call switch_to_pm ; EAX, EDX/ESI, DS, ES, FS, GS destroyed 1.103 + mov edx,esi 1.104 +switch_to_pm: 1.105 + movzx_e si,<offset sw2pm_params> 1.106 + org $-4 1.107 +sw2pm_addr dd ? 1.108 + mov ax,0DE0Ch ; vcpi: switch to pm 1.109 + cli ; load GDTR LDTR TR need 16 bytes in SS:ESP 1.110 + int 67h ; EAX, ESI, DS, ES, FS, GS destroyed 1.111 +pmode: 1.112 assume nothing 1.113 assume cs:DGROUP 1.114 1.115 ; Now we are in 16-bit protected mode 1.116 - mov bl,SEL_DATA 1.117 - mov ss,bx 1.118 - lea sp,[bp-8-9*4] 1.119 + push SEL_DATA 1.120 + pop ss 1.121 + test bx,bx 1.122 + jnz vm2rm_end 1.123 + 1.124 + ;lea sp,[bp-8-9*4] 1.125 + lea sp,[bp-9*4] 1.126 1.127 ; Call the routine (bp points to params on stack if any) 1.128 call do_memcpy_vcpi ; set ds=all_addrspace 1.129 @@ -287,7 +286,9 @@ 1.130 cli ; to be safe 1.131 clts ; 1.132 ; Go to vm86 mode. Sregs, esp, eflags (IF) restored from IRET stack 1.133 - jmp [pword cs:vcpi_pm_entry] 1.134 + call [pword cs:vcpi_pm_entry] 1.135 + ret 1.136 + ;jmp [pword cs:vcpi_pm_entry] 1.137 1.138 ;*************************************************************** 1.139 1.140 @@ -335,36 +336,37 @@ 1.141 ;*************************************************************** 1.142 ;****** Uses: Flags 1.143 ;*************************************************************** 1.144 - global _vm2rm:near 1.145 - proc _vm2rm near 1.146 + global _vm2rm:far 1.147 + proc _vm2rm far 1.148 1.149 assume cs:DGROUP,ds:DGROUP 1.150 + push ds 1.151 + ifdef QUICK_BOOT 1.152 + extrn _cmdnum:dword 1.153 +v86boot = (byte _cmdnum+24) 1.154 + cmp [v86boot],0 1.155 + jnz @vm2rm_ret 1.156 + endif 1.157 + mov bx,offset sssp 1.158 + mov [bx],sp 1.159 + ;mov [bx+2],ss 1.160 extrn sssp:dword 1.161 ifdef NO386 1.162 - p8086 1.163 extrn _vcpi:byte 1.164 - mov bx,offset sssp 1.165 test [_vcpi],bh 1.166 - jz vcpi_ret 1.167 else 1.168 - p386 1.169 smsw ax ;SMSW cannot be trapped! :-) 1.170 and al,1 ;MSW_PE 1.171 - jz vcpi_ret 1.172 - mov bx,offset sssp 1.173 endif 1.174 - p386 1.175 - pop ax ; convert 1.176 - push cs ; near call 1.177 - push ax ; to far call 1.178 - push ds 1.179 - mov [bx],sp 1.180 - ;mov [bx+2],ss 1.181 - 1.182 - call switch_to_pm ; EAX, EDX/ESI, DS, ES, FS, GS destroyed 1.183 + jz @vm2rm_ret 1.184 + jmp switch_to_pm ; EAX, ESI, DS, ES, FS, GS destroyed 1.185 +vm2rm_end: 1.186 assume nothing 1.187 assume cs:DGROUP 1.188 1.189 + ;push ss 1.190 + ;pop ds 1.191 + 1.192 ; Now we are in 16-bit protected mode 1.193 ; Black magic here 1.194 mov eax,cr0 1.195 @@ -374,6 +376,7 @@ 1.196 1.197 ; Now we are in rm, but not yet: have to restore sregs: 1.198 lss sp,[cs:bx] ; SS 1.199 +@vm2rm_ret: 1.200 pop ds ; DS 1.201 retf ; CS 1.202