Rev 1505 | Rev 1508 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1463 | art_zh | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) 2010 KolibriOS team. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;; ;; |
||
7 | ;; PCIe.INC ;; |
||
8 | ;; ;; |
||
9 | ;; Extended PCI express services ;; |
||
10 | ;; ;; |
||
11 | ;; art_zh |
||
12 | ;; ;; |
||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
14 | |||
15 | $Revision: 1463 $ |
||
16 | |||
17 | ;*************************************************************************** |
||
18 | ; Function |
||
19 | ; pci_ext_config: |
||
20 | ; |
||
21 | ; Description |
||
22 | ; PCIe extended (memory-mapped) config space detection |
||
23 | ; |
||
24 | ; WARNINGs: |
||
25 | ; 1) Very Experimental! |
||
26 | ; 2) direct HT-detection (no ACPI or BIOS service used) |
||
27 | ; 3) Only AMD/HT processors currently supported |
||
28 | ; |
||
29 | ;*************************************************************************** |
||
30 | |||
1487 | art_zh | 31 | mmio_pcie_cfg_addr dd 0x0 ; intel pcie space may be defined here |
32 | mmio_pcie_cfg_lim dd 0x0 ; upper pcie space address |
||
1463 | art_zh | 33 | |
34 | |||
35 | align 4 |
||
36 | |||
37 | pci_ext_config: |
||
38 | |||
1487 | art_zh | 39 | mov ebx, [mmio_pcie_cfg_addr] |
40 | or ebx,ebx |
||
41 | jz @f |
||
42 | or ebx, 0x7FFFFFFF ; required by PCI-SIG standards |
||
43 | jnz .pcie_failed |
||
44 | add ebx, 0x0FFFFC |
||
45 | cmp ebx, [mmio_pcie_cfg_lim]; is the space limit correct? |
||
46 | ja .pcie_failed |
||
47 | jmp .pcie_cfg_mapped |
||
48 | @@: |
||
49 | mov ebx, [cpu_vendor] |
||
50 | cmp ebx, dword [AMD_str] |
||
51 | jne .pcie_failed |
||
1463 | art_zh | 52 | mov bx, 0xC184 ; dev = 24, fn = 01, reg = 84h |
53 | |||
54 | .check_HT_mmio: |
||
55 | mov cx, bx |
||
56 | mov ax, 0x0002 ; bus = 0, 1dword to read |
||
57 | call pci_read_reg |
||
58 | mov bx, cx |
||
59 | sub bl, 4 |
||
60 | and al, 0x80 ; check the NP bit |
||
1487 | art_zh | 61 | jz .no_pcie_cfg |
1463 | art_zh | 62 | shl eax, 8 ; bus:[27..20], dev:[19:15] |
63 | or eax, 0x00007FFC ; fun:[14..12], reg:[11:2] |
||
64 | mov [mmio_pcie_cfg_lim], eax |
||
65 | mov cl, bl |
||
66 | mov ax, 0x0002 ; bus = 0, 1dword to read |
||
67 | call pci_read_reg |
||
68 | mov bx, cx |
||
69 | test al, 0x03 ; MMIO Base RW enabled? |
||
1487 | art_zh | 70 | jz .no_pcie_cfg |
1463 | art_zh | 71 | test al, 0x0C ; MMIO Base locked? |
1487 | art_zh | 72 | jnz .no_pcie_cfg |
1463 | art_zh | 73 | xor al, al |
74 | shl eax, 8 |
||
1487 | art_zh | 75 | test eax, 0x000F0000 ; MMIO Base must be bus0-aligned |
76 | jnz .no_pcie_cfg |
||
1463 | art_zh | 77 | mov [mmio_pcie_cfg_addr], eax |
78 | add eax, 0x000FFFFC |
||
79 | sub eax,[mmio_pcie_cfg_lim] ; MMIO must cover at least one bus |
||
1487 | art_zh | 80 | ja .no_pcie_cfg |
1463 | art_zh | 81 | |
82 | ; -- it looks like a true PCIe config space; |
||
83 | mov eax,[mmio_pcie_cfg_addr] ; physical address |
||
84 | or eax, (PG_SHARED + PG_LARGE + PG_USER) |
||
85 | mov ebx, PCIe_CONFIG_SPACE ; linear address |
||
86 | mov ecx, ebx |
||
87 | shr ebx, 20 |
||
88 | add ebx, sys_pgdir ; PgDir entry @ |
||
89 | @@: |
||
90 | mov dword[ebx], eax ; map 4 buses |
||
91 | invlpg [ecx] |
||
92 | cmp bl, 4 |
||
93 | jz .pcie_cfg_mapped ; fix it later |
||
94 | add bl, 4 ; next PgDir entry |
||
95 | add eax, 0x400000 ; eax += 4M |
||
96 | add ecx, 0x400000 |
||
97 | jmp @b |
||
98 | |||
99 | .pcie_cfg_mapped: |
||
100 | |||
101 | ; -- glad to have the extended PCIe config field found |
||
1487 | art_zh | 102 | ; mov esi, boot_pcie_ok |
103 | ; call boot_log |
||
1463 | art_zh | 104 | ret ; <<<<<<<<<<< OK >>>>>>>>>>> |
105 | |||
1487 | art_zh | 106 | .no_pcie_cfg: |
1463 | art_zh | 107 | |
108 | xor eax, eax |
||
109 | mov [mmio_pcie_cfg_addr], eax |
||
110 | mov [mmio_pcie_cfg_lim], eax |
||
111 | add bl, 12 |
||
112 | cmp bl, 0xC0 ; MMIO regs lay below this offset |
||
113 | jb .check_HT_mmio |
||
1487 | art_zh | 114 | .pcie_failed: |
115 | ; mov esi, boot_pcie_fail |
||
116 | ; call boot_log |
||
1463 | art_zh | 117 | ret ; <<<<<<<<< FAILURE >>>>>>>>>><><<><<<><<<<><<<<<><<<<<<><<<<<<<><<<<<<<<>><><<><<<><<<<><<<<<><<<<<<><<<<<<<><<<<<<<<><<<<<<<<<><<<<<<<<<<> |
118 |