Subversion Repositories Kolibri OS

Rev

Rev 1508 | Rev 1599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1463 art_zh 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) 2010 KolibriOS team.     All rights reserved.  ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;                                                              ;;
7
;;  PCIe.INC                                                    ;;
8
;;                                                              ;;
9
;;  Extended PCI express services                               ;;
10
;;                                                              ;;
11
;;  	            art_zh                  ;;
12
;;                                                              ;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
 
15
$Revision: 1463 $
16
 
17
;***************************************************************************
18
;   Function
19
;      pci_ext_config:
20
;
21
;   Description
22
;       PCIe extended (memory-mapped) config space detection
23
;
24
;   WARNINGs:
25
;	1) Very Experimental!
26
;	2) direct HT-detection (no ACPI or BIOS service used)
27
;	3) Only AMD/HT processors currently supported
28
;
29
;***************************************************************************
30
 
1551 art_zh 31
align 4
1508 art_zh 32
mmio_pcie_cfg_addr	dd  	0x00000000	; pcie space may be defined here
33
mmio_pcie_cfg_lim	dd	0x000FFFFF	; upper pcie space address
1551 art_zh 34
mmio_pcie_cfg_pdes	dw	0		; number of PDEs to map the space
35
PCIe_bus_range		dw	0		; the Bus range: power-of-2 Megabytes
1463 art_zh 36
 
37
 
38
align 4
39
pci_ext_config:
1487 art_zh 40
	mov	ebx, [mmio_pcie_cfg_addr]
41
	or	ebx,ebx
42
	jz	@f
43
	or	ebx, 0x7FFFFFFF		; required by PCI-SIG standards
44
	jnz	.pcie_failed
45
	add	ebx, 0x0FFFFC
46
	cmp	ebx, [mmio_pcie_cfg_lim]; is the space limit correct?
47
	ja	.pcie_failed
48
	jmp	.pcie_cfg_mapped
49
@@:
50
	mov	ebx, [cpu_vendor]
51
	cmp	ebx, dword [AMD_str]
52
	jne	.pcie_failed
1463 art_zh 53
	mov	bx, 0xC184		; dev = 24, fn = 01, reg = 84h
54
 
55
.check_HT_mmio:
56
	mov	cx, bx
57
	mov	ax, 0x0002		; bus = 0, 1dword to read
58
	call 	pci_read_reg
59
	mov	bx, cx
60
	sub	bl, 4
61
	and 	al, 0x80		; check the NP bit
1487 art_zh 62
	jz	.no_pcie_cfg
1463 art_zh 63
	shl	eax, 8			; bus:[27..20], dev:[19:15]
64
	or	eax, 0x00007FFC		; fun:[14..12], reg:[11:2]
1551 art_zh 65
;	mov	[mmio_pcie_cfg_lim], eax
1463 art_zh 66
	mov	cl, bl
67
	mov	ax, 0x0002		; bus = 0, 1dword to read
68
	call 	pci_read_reg
69
	mov	bx, cx
70
	test	al, 0x03		; MMIO Base RW enabled?
1487 art_zh 71
	jz	.no_pcie_cfg
1463 art_zh 72
	test	al, 0x0C		; MMIO Base locked?
1487 art_zh 73
	jnz	.no_pcie_cfg
1463 art_zh 74
	xor	al, al
75
	shl	eax, 8
1487 art_zh 76
	test	eax, 0x000F0000		; MMIO Base must be bus0-aligned
77
	jnz	.no_pcie_cfg
1463 art_zh 78
	mov	[mmio_pcie_cfg_addr], eax
1551 art_zh 79
;	add	eax, 0x000FFFFC
80
;	sub	eax,[mmio_pcie_cfg_lim]	; MMIO must cover at least one bus
81
;	ja	.no_pcie_cfg
1463 art_zh 82
 
83
;	-- it looks like a true PCIe config space;
84
 
85
.pcie_cfg_mapped:
86
 
1508 art_zh 87
	mov	esi, boot_pcie_ok
88
	call	boot_log
1463 art_zh 89
	ret	; <<<<<<<<<<< OK >>>>>>>>>>>
90
 
1487 art_zh 91
.no_pcie_cfg:
1463 art_zh 92
 
93
	xor	eax, eax
94
	mov	[mmio_pcie_cfg_addr], eax
95
	mov	[mmio_pcie_cfg_lim],  eax
96
	add	bl, 12
97
	cmp	bl, 0xC0		; MMIO regs lay below this offset
98
	jb	.check_HT_mmio
1487 art_zh 99
.pcie_failed:
1508 art_zh 100
	mov	esi, boot_pcie_fail
101
	call	boot_log
1463 art_zh 102
	ret	; <<<<<<<<< FAILURE >>>>>>>>>
103