1)fixed bug with wrong lfb size on some old videocards

2)set fpu/sse to default state for new thread
3)added driver sceletone

git-svn-id: svn://kolibrios.org@214 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge)
2006-11-20 07:06:00 +00:00
parent 44a74d9138
commit 00b8fb388c
18 changed files with 1236 additions and 355 deletions

View File

@@ -1,17 +1,6 @@
;
; This file is part of the Infinity sound AC97 driver.
; (C) copyright Serge 2006
; email: infinity_sound@mail.ru
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
DRV_ENTRY equ 1
DRV_EXIT equ -1
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword
@@ -713,6 +702,7 @@ proc load_driver stdcall, file_name:dword
endl
stdcall load_file, [file_name]
test eax, eax
jz .fail
@@ -809,7 +799,7 @@ proc load_driver stdcall, file_name:dword
stdcall kernel_free, [coff]
mov ebx, [start]
call ebx
stdcall ebx, DRV_ENTRY
test eax, eax
jnz .ok
@@ -819,6 +809,8 @@ proc load_driver stdcall, file_name:dword
.ok:
mov ebx, [img_base]
mov [eax+SRV.base], ebx
mov ecx, [start]
mov [eax+SRV.entry], ecx
ret
.fail:
xor eax, eax
@@ -930,12 +922,35 @@ proc load_library stdcall, file_name:dword
ret
endp
align 4
proc stop_all_services
pushf
cli
mov eax, [srv_map]
not eax
mov [srv_map], eax
.next:
bsf eax, [srv_map]
jnz .find
popf
ret
.find:
btr [srv_map], eax
shl eax,0x02
lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36
mov ebx, [eax+SRV.entry]
stdcall ebx, dword -1
jmp .next
endp
drv_sound db '/rd/1/drivers/unisound.obj', 0
drv_infinity db '/rd/1/drivers/infinity.obj', 0
drv_ati2d db '/rd/1/drivers/ati2d.obj', 0
szSound db 'SOUND',0
szInfinity db 'INFINITY',0
szHMouse db 'ATI2D',0
szSTART db 'START',0
szEXPORTS db 'EXPORTS',0
@@ -945,8 +960,12 @@ msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0
msg_CR db 13,10,0
align 4
set_hw_cursor dd 0
align 16
services:
dd szSound, drv_sound
dd szInfinity, drv_infinity
dd szHMouse, drv_ati2d
dd 0

View File

@@ -1,117 +0,0 @@
reg_eip equ ebp+4
reg_cs equ ebp+8
reg_eflags equ ebp+12
reg_esp equ ebp+16
reg_ss equ ebp+20
;fpu_ctrl equ ebp-28
align 4
except_16:
push ebp
mov ebp, esp
; sub esp, 28
push eax
push ebx
push ecx
push edx
mov ebx, [ss:CURRENT_TASK]
shl ebx, 8
mov eax, [ss:ebx+PROC_BASE+APPDATA.fpu_handler]
test eax, eax
jz .default
mov ecx, [reg_eip]
mov edx, [reg_esp]
sub edx, 4
mov [ss:edx+new_app_base], ecx
mov [reg_esp], edx
mov dword [reg_eip], eax
pop edx
pop ecx
pop ebx
pop eax
leave
iretd
.default:
pop edx
pop ecx
pop ebx
pop eax
leave
save_ring3_context ;debugger support
mov bl, 16
jmp exc_c
; fnstenv [fpu_ctrl]
; fnclex
; or word [fpu_ctrl], 0111111b
; fldenv [fpu_ctrl]
; pop edx
; pop ecx
; pop ebx
; pop eax
; leave
; iretd
align 16
except_19:
push ebp
mov ebp, esp
push eax
push ebx
push ecx
push edx
mov ebx, [ss:CURRENT_TASK]
shl ebx, 8
mov eax, [ss:ebx+PROC_BASE+APPDATA.sse_handler]
test eax, eax
jz .default
mov ecx, [reg_eip]
mov edx, [reg_esp]
sub edx, 4
mov [ss:edx+new_app_base], ecx
mov [reg_esp], edx
mov dword [reg_eip], eax
pop edx
pop ecx
pop ebx
pop eax
leave
iretd
.default:
pop edx
pop ecx
pop ebx
pop eax
leave
save_ring3_context ;debugger support
mov bl, 19
jmp exc_c
restore reg_eip
restore reg_cs
restore reg_eflags
restore reg_esp
restore reg_ss
;restore fpu_ctrl

View File

@@ -20,6 +20,10 @@ kernel_export:
dd szServiceHandler , srv_handler
dd szFpuSave , fpu_save
dd szFpuRestore , fpu_restore
dd szSetHwCursor , set_hw_cursor
dd szLoadFile , load_file
exp_lfb:
dd szLFBAddress , 0
dd 0
szKernel db 'KERNEL', 0
@@ -40,6 +44,9 @@ kernel_export:
szServiceHandler db 'ServiceHandler',0
szFpuSave db 'FpuSave',0
szFpuRestore db 'FpuRestore',0
szSetHwCursor db 'SetHwCursor',0
szLFBAddress db 'LFBAddress',0
szLoadFile db 'LoadFile',0
endg

223
kernel/trunk/core/fpu.inc Normal file
View File

@@ -0,0 +1,223 @@
init_fpu:
clts
fninit
bt [cpu_caps], CAPS_FXSR
jnc .no_FXSR
stdcall kernel_alloc, 512*256
mov [fpu_data], eax
mov ebx, cr4
mov ecx, cr0
or ebx, CR4_OSFXSR+CR4_OSXMMEXPT
mov cr4, ebx
and ecx, not (CR0_MP+CR0_EM)
or ecx, CR0_NE
mov cr0, ecx
mov dword [esp-4], SSE_INIT
ldmxcsr [esp-4]
xorps xmm0, xmm0
xorps xmm1, xmm1
xorps xmm2, xmm2
xorps xmm3, xmm3
xorps xmm4, xmm4
xorps xmm5, xmm5
xorps xmm6, xmm6
xorps xmm7, xmm7
fxsave [eax]
ret
.no_FXSR:
stdcall kernel_alloc, 112*256
mov [fpu_data], eax
mov ecx, cr0
and ecx, not CR0_EM
or ecx, CR0_MP+CR0_NE
mov cr0, ecx
fnsave [eax]
ret
align 4
proc fpu_save
clts
mov ebx, [fpu_owner]
shl ebx, 8
mov eax, [ebx+PROC_BASE+0x10]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
fxsave [eax]
fninit ;re-init fpu
ret
.no_SSE:
fnsave [eax]
ret
endp
align 4
proc fpu_restore
mov ebx, [CURRENT_TASK]
shl ebx, 8
mov eax, [ebx+PROC_BASE+0x10]
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
fxrstor [eax]
ret
.no_SSE:
fnclex ;fix possible problems
frstor [eax]
ret
endp
align 4
e7: ;#NM exception handler
save_ring3_context
clts
mov ax, os_data
mov ds, ax
mov es, ax
mov ebx, [fpu_owner]
cmp ebx, [CURRENT_TASK]
je .exit
shl ebx, 8
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
fxsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
fxrstor [eax]
.exit:
restore_ring3_context
iret
.no_SSE:
fnsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
frstor [eax]
restore_ring3_context
iret
iglobal
fpu_owner dd 1
endg
reg_eip equ ebp+4
reg_cs equ ebp+8
reg_eflags equ ebp+12
reg_esp equ ebp+16
reg_ss equ ebp+20
align 4
except_16: ;fpu native exceptions handler
push ebp
mov ebp, esp
push eax
push ebx
push ecx
push edx
mov ebx, [ss:CURRENT_TASK]
shl ebx, 8
mov eax, [ss:ebx+PROC_BASE+APPDATA.fpu_handler]
test eax, eax
jz .default
mov ecx, [reg_eip]
mov edx, [reg_esp]
sub edx, 4
mov [ss:edx+new_app_base], ecx
mov [reg_esp], edx
mov dword [reg_eip], eax
pop edx
pop ecx
pop ebx
pop eax
leave
iretd
.default:
pop edx
pop ecx
pop ebx
pop eax
leave
save_ring3_context ;debugger support
mov bl, 16
jmp exc_c
align 4
except_19: ;sse exceptions handler
push ebp
mov ebp, esp
push eax
push ebx
push ecx
push edx
mov ebx, [ss:CURRENT_TASK]
shl ebx, 8
mov eax, [ss:ebx+PROC_BASE+APPDATA.sse_handler]
test eax, eax
jz .default
mov ecx, [reg_eip]
mov edx, [reg_esp]
sub edx, 4
mov [ss:edx+new_app_base], ecx
mov [reg_esp], edx
mov dword [reg_eip], eax
pop edx
pop ecx
pop ebx
pop eax
leave
iretd
.default:
pop edx
pop ecx
pop ebx
pop eax
leave
save_ring3_context ;debugger support
mov bl, 19
jmp exc_c
restore reg_eip
restore reg_cs
restore reg_eflags
restore reg_esp
restore reg_ss

View File

@@ -680,7 +680,6 @@ l_0:
and eax, 0xFFFFF000
cmp eax, ecx ;alloc_size
jb m_next
jz @f
mov edx, esi
add edx, ecx
@@ -688,7 +687,7 @@ l_0:
or eax, FREE_BLOCK
shr edx, 12
mov [pages_tab+edx*4], eax
@@:
or ecx, USED_BLOCK
mov [pages_tab+ebx*4], ecx
shr ecx, 12
@@ -754,8 +753,6 @@ proc user_free stdcall, base:dword
shl ebx, 8
mov esi, dword [ebx+PROC_BASE+APPDATA.heap_base]; heap_base
mov edi, dword [ebx+PROC_BASE+APPDATA.heap_top]; heap_top
add esi, new_app_base
add edi, new_app_base
shr esi, 12
shr edi, 12
@@:
@@ -826,10 +823,10 @@ proc alloc_service
popf
xor eax, eax
ret
.find: btr [srv_map], eax
.find:
btr [srv_map], eax
popf
shl eax,5
add eax, srv_tab
shl eax,0x02
lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36
ret
endp

View File

@@ -3,13 +3,14 @@ tmp_page_tab equ 0x00C00000
align 4
proc mem_test
mov eax, cr0
and eax, not (CR0_CD+CR0_NW)
or eax, CR0_CD ;disable caching
or eax, CR0_CD ;disable caching
mov cr0, eax
wbinvd ;invalidate cache
wbinvd ;invalidate cache
xor edi, edi
xor edi, edi
mov ebx, 'TEST'
@@:
add edi, 0x400000
@@ -21,6 +22,7 @@ proc mem_test
and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax
mov eax, edi
mov [LFBSize], 0x00800000
ret
endp
@@ -49,8 +51,6 @@ proc init_memEx
mov dword [sys_pgdir+4], eax
add eax, 0x00400000
mov dword [sys_pgdir+8], eax
; add eax, 0x00400000
; mov dword [sys_pgdir+12], eax
mov dword [sys_pgdir+0x600], sys_pgdir+PG_SW
@@ -306,6 +306,8 @@ proc map_LFB
mov edi, [LFBSize]
mov esi, [LFBAddress]
mov dword [exp_lfb+4], esi
shr edi, 12
mov [pg_count], edi
shr edi, 10
@@ -1027,42 +1029,6 @@ proc strncmp stdcall, str1:dword, str2:dword, count:dword
ret
endp
align 4
proc fpu_save
clts
mov ebx, [fpu_owner]
shl ebx, 8
mov eax, [ebx+PROC_BASE+0x10]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
fxsave [eax]
fninit ;re-init fpu
ret
.no_SSE:
fnsave [eax]
ret
endp
align 4
proc fpu_restore
mov ebx, [CURRENT_TASK]
shl ebx, 8
mov eax, [ebx+PROC_BASE+0x10]
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
fxrstor [eax]
ret
.no_SSE:
fnclex ;fix possible problems
frstor [eax]
ret
endp
align 4
proc test_cpu
locals
@@ -1286,10 +1252,9 @@ align 16
tmp_task_ptab rd 1
tmp_task_data rd 1
; current_pdir rd 1
fpu_data rd 1
fdd_buff rd 1
LFBSize rd 1
stall_mcs rd 1
;;CPUID information
@@ -1303,7 +1268,7 @@ endg
uglobal
align 16
dll_tab rb 32*32
srv_tab rb 32*32
srv_tab rb 36*32
dll_map rd 1
srv_map rd 1

View File

@@ -192,63 +192,6 @@ exc_c:
restore_ring3_context
iretd
;;;;;;;;;;;;;;;;;;;;;;;
;; FPU ERROR HANDLER ;;
;;;;;;;;;;;;;;;;;;;;;;;
align 4
e7:
save_ring3_context
clts
mov ax, os_data
mov ds, ax
mov es, ax
mov ebx, [fpu_owner]
cmp ebx, [CURRENT_TASK]
je .exit
shl ebx, 8
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
fxsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
cmp dword [ebx+PROC_BASE+APPDATA.fpu_init], 0
je .init
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
fxrstor [eax]
restore_ring3_context
iret
.no_SSE:
fnsave [eax]
mov ebx, [CURRENT_TASK]
mov [fpu_owner], ebx
shl ebx, 8
cmp dword [ebx+PROC_BASE+APPDATA.fpu_init], 0
je .ready
mov eax, [ebx+PROC_BASE+APPDATA.fpu_state]
frstor [eax]
restore_ring3_context
iret
.init:
fninit ;<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>᪨஢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.ready:
mov dword [ebx+PROC_BASE+APPDATA.fpu_init], 1
.exit:
restore_ring3_context
iret
iglobal
fpu_owner dd 1
endg
writehex:
pusha

View File

@@ -1,4 +1,4 @@
GREEDY_KERNEL equ 0; 1
GREEDY_KERNEL equ 0
struc APP_HEADER_00
@@ -604,29 +604,34 @@ align 4
proc add_app_parameters stdcall,slot:dword,img_base:dword,\
cmd_line:dword, app_path:dword, flags:dword
mov eax,[slot]
mov edi, [slot]
mov esi, [fpu_data]
bt [cpu_caps], CAPS_FXSR
jnc .no_SSE
shl eax, 8
mov ebx, eax
add eax, eax
add eax, [fpu_data]
mov [ebx+PROC_BASE+APPDATA.fpu_state], eax
mov [ebx+PROC_BASE+APPDATA.fpu_handler], 0
mov [ebx+PROC_BASE+APPDATA.sse_handler], 0
jmp .m1
shl edi, 8
mov eax, edi
lea edi, [esi+edi*2]
mov [eax+PROC_BASE+APPDATA.fpu_state], edi
mov [eax+PROC_BASE+APPDATA.fpu_handler], 0
mov [eax+PROC_BASE+APPDATA.sse_handler], 0
mov ecx, 512/4
jmp @F
.no_SSE:
mov ecx, eax
mov ebx, eax
shl eax, 7
mov eax, edi
shl eax, 8
mov ebx, edi
shl edi, 7
shl ebx, 4
sub eax, ebx ;eax*=112
add eax, [fpu_data]
shl ecx, 8
mov [ecx+PROC_BASE+APPDATA.fpu_state], eax
mov [ecx+PROC_BASE+APPDATA.fpu_handler], 0
mov [ecx+PROC_BASE+APPDATA.sse_handler], 0
.m1:
sub edi, ebx ;edi*=112
add edi, esi
mov [eax+PROC_BASE+APPDATA.fpu_state], edi
mov [eax+PROC_BASE+APPDATA.fpu_handler], 0
mov [eax+PROC_BASE+APPDATA.sse_handler], 0
mov ecx, 112/4
@@:
rep movsd
mov ebx,[slot]
cmp ebx,[TASK_COUNT]
jle .noinc