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

@ -180,7 +180,7 @@ MOUSE_BUFF_COUNT equ OS_BASE+0x000FCFF
HD_CACHE_ENT equ OS_BASE+0x000FE10
LFBAddress equ OS_BASE+0x000FE80
MEM_AMOUNT equ OS_BASE+0x000FE8C
LFBSize equ OS_BASE+0x02f9050
;LFBSize equ OS_BASE+0x02f9050
SCR_X_SIZE equ OS_BASE+0x000FE00
SCR_Y_SIZE equ OS_BASE+0x000FE04
@ -377,6 +377,7 @@ struc SRV
.magic dd ?
.size dd ?
.base dd ?
.entry dd ?
.srv_proc dd ?
}

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 ;­ ¬ ­¥ ­ã¦­ë ­¥¬ áª¨à®¢ ­­ë¥ ¨áª«î祭¨ï
.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

View File

@ -0,0 +1,668 @@
;alpha version
format MS COFF
include 'proc32.inc'
DEBUG equ 0
VID_ATI equ 0x1002
R8500 equ 0x514C ;R200
R9000 equ 0x4966 ;RV250
R9200 equ 0x5961 ;RV280
R9500 equ 0x4144 ;R300
R9500P equ 0x4E45 ;R300
R9550 equ 0x4153 ;RV350
R9600 equ 0x4150 ;RV350
R9600XT equ 0x4152 ;RV360
R9700P equ 0x4E44 ;R300
R9800 equ 0x4E49 ;R350
R9800P equ 0x4E48 ;R350
R9800XT equ 0x4E4A ;R360
OS_BASE equ 0; 0x80400000
new_app_base equ 0x60400000; 0x01000000
PROC_BASE equ OS_BASE+0x0080000
PG_SW equ 0x003
PG_NOCACHE equ 0x018
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
;MMIO equ 0F9000000h
RD_RB3D_CNTL equ 1c3ch
RD_MEM_CNTL equ 0140h
RD_CRTC_GEN_CNTL equ 0050h
RD_CRTC_CUR_EN equ 10000h
RD_DISPLAY_BASE_ADDR equ 023ch
RD_DEFAULT_OFFSET equ 16e0h
CUR_HORZ_VERT_OFF equ 0268h
CUR_HORZ_VERT_POSN equ 0264h
CUR_OFFSET equ 0260h
RD_RB3D_CNTL equ 1c3ch
RD_RBBM_STATUS equ 0e40h
RD_RBBM_FIFOCNT_MASK equ 007fh
RD_RBBM_ACTIVE equ 80000000h
RD_TIMEOUT equ 2000000
RD_DP_GUI_MASTER_CNTL equ 0146ch
RD_DP_BRUSH_BKGD_CLR equ 01478h
RD_DP_BRUSH_FRGD_CLR equ 0147ch
RD_DP_SRC_BKGD_CLR equ 015dch
RD_DP_SRC_FRGD_CLR equ 015d8h
RD_DP_CNTL equ 016c0h
RD_DP_DATATYPE equ 016c4h
RD_DP_WRITE_MASK equ 016cch
RD_DP_SRC_SOURCE_MEMORY equ (2 shl 24)
RD_DP_SRC_SOURCE_HOST_DATA equ (3 shl 24)
RD_DEFAULT_SC_BOTTOM_RIGHT equ 16e8h
RD_GMC_BRUSH_SOLID_COLOR equ (13 shl 4)
RD_DEFAULT_SC_RIGHT_MAX equ 1fffh
RD_DEFAULT_SC_BOTTOM_MAX equ 1fff0000h
RD_GMC_DST_DATATYPE_SHIFT equ 8
RD_ROP3_S equ 00cc0000h
RD_ROP3_P equ 00f00000h
RD_RB2D_DSTCACHE_MODE equ 03428h
RD_RB2D_DSTCACHE_CTLSTAT equ 0342ch
RD_RB2D_DC_FLUSH_ALL equ 000fh
RD_RB2D_DC_BUSY equ 80000000h
RD_GMC_BRUSH_SOLID_COLOR equ 000000D0h
RD_GMC_SRC_DATATYPE_COLOR equ (3 shl 12)
RD_GMC_CLR_CMP_CNTL_DIS equ (1 shl 28)
RD_GMC_WR_MSK_DIS equ (1 shl 30)
cmdSolidFill equ 73f036d0h
RD_DST_PITCH_OFFSET equ 142ch
RD_SRC_PITCH_OFFSET equ 1428h
RD_DST_X_LEFT_TO_RIGHT equ 1
RD_DST_Y_TOP_TO_BOTTOM equ 2
RD_DST_Y_X equ 1438h
RD_DST_WIDTH_HEIGHT equ 1598h
RD_DST_LINE_START equ 1600h
RD_DST_LINE_END equ 1604h
R300_MEM_NUM_CHANNELS_MASK equ 0003h
macro rdr op1, op2
{
mov edi, [ati_io]
mov op1, [edi+op2]
}
macro wrr dest, src
{
mov edi, [ati_io]
mov dword [edi+dest], src
}
public START
public service_proc
extrn SysMsgBoardStr
extrn PciApi
extrn PciRead32
extrn AllocKernelSpace
extrn MapPage
extrn RegService
extrn SetHwCursor
extrn LFBAddress
extrn LoadFile
CURSOR_IMAGE_OFFSET equ 0x00500000
DRV_ENTRY equ 1
DRV_EXIT equ -1
section '.flat' code readable align 16
proc START stdcall, state:dword
mov eax, [state]
cmp eax, 1
je .entry
jmp .exit
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
call detect_ati
test eax, eax
jz .fail
stdcall LoadFile, user_file
test eax, eax
jz @F
mov [user_arrow], eax
@@:
stdcall ati_init_cursor, [user_arrow]
call init_ati
test eax, eax
jz .fail
stdcall RegService, sz_ati_srv, service_proc
test eax, eax
jz .fail
mov ebx, SetHwCursor
mov dword [ebx], drvCursorPos ;enable hardware cursor
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
end if
.exit:
xor eax, eax
mov ebx, SetHwCursor
mov dword [ebx], eax ;force disable hardware cursor
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
; mov edi, [ioctl]
; mov eax, [edi+io_code]
xor eax, eax
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
align 4
proc detect_ati
locals
last_bus dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
add edi, 4
jmp @B
.next: inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
inc eax
ret
.err:
xor eax, eax
ret
endp
align 4
proc init_ati
stdcall AllocKernelSpace, dword 0x10000
test eax, eax
jz .fail
mov [ati_io], eax
stdcall PciRead32, [bus], [devfn], dword 0x18
and eax, 0xFFFF0000
mov esi, eax
mov edi, [ati_io]
mov edx, 16
@@:
stdcall MapPage,edi,esi,PG_SW+PG_NOCACHE
add edi, 0x1000
add esi, 0x1000
dec edx
jnz @B
mov edi, [ati_io]
mov dword [edi+RD_RB3D_CNTL], 0
call engRestore
mov edi, [ati_io]
mov eax, [edi+0x50]
mov ebx,3
shl ebx,20
not ebx
and eax,ebx
mov ebx, 2
shl ebx,20
or eax, ebx
mov [edi+0x50], eax
pushd 0
pushd 0
call drvCursorPos
call drvShowCursor
xor eax, eax
inc eax
.fail:
ret
endp
align 4
drvShowCursor:
mov edi, [ati_io]
mov eax, [edi+RD_CRTC_GEN_CNTL]
bts eax,16
mov [edi+RD_CRTC_GEN_CNTL], eax
ret
align 4
drvCursorPos:
push ebp
mov ebp, esp
mov eax, 80000000h
wrr CUR_HORZ_VERT_OFF, eax
mov eax, [ebp+8]
shl eax, 16
or eax, [ebp+12]
or eax, 80000000h
wrr CUR_HORZ_VERT_POSN, eax
mov eax, CURSOR_IMAGE_OFFSET
wrr CUR_OFFSET, eax
leave
ret 8
align 4
proc ati_init_cursor stdcall, arrow:dword
locals
rBase dd ?
pQuad dd ?
pBits dd ?
pAnd dd ?
width dd ?
height dd ?
counter dd ?
endl
cld
mov esi, [arrow]
add esi,[esi+18d]
mov eax,esi
add eax, [esi]
mov [pQuad],eax
add eax,64
mov [pBits],eax
add eax, 0x200
mov [pAnd],eax
mov eax,[esi+4]
mov [width],eax
mov ebx,[esi+8]
shr ebx,1
mov [height],ebx
mov edi, pCursor
add edi, 32*31*4
mov [rBase],edi
mov esi,[pAnd]
mov ebx, [pBits]
.l1:
mov eax, [esi]
bswap eax
mov [counter], 16
@@:
xor edx, edx
shl eax,1
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0xF0
shr ecx, 2
add ecx, [pQuad]
mov ecx, [ecx]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi], edx
xor edx, edx
shl eax,1
setc dl
dec edx
mov ecx, [ebx]
and ecx, 0x0F
shl ecx, 2
add ecx, [pQuad]
mov ecx, [ecx]
and ecx, edx
and edx, 0xFF000000
or edx, ecx
mov [edi+4], edx
inc ebx
add edi, 8
dec [counter]
jnz @B
add esi, 4
mov edi,[rBase]
sub edi,128
mov [rBase],edi
sub [height],1
jnz .l1
mov edi, LFBAddress
add edi, CURSOR_IMAGE_OFFSET
mov ecx, 64*64
xor eax,eax
rep stosd
mov esi, pCursor
mov edi, LFBAddress
add edi, CURSOR_IMAGE_OFFSET
mov ebx, 32
lc:
mov ecx, 32
lb:
mov eax, [esi]
mov [edi], eax
add esi, 4
add edi, 4
sub ecx, 1
jnz lb
add edi, 128
sub ebx, 1
jnz lc
ret
endp
align 4
proc engFlush
mov edi, [ati_io]
mov eax, [edi+RD_RB2D_DSTCACHE_CTLSTAT]
or eax,RD_RB2D_DC_FLUSH_ALL
mov [edi+RD_RB2D_DSTCACHE_CTLSTAT],eax
mov ecx, RD_TIMEOUT
@@:
mov eax,[edi+RD_RB2D_DSTCACHE_CTLSTAT]
and eax, RD_RB2D_DC_BUSY
jz .exit
sub ecx,1
jnz @B
.exit:
ret
endp
align 4
engWaitForFifo:
cnt equ bp+8
push ebp
mov ebp, esp
mov edi, [ati_io]
mov ecx, RD_TIMEOUT
@@:
mov eax, [edi+RD_RBBM_STATUS]
and eax, RD_RBBM_FIFOCNT_MASK
cmp eax, [ebp+8]
jae .exit
sub ecx,1
jmp @B
.exit:
leave
ret 4
align 4
proc engWaitForIdle
push dword 64
call engWaitForFifo
mov edi, [ati_io]
mov ecx ,RD_TIMEOUT
@@:
mov eax, [edi+RD_RBBM_STATUS]
and eax,RD_RBBM_ACTIVE
jz .exit
sub ecx,1
jnz @B
.exit:
call engFlush
ret
endp
align 4
proc engRestore
; push dword 1
; call engWaitForFifo
; mov dword [MMIO+RD_RB2D_DSTCACHE_MODE], 0
push dword 3
call engWaitForFifo
mov edi, [ati_io]
mov eax, [edi+RD_DISPLAY_BASE_ADDR]
shr eax, 10d
or eax,(64d shl 22d)
mov [edi+RD_DEFAULT_OFFSET],eax
mov [edi+RD_SRC_PITCH_OFFSET],eax
mov [edi+RD_DST_PITCH_OFFSET],eax
push dword 1
call engWaitForFifo
mov edi, [ati_io]
mov eax, [edi+RD_DP_DATATYPE]
btr eax, 29d
mov [edi+RD_DP_DATATYPE],eax
push dword 1
call engWaitForFifo
mov edi, [ati_io]
mov dword [edi+RD_DEFAULT_SC_BOTTOM_RIGHT],\
(RD_DEFAULT_SC_RIGHT_MAX or RD_DEFAULT_SC_BOTTOM_MAX)
push dword 1
call engWaitForFifo
mov edi, [ati_io]
mov dword [edi+RD_DP_GUI_MASTER_CNTL],\
(RD_GMC_BRUSH_SOLID_COLOR or \
RD_GMC_SRC_DATATYPE_COLOR or \
(6 shl RD_GMC_DST_DATATYPE_SHIFT) or \
RD_GMC_CLR_CMP_CNTL_DIS or \
RD_ROP3_P or \
RD_GMC_WR_MSK_DIS)
push dword 7
call engWaitForFifo
mov edi, [ati_io]
mov dword [edi+RD_DST_LINE_START],0
mov dword [edi+RD_DST_LINE_END], 0
mov dword [edi+RD_DP_BRUSH_FRGD_CLR], 808000ffh
mov dword [edi+RD_DP_BRUSH_BKGD_CLR], 002020ffh
mov dword [edi+RD_DP_SRC_FRGD_CLR], 808000ffh
mov dword [edi+RD_DP_SRC_BKGD_CLR], 004000ffh
mov dword [edi+RD_DP_WRITE_MASK],0ffffffffh
call engWaitForIdle
ret
endp
align 4
engSetupSolidFill:
push ebp
mov ebp, esp
push dword 3
call engWaitForFifo
wrr RD_DP_GUI_MASTER_CNTL, cmdSolidFill
mov eax, [ebp+8]
wrr RD_DP_BRUSH_FRGD_CLR,eax
mov edi, [ati_io]
mov dword [edi+RD_DP_CNTL],(RD_DST_X_LEFT_TO_RIGHT or RD_DST_Y_TOP_TO_BOTTOM)
leave
ret 4
align 4
drvSolidFill:
;x:word,y:word,w:word,h:word,color:dword
push ebp
mov ebp, esp
x equ ebp+8
y equ ebp+12
w equ ebp+16
h equ ebp+20
color equ ebp+24
push dword [ebp+24]
call engSetupSolidFill
push dword 2
call engWaitForFifo
mov edi, [ati_io]
mov eax, [y]
mov ebx, [x]
shl eax,16
or eax, ebx
mov ecx, [w]
mov edx, [h]
shl ecx,16
or ecx, edx
mov [edi+RD_DST_Y_X], eax
mov [edi+RD_DST_WIDTH_HEIGHT], ecx
call engFlush
leave
ret 20
align 4
devices dd (R8500 shl 16)+VID_ATI
dd (R9000 shl 16)+VID_ATI
dd (R9200 shl 16)+VID_ATI
dd (R9500 shl 16)+VID_ATI
dd (R9500P shl 16)+VID_ATI
dd (R9550 shl 16)+VID_ATI
dd (R9600 shl 16)+VID_ATI
dd (R9600XT shl 16)+VID_ATI
dd (R9700P shl 16)+VID_ATI
dd (R9800 shl 16)+VID_ATI
dd (R9800P shl 16)+VID_ATI
dd (R9800XT shl 16)+VID_ATI
dd 0 ;terminator
;szKernel db 'KERNEL', 0
sz_ati_srv db 'ATI2D',0
user_file db '/rd/1/user.cur',0
msgInit db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgFail db 'device not found',13,10,0
user_arrow dd pArrow
align 16
pArrow:
file 'arrow.cur'
section '.data' data readable writable align 16
pCursor db 4096 dup(?)
bus dd ?
devfn dd ?
ati_io dd ?

View File

@ -27,7 +27,6 @@ new_app_base equ 0x60400000; 0x01000000
PROC_BASE equ OS_BASE+0x0080000
public START
public STOP
public service_proc
extrn AttachIntHandler
@ -73,7 +72,13 @@ end virtual
section '.flat' code readable align 16
START:
proc START stdcall, state:dword
mov eax, [state]
cmp eax, 1
je .entry
jmp .exit
.entry:
stdcall GetService, szSound
test eax, eax
jz .fail
@ -103,6 +108,7 @@ START:
mov esi, msgFail
call SysMsgBoardStr
end if
.exit:
xor eax, eax
ret
@ -112,8 +118,8 @@ START:
call SysMsgBoardStr
end if
xor eax, eax
STOP:
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
@ -406,7 +412,6 @@ proc play_buffer stdcall, str:dword
endp
align 4
proc stop_buffer stdcall, str:dword
@ -583,7 +588,6 @@ proc prepare_playlist
loop .l1
.exit:
ret
.fail:
stdcall DestroyBuffer, esi
jmp .restart
@ -739,7 +743,7 @@ szInfinity db 'INFINITY',0
szSound db 'SOUND',0
if DEBUG
msgFail db 'Sound service not found',13,10,0
msgFail db 'Sound service not loaded',13,10,0
msgPlay db 'Play buffer',13,10,0
msgStop db 'Stop',13,10,0
msgUser db 'User callback',13,10,0

View File

@ -0,0 +1,173 @@
;driver sceletone
format MS COFF
include 'proc32.inc'
OS_BASE equ 0;
new_app_base equ 0x60400000
PROC_BASE equ OS_BASE+0x0080000
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
public START
public service_proc
extrn AttachIntHandler
extrn SysMsgBoardStr
extrn PciApi
extrn PciRead32
extrn PciRead8
extrn PciWrite8
extrn AllocKernelSpace
extrn KernelAlloc
extrn MapPage
extrn GetPgAddr
extrn RegService
extrn ServiceHandler
extrn SetHwCursor
extrn LFBAddress
extrn LoadFile
extrn FpuSave
extrn FpuRestore
DEBUG equ 1
DRV_ENTRY equ 1
DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table
section '.flat' code readable align 16
proc START stdcall, state:dword
mov eax, [state]
cmp eax, 1
je .entry
jmp .exit
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
stdcall RegService, my_service, service_proc
ret
.fail:
.exit:
xor eax, eax
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
inp_size equ IOCTL.inp_size
output equ IOCTL.output
out_size equ IOCTL.out_size
align 4
proc service_proc stdcall, ioctl:dword
; mov edi, [ioctl]
; mov eax, [edi+io_code]
xor eax, eax
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
align 4
proc detect
locals
last_bus dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
add edi, STRIDE
jmp @B
.next: inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
inc eax
ret
.err:
xor eax, eax
ret
endp
;DEVICE_ID equ ; pci device id
;VENDOR_ID equ ; device vendor id
;all initialized data place here
align 4
devices dd (DEVICE_ID shl 16)+VENDOR_ID
dd 0 ;terminator
my_service db 'MY_SERVICE',0 ;max 16 chars include zero
msgInit db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgFail db 'device not found',13,10,0
section '.data' data readable writable align 16
;all uninitialized data place here

View File

@ -248,7 +248,6 @@ new_app_base equ 0x60400000; 0x01000000
PROC_BASE equ OS_BASE+0x0080000
public START
public STOP
public service_proc
extrn AttachIntHandler
@ -266,7 +265,13 @@ extrn GetCurrentTask
section '.flat' code readable align 16
START:
proc START stdcall, state:dword
mov eax, [state]
cmp eax, 1
je .entry
jmp .stop
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
@ -320,15 +325,18 @@ START:
call SysMsgBoardStr
ret
.fail:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
end if
STOP:
xor eax, eax
ret
xor eax, eax
ret
.stop:
call stop
mov [ctrl.user_callback], 0
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code

View File

@ -274,7 +274,6 @@ new_app_base equ 0x60400000; 0x01000000
PROC_BASE equ OS_BASE+0x0080000
public START
public STOP
public service_proc
extrn AttachIntHandler
@ -292,7 +291,14 @@ extrn GetCurrentTask
section '.flat' code readable align 16
START:
proc START stdcall, state:dword
mov eax, [state]
cmp eax, 1
je .entry
jmp .stop
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
@ -368,8 +374,12 @@ START:
call SysMsgBoardStr
end if
xor eax, eax
STOP:
ret
.stop:
call stop
mov [ctrl.user_callback], 0
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code

View File

@ -39,6 +39,11 @@ include 'm_com2.inc'
draw_mouse_under:
; return old picture
cmp [set_hw_cursor], 0
jz @F
ret
@@:
pushad
xor ecx,ecx
xor edx,edx
@ -75,6 +80,18 @@ mres:
ret
save_draw_mouse:
cmp [set_hw_cursor], 0
jz @F
mov [0xfb4a],ax
mov [0xfb4c],bx
movzx ebx,word [0xfb0c]
movzx eax,word [0xfb0a]
push ebx
push eax
call [set_hw_cursor]
ret
@@:
pushad
; save & draw
mov [0xfb4a],ax
@ -217,7 +234,7 @@ __sys_disable_mouse:
cmp dword [0xf204],dword 0
je @f
ret
@@:
@@:
pushad
cmp [0x3000],dword 1
je disable_m

View File

@ -394,12 +394,12 @@ include 'detect/disks.inc'
; btr [cpu_caps], CAPS_PSE ;test: don't use large pages
; btr [cpu_caps], CAPS_PGE ;test: don't use global pages
; btr [cpu_caps], CAPS_MTRR ;test: don't use MTRR
; btr [cpu_caps], CAPS_TSC ;test: don't use TSC
; bts [cpu_caps], CAPS_TSC ;test: don't use TSC
call init_memEx
call init_page_map
mov eax, sys_pgdir ;+PG_NOCACHE
mov eax, sys_pgdir
mov cr3, eax
mov eax,cr0
@ -409,6 +409,7 @@ include 'detect/disks.inc'
call init_kernel_heap
call init_LFB
call init_mtrr
call init_fpu
stdcall alloc_kernel_space, 0x4F000
mov [ipc_tmp], eax
@ -447,48 +448,6 @@ include 'detect/disks.inc'
mov ecx, 16
rep movsb
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
jmp .set_cr
.no_FXSR:
stdcall kernel_alloc, 112*256
mov [fpu_data], eax
mov ebx, cr4
mov ecx, cr0
and ebx, not (CR4_OSFXSR+CR4_OSXMMEXPT)
and ecx, not CR0_EM
or ecx, CR0_MP+CR0_NE
mov cr0, ecx
mov cr4, ebx
.set_cr:
mov edi, irq_tab
xor eax, eax
mov ecx, 16
@ -567,14 +526,7 @@ include 'vmodeld.inc'
; LOAD IDT
lidt [cs:idtreg]
;The CPU to this moment should be already in PM,
;and bit MP of the register cr0 should be installed in 1.
;finit ;reset of the FPU (finit, instead of fninit)
;fsetpm ;enable PM of the FPU
;finit ;reset the registers, contents which are still equal RM
;Now FPU too in PM
; DETECT DEVICES
cli
mov esi,boot_devices
call boot_log
@ -597,6 +549,9 @@ include 'vmodeld.inc'
call boot_log
call setmouse
mov [pci_access_enabled],1
stdcall get_service, szHMouse
; SET PRELIMINARY WINDOW STACK AND POSITIONS
mov esi,boot_windefs
@ -625,22 +580,34 @@ include 'vmodeld.inc'
mov esi,boot_setostask
call boot_log
; name for OS/IDLE process
mov dword [0x80000+256+APPDATA.app_name], dword 'OS/I'
mov dword [0x80000+256+APPDATA.app_name+4], dword 'DLE '
mov eax, [fpu_data]
mov dword [0x80000+APPDATA.fpu_state], eax
mov dword [0x80000+APPDATA.fpu_handler], 0
mov dword [0x80000+APPDATA.sse_handler], 0
add eax, 112
bt [cpu_caps], CAPS_FXSR
jnc .no_sse
add eax, 512-112
.no_sse:
mov dword [0x80000+256+APPDATA.fpu_state], eax
; name for OS/IDLE process
mov dword [0x80000+256+APPDATA.app_name], dword 'OS/I'
mov dword [0x80000+256+APPDATA.app_name+4], dword 'DLE '
mov dword [0x80000+256+APPDATA.fpu_handler], 0
mov dword [0x80000+256+APPDATA.sse_handler], 0
;set fpu save area
mov esi, eax
bt [cpu_caps], CAPS_FXSR
jnc .no_sse
lea edi, [eax+512]
mov dword [0x80000+256+APPDATA.fpu_state], edi
mov ecx, 512/4
jmp @F
.no_sse:
lea edi, [eax+112]
mov dword [0x80000+256+APPDATA.fpu_state], edi
mov ecx, 112/4
@@:
rep movsd
; task list
mov [0x3020+TASKDATA.wnd_number], 1 ; on screen number
mov [0x3020+TASKDATA.pid], 1 ; process id number
@ -1950,6 +1917,9 @@ sys_system:
sysfn_shutdown: ; 18.1 = BOOT
mov [0x2f0000+0x9030],byte 0
for_shutdown_parameter:
call stop_all_services
mov eax,[0x3004]
add eax,2
mov [shutdown_processes],eax
@ -3786,10 +3756,6 @@ set_io_access_rights:
ret
r_f_port_area:
test eax, eax
@ -3875,9 +3841,6 @@ r_f_port_area:
xor eax, eax
ret
free_port_area:
pushad
@ -3982,8 +3945,6 @@ reserve_free_irq:
mov [esp+36],ecx ; return in eax
ret
drawbackground:
inc [mouse_pause]
cmp [0xfe0c],word 0x12
@ -4299,8 +4260,6 @@ _rdtsc:
mov eax,0xffffffff
ret
rerouteirqs:
cli
@ -5034,9 +4993,9 @@ wraw_bacground_select db 0
windowtypechanged dd 0x0
align 4
cpu_caps dd 4 dup(0)
pg_data PG_DATA
heap_test dd ?
cpu_caps dd 4 dup(0)
endg
iglobal

View File

@ -217,13 +217,12 @@ include "core/sync.inc" ; macros for synhronization objects
include "core/sys32.inc" ; process management
include "core/sched.inc" ; process scheduling
include "core/syscall.inc" ; system call
include "core/fpu.inc" ; all fpu/sse support
include "core/memory.inc"
include "core/heap.inc"
include "core/heap.inc" ; kernel and app heap
include "core/taskman.inc"
include "core/dll.inc"
include "core/exports.inc"
include "core/except.inc"
; GUI stuff
include "gui/window.inc"

View File

@ -201,7 +201,7 @@
; 770000 -> 777fff tcp memory ( 32 kb)
;
; 778000 -> 77ffff window skinning ( 32 kb)
; 780000 -> 7fffff free (512 Kb)
; 780000 -> 7fffff reserved to physical memory manager
;
; 800000 -> 801FFF draw_data - 256 entries
;