Rev 1683 | Rev 2014 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1683 | Rev 1928 | ||
---|---|---|---|
Line 134... | Line 134... | ||
134 | call rs7xx_nbconfig_read_pci |
134 | call rs7xx_nbconfig_read_pci |
135 | mov ebx, eax |
135 | mov ebx, eax |
136 | call rs7xx_nbconfig_flush_pci |
136 | call rs7xx_nbconfig_flush_pci |
137 | mov eax, ebx |
137 | mov eax, ebx |
138 | and eax, 0xFFE00000 ; valid bits [31..21] |
138 | and eax, 0xFFE00000 ; valid bits [31..21] |
139 | jz $ ; NB BAR3 may be invisible! |
139 | jz $ ; invalid map! |
140 | .addr_found: |
140 | .addr_found: |
141 | mov dword[mmio_pcie_cfg_addr-OS_BASE], eax ; physical address (lower 32 bits) |
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 |
142 | add dword[mmio_pcie_cfg_lim-OS_BASE], eax |
Line -... | Line 143... | ||
- | 143 | ||
- | 144 | ; ---- common mapping procedure ---- |
|
- | 145 | ; (eax = phys. address of PCIe conf.space) |
|
- | 146 | ; |
|
143 | 147 | map_pcie_pages: |
|
144 | or eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW) ; by the way, UW is unsafe! |
148 | or eax, (PG_NOCACHE + PG_SHARED + PG_LARGE + PG_UW) ; UW is unsafe, fix it! |
145 | mov ecx, PCIe_CONFIG_SPACE ; linear address |
149 | mov ecx, PCIe_CONFIG_SPACE ; linear address |
146 | mov ebx, ecx |
150 | mov ebx, ecx |
147 | shr ebx, 20 |
151 | shr ebx, 20 |
148 | add ebx, (sys_pgdir - OS_BASE) ; PgDir entry @ |
152 | add ebx, (sys_pgdir - OS_BASE) ; PgDir entry @ |
Line 165... | Line 169... | ||
165 | ; mov eax, cr3 |
169 | ; mov eax, cr3 |
166 | ; mov cr3, eax ; flush TLB |
170 | ; mov cr3, eax ; flush TLB |
167 | .pcie_cfg_mapped: |
171 | .pcie_cfg_mapped: |
168 | ret ; <<< OK >>> |
172 | ret ; <<< OK >>> |
Line -... | Line 173... | ||
- | 173 | ||
- | 174 | ; ---- stepping 10h CPUs and Fusion APUs: the configspace is stored in MSR_C001_0058 ---- |
|
- | 175 | align 4 |
|
- | 176 | fusion_pcie_init: |
|
- | 177 | mov ecx, 0xC0010058 |
|
- | 178 | rdmsr |
|
- | 179 | or edx, edx |
|
- | 180 | jnz $ ; PCIe is in the upper memory. Stop. |
|
- | 181 | xchg dl, al |
|
- | 182 | mov dword[mmio_pcie_cfg_addr-OS_BASE], eax ; store the physical address |
|
- | 183 | mov ecx, edx |
|
- | 184 | and dl, 1 |
|
- | 185 | jz $ ; bit[0] = 1 means no PCIe mapping allowed. Stop. |
|
- | 186 | shr cl, 2 ; ecx = log2(number of buses) |
|
- | 187 | mov word[PCIe_bus_range-OS_BASE], cx |
|
- | 188 | sub cl, 2 |
|
- | 189 | jae @f |
|
- | 190 | xor cl, cl |
|
- | 191 | @@: |
|
- | 192 | shl edx, cl ; edx = number of 4M pages to map |
|
- | 193 | mov word[mmio_pcie_cfg_pdes-OS_BASE], dx |
|
- | 194 | shl edx, 22 |
|
- | 195 | dec edx |
|
- | 196 | add edx, eax ; the upper configspace limit |
|
- | 197 | mov dword[mmio_pcie_cfg_lim-OS_BASE], edx |
|
- | 198 | ||
Line 169... | Line 199... | ||
169 | 199 | jmp map_pcie_pages |
|
Line 170... | Line 200... | ||
170 | 200 | ||
Line 276... | Line 306... | ||
276 | xor eax, eax |
306 | xor eax, eax |
277 | mov [edx], eax |
307 | mov [edx], eax |
278 | pop edx |
308 | pop edx |
279 | ret><><<>4M> |
309 | ret |
Line -... | Line 310... | ||
- | 310 | ||
- | 311 | ;------------------------------------------------ |
|
- | 312 | align 4 |
|
- | 313 | sys_rdmsr: |
|
- | 314 | ; in: [esp+8] = MSR# |
|
- | 315 | ; out: [esp+8] = MSR[63:32] |
|
- | 316 | ; [eax] = MSR[31: 0] |
|
- | 317 | ;------------------------------------------------ |
|
- | 318 | push ecx edx |
|
- | 319 | mov ecx, [esp+16] |
|
- | 320 | rdmsr |
|
- | 321 | mov [esp+16], edx |
|
- | 322 | pop edx ecx |