Subversion Repositories Kolibri OS

Rev

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

Rev 3519 Rev 3526
Line 90... Line 90...
90
 
90
 
91
 
91
 
92
 
92
 
93
;***************************************************************************
93
;***************************************************************************
94
;   Function
94
;   Function
95
;      rs7xx_pcie_init:
95
;      fusion_pcie_init:
96
;
96
;
97
;   Description
97
;   Description
Line 98... Line 98...
98
;       PCIe extended (memory-mapped) config space detection
98
;       PCIe extended  config space detection and mapping
Line 99... Line -...
99
;
-
 
100
;***************************************************************************
-
 
101
 
-
 
102
align 4
-
 
103
 
-
 
104
rs7xx_pcie_init:
-
 
105
	call	rs7xx_unlock_bar3
-
 
106
	mov	al, 0x7C		       ; NB_IOC_CFG_CNTL
-
 
107
	call	rs7xx_nbconfig_read_pci
-
 
108
	mov	ebx, eax
-
 
109
;       call    rs7xx_nbconfig_flush_pci
-
 
110
	test	ebx, 0x20000000 		; BAR3 locked?
-
 
111
	jz	$
-
 
112
	mov	al, 0x84			; NB_PCI_ARB
-
 
113
	call	rs7xx_nbconfig_read_pci
-
 
114
	shr	eax,16
-
 
115
	and	ax, 7				; the Bus range lays here:
-
 
116
	jnz	@f
-
 
117
	mov	ax, 8					; 1=2Mb,  2=4MB,  3=8MB,  4=16MB
-
 
118
@@:
-
 
119
	mov	word[PCIe_bus_range-OS_BASE], ax	; 5=32Mb, 6=64MB, 7=128Mb, 8=256Mb
-
 
120
	mov	cl, al
-
 
121
	call	rs7xx_nbconfig_flush_pci
-
 
122
	dec	cl				; <4M ?
-
 
123
	jz	@f
-
 
124
	dec	cl				; one PDE needed anyway
-
 
125
@@:
-
 
126
	mov	ebx, 1
-
 
127
	shl	ebx, cl
-
 
128
	mov	word[mmio_pcie_cfg_pdes-OS_BASE], bx	; 1..64 PDE(s) needed,
-
 
129
	shl	ebx, 22
-
 
130
	mov	dword[mmio_pcie_cfg_lim-OS_BASE], ebx	; or 4..256Mb space to map
-
 
131
	dec	dword[mmio_pcie_cfg_lim-OS_BASE]
-
 
132
 
-
 
133
	mov	al, 0x1C			; NB_BAR3_PCIEXP_MMCFG
-
 
134
	call	rs7xx_nbconfig_read_pci
-
 
135
	mov	ebx, eax
-
 
136
	call	rs7xx_nbconfig_flush_pci
-
 
137
	mov	eax, ebx
-
 
Line 138... Line -...
138
	and	eax, 0xFFE00000 		; valid bits [31..21]
-
 
139
	jz	$				; invalid map!
-
 
140
.addr_found:
-
 
141
	mov	dword[mmio_pcie_cfg_addr-OS_BASE], eax	; physical address (lower 32 bits)
-
 
142
	add	dword[mmio_pcie_cfg_lim-OS_BASE],  eax
-
 
143
 
-
 
144
; ---- common mapping procedure ----
-
 
145
; (eax = phys. address of PCIe conf.space)
-
 
146
;
-
 
147
map_pcie_pages:
-
 
148
	or	eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW)  ;  UW is unsafe!
-
 
149
	mov	ecx, PCIe_CONFIG_SPACE			; linear address
-
 
150
	mov	ebx, ecx
-
 
151
	shr	ebx, 20
-
 
152
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
-
 
153
	mov	dl, byte[mmio_pcie_cfg_pdes-OS_BASE]	; 1 page = 4M in address space
-
 
154
	cmp	dl, 0x34	; =(USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4M
-
 
155
	jb	@f
-
 
156
	mov	dl, 0x33
-
 
157
	mov	byte[mmio_pcie_cfg_pdes-OS_BASE], dl
-
 
158
@@:
-
 
159
	xor	dx,  dx 			; PDEs counter
-
 
160
.write_pde:
-
 
161
	mov	dword[ebx], eax 		; map 4 buses
-
 
162
	add	bx,  4				; new PDE
-
 
Line 163... Line 99...
163
	add	eax, 0x400000			; +4M phys.
99
;
164
	add	ecx, 0x400000			; +4M lin.
100
;***************************************************************************
165
	cmp	dl, byte[mmio_pcie_cfg_pdes-OS_BASE]
101
 
166
	jae	pcie_cfg_mapped
102
align 4
Line 190... Line 126...
190
	shl	edx, 22
126
	shl	edx, 22
191
	dec	edx
127
	dec	edx
192
	add	edx, eax			; the upper configspace limit
128
	add	edx, eax			; the upper configspace limit
193
	mov	dword[mmio_pcie_cfg_lim-OS_BASE], edx
129
	mov	dword[mmio_pcie_cfg_lim-OS_BASE], edx
Line -... Line 130...
-
 
130
 
-
 
131
; ---- large pages mapping  ----
-
 
132
; (eax = phys. address of PCIe conf.space)
-
 
133
;
-
 
134
.map_pcie_pages:
-
 
135
	or	eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW)  ;  UW is unsafe!
-
 
136
	mov	ecx, PCIe_CONFIG_SPACE			; linear address
-
 
137
	mov	ebx, ecx
-
 
138
	shr	ebx, 20
-
 
139
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
-
 
140
	mov	dl, byte[mmio_pcie_cfg_pdes-OS_BASE]	; 1 page = 4M in address space
-
 
141
	cmp	dl, 0x34	; =(USER_DMA_BUFFER - PCIe_CONFIG_SPACE) / 4M
-
 
142
	jb	@f
-
 
143
	mov	dl, 0x33
-
 
144
	mov	byte[mmio_pcie_cfg_pdes-OS_BASE], dl
-
 
145
@@:
-
 
146
	xor	dx,  dx 			; PDEs counter
-
 
147
.write_pde:
-
 
148
	mov	dword[ebx], eax 		; map 4 buses
-
 
149
	add	bx,  4				; new PDE
-
 
150
	add	eax, 0x400000			; +4M phys.
-
 
151
	add	ecx, 0x400000			; +4M lin.
194
 
152
	cmp	dl, byte[mmio_pcie_cfg_pdes-OS_BASE]
-
 
153
	jae	.pcie_cfg_mapped
-
 
154
	inc	dl
Line 195... Line 155...
195
pcie_cfg_mapped:
155
	jmp	.write_pde
Line -... Line 156...
-
 
156
 
196
 
157
.pcie_cfg_mapped:
197
create_mmio_pte:
158
 
198
 
159
create_mmio_pte:
199
	mov	ecx, mmio_pte                           ; physical address
160
	mov	ecx, mmio_pte                           ; physical address
200
	or	ecx, (PG_NOCACHE + PG_SHARED)  
161
	or	ecx, (PG_NOCACHE + PG_SHARED)  
201
	mov	ebx, FUSION_MMIO			; linear address
162
	mov	ebx, FUSION_MMIO			; linear address
Line -... Line 163...
-
 
163
	shr	ebx, 20
202
	shr	ebx, 20
164
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
203
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
165
        mov     dword[ebx], ecx                         ; Fusion MMIO tables
204
        mov     dword[ebx], ecx                         ; Fusion MMIO tables
166
 
205
 
167
; ---- short page mapping  ----
206
map_apic_mmio:
168
.map_apic_mmio:
207
        mov     ecx, 0x01B      ; APIC BAR
169
        mov     ecx, 0x01B      ; APIC BAR
Line 208... Line 170...
208
        rdmsr
170
        rdmsr
Line 209... Line 171...
209
        and     eax, 0xFFFFF000                         ; physical address
171
        and     eax, 0xFFFFF000                         ; physical address