kernel: map_io_mem

git-svn-id: svn://kolibrios.org@741 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-02-16 08:46:57 +00:00
parent 2c7785b277
commit a24875d50b
6 changed files with 55 additions and 48 deletions

View File

@ -33,6 +33,7 @@ iglobal
szGetPgAddr db 'GetPgAddr',0 szGetPgAddr db 'GetPgAddr',0
szMapPage db 'MapPage',0 szMapPage db 'MapPage',0
szMapSpace db 'MapSpace',0 szMapSpace db 'MapSpace',0
szMapIoMem db 'MapIoMem',0
szCommitPages db 'CommitPages',0 szCommitPages db 'CommitPages',0
szReleasePages db 'ReleasePages',0 szReleasePages db 'ReleasePages',0
@ -101,6 +102,7 @@ kernel_export:
dd szFreePage , free_page dd szFreePage , free_page
dd szMapPage , map_page ;stdcall dd szMapPage , map_page ;stdcall
dd szMapSpace , map_space dd szMapSpace , map_space
dd szMapIoMem , map_io_mem ;stdcall
dd szGetPgAddr , get_pg_addr dd szGetPgAddr , get_pg_addr
dd szCommitPages , commit_pages ;not implemented dd szCommitPages , commit_pages ;not implemented
dd szReleasePages , release_pages dd szReleasePages , release_pages

View File

@ -143,6 +143,45 @@ proc free_page
ret ret
endp endp
proc map_io_mem stdcall, base:dword, size:dword, flags:dword
push ebx
push edi
mov eax, [size]
add eax, 4095
and eax, -4096
mov [size], eax
stdcall alloc_kernel_space, eax
test eax, eax
jz .fail
push eax
mov edi, 0x1000
mov ebx, eax
mov ecx,[size]
mov edx, [base]
shr eax, 12
shr ecx, 12
and edx, -4096
or edx, [flags]
@@:
mov [page_tabs+eax*4], edx
invlpg [ebx]
inc eax
add ebx, edi
add edx, edi
loop @B
pop eax
mov edx, [base]
and edx, 4095
add eax, edx
.fail:
pop edi
pop ebx
ret
endp
; param ; param
; eax= page base + page flags ; eax= page base + page flags
; ebx= liear address ; ebx= liear address
@ -150,7 +189,7 @@ endp
align 4 align 4
commit_pages: commit_pages:
push edi
test ecx, ecx test ecx, ecx
jz .fail jz .fail
@ -171,6 +210,7 @@ commit_pages:
jnz @B jnz @B
mov [pg_data.pg_mutex],ecx mov [pg_data.pg_mutex],ecx
.fail: .fail:
pop edi
ret ret

View File

@ -275,6 +275,7 @@ __exports:
free_kernel_space, 'FreeKernelSpace', \ ; stdcall free_kernel_space, 'FreeKernelSpace', \ ; stdcall
kernel_alloc, 'KernelAlloc', \ ; stdcall kernel_alloc, 'KernelAlloc', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall kernel_free, 'KernelFree', \ ; stdcall
map_io_mem, 'MapIoMem', \ ; stdcall
pci_api, 'PciApi', \ pci_api, 'PciApi', \
pci_read32, 'PciRead32', \ ; stdcall pci_read32, 'PciRead32', \ ; stdcall
reg_service, 'RegService', \ reg_service, 'RegService', \

View File

@ -344,27 +344,14 @@ endp
align 4 align 4
proc init_r200 proc init_r200
stdcall PciRead32, [bus], [devfn], dword 0x18
stdcall AllocKernelSpace, dword 0x10000 stdcall MapIoMem,eax,0x10000,(PG_SW+PG_NOCACHE)
test eax, eax test eax, eax
jz .fail jz .fail
mov [ati_io], eax mov [ati_io], eax
mov edi, 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 mov dword [edi+RD_RB3D_CNTL], 0
call engRestore call engRestore
@ -397,25 +384,13 @@ end if
align 4 align 4
proc init_r500 proc init_r500
stdcall AllocKernelSpace, dword 0x10000 stdcall PciRead32, [bus], [devfn], dword 0x18
stdcall MapIoMem,eax,0x10000,(PG_SW+PG_NOCACHE)
test eax, eax test eax, eax
jz .fail jz .fail
mov [ati_io], eax 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 [fnSelect], r500_SelectCursor mov [fnSelect], r500_SelectCursor
mov [fnSet], r500_SetCursor mov [fnSet], r500_SetCursor

View File

@ -35,6 +35,7 @@ kernel_export \
FreePage,\ FreePage,\
MapPage,\ MapPage,\
MapSpace,\ MapSpace,\
MapIoMem,\
GetPgAddr,\ GetPgAddr,\
CommitPages,\ CommitPages,\
ReleasePages,\ ReleasePages,\

View File

@ -802,24 +802,12 @@ PG_NOCACHE equ 0x018
align 4 align 4
proc set_ICH4 proc set_ICH4
stdcall AllocKernelSpace, dword 0x2000
mov edi, eax
mov ebx, [ctrl.codec_mem_base]
and ebx, -4096
stdcall MapPage, edi,ebx,PG_SW+PG_NOCACHE
mov ebx, [ctrl.codec_mem_base]
and ebx, 4095
add ebx, edi
mov [ctrl.codec_mem_base], ebx
add edi, 0x1000
mov ebx, [ctrl.ctrl_mem_base] stdcall MapIoMem,[ctrl.codec_mem_base],0x1000,PG_SW+PG_NOCACHE
and ebx, -4096 mov [ctrl.codec_mem_base], eax
stdcall MapPage, edi, ebx,PG_SW+PG_NOCACHE
mov ebx, [ctrl.ctrl_mem_base] stdcall MapIoMem,[ctrl.ctrl_mem_base],0x1000,PG_SW+PG_NOCACHE
and ebx, 4095 mov [ctrl.ctrl_mem_base], eax
add ebx, edi
mov [ctrl.ctrl_mem_base], ebx
mov [ctrl.codec_read16], codec_mem_r16 ;virtual mov [ctrl.codec_read16], codec_mem_r16 ;virtual
mov [ctrl.codec_write16], codec_mem_w16 ;virtual mov [ctrl.codec_write16], codec_mem_w16 ;virtual