#1591 sysfn62 rotation bug resque -- not stable yet!

git-svn-id: svn://kolibrios.org@1598 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2010-09-02 12:40:11 +00:00
parent c500a85785
commit e5c581d60d

View File

@ -170,8 +170,8 @@ pci_make_config_cmd:
; ;
; Description ; Description
; read a register from the PCI config space into EAX/AX/AL ; read a register from the PCI config space into EAX/AX/AL
; IN: ah=bus,device+func=bh,register address=bl ; IN: bh=bus,device+func=ch,register address=cl
; number of bytes to read (1,2,4) coded into AL, bits 0-1 ; number of bytes to read (1,2,4) coded into BL, bits 0-1
; (0 - byte, 1 - word, 2 - dword) ; (0 - byte, 1 - word, 2 - dword)
;*************************************************************************** ;***************************************************************************
@ -303,9 +303,9 @@ pci_read_reg_2:
; ;
; Description ; Description
; write a register from ECX/CX/CL into the PCI config space ; write a register from ECX/CX/CL into the PCI config space
; IN: ah=bus,device+func=bh,register address (dword aligned)=bl, ; IN: bh=bus,device+func=ch,register address (dword aligned)=cl,
; value to write in ecx ; value to write in edx
; number of bytes to write (1,2,4) coded into AL, bits 0-1 ; number of bytes to write (1,2,4) coded into BL, bits 0-1
; (0 - byte, 1 - word, 2 - dword) ; (0 - byte, 1 - word, 2 - dword)
;*************************************************************************** ;***************************************************************************
@ -468,9 +468,9 @@ pci_mmio_init:
; WARNING! This VERY EXPERIMENTAL service is for one chosen PCI device only! ; WARNING! This VERY EXPERIMENTAL service is for one chosen PCI device only!
; The target device address should be set in kernel var mmio_pci_addr ; The target device address should be set in kernel var mmio_pci_addr
; ;
; IN: ah = BAR#; ; IN: bh = BAR#;
; IN: ebx = block size (bytes); ; IN: ecx = block size (bytes);
; IN: ecx = offset in MMIO block (in 4K-pages, to avoid misaligned pages); ; IN: edx = offset in MMIO block (in 4K-pages, to avoid misaligned pages);
; ;
; Returns eax = MMIO block's linear address in the userspace (if no error) ; Returns eax = MMIO block's linear address in the userspace (if no error)
; ;
@ -484,13 +484,8 @@ pci_mmio_init:
;*************************************************************************** ;***************************************************************************
pci_mmio_map: pci_mmio_map:
;cross
mov eax,ebx
mov ebx,ecx
mov ecx,edx
;;;;;;;;;;;;;;;;;;;
and edx,0x0ffff and edx,0x0ffff
cmp ah,6 cmp bh, 6
jc .bar_0_5 jc .bar_0_5
jz .bar_rom jz .bar_rom
mov eax,-2 mov eax,-2
@ -498,18 +493,18 @@ pci_mmio_map:
.bar_rom: .bar_rom:
mov ah, 8 ; bar6 = Expansion ROM base address mov ah, 8 ; bar6 = Expansion ROM base address
.bar_0_5: .bar_0_5:
push edx
add ecx, 4095
and ecx, 0xFFFFF000 ; 4k-alignment
push ecx push ecx
add ebx, 4095 mov cl, bh ; cl = BAR# (0..5), however cl=8 for BAR6
and ebx,-4096 shl cl, 1
push ebx shl cl, 1
mov bl, ah ; bl = BAR# (0..5), however bl=8 for BAR6 add cl, 0x10 ; now cl = BAR offset in PCI config. space
shl bl, 1
shl bl, 1
add bl, 0x10 ; now bl = BAR offset in PCI config. space
mov ax, mmio_pci_addr mov ax, mmio_pci_addr
mov bh, al ; bh = dddddfff mov ch, al ; ch = dddddfff
mov al, 2 ; al : DW to read mov bl, 2 ; bl : DW to read
call pci_read_reg call pci_read_reg ; new call
or eax, eax or eax, eax
jnz @f jnz @f
mov eax,-3 ; empty I/O space mov eax,-3 ; empty I/O space
@ -520,12 +515,12 @@ pci_mmio_map:
mov eax,-4 ; damned ports (not MMIO space) mov eax,-4 ; damned ports (not MMIO space)
jmp mmio_ret_fail jmp mmio_ret_fail
@@: @@:
pop ecx ; ecx = block size, bytes (expanded to whole page) pop ecx ; ecx = block size, bytes (expanded to whole page)
mov ebx, ecx ; user_alloc destroys eax, ecx, edx, but saves ebx mov ebx, ecx ; user_alloc destroys eax, ecx, edx, but saves ebx
and eax, 0xFFFFFFF0 and al, 0xF0 ; clear flags
push eax ; store MMIO physical address + keep 2DWords in the stack push eax ; store MMIO physical address + keep 2DWords in the stack
stdcall user_alloc, ecx stdcall user_alloc, ecx
or eax, eax or eax, eax
jnz mmio_map_over jnz mmio_map_over
mov eax,-5 ; problem with page allocation mov eax,-5 ; problem with page allocation
@ -538,13 +533,11 @@ mmio_map_over:
mov ecx, ebx ; ecx = size (bytes, expanded to whole page) mov ecx, ebx ; ecx = size (bytes, expanded to whole page)
shr ecx, 12 ; ecx = number of pages shr ecx, 12 ; ecx = number of pages
mov ebx, eax ; ebx = linear address mov ebx, eax ; ebx = linear address
pop eax ; eax = MMIO start pop eax ; eax = MMIO start
pop edx ; edx = MMIO shift (pages) pop edx ; edx = MMIO shift (pages)
shl edx, 12 ; edx = MMIO shift (bytes) shl edx, 12 ; edx = MMIO shift (bytes)
add eax, edx ; eax = uMMIO physical address add eax, edx ; eax = uMMIO physical address
or eax, PG_SHARED or eax, PG_SHARED+PG_UW+PG_NOCACHE
or eax, PG_UW
or eax, PG_NOCACHE
mov edi, ebx mov edi, ebx
call commit_pages call commit_pages
mov eax, edi mov eax, edi
@ -642,17 +635,18 @@ sys_pcibios:
jmp ..nxt2 jmp ..nxt2
.not_FIND_PCI_CLASS_CODE: .not_FIND_PCI_CLASS_CODE:
mov edx, ecx
cmp ebp, 8 ; READ_CONFIG_* cmp ebp, 8 ; READ_CONFIG_*
jb .not_READ_CONFIG jb .not_READ_CONFIG
cmp ebp, 0x0A cmp ebp, 0x0A
ja .not_READ_CONFIG ja .not_READ_CONFIG
mov eax, ebp mov eax, ebp ; -- ??
mov ah, bh ; mov ah, bh ; bus
mov edx, edi mov ecx, edi
mov bh, bl mov ch, bl ; dev+fn
mov bl, dl ; mov cl, dl ; reg#
call pci_read_reg call pci_read_reg
mov ecx, eax mov edx, eax
xor ah, ah ; SUCCESSFUL xor ah, ah ; SUCCESSFUL
jmp .return_abc jmp .return_abc
.not_READ_CONFIG: .not_READ_CONFIG:
@ -661,10 +655,10 @@ sys_pcibios:
cmp ebp, 0x0D cmp ebp, 0x0D
ja .not_WRITE_CONFIG ja .not_WRITE_CONFIG
lea eax, [ebp+1] lea eax, [ebp+1]
mov ah, bh ; mov ah, bh ; bus
mov edx, edi mov ecx, edi
mov bh, bl mov ch, bl
mov bl, dl ; mov cl, dl
call pci_write_reg call pci_write_reg
xor ah, ah ; SUCCESSFUL xor ah, ah ; SUCCESSFUL
jmp .return_abc jmp .return_abc