Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1565 | art_zh | 1 | ;; rs780 PCIe Port indirect regs test |
2 | ;; (C) art_zh 2010 |
||
3 | ;; |
||
4 | |||
5 | |||
6 | use32 ; |
||
7 | org 0x0 ; |
||
8 | |||
9 | db 'MENUET01' ; |
||
10 | dd 0x01 ; |
||
11 | dd START ; |
||
12 | dd I_END ; |
||
13 | dd 0x1000 ; |
||
14 | dd 0x1000 ; |
||
15 | dd 0x0 ; |
||
16 | dd 0x0 ; |
||
17 | |||
18 | include 'MACROS.INC' ; |
||
19 | |||
20 | PCIE_SPACE equ 0xF0000000 |
||
21 | PCIEINDP_INDEX equ 0xF00100E0 |
||
22 | PCIEINDP_DATA equ 0xF00100E4 ; bus 0, dev 2 |
||
23 | BOX_COLOR equ 0xE0D8D0 |
||
24 | |||
25 | START: |
||
26 | |||
27 | |||
28 | |||
29 | |||
30 | |||
31 | red: |
||
32 | |||
33 | call draw_window |
||
34 | |||
35 | still: |
||
36 | mcall 10 ; event waiting |
||
37 | |||
38 | cmp eax,1 ; redraw window |
||
39 | je red ; |
||
40 | cmp eax,2 ; key pressed? |
||
41 | je key ; |
||
42 | cmp eax,3 ; button hit? |
||
43 | je button ; |
||
44 | |||
45 | jmp still ; none of that |
||
46 | |||
47 | ;--------------------------------------------------------------------- |
||
48 | |||
49 | key: ; key pressed |
||
50 | jmp red |
||
51 | |||
52 | ;--------------------------------------------------------------------- |
||
53 | |||
54 | button: |
||
55 | mcall 17 ; get the button ID |
||
56 | cmp ah, 1 |
||
57 | jne .bt2 |
||
58 | mcall -1 |
||
59 | .bt2: |
||
60 | cmp ah, 2 |
||
61 | jne .bt3 |
||
62 | dec [Reg] ; Rg# decrement |
||
63 | jmp red |
||
64 | .bt3: |
||
65 | cmp ah, 3 |
||
66 | jne .bt4 |
||
67 | inc [Reg] ; Rg# increment |
||
68 | jmp red |
||
69 | .bt4: |
||
70 | cmp ah, 4 |
||
71 | jne .bt5 |
||
72 | add [Reg],16 ; PgDn |
||
73 | jmp red |
||
74 | .bt5: |
||
75 | cmp ah, 5 |
||
76 | jne .bt6 |
||
77 | mov edx, [Reg] |
||
78 | cmp edx, 16 |
||
79 | jb @f |
||
80 | sub edx, 16 |
||
81 | mov [Reg],edx ; PgUp |
||
82 | jmp red |
||
83 | @@: |
||
84 | xor edx, edx |
||
85 | mov [Reg], edx |
||
86 | jmp red |
||
87 | |||
88 | .bt6: |
||
89 | cmp ah, 6 |
||
90 | jne still |
||
91 | mcall 37, 1 ; get the mouse pointer |
||
92 | shr eax, 16 ; only X needed |
||
93 | sub eax, 124 ; check the left border |
||
94 | jb red |
||
95 | xor edx, edx |
||
96 | mov ebx, 12 |
||
97 | div ebx |
||
98 | cmp eax, 32 ; check the right border |
||
99 | jnb red |
||
100 | mov ecx, 31 |
||
101 | sub ecx, eax ; reverse the bit order |
||
102 | mov ebx, [Rct] |
||
103 | btc ebx, ecx ; invert the bit |
||
104 | mov eax, [Reg] |
||
105 | mov [Rct], ebx |
||
106 | call write_pcieind_p |
||
107 | |||
108 | jmp red |
||
109 | |||
110 | |||
111 | ;------------------------------------------------ |
||
112 | print_config_reg: |
||
113 | ;------------------------------------------------ |
||
114 | mov eax, [Reg] |
||
115 | ; and eax, 0x0FF |
||
116 | mov ebx, 3*65536+256 ; 3 hex digits |
||
117 | mov ecx, eax |
||
118 | mov dx,[stX] |
||
119 | shl edx,16 ; = X*65536 |
||
120 | mov dx,[stY] ; = edx + Y |
||
121 | mov esi,0 |
||
122 | mcall 47 ; print reg# |
||
123 | mov ecx, edx |
||
124 | call read_pcieind_p |
||
125 | mov edx, ecx |
||
126 | mov ecx, eax |
||
127 | add edx, 36*65536 ; right column |
||
128 | mov ebx, 8*65536+256 ; 8 hex digits |
||
129 | mcall 47 ; print config data |
||
130 | ret |
||
131 | |||
132 | ;------------------------------------------------ |
||
133 | read_pcieind_p: |
||
134 | ; in: [Reg] = reg# | out: eax = [Rct] = data |
||
135 | ;------------------------------------------------ |
||
136 | mov edx, PCIEINDP_INDEX |
||
137 | xor eax, eax |
||
138 | mov ax, word [Reg] |
||
139 | mov [edx], eax |
||
140 | add dl, 4 |
||
141 | mov eax, [edx] |
||
142 | mov [Rct], eax |
||
143 | ret |
||
144 | |||
145 | ;------------------------------------------------ |
||
146 | write_pcieind_p: |
||
147 | ; in: [Reg] = reg#; [Rct] = data |
||
148 | ;------------------------------------------------ |
||
149 | mov edx, PCIEINDP_INDEX |
||
150 | xor eax, eax |
||
151 | mov ax, word [Reg] |
||
152 | mov [edx], eax |
||
153 | add dl, 4 |
||
154 | mov eax, [Rct] |
||
155 | mov [edx], eax |
||
156 | sub dl, 4 |
||
157 | xor eax, eax ; reg#1 = SCRATCH |
||
158 | inc al |
||
159 | mov [edx], eax ; safely switch the index |
||
160 | ret |
||
161 | |||
162 | |||
163 | ;------------------------------------------------ |
||
164 | draw_window: |
||
165 | ;------------------------------------------------ |
||
166 | |||
167 | |||
168 | mcall 12, 1 |
||
169 | mcall 0, 1128*65536+530, 410*65536+290, 0x14B4A0A0,,title |
||
170 | ; ----------------------------------------------------------------- |
||
171 | ; BUTTONS: Xleft Xwid, Ytop Yheig |
||
172 | mcall 8, 370*65536+ 40, 26*65536+ 18, 2, 0xB4A0A0 ; << |
||
173 | mcall , , 51*65536+ 18, 3, ; >> |
||
174 | mcall , 425*65536+ 90, 26*65536+ 18, 4, ; Next Page |
||
175 | mcall , , 51*65536+ 18, 5, ; Prev Page |
||
176 | mcall , 117*65536+400, 97*65536+ 40, 6, ; Bits |
||
177 | |||
178 | call read_pcieind_p |
||
179 | |||
180 | mov ebx, bitstr2 |
||
181 | inc ebx |
||
182 | mov edx, [Rct] |
||
183 | mov ecx, 0x80000000 |
||
184 | xor eax, eax |
||
185 | .stringtest: |
||
186 | test edx, ecx |
||
187 | jz @f |
||
188 | mov byte [ebx+eax*2],'I' ; bit dump |
||
189 | jmp .nextbit |
||
190 | @@: |
||
191 | mov byte [ebx+eax*2],'0' |
||
192 | .nextbit: |
||
193 | inc eax |
||
194 | shr ecx, 1 |
||
195 | jnz .stringtest |
||
196 | |||
197 | ; button txt: X *65536+ Y |
||
198 | mcall 4, 378*65536+32 ,0x10000000, butstr2,3 |
||
199 | mcall , 378*65536+57 , , butstr3, |
||
200 | mcall , 436*65536+32 , , butstr4,9 |
||
201 | mcall , 436*65536+57 , , butstr5, |
||
202 | |||
203 | mcall 4, 122*65536+101,0 , bitstr0,65 |
||
204 | mcall , 122*65536+110,0 , bitstr1,65 |
||
205 | mcall , 122*65536+117,0 , bitstr2,65 |
||
206 | mcall , 122*65536+126,0 , bitstr3,65 |
||
207 | ; ----------------------------------------------------------------- |
||
208 | ; draw the reg-value box |
||
209 | mov ebx, 10*65536+100 ; Xleft | Xwidth |
||
210 | mov ecx, 26*65536+250 ; Ytop | Yheight |
||
211 | mov edx, BOX_COLOR |
||
212 | mcall 13 |
||
213 | ; draw the reg-address box |
||
214 | mov ebx, 206*65536+146 ; Xleft | Xwidth |
||
215 | mov cx, 44 ; Yheight only |
||
216 | mcall 13 |
||
217 | |||
218 | ; fill the data box |
||
219 | mov bx, 40 ; upper position |
||
220 | mov [stY],bx |
||
221 | mov eax, [Reg] |
||
222 | mov [reg], eax ; store original# |
||
223 | .print_reg_names: |
||
224 | call print_config_reg |
||
225 | add [stY],14 |
||
226 | inc [Reg] |
||
227 | mov edx,[reg] |
||
228 | mov eax, 16 |
||
229 | add eax, edx |
||
230 | cmp eax,[Reg] |
||
231 | ja .print_reg_names |
||
232 | mov [Reg], edx ; restore original# |
||
233 | |||
234 | ; fill the status box |
||
235 | mcall 4, 210*65536+30,0,str1,12 |
||
236 | mcall , 210*65536+44, ,str2, |
||
237 | mcall , 210*65536+56, ,str3, |
||
238 | call read_pcieind_p |
||
239 | mov ecx, PCIEINDP_DATA |
||
240 | mov edx, 300*65536+30 |
||
241 | mov ebx, 8*65536+256 |
||
242 | mcall 47 |
||
243 | add dx, 14 |
||
244 | mov ecx,[Reg] |
||
245 | mov esi, 0 |
||
246 | mcall 47 |
||
247 | add dx,14 |
||
248 | mov ecx, [Rct] |
||
249 | mcall 47 |
||
250 | |||
251 | ; print extra info |
||
252 | mov ebx, 120*65536+170 |
||
253 | xor ecx, ecx |
||
254 | mov edx, info1 |
||
255 | @@: |
||
256 | mcall 4,,,,66 |
||
257 | add edx, 66 |
||
258 | add ebx, 14 |
||
259 | cmp edx, info_end |
||
260 | jb @b |
||
261 | |||
262 | |||
263 | mcall 12, 2 |
||
264 | |||
265 | ret |
||
266 | |||
267 | |||
268 | align 4 |
||
269 | ;------------------------------------------------- |
||
270 | |||
271 | pix dd 0x55AACC33 |
||
272 | pxX dd 200 |
||
273 | pxY dd 160 |
||
274 | stX dw 18 |
||
275 | stY dw 0 |
||
276 | reg dd 0 |
||
277 | |||
278 | Rct dd 0 ; reg content |
||
279 | Reg dd 0x00 ; reg number |
||
280 | |||
281 | |||
282 | title db ' RS780 PCIe GFX Port indirect registers ',0 |
||
283 | ;------------------------------------------------------------------------------------ |
||
284 | reg_str db 'Reg#| hex.Value ' |
||
285 | ;------------------------------------------------------------------------------------ |
||
286 | str1 db 'bdf address:' |
||
287 | str2 db 'Reg. number:' |
||
288 | str3 db 'Reg.content:' |
||
289 | |||
290 | butstr2 db ' << ' |
||
291 | butstr3 db ' >> ' |
||
292 | butstr4 db 'Next Page' |
||
293 | butstr5 db 'Prev Page' |
||
294 | |||
295 | bitstr0 db '31',209,205,209,205,209,205,209,205,209,205,209,205,'24',\ |
||
296 | 209,205,209,205,209,205,209,205,209,205,209,205,209,205,'16',\ |
||
297 | 209,'15',205,209,205,209,205,209,205,209,205,209,205,209,'8',\ |
||
298 | 205,'7',209,205,209,205,209,205,209,205,209,205,209,205,209,'0',184 |
||
299 | bitstr1 db 179,' | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ',179 |
||
300 | bitstr2 db 179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179,'9 8 7 6',\ |
||
301 | 179,'5 4 3 2',179,'1 0 9 8',179,'7 6 5 4',179,'3 2 1 0',179 |
||
302 | bitstr3 db 212,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\ |
||
303 | 205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\ |
||
304 | 205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,205,207,\ |
||
305 | 205,207,205,207,205,207,205,207,205,207,205,190 |
||
306 | |||
307 | info1 db '----------- PCIe GFX port indirect registers shortlist -----------' |
||
308 | db '| |' |
||
309 | info2 db '| reg 10 - port control; 20-25 - Tx control |' |
||
310 | db '| reg 30-36 - Tx credits; 50 - line status |' |
||
311 | db '| reg 60-62 - flow control; 70-72 Rx control |' |
||
312 | db '| reg 80-84 - Rx credits; A0,B1-B5 line control |' |
||
313 | db '| reg A1-A6 - lane training; A4 - speed control |' |
||
314 | db '------------------------------------------------------------------' |
||
315 | info_end: |
||
316 | |||
317 | I_END: ; end of program |
||
318 | |||
319 | rd 256 |
||
320 | |||
321 | align 256 |
||
322 | st_0:><> |