From b9e5a9d227be08a22849afde59a779f39d9b9e8a Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Sat, 15 Mar 2008 19:30:34 +0000 Subject: [PATCH] V86 improvements git-svn-id: svn://kolibrios.org@770 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/hd_drv.inc | 3 +- kernel/trunk/core/v86.inc | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/kernel/trunk/blkdev/hd_drv.inc b/kernel/trunk/blkdev/hd_drv.inc index 407588ce99..2bcf5a4ae3 100644 --- a/kernel/trunk/blkdev/hd_drv.inc +++ b/kernel/trunk/blkdev/hd_drv.inc @@ -910,7 +910,8 @@ int13_call: popad @@: mov word [ebx+v86_regs.esi], 510h - mov word [ebx+v86_regs.esp], 900h + mov word [ebx+v86_regs.ss], 9000h + mov word [ebx+v86_regs.esp], 0C000h mov word [ebx+v86_regs.eip], 500h mov [ebx+v86_regs.eflags], 20200h mov esi, [sys_v86_machine] diff --git a/kernel/trunk/core/v86.inc b/kernel/trunk/core/v86.inc index 0e35b35da1..a07f7a8dc5 100644 --- a/kernel/trunk/core/v86.inc +++ b/kernel/trunk/core/v86.inc @@ -216,6 +216,8 @@ init_sys_v86: mov byte [BOOT_VAR + 0x505], 0xF4 mov esi, eax mov ebx, [eax+V86_machine.pagedir] + mov dword [ebx+0x9B*4+0x1000], 0x9B000 or 111b + mov dword [ebx+0x9B*4+0x1800], OS_BASE + 0x9B000 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 @@ -549,6 +551,38 @@ v86_exc_c: inc word [esp+v86_regs.eip] popad iretd +.handle_pushfd: + cmp word [esp+v86_regs.esp], 4 + jae @f + mov bl, 12 ; #SS exception + jmp .nogp +@@: + movzx edx, word [esp+v86_regs.ss] + shl edx, 4 + movzx eax, word [esp+v86_regs.esp] + sub eax, 4 + 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+3] + call v86_get_lin_addr + cmp eax, 0x1000 + jae @f + mov bl, 14 ; #PF exception + jmp .nogp +@@: + sub word [esp+v86_regs.esp], 4 + movzx eax, word [esp+v86_regs.eflags] + mov [edx], eax + add word [esp+v86_regs.eip], 2 + popad + iretd .handle_popf: cmp word [esp+v86_regs.esp], 0xFFFF jnz @f @@ -580,6 +614,37 @@ v86_exc_c: inc word [esp+v86_regs.eip] popad iretd +.handle_popfd: + cmp word [esp+v86_regs.esp], 0x10000 - 4 + 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+3] + call v86_get_lin_addr + cmp eax, 0x1000 + jae @f + mov bl, 14 + jmp .nogp +@@: + mov eax, [edx] + mov word [esp+v86_regs.eflags], ax + add word [esp+v86_regs.esp], 4 + add word [esp+v86_regs.eip], 2 + popad + iretd .handle_cli: and byte [esp+v86_regs.eflags+1], not 2 inc word [esp+v86_regs.eip] @@ -616,6 +681,10 @@ v86_exc_c: cmp word [esp+v86_regs.eip], 0xFFFF jae .nogp lodsb + cmp al, 0x9C + jz .handle_pushfd + cmp al, 0x9D + jz .handle_popfd cmp al, 0xEF jz .handle_out_dword cmp al, 0xED