Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1164 | hidnplayr | 1 | include 'macros.inc' |
2 | MEOS_APP_START |
||
3 | |||
4 | type_ethernet equ 1 |
||
5 | |||
6 | CODE |
||
7 | call draw_window |
||
8 | |||
9 | still: mcall 10 ; wait here for event |
||
10 | dec eax ; redraw request ? |
||
11 | jz red |
||
12 | dec eax ; key in buffer ? |
||
13 | jz key |
||
14 | dec eax ; button in buffer ? |
||
15 | jz button |
||
16 | jmp still |
||
17 | |||
18 | red: ; redraw |
||
19 | mcall 9, Proc_Info, -1 ; window redraw requested so get new window coordinates and size |
||
20 | mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure |
||
21 | mov [Form + 2], ax ; x start position |
||
22 | mov eax, [Proc_Info.box.top]; |
||
23 | mov [Form + 6], ax ; ystart position |
||
24 | mov eax, [Proc_Info.box.width] ; |
||
25 | mov [Form], ax ; window width |
||
26 | mov eax, [Proc_Info.box.height] ; |
||
27 | mov [Form + 4] ,ax ; window height |
||
28 | call draw_window ; go redraw window now |
||
29 | jmp still |
||
30 | |||
31 | key: ; key |
||
32 | mcall 2 ; just read it and ignore |
||
33 | jmp still |
||
34 | button: ; button |
||
35 | mcall 17 ; get id |
||
36 | |||
37 | cmp ah, 1 ; button id = 1 ? |
||
38 | jne @f |
||
39 | mcall -1 ; close this program |
||
40 | @@: |
||
41 | cmp eax,0x0000fe00 |
||
42 | jg @f |
||
43 | |||
44 | cmp ah, 4 |
||
45 | je hook |
||
46 | |||
47 | jmp still |
||
48 | @@: |
||
49 | shr eax, 16 |
||
50 | mov dword[MAC],0 |
||
51 | mov word [MAC+4],0 |
||
52 | mov word [selected], ax |
||
53 | |||
54 | call load_drv |
||
55 | call draw_window |
||
56 | |||
57 | jmp still |
||
58 | |||
59 | load_drv: |
||
60 | ; mov ax , [selected] |
||
61 | test ax , ax |
||
62 | jz still |
||
63 | |||
64 | mov bl , 6 ; get a dword |
||
65 | mov bh , ah ; bus |
||
66 | mov ch , al ; dev |
||
67 | mov cl , 0 ; offset to device/vendor id |
||
68 | mcall 62 ; get ID's |
||
69 | |||
70 | mov word [PCI_Vendor], ax |
||
71 | shr eax, 16 |
||
72 | mov word [PCI_Device], ax |
||
73 | call get_drv_ptr |
||
74 | |||
75 | mov ecx, eax |
||
76 | mcall 68, 16 |
||
77 | |||
78 | mov [IOCTL.handle], eax |
||
79 | |||
80 | ret |
||
81 | |||
82 | hook: |
||
83 | mov ax , [selected] |
||
84 | test ax , ax |
||
85 | jz still |
||
86 | |||
87 | mov [hardwareinfo.pci_dev], al |
||
88 | mov [hardwareinfo.pci_bus], ah |
||
89 | |||
90 | mov [IOCTL.io_code], 1 ; SRV_HOOK |
||
91 | mov [IOCTL.inp_size], 3 |
||
92 | mov [IOCTL.input], hardwareinfo |
||
93 | mov [IOCTL.out_size], 0 |
||
94 | mov [IOCTL.output], 0 |
||
95 | |||
96 | mcall 68, 17, IOCTL |
||
97 | |||
98 | mov byte[drivernumber], al |
||
99 | |||
100 | printhdwaddr: |
||
101 | |||
102 | call draw_window |
||
103 | |||
104 | jmp still |
||
105 | |||
106 | draw_window: |
||
107 | mcall 12, 1 ; start of draw |
||
108 | mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title |
||
109 | |||
110 | mcall 73, 0 |
||
111 | mov ecx, eax |
||
112 | mcall 47, 1 shl 18, , 50 shl 16 + 10, 0x00000000 |
||
113 | |||
114 | call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device |
||
115 | |||
116 | cmp edx, 20 shl 16 + 110 |
||
117 | je .nonefound |
||
118 | |||
119 | mcall 4, 20 shl 16 + 100, 1 shl 31 + 0x00000000 , caption |
||
120 | |||
121 | mcall 8, 122 shl 16 + 100, 50 shl 16 + 18, 0x00000004, 0x00007f00 |
||
122 | mcall ,, 70 shl 16 + 18, 0x00000005, 0x007f0000 |
||
123 | |||
124 | mcall 4, 137 shl 16 + 57, 1 shl 31 + 0x00ffffff , btn_start |
||
125 | mcall , 140 shl 16 + 77, , btn_stop |
||
126 | |||
127 | mcall , 240 shl 16 + 77, 1 shl 31 + 0x00000000 , lbl_hdw_addr |
||
128 | mcall , 312 shl 16 + 57, , lbl_type |
||
129 | add ebx, 38 shl 16 |
||
130 | cmp byte [type],type_ethernet |
||
131 | jne @f |
||
132 | mcall , , 1 shl 31 + 0x00000000, lbl_ethernet |
||
133 | |||
134 | mcall 8,345 shl 16 + 17, 73 shl 16 + 14, 0x00000006, 0x00aaaa00 |
||
135 | mcall ,365 shl 16 + 17, , 0x00000007 |
||
136 | mcall ,385 shl 16 + 17, , 0x00000008 |
||
137 | mcall ,405 shl 16 + 17, , 0x00000009 |
||
138 | mcall ,425 shl 16 + 17, , 0x0000000a |
||
139 | mcall ,445 shl 16 + 17, , 0x0000000b |
||
140 | movzx ecx,byte[MAC] |
||
141 | mcall 47, 1 shl 17 + 1 shl 8,,349 shl 16 + 77, 0x000022cc |
||
142 | movzx ecx,byte[MAC+1] |
||
143 | add edx, 20 shl 16 |
||
144 | mcall |
||
145 | movzx ecx,byte[MAC+2] |
||
146 | add edx, 20 shl 16 |
||
147 | mcall |
||
148 | movzx ecx,byte[MAC+3] |
||
149 | add edx, 20 shl 16 |
||
150 | mcall |
||
151 | movzx ecx,byte[MAC+4] |
||
152 | add edx, 20 shl 16 |
||
153 | mcall |
||
154 | movzx ecx,byte[MAC+5] |
||
155 | add edx, 20 shl 16 |
||
156 | mcall |
||
157 | |||
158 | jmp .done |
||
159 | |||
160 | @@: |
||
161 | mcall 4, , 1 shl 31 + 0x00ff0000, lbl_unknown |
||
162 | jmp .done |
||
163 | |||
164 | .nonefound : |
||
165 | mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound |
||
166 | .done: |
||
167 | mcall 12, 2 ; end of draw |
||
168 | ret |
||
169 | |||
170 | |||
171 | ;------------------------------------------------------------------ |
||
172 | ;* Gets the PCI Version and Last Bus |
||
173 | Get_PCI_Info: |
||
174 | mcall 62, 0 |
||
175 | mov word [PCI_Version], ax |
||
176 | mcall 62, 1 |
||
177 | mov byte [PCI_LastBus], al |
||
178 | ;---------------------------------------------------------- |
||
179 | ;* Get all devices on PCI Bus |
||
180 | mov edx, 20 shl 16 + 110 ; set start write position |
||
181 | cmp al , 0xff ; 0xFF means no pci bus found |
||
182 | jne Pci_Exists ; |
||
183 | ret ; if no bus then leave |
||
184 | Pci_Exists: |
||
185 | mov byte [V_Bus], 0 ; reset varibles |
||
186 | mov byte [V_Dev], 0 ; |
||
187 | Start_Enum: |
||
188 | mov bl , 6 ; get a dword |
||
189 | mov bh , byte [V_Bus] ; bus of pci device |
||
190 | mov ch , byte [V_Dev] ; device number/function |
||
191 | mov cl , 0 ; offset to device/vendor id |
||
192 | mcall 62 ; get ID's |
||
193 | |||
194 | cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF |
||
195 | je nextDev ; check next device if nothing exists here |
||
196 | cmp ax, 0xffff ; |
||
197 | je nextDev ; |
||
198 | |||
199 | mov word [PCI_Vendor], ax ; There is a device here, save the ID's |
||
200 | shr eax, 16 ; |
||
201 | mov word [PCI_Device], ax ; |
||
202 | mov bl , 4 ; Read config byte |
||
203 | mov bh , byte [V_Bus] ; Bus # |
||
204 | mov ch , byte [V_Dev] ; Device # on bus |
||
205 | mov cl , 0x08 ; Register to read (Get Revision) |
||
206 | mcall 62 ; Read it |
||
207 | mov byte [PCI_Rev], al ; Save it |
||
208 | mov cl , 0x0b ; Register to read (Get class) |
||
209 | mcall 62 ; Read it |
||
210 | |||
211 | mov byte [PCI_Class], al ; Save it |
||
212 | mov cl , 0x0a ; Register to read (Get Subclass) |
||
213 | mcall 62 ; Read it |
||
214 | mov byte [PCI_SubClass], al ; Save it |
||
215 | mov cl , 0x09 ; Register to read (Get Interface) |
||
216 | mcall 62 ; Read it |
||
217 | mov [PCI_Interface], al ; Save it |
||
218 | mov cl , 0x3c ; Register to read (Get IRQ) |
||
219 | @@: mcall 62 ; Read it |
||
220 | mov [PCI_IRQ], al ; Save it |
||
221 | ; |
||
222 | ; inc byte [total] ; one more device found |
||
223 | |||
224 | cmp byte [PCI_Class],2 |
||
225 | jne nextDev |
||
226 | |||
227 | call Print_New_Device ; print device info to screen |
||
228 | nextDev: |
||
229 | add byte [V_Dev], 8 ; lower 3 bits are the function number |
||
230 | |||
231 | jnz Start_Enum ; jump until we reach zero |
||
232 | mov byte [V_Dev], 0 ; reset device number |
||
233 | inc byte [V_Bus] ; next bus |
||
234 | mov al , byte [PCI_LastBus] ; get last bus |
||
235 | cmp byte [V_Bus], al ; was it last bus |
||
236 | jbe Start_Enum ; if not jump to keep searching |
||
237 | ret |
||
238 | |||
239 | ;------------------------------------------------------------------ |
||
240 | ;* Print device info to screen |
||
241 | Print_New_Device: |
||
242 | |||
243 | push edx ; Magic ! (to print a button...) |
||
244 | |||
245 | mov ebx, 18 shl 16 |
||
246 | mov bx , [Form] |
||
247 | sub bx , 36 |
||
248 | |||
249 | mov cx , dx |
||
250 | dec cx |
||
251 | shl ecx, 16 |
||
252 | add ecx, 9 |
||
253 | |||
254 | movzx edx, byte [V_Bus] |
||
255 | shl dx , 8 |
||
256 | mov dl , byte [V_Dev] |
||
257 | |||
258 | mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise |
||
259 | cmp word [selected], dx |
||
260 | jne @f |
||
261 | mov esi, 0x00c0c000 |
||
262 | @@: |
||
263 | |||
264 | shl edx, 8 |
||
265 | or dl , 0xff |
||
266 | |||
267 | mcall 8 |
||
268 | pop edx |
||
269 | |||
270 | xor esi, esi ; Color of text |
||
271 | movzx ecx, word [PCI_Vendor] ; number to be written |
||
272 | mcall 47, 0x00040100 ; Write Vendor ID |
||
273 | |||
274 | add edx, (4*6+18) shl 16 |
||
275 | movzx ecx, word [PCI_Device] ; get Vendor ID |
||
276 | mcall ; Draw Vendor ID to Window |
||
277 | |||
278 | add edx, (4*6+18) shl 16 |
||
279 | movzx ecx, byte [V_Bus] ; get bus number |
||
280 | mcall ,0x00020100 ; draw bus number to screen |
||
281 | |||
282 | add edx, (2*6+18) shl 16 |
||
283 | movzx ecx, byte [V_Dev] ; get device number |
||
284 | shr ecx, 3 ; device number is bits 3-7 |
||
285 | mcall ; Draw device Number To Window |
||
286 | |||
287 | add edx, (2*6+18) shl 16 |
||
288 | movzx ecx, byte [PCI_Rev] ; get revision number |
||
289 | mcall ; Draw Revision to screen |
||
290 | |||
291 | add edx, (2*6+18) shl 16 |
||
292 | movzx ecx, [PCI_IRQ] |
||
293 | cmp cl , 0x0f ; IRQ must be between 0 and 15 |
||
294 | ja @f |
||
295 | mcall |
||
296 | @@: |
||
297 | ; |
||
298 | ;Write Names |
||
299 | movzx ebx, dx ; Set y position |
||
300 | or ebx, 230 shl 16 ; set Xposition |
||
301 | |||
302 | ;------------------------------------------------------------------ |
||
303 | ; Prints the Vendor's Name based on Vendor ID |
||
304 | ;------------------------------------------------------------------ |
||
305 | mov edx, VendorsTab |
||
306 | mov cx , word[PCI_Vendor] |
||
307 | |||
308 | .fn: mov ax , [edx] |
||
309 | add edx, 6 |
||
310 | test ax , ax |
||
311 | jz .find |
||
312 | cmp ax , cx |
||
313 | jne .fn |
||
314 | .find: mov edx, [edx - 4] |
||
315 | mcall 4,, 0x80000000 ; lets print the vendor Name |
||
316 | |||
317 | ;------------------------------------------------------------------ |
||
318 | ; Get description based on Class/Subclass |
||
319 | ;------------------------------------------------------------------ |
||
320 | mov eax, dword [PCI_Class] |
||
321 | and eax, 0xffffff |
||
322 | xor edx, edx |
||
323 | xor esi, esi |
||
324 | .fnc: inc esi |
||
325 | mov ecx, [Classes + esi * 8 - 8] |
||
326 | cmp cx , 0xffff |
||
327 | je .endfc |
||
328 | cmp cx , ax |
||
329 | jne .fnc |
||
330 | test ecx, 0xff000000 |
||
331 | jz @f |
||
332 | mov edx, [Classes + esi * 8 - 4] |
||
333 | jmp .fnc |
||
334 | @@: cmp eax, ecx |
||
335 | jne .fnc |
||
336 | xor edx, edx |
||
337 | .endfc: test edx, edx |
||
338 | jnz @f |
||
339 | mov edx, [Classes + esi * 8 - 4] |
||
340 | @@: |
||
341 | add ebx, 288 shl 16 |
||
342 | mcall 4,, 0x80000000,, 32 ; draw the text |
||
343 | movzx edx, bx ; get y coordinate |
||
344 | add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20 |
||
345 | |||
346 | ;------------------------------------------------------------------ |
||
347 | ; Print Driver Name |
||
348 | ;------------------------------------------------------------------ |
||
349 | push edx |
||
350 | add ebx, 120 shl 16 |
||
351 | push ebx |
||
352 | |||
353 | call get_drv_ptr |
||
354 | mov edx, eax |
||
355 | pop ebx |
||
356 | mcall 4,,0x80000000 ; lets print the vendor Name |
||
357 | pop edx |
||
358 | ret |
||
359 | |||
360 | get_drv_ptr: |
||
361 | mov eax, driverlist ; eax will be the pointer to latest driver title |
||
362 | mov ebx, driverlist ; ebx is the current pointer |
||
363 | mov ecx, dword[PCI_Vendor] ; the device/vendor id of we want to find |
||
364 | |||
365 | driverloop: |
||
366 | inc ebx |
||
367 | |||
368 | cmp byte[ebx],0 |
||
369 | jne driverloop |
||
370 | |||
371 | inc ebx ; the device/vendor id list for the driver eax is pointing to starts here. |
||
372 | |||
373 | deviceloop: |
||
374 | cmp dword[ebx],0 |
||
375 | je nextdriver |
||
376 | |||
377 | cmp dword[ebx],ecx |
||
378 | je driverfound |
||
379 | |||
380 | add ebx,4 |
||
381 | jmp deviceloop |
||
382 | |||
383 | nextdriver: |
||
384 | add ebx,4 |
||
385 | |||
386 | cmp dword[ebx],0 |
||
387 | je nodriver |
||
388 | |||
389 | mov eax,ebx |
||
390 | jmp driverloop |
||
391 | |||
392 | nodriver: |
||
393 | mov eax, lbl_none ; lets print the vendor Name |
||
394 | ret |
||
395 | |||
396 | driverfound: |
||
397 | ret |
||
398 | |||
399 | include 'VENDORS.INC' |
||
400 | include 'DRIVERS.INC' |
||
401 | ;------------------------------------------------------------------ |
||
402 | ; DATA AREA |
||
403 | DATA |
||
404 | |||
405 | |||
406 | Form: dw 800 ; window width (no more, special for 800x600) |
||
407 | dw 100 ; window x start |
||
408 | dw 220 ; window height |
||
409 | dw 100 ; window y start |
||
410 | |||
411 | title db 'Network Driver Control Center', 0 |
||
412 | |||
413 | caption db 'Vendor Device Bus Dev Rev IRQ Company Description DRIVER',0 |
||
414 | lbl_1 db 'Hardware control',0 |
||
415 | nonefound db 'No compatible devices were found!',0 |
||
416 | btn_start db 'Start driver',0 |
||
417 | btn_stop db 'Stop driver',0 |
||
418 | lbl_hdw_addr db 'hardware address:',0 |
||
419 | lbl_type db 'type:',0 |
||
420 | lbl_none db 'none',0 |
||
421 | lbl_unknown db 'unknown',0 |
||
422 | lbl_ethernet db 'ethernet',0 |
||
423 | |||
424 | |||
425 | IOCTL: |
||
426 | .handle dd ? |
||
427 | .io_code dd ? |
||
428 | .input dd ? |
||
429 | .inp_size dd ? |
||
430 | .output dd ? |
||
431 | .out_size dd ? |
||
432 | |||
433 | drivernumber db ? |
||
434 | MAC dp ? |
||
435 | |||
436 | hardwareinfo: |
||
437 | .type db 1 ; pci |
||
438 | .pci_bus db ? |
||
439 | .pci_dev db ? |
||
440 | |||
441 | |||
442 | ;------------------------------------------------------------------ |
||
443 | ; UNINITIALIZED DATA AREA |
||
444 | UDATA |
||
445 | |||
446 | type db ? |
||
447 | selected dw ? |
||
448 | V_Bus db ? |
||
449 | V_Dev db ? |
||
450 | PCI_Version dw ? |
||
451 | PCI_LastBus db ? |
||
452 | PCI_Vendor dw ? |
||
453 | PCI_Device dw ? |
||
454 | PCI_Bus db ? |
||
455 | PCI_Dev db ? |
||
456 | PCI_Rev db ? |
||
457 | ; don`t change order!!! |
||
458 | PCI_Class db ? |
||
459 | PCI_SubClass db ? |
||
460 | PCI_Interface db ? |
||
461 | PCI_IRQ db ? |
||
462 | |||
463 | Proc_Info process_information |
||
464 | |||
465 | |||
466 | MEOS_APP_END |