Rev 1463 | Rev 2288 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1463 | Rev 1487 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | ;; ;; |
6 | ;; ;; |
7 | ;; PCIe.INC ;; |
7 | ;; PCIe.INC ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; Extended PCI express services ;; |
9 | ;; Extended PCI express services ;; |
10 | ;; ;; |
10 | ;; ;; |
11 | ;; Author: ;; |
- | |
12 | ;; art_zh |
11 | ;; art_zh |
13 | ;; ;; |
12 | ;; ;; |
14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 15... | Line 14... | ||
15 | 14 | ||
Line 28... | Line 27... | ||
28 | ; 3) Only AMD/HT processors currently supported |
27 | ; 3) Only AMD/HT processors currently supported |
29 | ; |
28 | ; |
30 | ;*************************************************************************** |
29 | ;*************************************************************************** |
Line 31... | Line 30... | ||
31 | 30 | ||
32 | PCIe_CONFIG_SPACE equ 0xF0000000 ; to be moved to const.inc |
31 | PCIe_CONFIG_SPACE equ 0xF0000000 ; to be moved to const.inc |
33 | mmio_pcie_cfg_addr dd 0x0 ; not defined by default |
32 | mmio_pcie_cfg_addr dd 0x0 ; intel pcie space may be defined here |
Line 34... | Line 33... | ||
34 | mmio_pcie_cfg_lim dd 0x0 ; each bus needs 1Mb |
33 | mmio_pcie_cfg_lim dd 0x0 ; upper pcie space address |
Line 35... | Line 34... | ||
35 | 34 | ||
Line -... | Line 35... | ||
- | 35 | ||
36 | 36 | align 4 |
|
- | 37 | ||
- | 38 | pci_ext_config: |
|
- | 39 | ||
- | 40 | mov ebx, [mmio_pcie_cfg_addr] |
|
- | 41 | or ebx,ebx |
|
- | 42 | jz @f |
|
- | 43 | or ebx, 0x7FFFFFFF ; required by PCI-SIG standards |
|
- | 44 | jnz .pcie_failed |
|
- | 45 | add ebx, 0x0FFFFC |
|
- | 46 | cmp ebx, [mmio_pcie_cfg_lim]; is the space limit correct? |
|
- | 47 | ja .pcie_failed |
|
37 | align 4 |
48 | jmp .pcie_cfg_mapped |
Line 38... | Line 49... | ||
38 | 49 | @@: |
|
39 | pci_ext_config: |
50 | mov ebx, [cpu_vendor] |
40 | 51 | cmp ebx, dword [AMD_str] |
|
41 | push ebx |
52 | jne .pcie_failed |
42 | mov bx, 0xC184 ; dev = 24, fn = 01, reg = 84h |
53 | mov bx, 0xC184 ; dev = 24, fn = 01, reg = 84h |
43 | 54 | ||
44 | .check_HT_mmio: |
55 | .check_HT_mmio: |
45 | mov cx, bx |
56 | mov cx, bx |
46 | mov ax, 0x0002 ; bus = 0, 1dword to read |
57 | mov ax, 0x0002 ; bus = 0, 1dword to read |
47 | call pci_read_reg |
58 | call pci_read_reg |
48 | mov bx, cx |
59 | mov bx, cx |
49 | sub bl, 4 |
60 | sub bl, 4 |
50 | and al, 0x80 ; check the NP bit |
61 | and al, 0x80 ; check the NP bit |
51 | jz .not_pcie_cfg |
62 | jz .no_pcie_cfg |
52 | shl eax, 8 ; bus:[27..20], dev:[19:15] |
63 | shl eax, 8 ; bus:[27..20], dev:[19:15] |
53 | or eax, 0x00007FFC ; fun:[14..12], reg:[11:2] |
64 | or eax, 0x00007FFC ; fun:[14..12], reg:[11:2] |
54 | mov [mmio_pcie_cfg_lim], eax |
65 | mov [mmio_pcie_cfg_lim], eax |
55 | mov cl, bl |
66 | mov cl, bl |
56 | mov ax, 0x0002 ; bus = 0, 1dword to read |
67 | mov ax, 0x0002 ; bus = 0, 1dword to read |
57 | call pci_read_reg |
68 | call pci_read_reg |
58 | mov bx, cx |
69 | mov bx, cx |
59 | test al, 0x03 ; MMIO Base RW enabled? |
70 | test al, 0x03 ; MMIO Base RW enabled? |
60 | jz .not_pcie_cfg |
71 | jz .no_pcie_cfg |
61 | test al, 0x0C ; MMIO Base locked? |
72 | test al, 0x0C ; MMIO Base locked? |
62 | jnz .not_pcie_cfg |
73 | jnz .no_pcie_cfg |
63 | xor al, al |
74 | xor al, al |
64 | shl eax, 8 |
75 | shl eax, 8 |
Line 65... | Line 76... | ||
65 | ; test eax, 0x000F0000 ; MMIO Base must be bus0-aligned |
76 | test eax, 0x000F0000 ; MMIO Base must be bus0-aligned |
66 | ; jnz .not_pcie_cfg |
77 | jnz .no_pcie_cfg |
67 | mov [mmio_pcie_cfg_addr], eax |
78 | mov [mmio_pcie_cfg_addr], eax |
68 | add eax, 0x000FFFFC |
79 | add eax, 0x000FFFFC |
Line 87... | Line 98... | ||
87 | jmp @b |
98 | jmp @b |
Line 88... | Line 99... | ||
88 | 99 | ||
Line 89... | Line 100... | ||
89 | .pcie_cfg_mapped: |
100 | .pcie_cfg_mapped: |
90 | 101 | ||
91 | ; -- glad to have the extended PCIe config field found |
- | |
92 | mov esi, boot_pcie_ok |
102 | ; -- glad to have the extended PCIe config field found |
93 | pop ebx |
103 | ; mov esi, boot_pcie_ok |
Line 94... | Line 104... | ||
94 | call boot_log |
104 | ; call boot_log |
Line 95... | Line 105... | ||
95 | ret ; <<<<<<<<<<< OK >>>>>>>>>>> |
105 | ret ; <<<<<<<<<<< OK >>>>>>>>>>> |
96 | 106 | ||
97 | .not_pcie_cfg: |
107 | .no_pcie_cfg: |
98 | 108 | ||
99 | xor eax, eax |
109 | xor eax, eax |
100 | mov [mmio_pcie_cfg_addr], eax |
110 | mov [mmio_pcie_cfg_addr], eax |
- | 111 | mov [mmio_pcie_cfg_lim], eax |
|
101 | mov [mmio_pcie_cfg_lim], eax |
112 | add bl, 12 |
102 | add bl, 12 |
- | |
103 | cmp bl, 0xC0 ; MMIO regs lay below this offset |
113 | cmp bl, 0xC0 ; MMIO regs lay below this offset |
104 | jb .check_HT_mmio |
114 | jb .check_HT_mmio |