forked from KolibriOS/kolibrios
* V86 manager
* support of drives visible by BIOS through V86 mode * shutdown fixes * background redraw fixes * when booting from CD/DVD, load all floppy by tracks, not only used sectors git-svn-id: svn://kolibrios.org@709 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
73451d6086
commit
ebeed28881
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -10,6 +10,7 @@ $Revision$
|
||||
|
||||
; Low-level driver for HDD access
|
||||
; DMA support by Mario79
|
||||
; Access through BIOS by diamond
|
||||
|
||||
align 4
|
||||
hd_read:
|
||||
@ -45,6 +46,9 @@ hd_read:
|
||||
call find_empty_slot ; ret in edi
|
||||
cmp [hd_error],0
|
||||
jne return_01
|
||||
; Read through BIOS?
|
||||
cmp [hdpos], 0x80
|
||||
jae .bios
|
||||
; DMA read is permitted if [allow_dma_access]=1 or 2
|
||||
cmp [allow_dma_access], 2
|
||||
ja .nodma
|
||||
@ -54,6 +58,9 @@ hd_read:
|
||||
jmp @f
|
||||
.nodma:
|
||||
call hd_read_pio
|
||||
jmp @f
|
||||
.bios:
|
||||
call bd_read
|
||||
@@:
|
||||
; lea esi,[edi*8+HD_CACHE]
|
||||
; push eax
|
||||
@ -675,6 +682,8 @@ write_cache_sector:
|
||||
mov [cache_chain_size],1
|
||||
mov [cache_chain_pos],edi
|
||||
write_cache_chain:
|
||||
cmp [hdpos], 0x80
|
||||
jae bd_write_cache_chain
|
||||
push esi
|
||||
mov eax, IDE_descriptor_table
|
||||
mov edx,eax
|
||||
@ -773,3 +782,144 @@ uglobal
|
||||
IDEContrRegsBaseAddr dw ?
|
||||
endg
|
||||
; \end{Mario79}
|
||||
|
||||
; \begin{diamond}
|
||||
uglobal
|
||||
bios_hdpos dd 0 ; 0 is invalid value for [hdpos]
|
||||
bios_cur_sector dd ?
|
||||
bios_read_len dd ?
|
||||
endg
|
||||
bd_read:
|
||||
push eax
|
||||
push edx
|
||||
mov edx, [bios_hdpos]
|
||||
cmp edx, [hdpos]
|
||||
jne .notread
|
||||
mov edx, [bios_cur_sector]
|
||||
cmp eax, edx
|
||||
jb .notread
|
||||
add edx, [bios_read_len]
|
||||
dec edx
|
||||
cmp eax, edx
|
||||
ja .notread
|
||||
sub eax, [bios_cur_sector]
|
||||
shl eax, 9
|
||||
add eax, (OS_BASE+0x9C000)
|
||||
push ecx esi edi
|
||||
mov esi, eax
|
||||
shl edi, 9
|
||||
; add edi, HD_CACHE+0x10000
|
||||
push eax
|
||||
call calculate_cache_2
|
||||
add edi,eax
|
||||
pop eax
|
||||
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
pop edi esi ecx
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
.notread:
|
||||
push ecx
|
||||
mov dl, 42h
|
||||
mov ecx, 16
|
||||
call int13_call
|
||||
pop ecx
|
||||
test eax, eax
|
||||
jnz .v86err
|
||||
test edx, edx
|
||||
jz .readerr
|
||||
mov [bios_read_len], edx
|
||||
mov edx, [hdpos]
|
||||
mov [bios_hdpos], edx
|
||||
pop edx
|
||||
pop eax
|
||||
mov [bios_cur_sector], eax
|
||||
jmp bd_read
|
||||
.readerr:
|
||||
.v86err:
|
||||
mov [hd_error], 1
|
||||
jmp hd_read_error
|
||||
|
||||
bd_write_cache_chain:
|
||||
pusha
|
||||
mov esi, [cache_chain_pos]
|
||||
shl esi, 9
|
||||
call calculate_cache_2
|
||||
add esi, eax
|
||||
mov edi, OS_BASE + 0x9C000
|
||||
movzx ecx, [cache_chain_size]
|
||||
push ecx
|
||||
shl ecx, 9-2
|
||||
rep movsd
|
||||
pop ecx
|
||||
mov dl, 43h
|
||||
mov eax, [cache_chain_ptr]
|
||||
mov eax, [eax]
|
||||
call int13_call
|
||||
test eax, eax
|
||||
jnz .v86err
|
||||
cmp edx, ecx
|
||||
jnz .writeerr
|
||||
popa
|
||||
ret
|
||||
.v86err:
|
||||
.writeerr:
|
||||
popa
|
||||
mov [hd_error], 1
|
||||
jmp hd_write_error
|
||||
|
||||
uglobal
|
||||
int13_regs_in rb v86_regs.size
|
||||
int13_regs_out rb v86_regs.size
|
||||
endg
|
||||
|
||||
int13_call:
|
||||
; Because this code uses fixed addresses,
|
||||
; it can not be run simultaniously by many threads.
|
||||
; In current implementation it is protected by common mutex 'hd1_status'
|
||||
mov word [BOOT_VAR + 510h], 10h ; packet length
|
||||
mov word [BOOT_VAR + 512h], cx ; number of sectors
|
||||
mov dword [BOOT_VAR + 514h], 9C000000h ; buffer 9C00:0000
|
||||
mov dword [BOOT_VAR + 518h], eax
|
||||
and dword [BOOT_VAR + 51Ch], 0
|
||||
push ebx ecx esi edi
|
||||
mov ebx, int13_regs_in
|
||||
mov edi, ebx
|
||||
mov ecx, v86_regs.size/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
mov byte [ebx+v86_regs.eax+1], dl
|
||||
mov eax, [hdpos]
|
||||
lea eax, [BiosDisksData+(eax-80h)*4]
|
||||
mov dl, [eax]
|
||||
mov byte [ebx+v86_regs.edx], dl
|
||||
movzx edx, byte [eax+1]
|
||||
; mov dl, 5
|
||||
test edx, edx
|
||||
jnz .hasirq
|
||||
dec edx
|
||||
jmp @f
|
||||
.hasirq:
|
||||
pushad
|
||||
stdcall enable_irq, edx
|
||||
popad
|
||||
@@:
|
||||
mov word [ebx+v86_regs.esi], 510h
|
||||
mov word [ebx+v86_regs.esp], 900h
|
||||
mov word [ebx+v86_regs.eip], 500h
|
||||
mov [ebx+v86_regs.eflags], 20200h
|
||||
mov esi, [sys_v86_machine]
|
||||
mov ecx, 0x502
|
||||
call v86_start
|
||||
and [bios_hdpos], 0
|
||||
pop edi esi ecx ebx
|
||||
movzx edx, byte [BOOT_VAR + 512h]
|
||||
test byte [int13_regs_out+v86_regs.eflags], 1
|
||||
jnz @f
|
||||
mov edx, ecx
|
||||
@@:
|
||||
ret
|
||||
; \end{diamond}
|
||||
|
@ -37,11 +37,14 @@ write_cache_more:
|
||||
jb danger
|
||||
cmp eax,[PARTITION_END]
|
||||
ja danger
|
||||
cmp [hdpos], 0x80
|
||||
jae @f
|
||||
; DMA write is permitted only if [allow_dma_access]=1
|
||||
cmp [allow_dma_access], 2
|
||||
jae .nodma
|
||||
cmp [dma_hdd], 1
|
||||
jnz .nodma
|
||||
@@:
|
||||
; Ž¡ê¥¤¨ï¥¬ § ¯¨áì 楯®çª¨ ¯®á«¥¤®¢ ⥫ìëå ᥪâ®à®¢ ¢ ®¤® ®¡à 饨¥ ª ¤¨áªã
|
||||
cmp ecx, 1
|
||||
jz .nonext
|
||||
@ -60,7 +63,7 @@ write_cache_more:
|
||||
mov [cache_chain_ptr], esi
|
||||
@@:
|
||||
inc [cache_chain_size]
|
||||
cmp [cache_chain_size], 64
|
||||
cmp [cache_chain_size], 16
|
||||
jnz .continue
|
||||
jmp .write_chain
|
||||
.nonext:
|
||||
@ -174,6 +177,8 @@ calculate_cache:
|
||||
mov esi,[cache_ide2_data_pointer]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
@ -183,6 +188,31 @@ calculate_cache:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size-cache_ide0+eax]
|
||||
mov esi,[cache_ide0_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size-cache_ide0+eax]
|
||||
mov esi,[cache_ide0_data_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_1:
|
||||
@ -219,6 +249,8 @@ calculate_cache_1:
|
||||
mov esi,[cache_ide2_data_pointer]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov esi,[cache_ide3_pointer]
|
||||
@ -226,6 +258,30 @@ calculate_cache_1:
|
||||
.ide3_appl_data:
|
||||
mov esi,[cache_ide3_data_pointer]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov esi,[cache_ide0_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov esi,[cache_ide0_data_pointer-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_2:
|
||||
@ -262,6 +318,8 @@ calculate_cache_2:
|
||||
mov eax,[cache_ide2_appl_data]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov eax,[cache_ide3_system_data]
|
||||
@ -269,6 +327,26 @@ calculate_cache_2:
|
||||
.ide3_appl_data:
|
||||
mov eax,[cache_ide3_appl_data]
|
||||
ret
|
||||
.noide:
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov eax,[cache_ide0_system_data-cache_ide0+eax]
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov eax,[cache_ide0_appl_data-cache_ide0+eax]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_3:
|
||||
@ -313,6 +391,8 @@ calculate_cache_3:
|
||||
mov edi,[cache_ide2_appl_search_start]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov ecx,[cache_ide3_system_sad_size]
|
||||
@ -322,6 +402,31 @@ calculate_cache_3:
|
||||
mov ecx,[cache_ide3_appl_sad_size]
|
||||
mov edi,[cache_ide3_appl_search_start]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov ecx,[cache_ide0_system_sad_size-cache_ide0+eax]
|
||||
mov edi,[cache_ide0_search_start-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov ecx,[cache_ide0_appl_sad_size-cache_ide0+eax]
|
||||
mov edi,[cache_ide0_appl_search_start-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_4:
|
||||
@ -358,6 +463,8 @@ calculate_cache_4:
|
||||
cmp edi,[cache_ide2_appl_sad_size]
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
cmp edi,[cache_ide3_system_sad_size]
|
||||
@ -365,6 +472,30 @@ calculate_cache_4:
|
||||
.ide3_appl_data:
|
||||
cmp edi,[cache_ide3_appl_sad_size]
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
cmp edi,[cache_ide0_system_sad_size-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
cmp edi,[cache_ide0_appl_sad_size-cache_ide0+eax]
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
calculate_cache_5:
|
||||
@ -401,6 +532,8 @@ calculate_cache_5:
|
||||
mov [cache_ide2_appl_search_start],edi
|
||||
ret
|
||||
.ide3:
|
||||
cmp [hdpos],4
|
||||
jne .noide
|
||||
cmp [hdd_appl_data],0
|
||||
jne .ide3_appl_data
|
||||
mov [cache_ide3_search_start],edi
|
||||
@ -408,6 +541,29 @@ calculate_cache_5:
|
||||
.ide3_appl_data:
|
||||
mov [cache_ide3_appl_search_start],edi
|
||||
ret
|
||||
.noide:
|
||||
push eax
|
||||
mov eax,[hdpos]
|
||||
sub eax,80h
|
||||
cmp byte [BiosDisksData+eax*4+2], -1
|
||||
jz @f
|
||||
movzx eax,byte [BiosDisksData+eax*4+2]
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,cache_ide0
|
||||
jmp .get
|
||||
@@:
|
||||
imul eax,cache_ide1-cache_ide0
|
||||
add eax,BiosDiskCaches
|
||||
.get:
|
||||
cmp [hdd_appl_data],0
|
||||
jne .bd_appl_data
|
||||
mov [cache_ide0_search_start-cache_ide0+eax],edi
|
||||
pop eax
|
||||
ret
|
||||
.bd_appl_data:
|
||||
mov [cache_ide0_appl_search_start-cache_ide0+eax],edi
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
|
@ -341,7 +341,7 @@ cfgmanager:
|
||||
; settings:
|
||||
; a) preboot_graph = graphical mode
|
||||
; preboot_gprobe = probe this mode?
|
||||
; b) preboot_dma = use DMA access?
|
||||
; b) preboot_biosdisk = use BIOS disks through V86 emulation?
|
||||
; c) preboot_vrrm = use VRR?
|
||||
; d) preboot_device = from what boot?
|
||||
mov di, preboot_graph
|
||||
@ -381,9 +381,11 @@ cfgmanager:
|
||||
@@:
|
||||
mov [di], al
|
||||
.preboot_gr_end:
|
||||
; following 6 lines set variables to 1 if its current value is 0
|
||||
; following 8 lines set variables to 1 if its current value is 0
|
||||
cmp [di+preboot_dma-preboot_graph], 1
|
||||
adc [di+preboot_dma-preboot_graph], 0
|
||||
cmp [di+preboot_biosdisk-preboot_graph], 1
|
||||
adc [di+preboot_biosdisk-preboot_graph], 0
|
||||
cmp [di+preboot_vrrm-preboot_graph], 1
|
||||
adc [di+preboot_vrrm-preboot_graph], 0
|
||||
cmp [di+preboot_device-preboot_graph], 1
|
||||
@ -438,16 +440,19 @@ cfgmanager:
|
||||
.c:
|
||||
mov si, linef
|
||||
call printplain
|
||||
mov si, dma_msg
|
||||
call print
|
||||
cmp [preboot_dma], 2
|
||||
mov si, on_msg
|
||||
jb @f
|
||||
mov si, off_msg
|
||||
ja @f
|
||||
mov si, readonly_msg
|
||||
@@:
|
||||
call printplain
|
||||
; mov si, dma_msg
|
||||
; call print
|
||||
; cmp [preboot_dma], 2
|
||||
; mov si, on_msg
|
||||
; jb @f
|
||||
; mov si, off_msg
|
||||
; ja @f
|
||||
; mov si, readonly_msg
|
||||
;@@:
|
||||
; call printplain
|
||||
mov si, usebd_msg
|
||||
cmp [preboot_biosdisk], 1
|
||||
call .say_on_off
|
||||
mov si, vrrm_msg
|
||||
cmp [preboot_vrrm], 1
|
||||
call .say_on_off
|
||||
@ -530,11 +535,16 @@ cfgmanager:
|
||||
jmp .d
|
||||
.change_b:
|
||||
_setcursor 15,0
|
||||
mov si, ask_dma
|
||||
; mov si, ask_dma
|
||||
; call print
|
||||
; mov bx, '13'
|
||||
; call getkey
|
||||
; mov [preboot_dma], al
|
||||
mov si, ask_bd
|
||||
call print
|
||||
mov bx, '13'
|
||||
mov bx, '12'
|
||||
call getkey
|
||||
mov [preboot_dma], al
|
||||
mov [preboot_biosdisk], al
|
||||
_setcursor 11,0
|
||||
jmp .d
|
||||
.change_c:
|
||||
@ -817,6 +827,68 @@ bppl:
|
||||
xor ax, ax ; reset drive
|
||||
xor dx, dx
|
||||
int 0x13
|
||||
; do we boot from CD-ROM?
|
||||
mov ah, 41h
|
||||
mov bx, 55AAh
|
||||
xor dx, dx
|
||||
int 0x13
|
||||
jc .nocd
|
||||
cmp bx, 0AA55h
|
||||
jnz .nocd
|
||||
mov ah, 48h
|
||||
push ds
|
||||
push es
|
||||
pop ds
|
||||
mov si, 0xa000
|
||||
mov word [si], 30
|
||||
int 0x13
|
||||
pop ds
|
||||
jc .nocd
|
||||
push ds
|
||||
lds si, [es:si+26]
|
||||
test byte [ds:si+10], 40h
|
||||
pop ds
|
||||
jz .nocd
|
||||
; yes - read all floppy by 18 sectors
|
||||
mov cx, 0x0001 ; startcyl,startsector
|
||||
.a1:
|
||||
push cx dx
|
||||
mov al, 18
|
||||
mov bx, 0xa000
|
||||
call boot_read_floppy
|
||||
mov si, movedesc
|
||||
push es
|
||||
push ds
|
||||
pop es
|
||||
mov cx, 256*18
|
||||
mov ah, 0x87
|
||||
int 0x15
|
||||
pop es
|
||||
pop dx cx
|
||||
test ah, ah
|
||||
jnz sayerr_floppy
|
||||
add dword [si+8*3+2], 512*18
|
||||
inc dh
|
||||
cmp dh, 2
|
||||
jnz .a1
|
||||
mov dh, 0
|
||||
inc ch
|
||||
cmp ch, 80
|
||||
jae ok_sys_on_floppy
|
||||
pusha
|
||||
mov al, ch
|
||||
shr ch, 2
|
||||
add al, ch
|
||||
aam
|
||||
xchg al, ah
|
||||
add ax, '00'
|
||||
mov si, pros
|
||||
mov [si], ax
|
||||
call printplain
|
||||
popa
|
||||
jmp .a1
|
||||
.nocd:
|
||||
; no - read only used sectors from floppy
|
||||
; now load floppy image to memory
|
||||
; at first load boot sector and first FAT table
|
||||
mov cx, 0x0001 ; startcyl,startsector
|
||||
@ -1007,6 +1079,7 @@ sayerr_floppy:
|
||||
; readdone:
|
||||
; pop ax
|
||||
|
||||
ok_sys_on_floppy:
|
||||
mov si, backspace2
|
||||
call printplain
|
||||
mov si, okt
|
||||
|
@ -36,7 +36,8 @@ vrrmprint db "Apply VRR? (picture frequency greater than 60Hz"
|
||||
; db " Select port [1-3]: ",0
|
||||
;no_com1 db 13,10,186, " No COM1 mouse",0
|
||||
;no_com2 db 13,10,186, " No COM2 mouse",0
|
||||
ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0
|
||||
;ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0
|
||||
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
|
||||
;gr_direct db 186," Use direct LFB writing? "
|
||||
; db "[1-yes/2-no] ? ",0
|
||||
;mem_model db 13,10,186," Motherboard memory [1-16 Mb / 2-32 Mb / "
|
||||
@ -84,10 +85,11 @@ mode9 db "320x200, EGA/CGA 256 colors",0
|
||||
mode10 db "640x480, VGA 16 colors",0
|
||||
probeno_msg db " (standard mode)",0
|
||||
probeok_msg db " (check nonstandard modes)",0
|
||||
dma_msg db " [b] Use DMA for HDD access:",0
|
||||
;dma_msg db " [b] Use DMA for HDD access:",0
|
||||
usebd_msg db " [b] Add disks visible by BIOS:",0
|
||||
on_msg db " on",13,10,0
|
||||
off_msg db " off",13,10,0
|
||||
readonly_msg db " only for reading",13,10,0
|
||||
;readonly_msg db " only for reading",13,10,0
|
||||
vrrm_msg db " [c] Use VRR:",0
|
||||
preboot_device_msg db " [d] Floppy image: ",0
|
||||
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
|
||||
|
@ -36,7 +36,8 @@ vrrmprint db "Kinnita VRR? (ekraani sagedus suurem kui 60Hz"
|
||||
; db " Vali port [1-3]: ",0
|
||||
;no_com1 db 13,10,186, " No COM1 mouse",0
|
||||
;no_com2 db 13,10,186, " No COM2 mouse",0
|
||||
ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0
|
||||
;ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0
|
||||
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
|
||||
;gr_direct db 186," Use direct LFB writing? "
|
||||
; db "[1-yes/2-no] ? ",0
|
||||
;mem_model db 13,10,186," Motherboard memory [1-16 Mb / 2-32 Mb / "
|
||||
@ -84,10 +85,11 @@ mode9 db "320x200, EGA/CGA 256 v
|
||||
mode10 db "640x480, VGA 16 värvi",0
|
||||
probeno_msg db " (standard reziim)",0
|
||||
probeok_msg db " (kontrolli ebastandardseid reziime)",0
|
||||
dma_msg db " [b] Kasuta DMA'd HDD juurdepääsuks:",0
|
||||
;dma_msg db " [b] Kasuta DMA'd HDD juurdepääsuks:",0
|
||||
usebd_msg db " [b] Add disks visible by BIOS:",0
|
||||
on_msg db " sees",13,10,0
|
||||
off_msg db " väljas",13,10,0
|
||||
readonly_msg db " ainult lugemiseks",13,10,0
|
||||
;readonly_msg db " ainult lugemiseks",13,10,0
|
||||
vrrm_msg db " [c] Kasuta VRR:",0
|
||||
preboot_device_msg db " [d] Disketi kujutis: ",0
|
||||
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
|
||||
|
@ -41,7 +41,8 @@ vrrmprint db "VRR verwenden? (Monitorfrequenz groesser als 60Hz"
|
||||
; db " Waehle Port [1-3]: ",0
|
||||
;no_com1 db 13,10,186, " Keine COM1 Maus",0
|
||||
;no_com2 db 13,10,186, " Keine COM2 Maus",0
|
||||
ask_dma db "Nutze DMA zum HDD Zugriff? [1-ja, 2-allein fur Lesen, 3-nein]: ",0
|
||||
;ask_dma db "Nutze DMA zum HDD Zugriff? [1-ja, 2-allein fur Lesen, 3-nein]: ",0
|
||||
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
|
||||
;gr_direct db 186," Benutze direct LFB? "
|
||||
; db "[1-ja/2-nein] ? ",0
|
||||
;mem_model db 13,10,186," Hauptspeicher [1-16 Mb / 2-32 Mb / "
|
||||
@ -89,10 +90,11 @@ mode9 db "320x200, EGA/CGA 256 colors",0
|
||||
mode10 db "640x480, VGA 16 colors",0
|
||||
probeno_msg db " (Standard Modus)",0
|
||||
probeok_msg db " (teste nicht-standard Modi)",0
|
||||
dma_msg db " [b] Nutze DMA zum HDD Aufschreiben:",0
|
||||
;dma_msg db " [b] Nutze DMA zum HDD Aufschreiben:",0
|
||||
usebd_msg db " [b] Add disks visible by BIOS:",0
|
||||
on_msg db " an",13,10,0
|
||||
off_msg db " aus",13,10,0
|
||||
readonly_msg db " fur Lesen",13,10,0
|
||||
;readonly_msg db " fur Lesen",13,10,0
|
||||
vrrm_msg db " [c] Nutze VRR:",0
|
||||
preboot_device_msg db " [d] Diskettenimage: ",0
|
||||
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
|
||||
|
@ -36,7 +36,8 @@ vrrmprint db "
|
||||
; db " ‚ë¡¥à¨â¥ ¯®àâ [1-3]: ",0
|
||||
;no_com1 db 13,10,186," No COM1 mouse",0
|
||||
;no_com2 db 13,10,186," No COM2 mouse",0
|
||||
ask_dma db "ˆá¯®«ì§®¢ âì DMA ¤«ï ¤®áâ㯠ª HDD? [1-¤ , 2-⮫쪮 ç⥨¥, 3-¥â]: ",0
|
||||
;ask_dma db "ˆá¯®«ì§®¢ âì DMA ¤«ï ¤®áâ㯠ª HDD? [1-¤ , 2-⮫쪮 ç⥨¥, 3-¥â]: ",0
|
||||
ask_bd db "„®¡ ¢¨âì ¤¨áª¨, ¢¨¤¨¬ë¥ ç¥à¥§ BIOS ¢ ०¨¬¥ V86? [1-¤ , 2-¥â]: ",0
|
||||
;gr_direct db 186," ˆá¯®«ì§®¢ âì «¨¥©ë© ¢¨¤¥®¡ãä¥à? "
|
||||
; db "[1-¤ /2-¥â]: ",0
|
||||
;mem_model db 13,10,186," Ž¡ê+¬ ¯ ¬ï⨠[1-16 Mb / 2-32 Mb / "
|
||||
@ -84,10 +85,11 @@ mode9 db "320x200, EGA/CGA 256 梥⮢",0
|
||||
mode10 db "640x480, VGA 16 梥⮢",0
|
||||
probeno_msg db " (áâ ¤ àâë© ¢¨¤¥®à¥¦¨¬)",0
|
||||
probeok_msg db " (¯à®¢¥à¨âì ¥áâ ¤ àâë¥ à¥¦¨¬ë)",0
|
||||
dma_msg db " [b] ˆá¯®«ì§®¢ ¨¥ DMA ¤«ï ¤®áâ㯠ª HDD:",0
|
||||
;dma_msg db " [b] ˆá¯®«ì§®¢ ¨¥ DMA ¤«ï ¤®áâ㯠ª HDD:",0
|
||||
usebd_msg db " [b] „®¡ ¢¨âì ¤¨áª¨, ¢¨¤¨¬ë¥ ç¥à¥§ BIOS:",0
|
||||
on_msg db " ¢ª«",13,10,0
|
||||
off_msg db " ¢ëª«",13,10,0
|
||||
readonly_msg db " ⮫쪮 ç⥨¥",13,10,0
|
||||
;readonly_msg db " ⮫쪮 ç⥨¥",13,10,0
|
||||
vrrm_msg db " [c] ˆá¯®«ì§®¢ ¨¥ VRR:",0
|
||||
preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0
|
||||
preboot_device_msgs dw 0,pdm1,pdm2,pdm3,pdm4
|
||||
|
@ -25,6 +25,7 @@ preboot_device db 0 ; boot device
|
||||
; (1-floppy 2-harddisk 3-kernel restart 4-format ram disk)
|
||||
;!!!! 0 - autodetect !!!!
|
||||
preboot_blogesc db 1 ; start immediately after bootlog
|
||||
preboot_biosdisk db 0 ; use V86 to access disks through BIOS (1-yes, 2-no)
|
||||
|
||||
if $>0x200
|
||||
ERROR: prebooting parameters must fit in first sector!!!
|
||||
|
@ -416,9 +416,11 @@ debugger_notify:
|
||||
ret
|
||||
|
||||
debug_exc:
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_debug_exc
|
||||
; int 1 = #DB
|
||||
save_ring3_context
|
||||
cld
|
||||
save_ring3_context
|
||||
cld
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -16,20 +16,20 @@ DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
|
||||
align 4
|
||||
proc attach_int_handler stdcall, irq:dword, handler:dword
|
||||
|
||||
mov ebx, [irq] ; irq num
|
||||
test ebx, ebx
|
||||
jz .err
|
||||
cmp ebx, 15 ; hidnplayr says: we only have 16 IRQ's
|
||||
jg .err
|
||||
mov eax, [handler]
|
||||
test eax, eax
|
||||
jz .err
|
||||
mov [irq_tab+ebx*4], eax
|
||||
stdcall enable_irq, [irq]
|
||||
ret
|
||||
mov ebx, [irq] ;irq num
|
||||
test ebx, ebx
|
||||
jz .err
|
||||
cmp ebx, 15 ; hidnplayr says: we only have 16 IRQ's
|
||||
ja .err
|
||||
mov eax, [handler]
|
||||
test eax, eax
|
||||
jz .err
|
||||
mov [irq_tab+ebx*4], eax
|
||||
stdcall enable_irq, [irq]
|
||||
ret
|
||||
.err:
|
||||
xor eax, eax
|
||||
ret
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
@ -140,6 +140,9 @@ align 16
|
||||
mov ds, bx
|
||||
mov es, bx
|
||||
|
||||
cmp [v86_irqhooks+eax*8], 0
|
||||
jnz v86_irq
|
||||
|
||||
mov ebx, [irq_tab+eax*4]
|
||||
test ebx, ebx
|
||||
jz .exit
|
||||
|
@ -179,7 +179,7 @@ e7: ;#NM exception handler
|
||||
iret
|
||||
|
||||
iglobal
|
||||
fpu_owner dd 1
|
||||
fpu_owner dd 0
|
||||
endg
|
||||
|
||||
reg_eip equ ebp+4
|
||||
@ -190,6 +190,8 @@ reg_ss equ ebp+20
|
||||
|
||||
align 4
|
||||
except_16: ;fpu native exceptions handler
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_except_16
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
@ -234,6 +236,8 @@ except_16: ;fpu native exceptions handler
|
||||
|
||||
align 4
|
||||
except_19: ;sse exceptions handler
|
||||
test byte [esp+8+2], 2
|
||||
jnz v86_except_19
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
|
@ -472,6 +472,9 @@ get_pg_addr:
|
||||
align 4
|
||||
proc page_fault_handler
|
||||
|
||||
test byte [esp+12+2], 2
|
||||
jnz v86_page_fault
|
||||
|
||||
.err_code equ ebp+32
|
||||
.err_addr equ ebp-4
|
||||
|
||||
|
@ -225,9 +225,11 @@ do_change_task:
|
||||
je @F
|
||||
mov cr3, eax
|
||||
@@:
|
||||
mov eax, [ebx+APPDATA.pl0_stack]
|
||||
add eax, RING0_STACK_SIZE
|
||||
mov [tss._esp0], eax
|
||||
mov eax, [ebx+APPDATA.saved_esp0]
|
||||
mov [tss._esp0], eax
|
||||
; mov eax, [ebx+APPDATA.pl0_stack]
|
||||
; add eax, RING0_STACK_SIZE
|
||||
; mov [tss._esp0], eax
|
||||
mov ax, graph_data
|
||||
mov gs, ax
|
||||
mov ecx, cr0
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; ;;
|
||||
@ -100,7 +100,7 @@ macro exc_w_code [num]
|
||||
jmp exc_c
|
||||
}
|
||||
|
||||
exc_wo_code 0, 1, 2, 3, 4, 5, 6, 9, 15, 18
|
||||
exc_wo_code 0, 2, 3, 4, 5, 6, 9, 15, 18
|
||||
exc_w_code 8, 10, 11, 12, 13, 14, 17
|
||||
|
||||
exc_c:
|
||||
@ -108,6 +108,10 @@ exc_c:
|
||||
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíè
|
||||
mov es, ax ;â ðåãèñòðû
|
||||
|
||||
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
|
||||
test byte [esp+20h+8+2], 2
|
||||
jnz v86_exc_c
|
||||
|
||||
; test if debugging
|
||||
cli
|
||||
mov eax, [current_slot]
|
||||
@ -245,6 +249,7 @@ p_irq14:
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov byte [BOOT_VAR + 0x48E], 0xFF
|
||||
call [irq14_func]
|
||||
call ready_for_next_irq_1
|
||||
restore_ring3_context
|
||||
@ -254,6 +259,7 @@ p_irq15:
|
||||
mov ax, app_data ;os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov byte [BOOT_VAR + 0x48E], 0xFF
|
||||
call [irq15_func]
|
||||
call ready_for_next_irq_1
|
||||
restore_ring3_context
|
||||
@ -294,6 +300,8 @@ irqD:
|
||||
|
||||
|
||||
irqhandler:
|
||||
cmp [v86_irqhooks+edi*8], 0
|
||||
jnz v86_irq2
|
||||
|
||||
push edi
|
||||
|
||||
@ -443,7 +451,9 @@ terminate: ; terminate application
|
||||
shl esi, 8
|
||||
cmp [SLOT_BASE+esi+APPDATA.dir_table], 0
|
||||
jne @F
|
||||
add esp, 4
|
||||
pop esi
|
||||
shl esi, 5
|
||||
mov [CURRENT_TASK+esi+TASKDATA.state], 9
|
||||
ret
|
||||
@@:
|
||||
;mov esi,process_terminating
|
||||
@ -459,6 +469,24 @@ terminate: ; terminate application
|
||||
term9:
|
||||
call set_application_table_status
|
||||
|
||||
; if the process is in V86 mode...
|
||||
mov eax, [.slot]
|
||||
shl eax, 8
|
||||
mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack]
|
||||
add esi, RING0_STACK_SIZE
|
||||
cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi
|
||||
jz .nov86
|
||||
; ...it has page directory for V86 mode
|
||||
mov esi, [eax+SLOT_BASE+APPDATA.saved_esp0]
|
||||
mov ecx, [esi+4]
|
||||
mov [eax+SLOT_BASE+APPDATA.dir_table], ecx
|
||||
; ...and I/O permission map for V86 mode
|
||||
mov ecx, [esi+12]
|
||||
mov [eax+SLOT_BASE+APPDATA.io_map], ecx
|
||||
mov ecx, [esi+8]
|
||||
mov [eax+SLOT_BASE+APPDATA.io_map+4], ecx
|
||||
.nov86:
|
||||
|
||||
mov esi, [.slot]
|
||||
shl esi,8
|
||||
add esi, SLOT_BASE+APP_OBJ_OFFSET
|
||||
|
@ -995,6 +995,8 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
mov [SLOT_BASE+APPDATA.cursor+ebx],ecx
|
||||
mov eax, [pl0_stack]
|
||||
mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax
|
||||
add eax, RING0_STACK_SIZE
|
||||
mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax
|
||||
|
||||
push ebx
|
||||
stdcall kernel_alloc, 0x1000
|
||||
|
866
kernel/trunk/core/v86.inc
Normal file
866
kernel/trunk/core/v86.inc
Normal file
@ -0,0 +1,866 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2007-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Virtual-8086 mode manager
|
||||
; diamond, 2007, 2008
|
||||
|
||||
DEBUG_SHOW_IO = 0
|
||||
|
||||
struc V86_machine
|
||||
{
|
||||
; page directory
|
||||
.pagedir dd ?
|
||||
; translation table: V86 address -> flat linear address
|
||||
.pages dd ?
|
||||
; mutex to protect all data from writing by multiple threads at one time
|
||||
.mutex dd ?
|
||||
; i/o permission map
|
||||
.iopm dd ?
|
||||
.size = $
|
||||
}
|
||||
virtual at 0
|
||||
V86_machine V86_machine
|
||||
end virtual
|
||||
|
||||
; Create V86 machine
|
||||
; in: nothing
|
||||
; out: eax = handle (pointer to struc V86_machine)
|
||||
; eax = NULL => failure
|
||||
; destroys: ebx, ecx, edx (due to malloc)
|
||||
v86_create:
|
||||
; allocate V86_machine structure
|
||||
mov eax, V86_machine.size
|
||||
call malloc
|
||||
test eax, eax
|
||||
jz .fail
|
||||
; initialize mutex
|
||||
and dword [eax+V86_machine.mutex], 0
|
||||
; allocate tables
|
||||
mov ebx, eax
|
||||
; We allocate 4 pages.
|
||||
; First is main page directory for V86 mode.
|
||||
; Second page:
|
||||
; first half (0x800 bytes) is page table for addresses 0 - 0x100000,
|
||||
; second half is for V86-to-linear translation.
|
||||
; Third and fourth are for I/O permission map.
|
||||
push 4000h
|
||||
call kernel_alloc
|
||||
test eax, eax
|
||||
jz .fail2
|
||||
mov [ebx+V86_machine.pagedir], eax
|
||||
push edi eax
|
||||
mov edi, eax
|
||||
add eax, 1800h
|
||||
mov [ebx+V86_machine.pages], eax
|
||||
; initialize tables
|
||||
mov ecx, 2000h/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
mov [ebx+V86_machine.iopm], edi
|
||||
dec eax
|
||||
mov ecx, 2000h/4
|
||||
rep stosd
|
||||
pop eax
|
||||
; page directory: first entry is page table...
|
||||
mov edi, eax
|
||||
add eax, 1000h
|
||||
push eax
|
||||
call get_pg_addr
|
||||
or al, PG_UW
|
||||
stosd
|
||||
; ...and also copy system page tables
|
||||
; thx to Serge, system is located at high addresses
|
||||
add edi, (OS_BASE shr 20) - 4
|
||||
push esi
|
||||
mov esi, (OS_BASE shr 20) + sys_pgdir
|
||||
mov ecx, 0x80000000 shr 22
|
||||
rep movsd
|
||||
pop esi
|
||||
; now V86 specific: initialize known addresses in first Mb
|
||||
pop eax edi
|
||||
; first page - BIOS data (shared between all machines!)
|
||||
; physical address = 0x2f0000
|
||||
; linear address = BOOT_VAR = OS_BASE + 0x2f0000
|
||||
mov dword [eax], (BOOT_VAR - OS_BASE) or 111b
|
||||
mov dword [eax+800h], BOOT_VAR
|
||||
; page before 0xA0000 - Extended BIOS Data Area (shared between all machines!)
|
||||
; physical address = 0x9F000
|
||||
; linear address = 0x8009F000
|
||||
mov dword [eax+0x9E*4], 0x9E000 or 111b
|
||||
mov dword [eax+0x9E*4+800h], 0x9E000 + OS_BASE
|
||||
mov dword [eax+0x9F*4], 0x9F000 or 111b
|
||||
mov dword [eax+0x9F*4+800h], 0x9F000 + OS_BASE
|
||||
; addresses 0xC0000 - 0xFFFFF - BIOS code (shared between all machines!)
|
||||
; physical address = 0xC0000
|
||||
; linear address = 0x800C0000
|
||||
mov ecx, 0xC0
|
||||
@@:
|
||||
mov edx, ecx
|
||||
shl edx, 12
|
||||
push edx
|
||||
or edx, 101b
|
||||
mov [eax+ecx*4], edx
|
||||
pop edx
|
||||
add edx, OS_BASE
|
||||
mov [eax+ecx*4+0x800], edx
|
||||
inc cl
|
||||
jnz @b
|
||||
mov eax, ebx
|
||||
ret
|
||||
.fail2:
|
||||
mov eax, ebx
|
||||
call free
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
; Destroy V86 machine
|
||||
; in: eax = handle
|
||||
; out: nothing
|
||||
; destroys: eax, ebx, ecx, edx (due to free)
|
||||
v86_destroy:
|
||||
push eax
|
||||
stdcall kernel_free, [eax+V86_machine.pagedir]
|
||||
pop eax
|
||||
jmp free
|
||||
|
||||
; Translate V86-address to linear address
|
||||
; in: eax=V86 address
|
||||
; esi=handle
|
||||
; out: eax=linear address
|
||||
; destroys: nothing
|
||||
v86_get_lin_addr:
|
||||
push ecx edx
|
||||
mov ecx, eax
|
||||
mov edx, [esi+V86_machine.pages]
|
||||
shr ecx, 12
|
||||
and eax, 0xFFF
|
||||
add eax, [edx+ecx*4] ; atomic operation, no mutex needed
|
||||
pop edx ecx
|
||||
ret
|
||||
|
||||
; Sets linear address for V86-page
|
||||
; in: eax=linear address (must be page-aligned)
|
||||
; ecx=V86 page (NOT address!)
|
||||
; esi=handle
|
||||
; out: nothing
|
||||
; destroys: nothing
|
||||
v86_set_page:
|
||||
push eax ebx
|
||||
mov ebx, [esi+V86_machine.pagedir]
|
||||
mov [ebx+ecx*4+0x1800], eax
|
||||
call get_pg_addr
|
||||
or al, 111b
|
||||
mov [ebx+ecx*4+0x1000], eax
|
||||
pop ebx eax
|
||||
ret
|
||||
|
||||
; Allocate memory in V86 machine
|
||||
; in: eax=size (in bytes)
|
||||
; esi=handle
|
||||
; out: eax=V86 address, para-aligned (0x10 multiple)
|
||||
; destroys: nothing
|
||||
; ¥¤®¯¨á !!!
|
||||
;v86_alloc:
|
||||
; push ebx ecx edx edi
|
||||
; lea ebx, [esi+V86_machine.mutex]
|
||||
; call wait_mutex
|
||||
; add eax, 0x1F
|
||||
; shr eax, 4
|
||||
; mov ebx, 0x1000 ; start with address 0x1000 (second page)
|
||||
; mov edi, [esi+V86_machine.tables]
|
||||
;.l:
|
||||
; mov ecx, ebx
|
||||
; shr ecx, 12
|
||||
; mov edx, [edi+0x1000+ecx*4] ; get linear address
|
||||
; test edx, edx ; page allocated?
|
||||
; jz .unalloc
|
||||
; mov ecx, ebx
|
||||
; and ecx, 0xFFF
|
||||
; add edx, ecx
|
||||
; cmp dword [edx], 0 ; free block?
|
||||
; jnz .n
|
||||
; cmp dword [edx+4],
|
||||
; and [esi+V86_machine.mutex], 0
|
||||
; pop edi edx ecx ebx
|
||||
; ret
|
||||
|
||||
uglobal
|
||||
sys_v86_machine dd ?
|
||||
endg
|
||||
|
||||
; Called from kernel.asm at first stages of loading
|
||||
; Initialize system V86 machine (used to simulate BIOS int 13h)
|
||||
init_sys_v86:
|
||||
call v86_create
|
||||
mov [sys_v86_machine], eax
|
||||
test eax, eax
|
||||
jz .ret
|
||||
mov byte [BOOT_VAR + 0x500], 0xCD
|
||||
mov byte [BOOT_VAR + 0x501], 0x13
|
||||
mov byte [BOOT_VAR + 0x502], 0xF4
|
||||
mov byte [BOOT_VAR + 0x503], 0xCD
|
||||
mov byte [BOOT_VAR + 0x504], 0x10
|
||||
mov byte [BOOT_VAR + 0x505], 0xF4
|
||||
mov esi, eax
|
||||
mov ebx, [eax+V86_machine.pagedir]
|
||||
mov dword [ebx+0x9C*4+0x1000], 0x9C000 or 111b
|
||||
mov dword [ebx+0x9C*4+0x1800], OS_BASE + 0x9C000
|
||||
mov dword [ebx+0x9D*4+0x1000], 0x9D000 or 111b
|
||||
mov dword [ebx+0x9D*4+0x1800], OS_BASE + 0x9D000
|
||||
if ~DEBUG_SHOW_IO
|
||||
; allow access to all ports
|
||||
mov ecx, [esi+V86_machine.iopm]
|
||||
xor eax, eax
|
||||
mov edi, ecx
|
||||
mov ecx, 10000h/8/4
|
||||
rep stosd
|
||||
end if
|
||||
.ret:
|
||||
ret
|
||||
|
||||
struc v86_regs
|
||||
{
|
||||
; don't change the order, it is important
|
||||
.edi dd ?
|
||||
.esi dd ?
|
||||
.ebp dd ?
|
||||
dd ? ; ignored
|
||||
.ebx dd ?
|
||||
.edx dd ?
|
||||
.ecx dd ?
|
||||
.eax dd ?
|
||||
.eip dd ?
|
||||
.cs dd ?
|
||||
.eflags dd ? ; VM flag must be set!
|
||||
.esp dd ?
|
||||
.ss dd ?
|
||||
.es dd ?
|
||||
.ds dd ?
|
||||
.fs dd ?
|
||||
.gs dd ?
|
||||
.size = $
|
||||
}
|
||||
virtual at 0
|
||||
v86_regs v86_regs
|
||||
end virtual
|
||||
|
||||
; Run V86 machine
|
||||
; in: ebx -> registers for V86 (two structures: in and out)
|
||||
; esi = handle
|
||||
; ecx = expected end address (CS:IP)
|
||||
; edx = IRQ to hook or -1 if not required
|
||||
; out: structure pointed to by ebx is filled with new values
|
||||
; eax = 1 - exception has occured, cl contains code
|
||||
; eax = 2 - access to disabled i/o port, ecx contains port address
|
||||
; eax = 3 - IRQ is already hooked by another VM
|
||||
; destroys: nothing
|
||||
v86_start:
|
||||
pushad
|
||||
|
||||
cli
|
||||
|
||||
mov ecx, [CURRENT_TASK]
|
||||
shl ecx, 8
|
||||
add ecx, SLOT_BASE
|
||||
|
||||
mov eax, [esi+V86_machine.iopm]
|
||||
call get_pg_addr
|
||||
inc eax
|
||||
push dword [ecx+APPDATA.io_map]
|
||||
push dword [ecx+APPDATA.io_map+4]
|
||||
mov dword [ecx+APPDATA.io_map], eax
|
||||
mov dword [page_tabs + (tss._io_map_0 shr 10)], eax
|
||||
add eax, 0x1000
|
||||
mov dword [ecx+APPDATA.io_map+4], eax
|
||||
mov dword [page_tabs + (tss._io_map_1 shr 10)], eax
|
||||
|
||||
push [ecx+APPDATA.dir_table]
|
||||
push [ecx+APPDATA.saved_esp0]
|
||||
mov [ecx+APPDATA.saved_esp0], esp
|
||||
mov [tss._esp0], esp
|
||||
|
||||
mov eax, [esi+V86_machine.pagedir]
|
||||
call get_pg_addr
|
||||
mov [ecx+APPDATA.dir_table], eax
|
||||
mov cr3, eax
|
||||
|
||||
; mov [irq_tab+5*4], my05
|
||||
|
||||
; We do not enable interrupts, because V86 IRQ redirector assumes that
|
||||
; machine is running
|
||||
; They will be enabled by IRET.
|
||||
; sti
|
||||
|
||||
mov eax, esi
|
||||
sub esp, v86_regs.size
|
||||
mov esi, ebx
|
||||
mov edi, esp
|
||||
mov ecx, v86_regs.size/4
|
||||
rep movsd
|
||||
|
||||
cmp edx, -1
|
||||
jz .noirqhook
|
||||
uglobal
|
||||
v86_irqhooks rd 16*2
|
||||
endg
|
||||
cmp [v86_irqhooks+edx*8], 0
|
||||
jz @f
|
||||
cmp [v86_irqhooks+edx*8], eax
|
||||
jz @f
|
||||
mov esi, v86_irqerr
|
||||
call sys_msg_board_str
|
||||
inc [v86_irqhooks+edx*8+4]
|
||||
mov eax, 3
|
||||
jmp v86_exc_c.exit
|
||||
@@:
|
||||
mov [v86_irqhooks+edx*8], eax
|
||||
inc [v86_irqhooks+edx*8+4]
|
||||
.noirqhook:
|
||||
|
||||
popad
|
||||
iretd
|
||||
|
||||
; It is only possible to leave virtual-8086 mode by faulting to
|
||||
; a protected-mode interrupt handler (typically the general-protection
|
||||
; exception handler, which in turn calls the virtual 8086-mode monitor).
|
||||
|
||||
v86_debug_exc:
|
||||
pushad
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
mov bl, 1
|
||||
jmp v86_exc_c
|
||||
|
||||
v86_page_fault:
|
||||
add esp, 4
|
||||
pushad
|
||||
mov bl, 14
|
||||
jmp v86_exc_c
|
||||
|
||||
v86_except_16:
|
||||
pushad
|
||||
mov bl, 16
|
||||
jmp v86_exc_c
|
||||
v86_except_19:
|
||||
pushad
|
||||
mov bl, 19
|
||||
|
||||
iglobal
|
||||
v86_exc_str1 db 'V86 : unexpected exception ',0
|
||||
v86_exc_str2 db ' at ',0
|
||||
v86_exc_str3 db ':',0
|
||||
v86_exc_str4 db 13,10,'V86 : faulted code:',0
|
||||
v86_exc_str5 db ' (unavailable)',0
|
||||
v86_newline db 13,10,0
|
||||
v86_io_str1 db 'V86 : access to disabled i/o port ',0
|
||||
v86_io_byte db ' (byte)',13,10,0
|
||||
v86_io_word db ' (word)',13,10,0
|
||||
v86_io_dword db ' (dword)',13,10,0
|
||||
v86_irqerr db 'V86 : IRQ already hooked',13,10,0
|
||||
endg
|
||||
|
||||
v86_exc_c:
|
||||
mov ax, app_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
; Did we all that we have wanted to do?
|
||||
mov eax, [esp+v86_regs.size+10h+18h]
|
||||
cmp word [esp+v86_regs.eip], ax
|
||||
jnz @f
|
||||
shr eax, 16
|
||||
cmp word [esp+v86_regs.cs], ax
|
||||
jz .done
|
||||
@@:
|
||||
; Various system events, which must be handled, result in #GP
|
||||
cmp bl, 13
|
||||
jnz .nogp
|
||||
; If faulted EIP exceeds 0xFFFF, we have #GP and it is an error
|
||||
cmp word [esp+v86_regs.eip+2], 0
|
||||
jnz .nogp
|
||||
; Otherwise we can safely access byte at CS:IP
|
||||
; (because it is #GP, not #PF handler)
|
||||
; …᫨ ¡ë ¬ë ¬®£«¨ áå«®¯®â âì ¨áª«î票¥ ⮫쪮 ¨§-§ çâ¥¨ï ¡ ©â®¢ ª®¤ ,
|
||||
; ¬ë ¡ë ¥£® 㦥 áå«®¯®â «¨ ¨ íâ® ¡ë«® ¡ë ¥ #GP
|
||||
movzx esi, word [esp+v86_regs.cs]
|
||||
shl esi, 4
|
||||
add esi, [esp+v86_regs.eip]
|
||||
lodsb
|
||||
cmp al, 0xCD ; int xx command = CD xx
|
||||
jz .handle_int
|
||||
cmp al, 0xCF
|
||||
jz .handle_iret
|
||||
cmp al, 0xF3
|
||||
jz .handle_rep
|
||||
cmp al, 0xEC
|
||||
jz .handle_in
|
||||
cmp al, 0xED
|
||||
jz .handle_in_word
|
||||
cmp al, 0xEE
|
||||
jz .handle_out
|
||||
cmp al, 0xEF
|
||||
jz .handle_out_word
|
||||
cmp al, 0xE4
|
||||
jz .handle_in_imm
|
||||
cmp al, 0xE6
|
||||
jz .handle_out_imm
|
||||
cmp al, 0x9C
|
||||
jz .handle_pushf
|
||||
cmp al, 0x9D
|
||||
jz .handle_popf
|
||||
cmp al, 0xFA
|
||||
jz .handle_cli
|
||||
cmp al, 0xFB
|
||||
jz .handle_sti
|
||||
cmp al, 0x66
|
||||
jz .handle_66
|
||||
jmp .nogp
|
||||
.handle_int:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
xor eax, eax
|
||||
lodsb
|
||||
; call sys_msg_board_byte
|
||||
; simulate INT command
|
||||
; N.B. It is possible that some checks need to be corrected,
|
||||
; but at least in case of normal execution the code works.
|
||||
.simulate_int:
|
||||
cmp word [esp+v86_regs.esp], 6
|
||||
jae @f
|
||||
mov bl, 12 ; #SS exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
push eax
|
||||
movzx eax, word [esp+4+v86_regs.esp]
|
||||
sub eax, 6
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+4+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+5]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
sub word [esp+4+v86_regs.esp], 6
|
||||
mov eax, [esp+4+v86_regs.eip]
|
||||
inc eax
|
||||
inc eax
|
||||
mov word [edx], ax
|
||||
mov eax, [esp+4+v86_regs.cs]
|
||||
mov word [edx+2], ax
|
||||
mov eax, [esp+4+v86_regs.eflags]
|
||||
mov word [edx+4], ax
|
||||
pop eax
|
||||
mov cx, [eax*4]
|
||||
mov word [esp+v86_regs.eip], cx
|
||||
mov cx, [eax*4+2]
|
||||
mov word [esp+v86_regs.cs], cx
|
||||
; note that interrupts will be disabled globally at IRET
|
||||
and byte [esp+v86_regs.eflags+1], not 3 ; clear IF and TF flags
|
||||
; continue V86 execution
|
||||
popad
|
||||
iretd
|
||||
.handle_iret:
|
||||
cmp word [esp+v86_regs.esp], 0x10000 - 6
|
||||
jbe @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
movzx eax, word [esp+v86_regs.esp]
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+5]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
mov ax, [edx]
|
||||
mov word [esp+v86_regs.eip], ax
|
||||
mov ax, [edx+2]
|
||||
mov word [esp+v86_regs.cs], ax
|
||||
mov ax, [edx+4]
|
||||
mov word [esp+v86_regs.eflags], ax
|
||||
add word [esp+v86_regs.esp], 6
|
||||
popad
|
||||
iretd
|
||||
.handle_pushf:
|
||||
cmp word [esp+v86_regs.esp], 1
|
||||
jnz @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
mov eax, [esp+v86_regs.esp]
|
||||
sub eax, 2
|
||||
movzx eax, ax
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+1]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
sub word [esp+v86_regs.esp], 2
|
||||
mov eax, [esp+v86_regs.eflags]
|
||||
mov [edx], ax
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_popf:
|
||||
cmp word [esp+v86_regs.esp], 0xFFFF
|
||||
jnz @f
|
||||
mov bl, 12
|
||||
jmp .nogp
|
||||
@@:
|
||||
movzx edx, word [esp+v86_regs.ss]
|
||||
shl edx, 4
|
||||
movzx eax, word [esp+v86_regs.esp]
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14 ; #PF exception
|
||||
jmp .nogp
|
||||
@@:
|
||||
lea eax, [edx+1]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jae @f
|
||||
mov bl, 14
|
||||
jmp .nogp
|
||||
@@:
|
||||
mov ax, [edx]
|
||||
mov word [esp+v86_regs.eflags], ax
|
||||
add word [esp+v86_regs.esp], 2
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_cli:
|
||||
and byte [esp+v86_regs.eflags+1], not 2
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_sti:
|
||||
or byte [esp+v86_regs.eflags+1], 2
|
||||
inc word [esp+v86_regs.eip]
|
||||
popad
|
||||
iretd
|
||||
.handle_rep:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
lodsb
|
||||
cmp al, 6Eh
|
||||
jz .handle_rep_outsb
|
||||
jmp .nogp
|
||||
.handle_rep_outsb:
|
||||
.handle_in:
|
||||
.handle_out:
|
||||
.invalid_io_byte:
|
||||
movzx ebx, word [esp+v86_regs.edx]
|
||||
mov ecx, 1
|
||||
jmp .invalid_io
|
||||
.handle_in_imm:
|
||||
.handle_out_imm:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
lodsb
|
||||
movzx ebx, al
|
||||
mov ecx, 1
|
||||
jmp .invalid_io
|
||||
.handle_66:
|
||||
cmp word [esp+v86_regs.eip], 0xFFFF
|
||||
jae .nogp
|
||||
lodsb
|
||||
cmp al, 0xEF
|
||||
jz .handle_out_dword
|
||||
cmp al, 0xED
|
||||
jz .handle_in_dword
|
||||
jmp .nogp
|
||||
.handle_in_word:
|
||||
.handle_out_word:
|
||||
movzx ebx, word [esp+v86_regs.edx]
|
||||
mov ecx, 2
|
||||
jmp .invalid_io
|
||||
.handle_in_dword:
|
||||
.handle_out_dword:
|
||||
.invalid_io_dword:
|
||||
movzx ebx, word [esp+v86_regs.edx]
|
||||
mov ecx, 4
|
||||
.invalid_io:
|
||||
mov esi, v86_io_str1
|
||||
call sys_msg_board_str
|
||||
mov eax, ebx
|
||||
call sys_msg_board_dword
|
||||
mov esi, v86_io_byte
|
||||
cmp ecx, 1
|
||||
jz @f
|
||||
mov esi, v86_io_word
|
||||
cmp ecx, 2
|
||||
jz @f
|
||||
mov esi, v86_io_dword
|
||||
@@:
|
||||
call sys_msg_board_str
|
||||
if DEBUG_SHOW_IO
|
||||
mov edx, ebx
|
||||
mov ebx, 200
|
||||
call delay_hs
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
mov eax, [esi+V86_machine.iopm]
|
||||
@@:
|
||||
btr [eax], edx
|
||||
inc edx
|
||||
loop @b
|
||||
popad
|
||||
iretd
|
||||
else
|
||||
mov eax, 2
|
||||
jmp .exit
|
||||
end if
|
||||
.nogp:
|
||||
|
||||
mov esi, v86_exc_str1
|
||||
call sys_msg_board_str
|
||||
mov al, bl
|
||||
call sys_msg_board_byte
|
||||
mov esi, v86_exc_str2
|
||||
call sys_msg_board_str
|
||||
mov ax, [esp+32+4]
|
||||
call sys_msg_board_word
|
||||
mov esi, v86_exc_str3
|
||||
call sys_msg_board_str
|
||||
mov ax, [esp+32]
|
||||
call sys_msg_board_word
|
||||
mov esi, v86_exc_str4
|
||||
call sys_msg_board_str
|
||||
mov ecx, 8
|
||||
movzx edx, word [esp+32+4]
|
||||
shl edx, 4
|
||||
add edx, [esp+32]
|
||||
@@:
|
||||
mov esi, [esp+v86_regs.size+10h+4]
|
||||
mov eax, edx
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jb .nopage
|
||||
mov esi, v86_exc_str3-2
|
||||
call sys_msg_board_str
|
||||
mov al, [edx]
|
||||
call sys_msg_board_byte
|
||||
inc edx
|
||||
loop @b
|
||||
jmp @f
|
||||
.nopage:
|
||||
mov esi, v86_exc_str5
|
||||
call sys_msg_board_str
|
||||
@@:
|
||||
mov esi, v86_newline
|
||||
call sys_msg_board_str
|
||||
mov eax, 1
|
||||
jmp .exit
|
||||
|
||||
.done:
|
||||
xor eax, eax
|
||||
|
||||
.exit:
|
||||
mov [esp+v86_regs.size+10h+1Ch], eax
|
||||
mov [esp+v86_regs.size+10h+18h], ebx
|
||||
|
||||
mov edx, [esp+v86_regs.size+10h+14h]
|
||||
cmp edx, -1
|
||||
jz @f
|
||||
dec [v86_irqhooks+edx*8+4]
|
||||
jnz @f
|
||||
and [v86_irqhooks+edx*8], 0
|
||||
@@:
|
||||
|
||||
mov esi, esp
|
||||
mov edi, [esi+v86_regs.size+10h+10h]
|
||||
add edi, v86_regs.size
|
||||
mov ecx, v86_regs.size/4
|
||||
rep movsd
|
||||
mov esp, esi
|
||||
|
||||
cli
|
||||
mov ecx, [CURRENT_TASK]
|
||||
shl ecx, 8
|
||||
pop eax
|
||||
mov [SLOT_BASE+ecx+APPDATA.saved_esp0], eax
|
||||
mov [tss._esp0], eax
|
||||
pop eax
|
||||
mov [SLOT_BASE+ecx+APPDATA.dir_table], eax
|
||||
pop ebx
|
||||
mov dword [SLOT_BASE+ecx+APPDATA.io_map+4], ebx
|
||||
mov dword [page_tabs + (tss._io_map_1 shr 10)], ebx
|
||||
pop ebx
|
||||
mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx
|
||||
mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
|
||||
mov cr3, eax
|
||||
; mov [irq_tab+5*4], 0
|
||||
sti
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
;my05:
|
||||
; mov dx, 30C2h
|
||||
; mov cx, 4
|
||||
;.0:
|
||||
; in al, dx
|
||||
; cmp al, 0FFh
|
||||
; jz @f
|
||||
; test al, 4
|
||||
; jnz .1
|
||||
;@@:
|
||||
; add dx, 8
|
||||
; in al, dx
|
||||
; cmp al, 0FFh
|
||||
; jz @f
|
||||
; test al, 4
|
||||
; jnz .1
|
||||
;@@:
|
||||
; loop .0
|
||||
; ret
|
||||
;.1:
|
||||
; or al, 84h
|
||||
; out dx, al
|
||||
;.2:
|
||||
; mov dx, 30F7h
|
||||
; in al, dx
|
||||
; mov byte [BOOT_VAR + 48Eh], 0FFh
|
||||
; ret
|
||||
|
||||
v86_irq:
|
||||
; push eax/pushad/jmp v86_irq
|
||||
; eax = irq
|
||||
mov ebx, eax
|
||||
lea esi, [esp+18h]
|
||||
lea edi, [esi+4]
|
||||
mov ecx, 7
|
||||
std
|
||||
rep movsd
|
||||
cld
|
||||
mov edi, ebx
|
||||
|
||||
v86_irq2:
|
||||
; pushad/call v86_irq2
|
||||
; edi = irq
|
||||
pop eax
|
||||
mov esi, [v86_irqhooks+edi*8] ; get VM handle
|
||||
mov eax, [esi+V86_machine.pagedir]
|
||||
call get_pg_addr
|
||||
mov ecx, [CURRENT_TASK]
|
||||
shl ecx, 8
|
||||
cmp [SLOT_BASE+ecx+APPDATA.dir_table], eax
|
||||
jnz .notcurrent
|
||||
lea eax, [edi+8]
|
||||
cmp al, 10h
|
||||
jb @f
|
||||
add al, 70h-8
|
||||
@@:
|
||||
jmp v86_exc_c.simulate_int
|
||||
.notcurrent:
|
||||
mov ebx, SLOT_BASE + 0x100
|
||||
mov ecx, [TASK_COUNT]
|
||||
.scan:
|
||||
cmp [ebx+APPDATA.dir_table], eax
|
||||
jnz .cont
|
||||
push ecx
|
||||
mov ecx, [ebx+APPDATA.saved_esp0]
|
||||
cmp word [ecx-v86_regs.size+v86_regs.esp], 6
|
||||
jb .cont2
|
||||
movzx edx, word [ecx-v86_regs.size+v86_regs.ss]
|
||||
shl edx, 4
|
||||
push eax
|
||||
movzx eax, word [ecx-v86_regs.size+v86_regs.esp]
|
||||
sub eax, 6
|
||||
add edx, eax
|
||||
mov eax, edx
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jb .cont3
|
||||
lea eax, [edx+5]
|
||||
call v86_get_lin_addr
|
||||
cmp eax, 0x1000
|
||||
jb .cont3
|
||||
pop eax
|
||||
pop ecx
|
||||
jmp .found
|
||||
.cont3:
|
||||
pop eax
|
||||
.cont2:
|
||||
pop ecx
|
||||
.cont:
|
||||
loop .scan
|
||||
mov al, 20h
|
||||
out 20h, al
|
||||
cmp edi, 8
|
||||
jb @f
|
||||
out 0A0h, al
|
||||
@@:
|
||||
popad
|
||||
iretd
|
||||
.found:
|
||||
mov cr3, eax
|
||||
sub word [esi-v86_regs.size+v86_regs.esp], 6
|
||||
mov ecx, [esi-v86_regs.size+v86_regs.eip]
|
||||
mov word [edx], cx
|
||||
mov ecx, [esi-v86_regs.size+v86_regs.cs]
|
||||
mov word [edx+2], cx
|
||||
mov ecx, [esi-v86_regs.size+v86_regs.eflags]
|
||||
mov word [edx+4], cx
|
||||
lea eax, [edi+8]
|
||||
cmp al, 10h
|
||||
jb @f
|
||||
add al, 70h-8
|
||||
@@:
|
||||
mov cx, [eax*4]
|
||||
mov word [esi-v86_regs.size+v86_regs.eip], cx
|
||||
mov cx, [eax*4+2]
|
||||
mov word [esi-v86_regs.size+v86_regs.cs], cx
|
||||
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3
|
||||
push ebx
|
||||
call update_counters
|
||||
pop ebx
|
||||
sub ebx, SLOT_BASE
|
||||
shr ebx, 8
|
||||
mov esi, [CURRENT_TASK]
|
||||
call do_change_task
|
||||
popad
|
||||
iretd
|
@ -363,6 +363,7 @@ img_background rd 1
|
||||
mem_BACKGROUND rd 1
|
||||
wraw_bacground_select rb 1
|
||||
|
||||
cache_ide0:
|
||||
cache_ide0_pointer rd 1
|
||||
cache_ide0_size rd 1 ; not use
|
||||
cache_ide0_data_pointer rd 1
|
||||
@ -375,6 +376,7 @@ cache_ide0_appl_sad_size rd 1
|
||||
cache_ide0_search_start rd 1
|
||||
cache_ide0_appl_search_start rd 1
|
||||
|
||||
cache_ide1:
|
||||
cache_ide1_pointer rd 1
|
||||
cache_ide1_size rd 1 ; not use
|
||||
cache_ide1_data_pointer rd 1
|
||||
@ -387,6 +389,7 @@ cache_ide1_appl_sad_size rd 1
|
||||
cache_ide1_search_start rd 1
|
||||
cache_ide1_appl_search_start rd 1
|
||||
|
||||
cache_ide2:
|
||||
cache_ide2_pointer rd 1
|
||||
cache_ide2_size rd 1 ; not use
|
||||
cache_ide2_data_pointer rd 1
|
||||
@ -399,6 +402,7 @@ cache_ide2_appl_sad_size rd 1
|
||||
cache_ide2_search_start rd 1
|
||||
cache_ide2_appl_search_start rd 1
|
||||
|
||||
cache_ide3:
|
||||
cache_ide3_pointer rd 1
|
||||
cache_ide3_size rd 1 ; not use
|
||||
cache_ide3_data_pointer rd 1
|
||||
@ -419,5 +423,10 @@ lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
pci_access_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
timer_ticks_enable rb 1 ; for cd driver
|
||||
|
||||
NumBiosDisks rd 1
|
||||
BiosDisksData rb 200h
|
||||
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
|
||||
BiosDiskPartitions rd 80h
|
||||
|
||||
IncludeUGlobals
|
||||
|
||||
|
76
kernel/trunk/detect/biosdisk.inc
Normal file
76
kernel/trunk/detect/biosdisk.inc
Normal file
@ -0,0 +1,76 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Detect all BIOS hard drives.
|
||||
; diamond, 2008
|
||||
|
||||
xor cx, cx
|
||||
mov es, cx
|
||||
mov di, 0x9080
|
||||
mov byte [es:di-1], cl
|
||||
cmp [preboot_biosdisk], 1
|
||||
jnz bdde
|
||||
mov dl, 80h
|
||||
bdds:
|
||||
mov ah, 15h
|
||||
push cx dx di
|
||||
int 13h
|
||||
pop di dx cx
|
||||
jc bddc
|
||||
test ah, ah
|
||||
jz bddc
|
||||
inc cx
|
||||
mov ah, 48h
|
||||
push ds
|
||||
push es
|
||||
pop ds
|
||||
mov si, 0xA000
|
||||
mov word [si], 1Eh
|
||||
mov ah, 48h
|
||||
int 13h
|
||||
pop ds
|
||||
jc bddc2
|
||||
inc byte [es:0x907F]
|
||||
cmp word [es:si], 1Eh
|
||||
jb bddl
|
||||
cmp word [es:si+1Ah], 0xFFFF
|
||||
jz bddl
|
||||
mov al, dl
|
||||
stosb
|
||||
push ds
|
||||
lds si, [es:si+1Ah]
|
||||
mov al, [si+6]
|
||||
and al, 0xF
|
||||
stosb
|
||||
mov al, byte [si+4]
|
||||
shr al, 4
|
||||
and ax, 1
|
||||
cmp word [si], 1F0h
|
||||
jz @f
|
||||
inc ax
|
||||
inc ax
|
||||
cmp word [si], 170h
|
||||
jz @f
|
||||
mov ax, -1
|
||||
@@:
|
||||
stosw
|
||||
pop ds
|
||||
jmp bddc2
|
||||
bddl:
|
||||
mov al, dl
|
||||
stosb
|
||||
mov al, 0
|
||||
stosb
|
||||
mov ax, -1
|
||||
stosw
|
||||
bddc2:
|
||||
cmp cl, [es:0x475]
|
||||
jae bdde
|
||||
bddc:
|
||||
inc dl
|
||||
jnz bdds
|
||||
bdde:
|
@ -1,17 +1,6 @@
|
||||
|
||||
$Revision: 0 $
|
||||
|
||||
|
||||
;cache_ide0_pointer dd 0
|
||||
;cache_ide0_size dd 0 ; not use
|
||||
;cache_ide0_data_pointer dd 0
|
||||
;cache_ide0_system_data_size dd 0 ; not use
|
||||
;cache_ide0_appl_data_size dd 0 ; not use
|
||||
;cache_ide0_system_data dd 0
|
||||
;cache_ide0_appl_data dd 0
|
||||
;cache_ide0_system_sad_size dd 0
|
||||
;cache_ide0_appl_sad_size dd 0
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,[pg_data.pages_free]
|
||||
@ -39,287 +28,97 @@ $Revision: 0 $
|
||||
mov [cache_ide2_size],eax
|
||||
mov [cache_ide3_size],eax
|
||||
xor eax,eax
|
||||
mov [cache_ide0_search_start],eax
|
||||
mov [cache_ide0_appl_search_start],eax
|
||||
mov [cache_ide1_search_start],eax
|
||||
mov [cache_ide1_appl_search_start],eax
|
||||
mov [cache_ide2_search_start],eax
|
||||
mov [cache_ide2_appl_search_start],eax
|
||||
mov [cache_ide3_search_start],eax
|
||||
mov [cache_ide3_appl_search_start],eax
|
||||
mov [hdd_appl_data],1 ;al
|
||||
mov [cd_appl_data],1
|
||||
|
||||
mov cl,[DRIVE_DATA+1]
|
||||
mov ch,cl
|
||||
mov ch,[DRIVE_DATA+1]
|
||||
mov cl,ch
|
||||
and cl,11b
|
||||
cmp cl,0
|
||||
je .ide2
|
||||
call get_cache_ide3
|
||||
mov esi,cache_ide3
|
||||
call get_cache_ide
|
||||
.ide2:
|
||||
mov cl,ch
|
||||
and cl,1100b
|
||||
cmp cl,0
|
||||
shr cl,2
|
||||
and cl,11b
|
||||
je .ide1
|
||||
call get_cache_ide2
|
||||
mov esi,cache_ide2
|
||||
call get_cache_ide
|
||||
.ide1:
|
||||
mov cl,ch
|
||||
and cl,110000b
|
||||
cmp cl,0
|
||||
shr cl,4
|
||||
and cl,11b
|
||||
je .ide0
|
||||
call get_cache_ide1
|
||||
mov esi,cache_ide1
|
||||
call get_cache_ide
|
||||
.ide0:
|
||||
mov cl,ch
|
||||
and cl,11000000b
|
||||
cmp cl,0
|
||||
je end_get_cache
|
||||
call get_cache_ide0
|
||||
shr cl,6
|
||||
and cl,11b
|
||||
je @f
|
||||
mov esi,cache_ide0
|
||||
call get_cache_ide
|
||||
@@:
|
||||
xor ecx,ecx
|
||||
cmp [NumBiosDisks],ecx
|
||||
jz .endbd
|
||||
mov esi,BiosDiskCaches
|
||||
.loopbd:
|
||||
cmp byte [BiosDisksData+ecx*4+2],-1
|
||||
jnz .contbd
|
||||
mov eax,[cache_ide0_size]
|
||||
mov [esi+cache_ide0_size-cache_ide0],eax
|
||||
push ecx
|
||||
mov cl,1
|
||||
call get_cache_ide
|
||||
pop ecx
|
||||
.contbd:
|
||||
add esi,cache_ide1-cache_ide0
|
||||
inc ecx
|
||||
cmp ecx,[NumBiosDisks]
|
||||
jb .loopbd
|
||||
.endbd:
|
||||
jmp end_get_cache
|
||||
|
||||
get_cache_ide0:
|
||||
get_cache_ide:
|
||||
and [esi+cache_ide0_search_start-cache_ide0],0
|
||||
and [esi+cache_ide0_appl_search_start-cache_ide0],0
|
||||
push ecx
|
||||
stdcall kernel_alloc,[cache_ide0_size]
|
||||
mov [cache_ide0_pointer],eax
|
||||
stdcall kernel_alloc,[esi+cache_ide0_size-cache_ide0]
|
||||
mov [esi+cache_ide0_pointer-cache_ide0],eax
|
||||
pop ecx
|
||||
mov edx,eax
|
||||
mov eax,[cache_ide0_size]
|
||||
mov eax,[esi+cache_ide0_size-cache_ide0]
|
||||
shr eax,3
|
||||
mov [cache_ide0_system_data_size],eax
|
||||
mov [esi+cache_ide0_system_data_size-cache_ide0],eax
|
||||
mov ebx,eax
|
||||
imul eax,7
|
||||
mov [cache_ide0_appl_data_size],eax
|
||||
mov [esi+cache_ide0_appl_data_size-cache_ide0],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide0_data_pointer],ebx
|
||||
|
||||
cmp cl,10000000b
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide0_system_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide0_pointer]
|
||||
mov [cache_ide0_system_data],eax
|
||||
mov [cache_ide0_system_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide0_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide0_appl_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide0_data_pointer]
|
||||
mov [cache_ide0_appl_data],eax
|
||||
mov [cache_ide0_appl_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide0_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax,[cache_ide0_system_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide0_pointer]
|
||||
mov [cache_ide0_system_data],eax
|
||||
mov [cache_ide0_system_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide0_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide0_appl_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide0_data_pointer]
|
||||
mov [cache_ide0_appl_data],eax
|
||||
mov [cache_ide0_appl_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide0_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
get_cache_ide1:
|
||||
push ecx
|
||||
stdcall kernel_alloc,[cache_ide1_size]
|
||||
mov [cache_ide1_pointer],eax
|
||||
pop ecx
|
||||
mov edx,eax
|
||||
mov eax,[cache_ide1_size]
|
||||
shr eax,3
|
||||
mov [cache_ide1_system_data_size],eax
|
||||
mov ebx,eax
|
||||
imul eax,7
|
||||
mov [cache_ide1_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide1_data_pointer],ebx
|
||||
|
||||
cmp cl,100000b
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide1_system_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide1_pointer]
|
||||
mov [cache_ide1_system_data],eax
|
||||
mov [cache_ide1_system_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide1_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide1_appl_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide1_data_pointer]
|
||||
mov [cache_ide1_appl_data],eax
|
||||
mov [cache_ide1_appl_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide1_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax,[cache_ide1_system_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide1_pointer]
|
||||
mov [cache_ide1_system_data],eax
|
||||
mov [cache_ide1_system_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide1_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide1_appl_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide1_data_pointer]
|
||||
mov [cache_ide1_appl_data],eax
|
||||
mov [cache_ide1_appl_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide1_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
get_cache_ide2:
|
||||
push ecx
|
||||
stdcall kernel_alloc,[cache_ide2_size]
|
||||
mov [cache_ide2_pointer],eax
|
||||
pop ecx
|
||||
mov edx,eax
|
||||
mov eax,[cache_ide2_size]
|
||||
shr eax,3
|
||||
mov [cache_ide2_system_data_size],eax
|
||||
mov ebx,eax
|
||||
imul eax,7
|
||||
mov [cache_ide2_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide2_data_pointer],ebx
|
||||
|
||||
cmp cl,1000b
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide2_system_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide2_pointer]
|
||||
mov [cache_ide2_system_data],eax
|
||||
mov [cache_ide2_system_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide2_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide2_appl_data_size]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide2_data_pointer]
|
||||
mov [cache_ide2_appl_data],eax
|
||||
mov [cache_ide2_appl_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide2_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax,[cache_ide2_system_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide2_pointer]
|
||||
mov [cache_ide2_system_data],eax
|
||||
mov [cache_ide2_system_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide2_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide2_appl_data_size]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide2_data_pointer]
|
||||
mov [cache_ide2_appl_data],eax
|
||||
mov [cache_ide2_appl_sad_size],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide2_data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
get_cache_ide3:
|
||||
push ecx
|
||||
stdcall kernel_alloc,[cache_ide3_size]
|
||||
mov [cache_ide3_pointer],eax
|
||||
pop ecx
|
||||
mov edx,eax
|
||||
mov eax,[cache_ide3_size]
|
||||
shr eax,3
|
||||
mov [cache_ide3_system_data_size],eax
|
||||
mov ebx,eax
|
||||
imul eax,7
|
||||
mov [cache_ide3_appl_data_size],eax
|
||||
add ebx,edx
|
||||
mov [cache_ide3_data_pointer],ebx
|
||||
mov [esi+cache_ide0_data_pointer-cache_ide0],ebx
|
||||
|
||||
cmp cl,10b
|
||||
je .cd
|
||||
push ecx
|
||||
mov eax,[cache_ide3_system_data_size]
|
||||
mov eax,[esi+cache_ide0_system_data_size-cache_ide0]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide3_pointer]
|
||||
mov [cache_ide3_system_data],eax
|
||||
mov [cache_ide3_system_sad_size],ecx
|
||||
add eax,[esi+cache_ide0_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_system_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_system_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide3_pointer]
|
||||
mov edi,[esi+cache_ide0_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide3_appl_data_size]
|
||||
mov eax,[esi+cache_ide0_appl_data_size-cache_ide0]
|
||||
call calculate_for_hd
|
||||
add eax,[cache_ide3_data_pointer]
|
||||
mov [cache_ide3_appl_data],eax
|
||||
mov [cache_ide3_appl_sad_size],ecx
|
||||
add eax,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_appl_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_appl_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide3_data_pointer]
|
||||
mov edi,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
@ -327,25 +126,25 @@ get_cache_ide3:
|
||||
ret
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax,[cache_ide3_system_data_size]
|
||||
mov eax,[esi+cache_ide0_system_data_size-cache_ide0]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide3_pointer]
|
||||
mov [cache_ide3_system_data],eax
|
||||
mov [cache_ide3_system_sad_size],ecx
|
||||
add eax,[esi+cache_ide0_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_system_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_system_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide3_pointer]
|
||||
mov edi,[esi+cache_ide0_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax,[cache_ide3_appl_data_size]
|
||||
mov eax,[esi+cache_ide0_appl_data_size-cache_ide0]
|
||||
call calculate_for_cd
|
||||
add eax,[cache_ide3_data_pointer]
|
||||
mov [cache_ide3_appl_data],eax
|
||||
mov [cache_ide3_appl_sad_size],ecx
|
||||
add eax,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_appl_data-cache_ide0],eax
|
||||
mov [esi+cache_ide0_appl_sad_size-cache_ide0],ecx
|
||||
|
||||
push edi
|
||||
mov edi,[cache_ide3_data_pointer]
|
||||
mov edi,[esi+cache_ide0_data_pointer-cache_ide0]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -82,6 +82,31 @@ $Revision$
|
||||
inc [fat32part]
|
||||
jmp search_partitions_ide3_1
|
||||
|
||||
end_search_partitions_ide:
|
||||
mov [hdpos], 80h
|
||||
mov ecx, [NumBiosDisks]
|
||||
test ecx, ecx
|
||||
jz end_search_partitions
|
||||
start_search_partitions_bd:
|
||||
push ecx
|
||||
mov eax, [hdpos]
|
||||
and [BiosDiskPartitions+(eax-80h)*4], 0
|
||||
mov [fat32part], 1
|
||||
search_partitions_bd:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition], 0
|
||||
jne end_search_partitions_bd
|
||||
mov eax, [hdpos]
|
||||
inc [BiosDiskPartitions+(eax-80h)*4]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
jmp search_partitions_bd
|
||||
end_search_partitions_bd:
|
||||
pop ecx
|
||||
inc [hdpos]
|
||||
loop start_search_partitions_bd
|
||||
jmp end_search_partitions
|
||||
|
||||
partition_data_transfer:
|
||||
mov edi,[transfer_adress]
|
||||
@ -103,7 +128,7 @@ partition_data_transfer_1:
|
||||
; sti
|
||||
ret
|
||||
|
||||
end_search_partitions_ide:
|
||||
end_search_partitions:
|
||||
|
||||
;PARTITION_START dd 0x3f
|
||||
;PARTITION_END dd 0
|
||||
|
@ -131,6 +131,10 @@ hd_in_cache db ?
|
||||
endg
|
||||
|
||||
reserve_hd_channel:
|
||||
; BIOS disk accesses are protected with common mutex hd1_status
|
||||
; This must be modified when hd1_status will not be valid!
|
||||
cmp [hdpos], 0x80
|
||||
jae .ret
|
||||
cmp [hdbase], 0x1F0
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
@ -165,13 +169,18 @@ reserve_hd_channel:
|
||||
call clear_hd_cache
|
||||
@@:
|
||||
pop eax
|
||||
.ret:
|
||||
ret
|
||||
|
||||
free_hd_channel:
|
||||
; see comment at reserve_hd_channel
|
||||
cmp [hdpos], 0x80
|
||||
jae .ret
|
||||
cmp [hdbase], 0x1F0
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
mov [IDE_Channel_1],0
|
||||
.ret:
|
||||
ret
|
||||
.IDE_Channel_2:
|
||||
mov [IDE_Channel_2],0
|
||||
|
@ -365,13 +365,29 @@ choice_necessity_partition_1:
|
||||
xor eax,eax
|
||||
mov [hd_entries], eax ; entries in hd cache
|
||||
mov edx,DRIVE_DATA+2
|
||||
cmp ecx,0x80
|
||||
jb search_partition_array
|
||||
mov ecx,4
|
||||
search_partition_array:
|
||||
mov bl,[edx]
|
||||
movzx ebx,bl
|
||||
add eax,ebx
|
||||
inc edx
|
||||
loop search_partition_array
|
||||
mov ecx,[hdpos]
|
||||
mov edx,BiosDiskPartitions
|
||||
sub ecx,0x80
|
||||
jb .s
|
||||
je .f
|
||||
@@:
|
||||
mov ebx,[edx]
|
||||
add edx,4
|
||||
add eax,ebx
|
||||
loop @b
|
||||
jmp .f
|
||||
.s:
|
||||
sub eax,ebx
|
||||
.f:
|
||||
add eax,[fat32part]
|
||||
dec eax
|
||||
xor edx,edx
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -82,6 +82,12 @@ virtual_root_query:
|
||||
db 'cd3',0
|
||||
;**********************************************
|
||||
dd 0
|
||||
|
||||
fs_additional_handlers:
|
||||
dd biosdisk_handler, biosdisk_enum_root
|
||||
; add new handlers here
|
||||
dd 0
|
||||
|
||||
endg
|
||||
|
||||
file_system_lfn:
|
||||
@ -141,7 +147,7 @@ file_system_lfn:
|
||||
scasd
|
||||
mov cl, byte [edi]
|
||||
test cl, cl
|
||||
jz .notfound
|
||||
jz .notfound_try
|
||||
inc edi
|
||||
push esi
|
||||
@@:
|
||||
@ -158,6 +164,8 @@ file_system_lfn:
|
||||
pop eax
|
||||
; directory /xxx
|
||||
.maindir:
|
||||
mov esi, [edi+4]
|
||||
.maindir_noesi:
|
||||
cmp dword [ebx], 1
|
||||
jnz .access_denied
|
||||
xor eax, eax
|
||||
@ -166,11 +174,12 @@ file_system_lfn:
|
||||
; add edx, std_application_base_address
|
||||
push dword [ebx+4] ; first block
|
||||
mov ebx, [ebx+8] ; flags
|
||||
mov esi, [edi+4]
|
||||
; ebx=flags, [esp]=first block, ebp=number of blocks, edx=return area, esi='Next' handler
|
||||
mov edi, edx
|
||||
push ecx
|
||||
mov ecx, 32/4
|
||||
rep stosd
|
||||
pop ecx
|
||||
mov byte [edx], 1 ; version
|
||||
.maindir_loop:
|
||||
call esi
|
||||
@ -186,14 +195,17 @@ file_system_lfn:
|
||||
push eax
|
||||
xor eax, eax
|
||||
add edi, 8
|
||||
push ecx
|
||||
mov ecx, 40/4-2
|
||||
rep stosd
|
||||
pop ecx
|
||||
pop eax
|
||||
push eax edx
|
||||
; convert number in eax to decimal UNICODE string
|
||||
push edi
|
||||
push ecx
|
||||
push -'0'
|
||||
mov cl, 10
|
||||
mov ecx, 10
|
||||
@@:
|
||||
xor edx, edx
|
||||
div ecx
|
||||
@ -212,6 +224,7 @@ file_system_lfn:
|
||||
test al, al
|
||||
jnz @b
|
||||
mov byte [edi-1], 0
|
||||
pop ecx
|
||||
pop edi
|
||||
; UNICODE name length is 520 bytes, ANSI - 264
|
||||
add edi, 520
|
||||
@ -256,7 +269,7 @@ file_system_lfn:
|
||||
mov byte [edx], 1 ; version
|
||||
.readroot_loop:
|
||||
cmp dword [esi], eax
|
||||
jz .readroot_done
|
||||
jz .readroot_done_static
|
||||
call dword [esi]
|
||||
add esi, 4
|
||||
test eax, eax
|
||||
@ -276,7 +289,7 @@ file_system_lfn:
|
||||
js .readroot_next
|
||||
inc dword [edx+4]
|
||||
mov dword [edi], 0x10 ; attributes: folder
|
||||
mov dword [edi+4], 1 ; name type: UNICODE
|
||||
mov dword [edi+4], ebx ; name type: UNICODE
|
||||
add edi, 8
|
||||
mov ecx, 40/4-2
|
||||
rep stosd
|
||||
@ -297,7 +310,54 @@ file_system_lfn:
|
||||
jnz .readroot_loop
|
||||
sub edi, 520-264
|
||||
jmp .readroot_loop
|
||||
.readroot_done_static:
|
||||
mov esi, fs_additional_handlers-8
|
||||
sub esp, 16
|
||||
.readroot_ah_loop:
|
||||
add esi, 8
|
||||
cmp dword [esi], 0
|
||||
jz .readroot_done
|
||||
xor eax, eax
|
||||
.readroot_ah_loop2:
|
||||
push edi
|
||||
lea edi, [esp+4]
|
||||
call dword [esi+4]
|
||||
pop edi
|
||||
test eax, eax
|
||||
jz .readroot_ah_loop
|
||||
inc dword [edx+8]
|
||||
dec dword [esp+16]
|
||||
jns .readroot_ah_loop2
|
||||
dec ebp
|
||||
js .readroot_ah_loop2
|
||||
push eax
|
||||
xor eax, eax
|
||||
inc dword [edx+4]
|
||||
mov dword [edi], 0x10 ; attributes: folder
|
||||
mov dword [edi+4], ebx
|
||||
add edi, 8
|
||||
mov ecx, 40/4-2
|
||||
rep stosd
|
||||
push esi edi
|
||||
lea esi, [esp+12]
|
||||
@@:
|
||||
lodsb
|
||||
stosb
|
||||
test bl, 1
|
||||
jz .ansi3
|
||||
mov byte [edi], 0
|
||||
inc edi
|
||||
.ansi3:
|
||||
test al, al
|
||||
jnz @b
|
||||
pop edi esi eax
|
||||
add edi, 520
|
||||
test bl, 1
|
||||
jnz .readroot_ah_loop2
|
||||
sub edi, 520-264
|
||||
jmp .readroot_ah_loop2
|
||||
.readroot_done:
|
||||
add esp, 16
|
||||
pop eax
|
||||
mov ebx, [edx+4]
|
||||
xor eax, eax
|
||||
@ -308,15 +368,31 @@ file_system_lfn:
|
||||
mov [image_of_eax], eax
|
||||
mov [image_of_ebx], ebx
|
||||
ret
|
||||
.notfound_try:
|
||||
mov edi, fs_additional_handlers
|
||||
@@:
|
||||
cmp dword [edi], 0
|
||||
jz @f
|
||||
call dword [edi]
|
||||
scasd
|
||||
scasd
|
||||
jmp @b
|
||||
.notfound:
|
||||
mov dword [image_of_eax], ERROR_FILE_NOT_FOUND
|
||||
and dword [image_of_ebx], 0
|
||||
ret
|
||||
|
||||
.notfounda:
|
||||
cmp edi, esp
|
||||
jnz .notfound
|
||||
add esp, 8
|
||||
jmp .notfound
|
||||
|
||||
.found1:
|
||||
pop eax
|
||||
cmp byte [esi], 0
|
||||
jz .maindir
|
||||
.found2:
|
||||
; read partition number
|
||||
xor ecx, ecx
|
||||
xor eax, eax
|
||||
@ -328,12 +404,12 @@ file_system_lfn:
|
||||
jz .done1
|
||||
sub al, '0'
|
||||
cmp al, 9
|
||||
ja .notfound
|
||||
ja .notfounda
|
||||
lea ecx, [ecx*5]
|
||||
lea ecx, [ecx*2+eax]
|
||||
jmp @b
|
||||
.done1:
|
||||
jecxz .notfound
|
||||
jecxz .notfounda
|
||||
test al, al
|
||||
jnz @f
|
||||
dec esi
|
||||
@ -451,8 +527,9 @@ fs_OnHd:
|
||||
pop eax
|
||||
mov [hdpos], eax
|
||||
cmp ecx, 0x100
|
||||
jae .nf
|
||||
jae fs_OnHdAndBd.nf
|
||||
cmp cl, [DRIVE_DATA+1+eax]
|
||||
fs_OnHdAndBd:
|
||||
jbe @f
|
||||
.nf:
|
||||
call free_hd_channel
|
||||
@ -708,6 +785,145 @@ fs_NextCd:
|
||||
ret
|
||||
;*******************************************************
|
||||
|
||||
; Additional FS handlers.
|
||||
; This handler gets the control each time when fn 70 is called
|
||||
; with unknown item of root subdirectory.
|
||||
; in: esi -> name
|
||||
; ebp = 0 or rest of name relative to esi
|
||||
; out: if the handler processes path, he must not return in file_system_lfn,
|
||||
; but instead pop return address and return directly to the caller
|
||||
; otherwise simply return
|
||||
|
||||
; here we test for /bd<N>/... - BIOS disks
|
||||
biosdisk_handler:
|
||||
cmp [NumBiosDisks], 0
|
||||
jz .ret
|
||||
mov al, [esi]
|
||||
or al, 20h
|
||||
cmp al, 'b'
|
||||
jnz .ret
|
||||
mov al, [esi+1]
|
||||
or al, 20h
|
||||
cmp al, 'd'
|
||||
jnz .ret
|
||||
push esi
|
||||
inc esi
|
||||
inc esi
|
||||
cmp byte [esi], '0'
|
||||
jb .ret2
|
||||
cmp byte [esi], '9'
|
||||
ja .ret2
|
||||
xor edx, edx
|
||||
@@:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .ok
|
||||
cmp al, '/'
|
||||
jz .ok
|
||||
sub al, '0'
|
||||
cmp al, 9
|
||||
ja .ret2
|
||||
lea edx, [edx*5]
|
||||
lea edx, [edx*2+eax]
|
||||
jmp @b
|
||||
.ret2:
|
||||
pop esi
|
||||
.ret:
|
||||
ret
|
||||
.ok:
|
||||
cmp al, '/'
|
||||
jz @f
|
||||
dec esi
|
||||
@@:
|
||||
add dl, 80h
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
cmp dl, [BiosDisksData+ecx*4]
|
||||
jz .ok2
|
||||
inc ecx
|
||||
cmp ecx, [NumBiosDisks]
|
||||
jb @b
|
||||
jmp .ret2
|
||||
.ok2:
|
||||
add esp, 8
|
||||
test al, al
|
||||
jnz @f
|
||||
mov esi, fs_BdNext
|
||||
jmp file_system_lfn.maindir_noesi
|
||||
@@:
|
||||
push ecx
|
||||
push fs_OnBd
|
||||
mov edi, esp
|
||||
jmp file_system_lfn.found2
|
||||
|
||||
fs_BdNext:
|
||||
cmp eax, [BiosDiskPartitions+ecx*4]
|
||||
inc eax
|
||||
cmc
|
||||
ret
|
||||
|
||||
fs_OnBd:
|
||||
pop edx edx
|
||||
; edx = disk number, ecx = partition number
|
||||
; esi+ebp = name
|
||||
call reserve_hd1
|
||||
add edx, 0x80
|
||||
mov [hdpos], edx
|
||||
cmp ecx, [BiosDiskPartitions+(edx-0x80)*4]
|
||||
jmp fs_OnHdAndBd
|
||||
|
||||
; This handler is called when virtual root is enumerated
|
||||
; and must return all items which can be handled by this.
|
||||
; It is called several times, first time with eax=0
|
||||
; in: eax = 0 for first call, previously returned value for subsequent calls
|
||||
; out: eax = 0 => no more items
|
||||
; eax != 0 => buffer pointed to by edi contains name of item
|
||||
|
||||
; here we enumerate existing BIOS disks /bd<N>
|
||||
biosdisk_enum_root:
|
||||
cmp eax, [NumBiosDisks]
|
||||
jae .end
|
||||
push eax
|
||||
movzx eax, byte [BiosDisksData+eax*4]
|
||||
sub al, 80h
|
||||
push eax
|
||||
mov al, 'b'
|
||||
stosb
|
||||
mov al, 'd'
|
||||
stosb
|
||||
pop eax
|
||||
cmp al, 10
|
||||
jae .big
|
||||
add al, '0'
|
||||
stosb
|
||||
mov byte [edi], 0
|
||||
pop eax
|
||||
inc eax
|
||||
ret
|
||||
.end:
|
||||
xor eax, eax
|
||||
ret
|
||||
.big:
|
||||
push ecx
|
||||
push -'0'
|
||||
mov ecx, 10
|
||||
@@:
|
||||
xor edx, edx
|
||||
div ecx
|
||||
push edx
|
||||
test eax, eax
|
||||
jnz @b
|
||||
xchg eax, edx
|
||||
@@:
|
||||
pop eax
|
||||
add al, '0'
|
||||
stosb
|
||||
jnz @b
|
||||
pop ecx
|
||||
pop eax
|
||||
inc eax
|
||||
ret
|
||||
|
||||
process_replace_file_name:
|
||||
mov ebp, [full_file_name_table]
|
||||
mov edi, [full_file_name_table.size]
|
||||
|
@ -104,6 +104,7 @@ iglobal
|
||||
db 0xd4 ; Old Multiuser DOS secured: fat16 <32M
|
||||
db 0xd6 ; Old Multiuser DOS secured: fat16 >32M
|
||||
db 0x07 ; NTFS
|
||||
db 0x27 ; NTFS, hidden
|
||||
partition_types_end:
|
||||
|
||||
|
||||
@ -132,10 +133,11 @@ set_FAT32_variables:
|
||||
call reserve_hd1
|
||||
call reserve_hd_channel
|
||||
|
||||
pushad
|
||||
|
||||
cmp dword [hdpos],0
|
||||
je problem_hd
|
||||
|
||||
pushad
|
||||
xor ecx,ecx ; partition count
|
||||
mov edx,-1 ; flag for partition
|
||||
xor eax,eax ; read MBR
|
||||
@ -324,9 +326,9 @@ problem_fat_dec_count: ; bootsector is missing or another problem
|
||||
dec [partition_count] ; remove it from partition_count
|
||||
|
||||
problem_partition_or_fat:
|
||||
problem_hd:
|
||||
popad
|
||||
|
||||
problem_hd:
|
||||
mov [fs_type],0
|
||||
call free_hd_channel
|
||||
mov [hd1_status],0 ; free
|
||||
@ -368,8 +370,10 @@ hd_and_partition_ok:
|
||||
boot_read_ok:
|
||||
; mov [hd_setup], 0
|
||||
; if we are running on NTFS, check bootsector
|
||||
cmp [fs_type], 7
|
||||
jz ntfs_setup
|
||||
; cmp [fs_type], 7
|
||||
; jz ntfs_setup
|
||||
call ntfs_test_bootsec
|
||||
jnc ntfs_setup
|
||||
|
||||
cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector?
|
||||
jnz problem_fat_dec_count
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -499,7 +499,7 @@ display_settings:
|
||||
repos_windows:
|
||||
mov ecx,[TASK_COUNT]
|
||||
mov edi, OS_BASE+0x20*2
|
||||
mov byte[REDRAW_BACKGROUND],1
|
||||
call force_redraw_background
|
||||
dec ecx
|
||||
jge @f
|
||||
ret
|
||||
|
@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved.
|
||||
;; PROGRAMMING:
|
||||
;; Ivan Poddubny
|
||||
;; Marat Zakiyanov (Mario79)
|
||||
@ -132,6 +132,7 @@ end if
|
||||
|
||||
include "boot/bootcode.inc" ; 16 bit system boot code
|
||||
include "bus/pci/pci16.inc"
|
||||
include "detect/biosdisk.inc"
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
@ -363,6 +364,11 @@ high_code:
|
||||
mov ax,[BOOT_VAR+0x9001] ; for other modes
|
||||
mov [BytesPerScanLine],ax
|
||||
@@:
|
||||
mov esi, BOOT_VAR+0x9080
|
||||
movzx ecx, byte [esi-1]
|
||||
mov [NumBiosDisks], ecx
|
||||
mov edi, BiosDisksData
|
||||
rep movsd
|
||||
|
||||
; GRAPHICS ADDRESSES
|
||||
|
||||
@ -505,6 +511,9 @@ high_code:
|
||||
add eax, ebx
|
||||
mov [ipc_ptab], eax
|
||||
|
||||
stdcall kernel_alloc, unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl (unpack.lc+unpack.lp))
|
||||
mov [unpack.p], eax
|
||||
|
||||
call init_events
|
||||
mov eax, srv.fd-SRV_FD_OFFSET
|
||||
mov [srv.fd], eax
|
||||
@ -537,6 +546,14 @@ high_code:
|
||||
stdcall kernel_alloc, [mem_BACKGROUND]
|
||||
mov [img_background], eax
|
||||
|
||||
mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE
|
||||
|
||||
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
|
||||
|
||||
call rerouteirqs
|
||||
|
||||
; Initialize system V86 machine
|
||||
call init_sys_v86
|
||||
|
||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
include 'detect/disks.inc'
|
||||
@ -601,15 +618,6 @@ no_lib_load:
|
||||
mov eax, 0x00040000
|
||||
call display_number_force
|
||||
|
||||
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
|
||||
|
||||
mov esi,boot_irqs
|
||||
call boot_log
|
||||
call rerouteirqs
|
||||
|
||||
mov esi,boot_tss
|
||||
call boot_log
|
||||
|
||||
; BUILD SCHEDULER
|
||||
|
||||
call build_scheduler ; sys32.inc
|
||||
@ -683,6 +691,7 @@ no_lib_load:
|
||||
mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi
|
||||
add edi, 0x2000-512
|
||||
mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi
|
||||
mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case
|
||||
mov dword [SLOT_BASE+256+APPDATA.io_map],\
|
||||
(tss._io_map_0-OS_BASE+PG_MAP)
|
||||
mov dword [SLOT_BASE+256+APPDATA.io_map+4],\
|
||||
@ -2057,9 +2066,8 @@ sysfn_shutdown: ; 18.1 = BOOT
|
||||
for_shutdown_parameter:
|
||||
|
||||
mov eax,[TASK_COUNT]
|
||||
add eax,2
|
||||
mov [shutdown_processes],eax
|
||||
mov [SYS_SHUTDOWN],al
|
||||
mov [shutdown_processes],eax
|
||||
and dword [esp+32], 0
|
||||
ret
|
||||
uglobal
|
||||
@ -2442,8 +2450,9 @@ draw_background_temp:
|
||||
; je nosb31
|
||||
;draw_background_temp:
|
||||
; mov [bgrchanged],1 ;0
|
||||
mov [REDRAW_BACKGROUND],byte 1
|
||||
mov [background_defined], 1
|
||||
call force_redraw_background
|
||||
mov [REDRAW_BACKGROUND], byte 2
|
||||
nosb31:
|
||||
ret
|
||||
nosb3:
|
||||
@ -2551,6 +2560,17 @@ nosb6:
|
||||
nosb7:
|
||||
ret
|
||||
|
||||
force_redraw_background:
|
||||
mov [draw_data+32 + RECT.left],dword 0
|
||||
mov [draw_data+32 + RECT.top],dword 0
|
||||
push eax ebx
|
||||
mov eax,[ScreenWidth]
|
||||
mov ebx,[ScreenHeight]
|
||||
mov [draw_data+32 + RECT.right],eax
|
||||
mov [draw_data+32 + RECT.bottom],ebx
|
||||
pop ebx eax
|
||||
mov byte [REDRAW_BACKGROUND], 1
|
||||
ret
|
||||
|
||||
align 4
|
||||
|
||||
@ -3518,20 +3538,21 @@ mouse_not_active:
|
||||
jz nobackgr
|
||||
cmp [background_defined], 0
|
||||
jz nobackgr
|
||||
; mov [REDRAW_BACKGROUND],byte 2
|
||||
; call change_task
|
||||
cmp [REDRAW_BACKGROUND], byte 2
|
||||
jnz no_set_bgr_event
|
||||
xor edi, edi
|
||||
mov ecx, [TASK_COUNT]
|
||||
set_bgr_event:
|
||||
add edi, 256
|
||||
or [edi+SLOT_BASE+APPDATA.event_mask], 16
|
||||
loop set_bgr_event
|
||||
mov [draw_data+32 + RECT.left],dword 0
|
||||
mov [draw_data+32 + RECT.top],dword 0
|
||||
mov eax,[ScreenWidth]
|
||||
mov ebx,[ScreenHeight]
|
||||
mov [draw_data+32 + RECT.right],eax
|
||||
mov [draw_data+32 + RECT.bottom],ebx
|
||||
no_set_bgr_event:
|
||||
; mov [draw_data+32 + RECT.left],dword 0
|
||||
; mov [draw_data+32 + RECT.top],dword 0
|
||||
; mov eax,[ScreenWidth]
|
||||
; mov ebx,[ScreenHeight]
|
||||
; mov [draw_data+32 + RECT.right],eax
|
||||
; mov [draw_data+32 + RECT.bottom],ebx
|
||||
call drawbackground
|
||||
mov [REDRAW_BACKGROUND],byte 0
|
||||
mov [MOUSE_BACKGROUND],byte 0
|
||||
@ -3544,26 +3565,24 @@ nobackgr:
|
||||
je noshutdown
|
||||
|
||||
mov edx,[shutdown_processes]
|
||||
sub dl,2
|
||||
|
||||
cmp [SYS_SHUTDOWN],dl
|
||||
jne no_mark_system_shutdown
|
||||
|
||||
lea ecx,[edx-1]
|
||||
mov edx,OS_BASE+0x3040
|
||||
movzx ecx,byte [SYS_SHUTDOWN]
|
||||
add ecx,5
|
||||
jecxz @f
|
||||
markz:
|
||||
mov [edx+TASKDATA.state],byte 3
|
||||
add edx,0x20
|
||||
loop markz
|
||||
@@:
|
||||
|
||||
no_mark_system_shutdown:
|
||||
|
||||
call [disable_mouse]
|
||||
|
||||
dec byte [SYS_SHUTDOWN]
|
||||
|
||||
cmp [SYS_SHUTDOWN],byte 0
|
||||
je system_shutdown
|
||||
|
||||
noshutdown:
|
||||
@ -3584,10 +3603,8 @@ newct:
|
||||
inc esi
|
||||
dec eax
|
||||
jnz newct
|
||||
|
||||
ret
|
||||
|
||||
|
||||
; redraw screen
|
||||
|
||||
redrawscreen:
|
||||
@ -3651,8 +3668,36 @@ redrawscreen:
|
||||
|
||||
bgli:
|
||||
|
||||
cmp edi,esi
|
||||
jz ricino
|
||||
cmp ecx,1
|
||||
jnz .az
|
||||
mov al,[REDRAW_BACKGROUND]
|
||||
cmp al,2
|
||||
jz newdw8
|
||||
test al,al
|
||||
jz .az
|
||||
lea eax,[edi+draw_data-window_data]
|
||||
mov ebx,[dlx]
|
||||
cmp ebx,[eax+RECT.left]
|
||||
jae @f
|
||||
mov [eax+RECT.left],ebx
|
||||
@@:
|
||||
mov ebx,[dly]
|
||||
cmp ebx,[eax+RECT.top]
|
||||
jae @f
|
||||
mov [eax+RECT.top],ebx
|
||||
@@:
|
||||
mov ebx,[dlxe]
|
||||
cmp ebx,[eax+RECT.right]
|
||||
jbe @f
|
||||
mov [eax+RECT.right],ebx
|
||||
@@:
|
||||
mov ebx,[dlye]
|
||||
cmp ebx,[eax+RECT.bottom]
|
||||
jbe @f
|
||||
mov [eax+RECT.bottom],ebx
|
||||
@@:
|
||||
jmp newdw8
|
||||
.az:
|
||||
|
||||
mov eax,edi
|
||||
add eax,draw_data-window_data
|
||||
@ -3668,11 +3713,9 @@ redrawscreen:
|
||||
|
||||
sub eax,draw_data-window_data
|
||||
|
||||
cmp ecx,1
|
||||
cmp dword [esp],1
|
||||
jne nobgrd
|
||||
cmp esi,1
|
||||
je newdw8
|
||||
call drawbackground
|
||||
mov byte [REDRAW_BACKGROUND], 1
|
||||
|
||||
newdw8:
|
||||
nobgrd:
|
||||
@ -4613,6 +4656,48 @@ sys_msg_board_str:
|
||||
popad
|
||||
ret
|
||||
|
||||
sys_msg_board_byte:
|
||||
; in: al = byte to display
|
||||
; out: nothing
|
||||
; destroys: nothing
|
||||
pushad
|
||||
mov ecx, 2
|
||||
shl eax, 24
|
||||
jmp @f
|
||||
|
||||
sys_msg_board_word:
|
||||
; in: ax = word to display
|
||||
; out: nothing
|
||||
; destroys: nothing
|
||||
pushad
|
||||
mov ecx, 4
|
||||
shl eax, 16
|
||||
jmp @f
|
||||
|
||||
sys_msg_board_dword:
|
||||
; in: eax = dword to display
|
||||
; out: nothing
|
||||
; destroys: nothing
|
||||
pushad
|
||||
mov ecx, 8
|
||||
@@:
|
||||
push ecx
|
||||
rol eax, 4
|
||||
push eax
|
||||
and al, 0xF
|
||||
cmp al, 10
|
||||
sbb al, 69h
|
||||
das
|
||||
mov bl, al
|
||||
xor eax, eax
|
||||
inc eax
|
||||
call sys_msg_board
|
||||
pop eax
|
||||
pop ecx
|
||||
loop @b
|
||||
popad
|
||||
ret
|
||||
|
||||
uglobal
|
||||
msg_board_data: times 4096 db 0
|
||||
msg_board_count dd 0x0
|
||||
@ -5086,9 +5171,9 @@ read_from_hd: ; Read from hd - fn not in use
|
||||
|
||||
ret
|
||||
|
||||
align 4
|
||||
paleholder:
|
||||
ret
|
||||
ret
|
||||
|
||||
|
||||
; --------------- APM ---------------------
|
||||
apm_entry dp 0
|
||||
@ -5190,6 +5275,7 @@ yes_shutdown_param:
|
||||
out 0x21, al
|
||||
out 0xA1, al
|
||||
|
||||
if 1
|
||||
mov word [OS_BASE+0x467+0],pr_mode_exit
|
||||
mov word [OS_BASE+0x467+2],0x1000
|
||||
|
||||
@ -5200,8 +5286,123 @@ yes_shutdown_param:
|
||||
|
||||
mov al,0xFE
|
||||
out 0x64,al
|
||||
|
||||
hlt
|
||||
|
||||
else
|
||||
cmp byte [OS_BASE + 0x9030], 2
|
||||
jnz no_acpi_power_off
|
||||
|
||||
; scan for RSDP
|
||||
; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA).
|
||||
movzx eax, word [OS_BASE + 0x40E]
|
||||
shl eax, 4
|
||||
jz @f
|
||||
mov ecx, 1024/16
|
||||
call scan_rsdp
|
||||
jnc .rsdp_found
|
||||
@@:
|
||||
; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh.
|
||||
mov eax, 0xE0000
|
||||
mov ecx, 0x2000
|
||||
call scan_rsdp
|
||||
jc no_acpi_power_off
|
||||
.rsdp_found:
|
||||
mov esi, [eax+16] ; esi contains physical address of the RSDT
|
||||
mov ebp, [ipc_tmp]
|
||||
stdcall map_page, ebp, esi, PG_MAP
|
||||
lea eax, [esi+1000h]
|
||||
lea edx, [ebp+1000h]
|
||||
stdcall map_page, edx, eax, PG_MAP
|
||||
and esi, 0xFFF
|
||||
add esi, ebp
|
||||
cmp dword [esi], 'RSDT'
|
||||
jnz no_acpi_power_off
|
||||
mov ecx, [esi+4]
|
||||
sub ecx, 24h
|
||||
jbe no_acpi_power_off
|
||||
shr ecx, 2
|
||||
add esi, 24h
|
||||
.scan_fadt:
|
||||
lodsd
|
||||
mov ebx, eax
|
||||
lea eax, [ebp+2000h]
|
||||
stdcall map_page, eax, ebx, PG_MAP
|
||||
lea eax, [ebp+3000h]
|
||||
add ebx, 0x1000
|
||||
stdcall map_page, eax, ebx, PG_MAP
|
||||
and ebx, 0xFFF
|
||||
lea ebx, [ebx+ebp+2000h]
|
||||
cmp dword [ebx], 'FACP'
|
||||
jz .fadt_found
|
||||
loop .scan_fadt
|
||||
jmp no_acpi_power_off
|
||||
.fadt_found:
|
||||
; ebx is linear address of FADT
|
||||
mov edx, [ebx+48]
|
||||
test edx, edx
|
||||
jz .nosmi
|
||||
mov al, [ebx+52]
|
||||
out dx, al
|
||||
mov edx, [ebx+64]
|
||||
@@:
|
||||
in ax, dx
|
||||
test al, 1
|
||||
jz @b
|
||||
.nosmi:
|
||||
mov edx, [ebx+64]
|
||||
in ax, dx
|
||||
and ax, 203h
|
||||
or ax, 3C00h
|
||||
out dx, ax
|
||||
mov edx, [ebx+68]
|
||||
test edx, edx
|
||||
jz @f
|
||||
in ax, dx
|
||||
and ax, 203h
|
||||
or ax, 3C00h
|
||||
out dx, ax
|
||||
@@:
|
||||
jmp $
|
||||
|
||||
|
||||
no_acpi_power_off:
|
||||
mov word [OS_BASE+0x467+0],pr_mode_exit
|
||||
mov word [OS_BASE+0x467+2],0x1000
|
||||
|
||||
mov al,0x0F
|
||||
out 0x70,al
|
||||
mov al,0x05
|
||||
out 0x71,al
|
||||
|
||||
mov al,0xFE
|
||||
out 0x64,al
|
||||
|
||||
hlt
|
||||
|
||||
scan_rsdp:
|
||||
add eax, OS_BASE
|
||||
.s:
|
||||
cmp dword [eax], 'RSD '
|
||||
jnz .n
|
||||
cmp dword [eax+4], 'PTR '
|
||||
jnz .n
|
||||
xor edx, edx
|
||||
xor esi, esi
|
||||
@@:
|
||||
add dl, [eax+esi]
|
||||
inc esi
|
||||
cmp esi, 20
|
||||
jnz @b
|
||||
test dl, dl
|
||||
jz .ok
|
||||
.n:
|
||||
add eax, 10h
|
||||
loop .s
|
||||
stc
|
||||
.ok:
|
||||
ret
|
||||
end if
|
||||
|
||||
include "data32.inc"
|
||||
|
||||
|
@ -130,8 +130,9 @@ struc APPDATA
|
||||
.dbg_state dd ? ;+76
|
||||
.cur_dir dd ? ;+80
|
||||
.wait_timeout dd ? ;+84
|
||||
.saved_esp0 dd ? ;+88
|
||||
|
||||
db 40 dup(?) ;+88
|
||||
db 36 dup(?) ;+92
|
||||
|
||||
.wnd_shape dd ? ;+128
|
||||
.wnd_shape_scale dd ? ;+132
|
||||
@ -177,6 +178,7 @@ include "core/dll.inc"
|
||||
include "core/peload.inc" ;
|
||||
include "core/exports.inc"
|
||||
include "core/string.inc"
|
||||
include "core/v86.inc" ; virtual-8086 manager
|
||||
|
||||
; GUI stuff
|
||||
include "gui/window.inc"
|
||||
|
@ -21,6 +21,8 @@
|
||||
; 0x9040 - dword - entry point of APM BIOS
|
||||
; 0x9044 - word - version (BCD)
|
||||
; 0x9046 - word - flags
|
||||
; 0:907F byte number of BIOS hard disks
|
||||
; 0:9080 Nbytes BIOS hard disks
|
||||
;
|
||||
; Runtime:
|
||||
;
|
||||
@ -149,7 +151,10 @@
|
||||
; 44 dword io permission map page 0
|
||||
; 48 dword io permission map page 1
|
||||
; 4c dword debug state: 1= load debug registers
|
||||
; 50-7F unused
|
||||
; 50 dword current directory ptr
|
||||
; 54 dword wait timeout
|
||||
; 58 dword thread TSS._esp0 (= pl0 stack base + size except for V86)
|
||||
; 5C-7F unused
|
||||
;
|
||||
; 80 dword address of random shaped window area
|
||||
; 84 byte shape area scale
|
||||
|
@ -166,7 +166,7 @@ unpack:
|
||||
; result=0;
|
||||
mov ecx, .Literal + (.LZMA_LIT_SIZE shl (.lc+.lp))
|
||||
mov eax, .kBitModelTotal/2
|
||||
mov edi, .p
|
||||
mov edi, [.p]
|
||||
rep stosd
|
||||
; RangeDecoderInit
|
||||
; rd->ExtraBytes = 0
|
||||
@ -187,7 +187,8 @@ unpack:
|
||||
and edx, .posStateMask
|
||||
mov eax, ebx
|
||||
shl eax, .kNumPosBitsMax+2
|
||||
lea eax, [.p + .IsMatch*4 + eax + edx*4]
|
||||
lea eax, [.IsMatch*4 + eax + edx*4]
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitDecode
|
||||
jc .1
|
||||
movzx eax, [.previousByte]
|
||||
@ -197,7 +198,8 @@ if .literalPosMask
|
||||
end if
|
||||
shr eax, 8-.lc
|
||||
imul eax, .LZMA_LIT_SIZE*4
|
||||
add eax, .p+.Literal*4
|
||||
add eax, .Literal*4
|
||||
add eax, [.p]
|
||||
cmp ebx, .kNumLitStates
|
||||
jb .literal
|
||||
xor edx, edx
|
||||
@ -220,15 +222,18 @@ end if
|
||||
@@: sub bl, al
|
||||
jmp .main_loop
|
||||
.1:
|
||||
lea eax, [.p + .IsRep*4 + ebx*4]
|
||||
lea eax, [.IsRep*4 + ebx*4]
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitDecode
|
||||
jnc .10
|
||||
lea eax, [.p + .IsRepG0*4 + ebx*4]
|
||||
lea eax, [.IsRepG0*4 + ebx*4]
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitDecode
|
||||
jc .111
|
||||
mov eax, ebx
|
||||
shl eax, .kNumPosBitsMax+2
|
||||
lea eax, [.p + .IsRep0Long*4 + eax + edx*4]
|
||||
lea eax, [.IsRep0Long*4 + eax + edx*4]
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitDecode
|
||||
jc .1101
|
||||
cmp bl, 7
|
||||
@ -241,12 +246,14 @@ end if
|
||||
mov [.previousByte], al
|
||||
jmp .main_loop
|
||||
.111:
|
||||
lea eax, [.p + .IsRepG1*4 + ebx*4]
|
||||
lea eax, [.IsRepG1*4 + ebx*4]
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitDecode
|
||||
mov eax, [.rep1]
|
||||
jnc .l3
|
||||
.l1:
|
||||
lea eax, [.p + .IsRepG2*4 + ebx*4]
|
||||
lea eax, [.IsRepG2*4 + ebx*4]
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitDecode
|
||||
mov eax, [.rep2]
|
||||
jnc .l2
|
||||
@ -258,7 +265,8 @@ end if
|
||||
xchg eax, [.rep0]
|
||||
mov [.rep1], eax
|
||||
.1101:
|
||||
mov eax, .p + .RepLencoder*4
|
||||
mov eax, .RepLencoder*4
|
||||
add eax, [.p]
|
||||
call .LzmaLenDecode
|
||||
cmp bl, 7
|
||||
setc bl
|
||||
@ -276,7 +284,8 @@ end if
|
||||
adc bl, bl
|
||||
xor bl, 3
|
||||
add bl, 7
|
||||
mov eax, .p + .Lencoder*4
|
||||
mov eax, .Lencoder*4
|
||||
add eax, [.p]
|
||||
call .LzmaLenDecode
|
||||
mov eax, .kNumLenToPosStates-1
|
||||
cmp eax, ecx
|
||||
@ -287,7 +296,8 @@ end if
|
||||
mov ecx, .kNumPosSlotBits
|
||||
shl eax, cl
|
||||
shl eax, 2
|
||||
add eax, .p+.PosSlot*4
|
||||
add eax, .PosSlot*4
|
||||
add eax, [.p]
|
||||
call .RangeDecoderBitTreeDecode
|
||||
mov [.rep0], ecx
|
||||
cmp ecx, .kStartPosModelIndex
|
||||
@ -305,7 +315,8 @@ end if
|
||||
jae .l5
|
||||
sub eax, edx
|
||||
shl eax, 2
|
||||
add eax, .p + (.SpecPos - 1)*4
|
||||
add eax, (.SpecPos - 1)*4
|
||||
add eax, [.p]
|
||||
call .RangeDecoderReverseBitTreeDecode
|
||||
add [.rep0], ecx
|
||||
jmp .l6
|
||||
@ -315,7 +326,8 @@ end if
|
||||
mov ecx, .kNumAlignBits
|
||||
shl eax, cl
|
||||
add [.rep0], eax
|
||||
mov eax, .p+.Align_*4
|
||||
mov eax, .Align_*4
|
||||
add eax, [.p]
|
||||
call .RangeDecoderReverseBitTreeDecode
|
||||
add [.rep0], ecx
|
||||
.l6:
|
||||
@ -503,7 +515,8 @@ end if
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
unpack.p rd unpack.LZMA_BASE_SIZE + (unpack.LZMA_LIT_SIZE shl (unpack.lc+unpack.lp))
|
||||
;unpack.p rd unpack.LZMA_BASE_SIZE + (unpack.LZMA_LIT_SIZE shl (unpack.lc+unpack.lp))
|
||||
unpack.p dd ?
|
||||
unpack.code_ dd ?
|
||||
unpack.range dd ?
|
||||
unpack.rep0 dd ?
|
||||
|
Loading…
Reference in New Issue
Block a user