Subversion Repositories Kolibri OS

Rev

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

Rev 2014 Rev 3519
Line 143... Line 143...
143
 
143
 
144
; ---- common mapping procedure ----
144
; ---- common mapping procedure ----
145
; (eax = phys. address of PCIe conf.space)
145
; (eax = phys. address of PCIe conf.space)
146
;
146
;
147
map_pcie_pages:
147
map_pcie_pages:
148
	or	eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW)  ;  UW is unsafe, fix it!
148
	or	eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW)  ;  UW is unsafe!
149
	mov	ecx, PCIe_CONFIG_SPACE			; linear address
149
	mov	ecx, PCIe_CONFIG_SPACE			; linear address
150
	mov	ebx, ecx
150
	mov	ebx, ecx
151
	shr	ebx, 20
151
	shr	ebx, 20
152
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
152
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
Line 161... Line 161...
161
	mov	dword[ebx], eax 		; map 4 buses
161
	mov	dword[ebx], eax 		; map 4 buses
162
	add	bx,  4				; new PDE
162
	add	bx,  4				; new PDE
163
	add	eax, 0x400000			; +4M phys.
163
	add	eax, 0x400000			; +4M phys.
164
	add	ecx, 0x400000			; +4M lin.
164
	add	ecx, 0x400000			; +4M lin.
165
	cmp	dl, byte[mmio_pcie_cfg_pdes-OS_BASE]
165
	cmp	dl, byte[mmio_pcie_cfg_pdes-OS_BASE]
166
	jae	.pcie_cfg_mapped
166
	jae	pcie_cfg_mapped
167
	inc	dl
167
	inc	dl
168
	jmp	.write_pde
168
	jmp	.write_pde
169
;        mov     eax, cr3
-
 
170
;        mov     cr3, eax                        ; flush TLB
-
 
171
.pcie_cfg_mapped:
-
 
172
	ret	; <<< OK >>>
-
 
Line 173... Line 169...
173
 
169
 
174
; ---- stepping 10h CPUs and Fusion APUs: the configspace is stored in MSR_C001_0058 ----
170
; ---- stepping 10h CPUs and Fusion APUs: the configspace is stored in MSR_C001_0058 ----
175
align 4
171
align 4
176
fusion_pcie_init:
172
fusion_pcie_init:
Line 194... Line 190...
194
	shl	edx, 22
190
	shl	edx, 22
195
	dec	edx
191
	dec	edx
196
	add	edx, eax			; the upper configspace limit
192
	add	edx, eax			; the upper configspace limit
197
	mov	dword[mmio_pcie_cfg_lim-OS_BASE], edx
193
	mov	dword[mmio_pcie_cfg_lim-OS_BASE], edx
Line -... Line 194...
-
 
194
 
-
 
195
pcie_cfg_mapped:
-
 
196
 
-
 
197
create_mmio_pte:
-
 
198
 
-
 
199
	mov	ecx, mmio_pte                           ; physical address
-
 
200
	or	ecx, (PG_NOCACHE + PG_SHARED)  
-
 
201
	mov	ebx, FUSION_MMIO			; linear address
-
 
202
	shr	ebx, 20
-
 
203
	add	ebx, (sys_pgdir - OS_BASE)		; PgDir entry @
-
 
204
        mov     dword[ebx], ecx                         ; Fusion MMIO tables
198
 
205
 
-
 
206
map_apic_mmio:
-
 
207
        mov     ecx, 0x01B      ; APIC BAR
-
 
208
        rdmsr
-
 
209
        and     eax, 0xFFFFF000                         ; physical address
-
 
210
	or	eax, (PG_NOCACHE + PG_SHARED + PG_UW)   ;  UW is unsafe!
-
 
211
        mov     dword[mmio_pte + 0], eax
-
 
212
 
Line 199... Line 213...
199
	jmp	map_pcie_pages
213
	ret	; <<< OK >>>
Line 200... Line 214...
200
 
214