2010-06-25 20:47:51 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Copyright (C) 2010 KolibriOS team. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; ;;
|
|
|
|
;; PCIe.INC ;;
|
|
|
|
;; ;;
|
|
|
|
;; Extended PCI express services ;;
|
|
|
|
;; ;;
|
2010-08-07 16:38:03 +04:00
|
|
|
;; art_zh <artem@jerdev.co.uk> ;;
|
2010-06-25 20:47:51 +04:00
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2010-08-07 16:38:03 +04:00
|
|
|
$Revision: 1554 $
|
2010-06-25 20:47:51 +04:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; pci_ext_config:
|
|
|
|
;
|
|
|
|
; Description
|
|
|
|
; PCIe extended (memory-mapped) config space detection
|
|
|
|
;
|
2010-08-07 16:38:03 +04:00
|
|
|
; WARNINGs:
|
|
|
|
; 1) Very Experimental!
|
|
|
|
; 2) direct HT-detection (no ACPI or BIOS service used)
|
|
|
|
; 3) Only AMD/HT processors currently supported
|
2010-06-25 20:47:51 +04:00
|
|
|
;
|
|
|
|
;***************************************************************************
|
|
|
|
|
2010-08-03 17:07:43 +04:00
|
|
|
align 4
|
2010-08-07 16:38:03 +04:00
|
|
|
mmio_pcie_cfg_addr dd 0x00000000 ; pcie space may be defined here
|
|
|
|
mmio_pcie_cfg_lim dd 0x000FFFFF ; upper pcie space address
|
|
|
|
mmio_pcie_cfg_pdes dw 1 ; number of PDEs to map the space
|
|
|
|
PCIe_bus_range dw 2 ; the Bus range: power-of-2 Megabytes
|
2010-06-25 20:47:51 +04:00
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
pci_ext_config:
|
2010-08-07 16:38:03 +04:00
|
|
|
mov eax, [mmio_pcie_cfg_addr]
|
|
|
|
mov ebx, eax
|
|
|
|
or ebx, ebx
|
2010-06-25 20:47:51 +04:00
|
|
|
jz @f
|
2010-08-07 16:38:03 +04:00
|
|
|
or ebx, 0x7FFFFFFF ; required by PCI-SIG standards
|
2010-06-25 20:47:51 +04:00
|
|
|
jnz .pcie_failed
|
|
|
|
add ebx, 0x0FFFFC
|
|
|
|
cmp ebx, [mmio_pcie_cfg_lim]; is the space limit correct?
|
|
|
|
ja .pcie_failed
|
2010-08-07 16:38:03 +04:00
|
|
|
ret ; return the address forced
|
2010-06-25 20:47:51 +04:00
|
|
|
@@:
|
|
|
|
mov ebx, [cpu_vendor]
|
|
|
|
cmp ebx, dword [AMD_str]
|
|
|
|
jne .pcie_failed
|
|
|
|
mov bx, 0xC184 ; dev = 24, fn = 01, reg = 84h
|
|
|
|
|
|
|
|
.check_HT_mmio:
|
|
|
|
mov cx, bx
|
|
|
|
mov ax, 0x0002 ; bus = 0, 1dword to read
|
2010-08-07 16:38:03 +04:00
|
|
|
call pci_read_reg
|
2010-06-25 20:47:51 +04:00
|
|
|
mov bx, cx
|
|
|
|
sub bl, 4
|
2010-08-07 16:38:03 +04:00
|
|
|
and al, 0x80 ; check the NP bit
|
2010-06-25 20:47:51 +04:00
|
|
|
jz .no_pcie_cfg
|
2010-08-07 16:38:03 +04:00
|
|
|
shl eax, 8 ; bus:[27..20], dev:[19:15]
|
|
|
|
or eax, 0x00007FFC ; fun:[14..12], reg:[11:2]
|
|
|
|
; mov [mmio_pcie_cfg_lim], eax
|
2010-06-25 20:47:51 +04:00
|
|
|
mov cl, bl
|
|
|
|
mov ax, 0x0002 ; bus = 0, 1dword to read
|
2010-08-07 16:38:03 +04:00
|
|
|
call pci_read_reg
|
2010-06-25 20:47:51 +04:00
|
|
|
mov bx, cx
|
|
|
|
test al, 0x03 ; MMIO Base RW enabled?
|
|
|
|
jz .no_pcie_cfg
|
|
|
|
test al, 0x0C ; MMIO Base locked?
|
|
|
|
jnz .no_pcie_cfg
|
|
|
|
xor al, al
|
|
|
|
shl eax, 8
|
2010-08-07 16:38:03 +04:00
|
|
|
test eax, 0x000F0000 ; MMIO Base must be bus0-aligned
|
2010-06-25 20:47:51 +04:00
|
|
|
jnz .no_pcie_cfg
|
|
|
|
ret ; <<<<<<<<<<< OK >>>>>>>>>>>
|
|
|
|
|
2010-08-07 16:38:03 +04:00
|
|
|
.no_pcie_cfg:
|
2010-06-25 20:47:51 +04:00
|
|
|
xor eax, eax
|
|
|
|
mov [mmio_pcie_cfg_addr], eax
|
|
|
|
mov [mmio_pcie_cfg_lim], eax
|
|
|
|
add bl, 12
|
|
|
|
cmp bl, 0xC0 ; MMIO regs lay below this offset
|
|
|
|
jb .check_HT_mmio
|
2010-08-07 16:38:03 +04:00
|
|
|
|
2010-06-25 20:47:51 +04:00
|
|
|
.pcie_failed:
|
2010-06-28 15:46:11 +04:00
|
|
|
mov esi, boot_pcie_fail
|
|
|
|
call boot_log
|
2010-10-04 03:11:42 +04:00
|
|
|
xor eax, eax
|
2010-06-25 20:47:51 +04:00
|
|
|
ret ; <<<<<<<<< FAILURE >>>>>>>>>
|
|
|
|
|
2010-09-03 00:24:07 +04:00
|
|
|
|
|
|
|
;--------------------------------------------------------------------------
|
|
|
|
; this routine is platform-specific and used to change some BIOS settengs
|
|
|
|
; pcie_init_gfx
|
|
|
|
; sets the GPP mode of GFX bus
|
|
|
|
|
|
|
|
|
|
|
|
; this option disables external graphics
|
|
|
|
pcie_init_gfx:
|
|
|
|
|
|
|
|
ret
|