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