Subversion Repositories Kolibri OS

Rev

Rev 1551 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1551 Rev 1560
Line 9... Line 9...
9
;;                                                              ;;
9
;;                                                              ;;
10
;;                  art_zh                  ;;
10
;;                  art_zh                  ;;
11
;;                                                              ;;
11
;;                                                              ;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 13...
-
 
13
 
Line 13... Line -...
13
 
-
 
Line 14... Line 14...
14
 
14
$Revision: 1554 $
15
 
15
 
16
align 4
16
 
17
 
17
 
18
;=============================================================================
18
;=============================================================================
-
 
19
;
Line 19... Line 20...
19
;
20
; This code is a part of Kolibri-A and will only work with AMD RS760+ chipsets
20
; This code is a part of Kolibri-A and will only work with AMD RS760+ chipsets
21
;
21
;
22
;=============================================================================
22
;=============================================================================
23
align 4
Line 31... Line 32...
31
	mov	dx,  0x0CF8		 ; write to index reg
32
	mov	dx,  0x0CF8		 ; write to index reg
32
	out	dx, eax
33
	out	dx, eax
33
	add	dl, 4
34
	add	dl, 4
34
	in	eax, dx
35
	in	eax, dx
35
	ret
36
	ret
-
 
37
align 4
Line 36... Line 38...
36
 
38
 
37
rs7xx_nbconfig_flush_pci:
39
rs7xx_nbconfig_flush_pci:
38
	mov	eax, 0x0B0		; a scratch reg
40
	mov	eax, 0x0B0		; a scratch reg
39
	mov	dx,  0xCF8
41
	mov	dx,  0xCF8
40
	out	dx,  eax
42
	out	dx,  eax
Line -... Line 43...
-
 
43
	ret
Line 41... Line 44...
41
	ret
44
 
42
 
45
align 4
43
 
46
 
44
rs7xx_nbconfig_write_pci:
47
rs7xx_nbconfig_write_pci:
Line 58... Line 61...
58
;   Description
61
;   Description
59
;       PCIe extended (memory-mapped) config space detection
62
;       PCIe extended (memory-mapped) config space detection
60
;
63
;
61
;***************************************************************************
64
;***************************************************************************
Line -... Line 65...
-
 
65
 
-
 
66
align 4
62
 
67
 
63
rs7xx_pcie_init:
-
 
64
;        mov     al,  0x7C                       ; NB_IOC_CFG_CNTL
-
 
65
;        mov     ebx, 0x20000000
-
 
66
;        call    rs7xx_nbconfig_write_pci
68
rs7xx_pcie_init:
67
	mov	al, 0x7C		       ; NB_IOC_CFG_CNTL
69
	mov	al, 0x7C		       ; NB_IOC_CFG_CNTL
68
	call	rs7xx_nbconfig_read_pci
70
	call	rs7xx_nbconfig_read_pci
69
	mov	ebx, eax
71
	mov	ebx, eax
70
	call	rs7xx_nbconfig_flush_pci
72
	call	rs7xx_nbconfig_flush_pci
Line 96... Line 98...
96
	call	rs7xx_nbconfig_read_pci
98
	call	rs7xx_nbconfig_read_pci
97
	mov	ebx, eax
99
	mov	ebx, eax
98
	call	rs7xx_nbconfig_flush_pci
100
	call	rs7xx_nbconfig_flush_pci
99
	mov	eax, ebx
101
	mov	eax, ebx
100
	and	eax, 0xFFE00000 		; valid bits [31..21]
102
	and	eax, 0xFFE00000 		; valid bits [31..21]
101
	jnz	@f				; NB BAR3 may be invisible!
103
	jz	.rs7xx_pcie_blocked		; NB BAR3 may be invisible!
102
	call  pci_ext_config		; try to get pcie ecfg address indirectly
104
						; try to get pcie ecfg address indirectly
103
@@:
-
 
104
	or 	eax, eax
105
.addr_found:
105
	jz	.rs7xx_pcie_fail
-
 
106
	mov	[mmio_pcie_cfg_addr], eax	; physical address (lower 32 bits)
106
	mov	[mmio_pcie_cfg_addr], eax	; physical address (lower 32 bits)
107
	add	[mmio_pcie_cfg_lim],  eax
107
	add	[mmio_pcie_cfg_lim],  eax
Line 108... Line -...
108
 
-
 
109
;       -- map the whole PCIe config space;
108
 
110
	or	eax, (PG_SHARED + PG_LARGE + PG_UW)  ;  by the way, UW is unsafe!
109
	or	eax, (PG_SHARED + PG_LARGE + PG_UW)  ;  by the way, UW is unsafe!
111
	mov	ecx, PCIe_CONFIG_SPACE		; linear address
110
	mov	ecx, PCIe_CONFIG_SPACE		; linear address
112
	mov	ebx, ecx
111
	mov	ebx, ecx
113
	shr	ebx, 20
112
	shr	ebx, 20
-
 
113
	add	ebx, sys_pgdir			; PgDir entry @
-
 
114
	mov	dl, byte[mmio_pcie_cfg_pdes]	; 1 page = 4M in address space
-
 
115
	cmp	dl, (USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4194304
-
 
116
	jb	@f
-
 
117
	mov	dl, ((USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4194304) - 1
-
 
118
	mov	byte[mmio_pcie_cfg_pdes], dl
114
	add	ebx, sys_pgdir			; PgDir entry @
119
@@:
115
	xor	dx,  dx 				; PDEs counter
120
	xor	dx,  dx 			; PDEs counter
116
@@:
121
@@:
117
	mov	dword[ebx], eax 			; map 4 buses
122
	mov	dword[ebx], eax 		; map 4 buses
118
	invlpg	[ecx]				; next PgDir entry
123
	invlpg	[ecx]				; next PgDir entry
119
	add	bx,  4				; new PDE
124
	add	bx,  4				; new PDE
120
	add	eax, 0x400000			; +4M phys.
125
	add	eax, 0x400000			; +4M phys.
-
 
126
	add	ecx, 0x400000			; +4M lin.
-
 
127
	cmp	dl, byte[mmio_pcie_cfg_pdes]
121
	add	ecx, 0x400000			; +4M lin.
128
	jnc	.pcie_cfg_mapped
122
	inc	dx
-
 
123
	cmp	dx, [mmio_pcie_cfg_pdes]	; all mapped yet?
129
	inc	dl
124
	jnz	@b
-
 
125
 
130
	jmp	@b
126
.pcie_cfg_mapped:
131
.pcie_cfg_mapped:
127
	mov	esi, boot_pcie_ok
132
	mov	esi, boot_pcie_ok
128
	call	boot_log
133
	call	boot_log
129
	ret	; <<<<<<<<<<< OK >>>>>>>>>>>
-
 
130
 
134
	ret	; <<< OK >>>
131
.rs7xx_pcie_fail:
135
.rs7xx_pcie_fail:
132
	mov	esi, boot_rs7xx_fail
136
	mov	esi, boot_rs7xx_fail
133
	call	boot_log
137
	call	boot_log
134
	ret
-
 
135
 
138
	ret
136
.rs7xx_pcie_blocked:
139
.rs7xx_pcie_blocked:
137
	mov	esi, boot_rs7xx_blkd
140
	mov	esi, boot_rs7xx_blkd
-
 
141
	call	boot_log
-
 
142
	call	pci_ext_config
-
 
143
	jmp	.addr_found
Line 138... Line -...
138
	call	boot_log
-