Subversion Repositories Kolibri OS

Rev

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

Rev 1560 Rev 1599
Line 5... Line 5...
5
;;                                                              ;;
5
;;                                                              ;;
6
;;  HT.inc                                                      ;;                                                    ;;
6
;;  HT.inc                                                      ;;                                                    ;;
7
;;                                                              ;;
7
;;                                                              ;;
8
;;  AMD HyperTransport bus control                              ;;
8
;;  AMD HyperTransport bus control                              ;;
9
;;                                                              ;;
9
;;                                                              ;;
10
;;                  art_zh                  ;;
10
;;                  art_zh                ;;
11
;;                                                              ;;
11
;;                                                              ;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 13... Line 13...
13
 
13
 
Line 14... Line -...
14
$Revision: 1554 $
-
 
-
 
14
$Revision: 1554 $
-
 
15
 
-
 
16
NB_MISC_INDEX	equ	0xF0000060	; NB Misc indirect access
-
 
17
NB_MISC_DATA	equ	0xF0000064
Line 15... Line 18...
15
 
18
PCIEIND_INDEX	equ	0xF00000E0	; PCIe Core indirect config space access
16
 
19
HTIU_NB_INDEX	equ	0xF0000094	; HyperTransport indirect config space access
17
 
20
 
18
;=============================================================================
21
;=============================================================================
Line 42... Line 45...
42
	out	dx,  eax
45
	out	dx,  eax
43
	ret
46
	ret
Line 44... Line 47...
44
 
47
 
Line -... Line 48...
-
 
48
align 4
-
 
49
 
-
 
50
;------------------------------------------
-
 
51
;       params:   al = nbconfig register#
45
align 4
52
;                ebx = register content
46
 
53
;
47
rs7xx_nbconfig_write_pci:
54
rs7xx_nbconfig_write_pci:
48
	and	eax, 0x0FC		 ; leave register# only
55
	and	eax, 0x0FC		 ; leave register# only
49
	or	eax, 0x80000000 	 ; bdf = 0:0.0
56
	or	eax, 0x80000000 	 ; bdf = 0:0.0
Line 54... Line 61...
54
	out	dx, eax
61
	out	dx, eax
55
	ret
62
	ret
Line 56... Line 63...
56
 
63
 
57
;***************************************************************************
64
;***************************************************************************
-
 
65
;   Function
-
 
66
;      rs7xx_unlock_bar3:     unlocks the BAR3 register of nbconfig that
-
 
67
;                             makes pcie config address space visible
-
 
68
;   -----------------------
-
 
69
;   in: nothing      out: nothing      destroys:   eax ebx edx
-
 
70
;
-
 
71
;***************************************************************************
-
 
72
align 4
-
 
73
rs7xx_unlock_bar3:
-
 
74
	mov	eax, NB_MISC_INDEX
-
 
75
	mov	ebx, 0x080			; reg#0; write-enable
-
 
76
	call	rs7xx_nbconfig_write_pci	; set index
-
 
77
	mov	eax, NB_MISC_DATA
-
 
78
	call	rs7xx_nbconfig_read_pci 	; read data
-
 
79
	mov	ebx, eax
-
 
80
	and	ebx, 0xFFFFFFF7 		; clear bit3
-
 
81
	mov	eax, NB_MISC_DATA
-
 
82
	call	rs7xx_nbconfig_write_pci	; write it back
-
 
83
	mov	eax, NB_MISC_INDEX
-
 
84
	xor	ebx, ebx			; reg#0; write-locked
-
 
85
	call	rs7xx_nbconfig_write_pci	; set index
-
 
86
	ret
-
 
87
 
-
 
88
;--------------------------------------------------------------
-
 
89
align 4
-
 
90
rs780_read_misc:
-
 
91
;  in: eax(al) - reg#           out: eax = NBMISCIND data
-
 
92
	push	edx
-
 
93
	mov	edx, NB_MISC_INDEX
-
 
94
	and	eax, 0x07F
-
 
95
	mov	[edx], eax
-
 
96
	add	dl, 4
-
 
97
	mov	eax, [edx]
-
 
98
	pop	edx
-
 
99
	ret
-
 
100
 
-
 
101
;-------------------------------------------
-
 
102
align 4
-
 
103
rs780_write_misc:
-
 
104
;  in: eax(al) - reg#     ebx = NBMISCIND data
-
 
105
	push	edx
-
 
106
	mov	edx, NB_MISC_INDEX
-
 
107
	and	eax, 0x07F
-
 
108
	or	eax, 0x080		; set WE
-
 
109
	mov	[edx], eax
-
 
110
	add	dl, 4
-
 
111
	mov	[edx], ebx
-
 
112
	sub	dl, 4
-
 
113
	xor	eax,   eax
-
 
114
	mov	[edx], eax		; safety last
-
 
115
	pop	edx
-
 
116
	ret
-
 
117
 
-
 
118
;-------------------------------------------------------------
-
 
119
align 4
-
 
120
rs780_read_pcieind:
-
 
121
;  in: ah = bridge#, al = reg#           out: eax = PCIEIND data
-
 
122
	push	edx
-
 
123
	xor	edx, edx
-
 
124
	mov	ah,  dl 		; bridge# :     0 = Core+GFX;   0x10 = Core+SB
-
 
125
	and	dl,  15 		;            0x20 = Core+GPP;  2..12 = a PortBridge
-
 
126
	shl	edx, 15 		; device#
-
 
127
	add	edx, PCIEIND_INDEX	; full bdf-address
-
 
128
	and	eax, 0x30FF
-
 
129
	or	al,  al
-
 
130
	jnz	@f
-
 
131
	shl	eax, 4			; set bits 17..16 for a Core bridge
-
 
132
@@:
-
 
133
	mov	[edx], eax
-
 
134
	add	dl,  4
-
 
135
	mov	eax, [edx]
-
 
136
	pop	edx
-
 
137
	ret
-
 
138
 
-
 
139
;-------------------------------------------
-
 
140
align 4
-
 
141
rs780_write_pcieind:
-
 
142
;  in: ah = bridge#, al = reg#,  ebx = PCIEIND data
-
 
143
	push	edx
-
 
144
	xor	edx, edx
-
 
145
	mov	ah,  dl 		; bridge# :     0 = Core+GFX;   0x10 = Core+SB
-
 
146
	and	dl,  15 		;            0x20 = Core+GPP;  2..12 = a PortBridge
-
 
147
	shl	edx, 15 		; device#
-
 
148
	add	edx, PCIEIND_INDEX	; full bdf-address
-
 
149
	and	eax, 0x30FF
-
 
150
	or	al,  al
-
 
151
	jnz	@f
-
 
152
	shl	eax, 4			; set bits 17..16 for a Core bridge
-
 
153
@@:
-
 
154
	mov	[edx], eax
-
 
155
	add	dl,  4
-
 
156
	mov	[edx], ebx
-
 
157
	sub	dl,  4
-
 
158
	xor	eax,   eax
-
 
159
	mov	[edx], eax		; safety last
-
 
160
	pop	edx
-
 
161
	ret
-
 
162
 
-
 
163
;------------------------------------------------
-
 
164
align 4
-
 
165
rs780_read_htiu:
-
 
166
; in:  al = reg#  |  out: eax = HTIU data
-
 
167
;------------------------------------------------
-
 
168
	push	edx
-
 
169
	mov	edx,  HTIU_NB_INDEX
-
 
170
	and	eax, 0x07F
-
 
171
	mov	[edx], eax
-
 
172
	add	dl,  4
-
 
173
	mov	eax, [edx]
-
 
174
	pop	edx
-
 
175
	ret
-
 
176
;------------------------------------------------
-
 
177
align 4
-
 
178
rs780_write_htiu:
-
 
179
; in:  al = reg#; ebx = data
-
 
180
;------------------------------------------------
-
 
181
	push	edx
-
 
182
	mov	edx,  HTIU_NB_INDEX
-
 
183
	and	eax, 0x07F
-
 
184
	or	eax, 0x100
-
 
185
	mov	[edx], eax
-
 
186
	add	dl,  4
-
 
187
	mov	[edx], ebx
-
 
188
	sub	dl,  4
-
 
189
	xor	eax,   eax
-
 
190
	mov	[edx], eax
-
 
191
	pop	edx
-
 
192
	ret
-
 
193
 
-
 
194
 
-
 
195
 
-
 
196
;***************************************************************************
58
;   Function
197
;   Function
59
;      rs7xx_pcie_init:
198
;      rs7xx_pcie_init:
60
;
199
;
61
;   Description
200
;   Description
62
;       PCIe extended (memory-mapped) config space detection
201
;       PCIe extended (memory-mapped) config space detection
63
;
202
;
Line 64... Line 203...
64
;***************************************************************************
203
;***************************************************************************
Line 65... Line 204...
65
 
204
 
-
 
205
align 4
66
align 4
206
 
67
 
207
rs7xx_pcie_init:
68
rs7xx_pcie_init:
208
	call	rs7xx_unlock_bar3
69
	mov	al, 0x7C		       ; NB_IOC_CFG_CNTL
209
	mov	al, 0x7C		       ; NB_IOC_CFG_CNTL
70
	call	rs7xx_nbconfig_read_pci
210
	call	rs7xx_nbconfig_read_pci
Line 118... Line 258...
118
	mov	byte[mmio_pcie_cfg_pdes], dl
258
	mov	byte[mmio_pcie_cfg_pdes], dl
119
@@:
259
@@:
120
	xor	dx,  dx 			; PDEs counter
260
	xor	dx,  dx 			; PDEs counter
121
@@:
261
@@:
122
	mov	dword[ebx], eax 		; map 4 buses
262
	mov	dword[ebx], eax 		; map 4 buses
123
	invlpg	[ecx]				; next PgDir entry
-
 
124
	add	bx,  4				; new PDE
263
	add	bx,  4				; new PDE
125
	add	eax, 0x400000			; +4M phys.
264
	add	eax, 0x400000			; +4M phys.
126
	add	ecx, 0x400000			; +4M lin.
265
	add	ecx, 0x400000			; +4M lin.
127
	cmp	dl, byte[mmio_pcie_cfg_pdes]
266
	cmp	dl, byte[mmio_pcie_cfg_pdes]
128
	jnc	.pcie_cfg_mapped
267
	jnc	.pcie_cfg_mapped
129
	inc	dl
268
	inc	dl
130
	jmp	@b
269
	jmp	@b
-
 
270
	mov	eax, cr3
-
 
271
	mov	cr3, eax			; flush TLB
131
.pcie_cfg_mapped:
272
.pcie_cfg_mapped:
132
	mov	esi, boot_pcie_ok
273
	mov	esi, boot_pcie_ok
133
	call	boot_log
274
	call	boot_log
134
	ret	; <<< OK >>>
275
	ret	; <<< OK >>>
135
.rs7xx_pcie_fail:
276
.rs7xx_pcie_fail:
136
	mov	esi, boot_rs7xx_fail
277
	mov	esi, boot_rs7xx_fail
137
	call	boot_log
278
	call	boot_log
138
	ret
279
	jmp	$
139
.rs7xx_pcie_blocked:
280
.rs7xx_pcie_blocked:
140
	mov	esi, boot_rs7xx_blkd
281
	mov	esi, boot_rs7xx_blkd
141
	call	boot_log
282
	call	boot_log
142
	call	pci_ext_config
-
 
143
	jmp	.addr_found
-
 
144
	ret
283
	jmp	$