Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 213 → Rev 214

/kernel/trunk/core/except.inc
File deleted
/kernel/trunk/core/dll.inc
1,18 → 1,7
;
; 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
endl
 
stdcall load_file, [file_name]
 
test eax, eax
jz .fail
 
809,7 → 799,7
stdcall kernel_free, [coff]
 
mov ebx, [start]
call ebx
stdcall ebx, DRV_ENTRY
test eax, eax
jnz .ok
 
819,6 → 809,8
.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
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_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
/kernel/trunk/core/exports.inc
20,6 → 20,10
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
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
 
/kernel/trunk/core/fpu.inc
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
 
 
/kernel/trunk/core/heap.inc
680,7 → 680,6
and eax, 0xFFFFF000
cmp eax, ecx ;alloc_size
jb m_next
jz @f
 
mov edx, esi
add edx, ecx
688,7 → 687,7
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
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
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
/kernel/trunk/core/memory.inc
3,6 → 3,7
 
align 4
proc mem_test
 
mov eax, cr0
and eax, not (CR0_CD+CR0_NW)
or eax, CR0_CD ;disable caching
21,6 → 22,7
and eax, not (CR0_CD+CR0_NW) ;enable caching
mov cr0, eax
mov eax, edi
mov [LFBSize], 0x00800000
ret
endp
 
49,8 → 51,6
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
 
mov edi, [LFBSize]
mov esi, [LFBAddress]
mov dword [exp_lfb+4], esi
 
shr edi, 12
mov [pg_count], edi
shr edi, 10
1028,42 → 1030,6
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
cpu_type dd ?
1286,10 → 1252,9
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
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
 
/kernel/trunk/core/sys32.inc
192,63 → 192,6
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 ;­ ¬ ­¥ ­ã¦­ë ­¥¬ áª¨à®¢ ­­ë¥ ¨áª«î祭¨ï
.ready:
mov dword [ebx+PROC_BASE+APPDATA.fpu_init], 1
.exit:
restore_ring3_context
iret
 
iglobal
fpu_owner dd 1
endg
 
 
writehex:
pusha
 
/kernel/trunk/core/taskman.inc
1,4 → 1,4
GREEDY_KERNEL equ 0; 1
GREEDY_KERNEL equ 0
 
 
struc APP_HEADER_00
604,29 → 604,34
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 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 eax, edi
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
.no_SSE:
mov ecx, eax
mov ebx, eax
shl eax, 7
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