Subversion Repositories Kolibri OS

Rev

Rev 3871 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1356 diamond 1
;***************************************************************
132 diamond 2
; project name:    PCI Device Enumeration
475 Ghost 3
; target platform: KolibriOS
1351 art_zh 4
; compiler:        flat assembler 1.68
1982 mario79 5
; version:         2.3
1993 mario79 6
; last update:     Jule 2011
1983 yogev_ezra 7
; maintained by:   Jason Delozier 
8
;                  Sergey Kuzmin 
9
;                  Mihailov Ilia 
1982 mario79 10
;                  Marat Zakiyanov 
1983 yogev_ezra 11
;                  Artem Jerdev  
12
;                  Evgeny Grechnikov (diamond)
13
;                  Veronica (CleverMouse)
1982 mario79 14
; old project site:  http://www.coolthemes.narod.ru/pcidev.html
15
; new project site:  http://board.kolibrios.org/viewtopic.php?f=42&t=73
132 diamond 16
;***************************************************************
17
;Summary: This program will attempt to scan the PCI Bus
18
;        and display basic information about each device
19
;        connected to the PCI Bus.
20
;***************************************************************
1982 mario79 21
	use32
22
	org 0x0
23
	db 'MENUET01'	; 8 byte id
24
	dd 0x01		; header version
25
	dd START	; start of code
26
	dd IM_END	; size of image
27
	dd I_END	; memory for app
28
	dd stacktop	; esp
29
	dd 0	; I_Param
1983 yogev_ezra 30
	dd path		; APPLICATION PATH
1982 mario79 31
;-----------------------------------------------------------------------------
3871 mario79 32
include 'lang.inc'	;language support
33
include '../../../macros.inc'
34
include	'../../../develop/libraries/box_lib/load_lib.mac'
35
;-----------------------------------------------------------------------------
1982 mario79 36
@use_library	; load_lib macro
37
;-----------------------------------------------------------------------------
38
START:
39
	mcall	68,11
40
	mcall	66,1,1
41
;-----------------------------------------------------------------------------
42
load_libraries l_libs_start,end_l_libs
43
;-----------------------------------------------------------------------------
44
;OpenDialog	initialisation
45
	push    dword OpenDialog_data
46
	call    [OpenDialog_Init]
3630 fedesco 47
 
1982 mario79 48
	mov	edi,filename_area
49
	mov	esi,start_temp_file_name
50
	call	copy_file_name_path
51
;-----------------------------------------------------------------------------
1984 mario79 52
	mcall	68,12,4096*4 ; 16 Kb - I hope this will be enough for store of data
1982 mario79 53
	mov	[store_text_area_start],eax
3630 fedesco 54
;-----------------------------------------------------------------------------
475 Ghost 55
	call draw_window
1982 mario79 56
still:
57
	mcall	10			; wait here for event
475 Ghost 58
	dec	eax			; redraw request ?
59
	jz	red
60
	dec	eax			; key in buffer ?
61
	jz	key
62
	dec	eax			; button in buffer ?
63
	jz	button
64
	jmp	still
1982 mario79 65
;-----------------------------------------------------------------------------
475 Ghost 66
red:					; redraw
2057 mario79 67
	call	get_window_param
485 heavyiron 68
	mov	eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure
475 Ghost 69
	mov	[Form + 2], ax		; x start position
485 heavyiron 70
	mov	eax, [Proc_Info.box.top];
475 Ghost 71
	mov	[Form + 6], ax		; ystart position
485 heavyiron 72
	mov	eax, [Proc_Info.box.width]	;
475 Ghost 73
	mov	[Form], ax		; window width
485 heavyiron 74
	mov	eax, [Proc_Info.box.height]	;
475 Ghost 75
	mov	[Form + 4] ,ax		; window height
76
	call	draw_window		; go redraw window now
77
	jmp	still
1982 mario79 78
;-----------------------------------------------------------------------------
475 Ghost 79
key:					; key
80
	mcall	2			; just read it and ignore
1982 mario79 81
	cmp	[extended_key],1
82
	je	.extended_key
83
	test	al, al
84
	jnz	still
85
	cmp	ah, 0xE0
86
	jne	@f
87
	mov	[extended_key],1
475 Ghost 88
	jmp	still
1982 mario79 89
@@:
90
	cmp	ah,129	; Esc
91
	je	button.exit
92
	cmp	ah,159
93
	je	call_OpenDialog
94
	jmp	still
95
.extended_key:
96
	mov	[extended_key],0
97
	cmp	ah,129	; Esc
98
	je	button.exit
99
	cmp	ah,159
100
	je	call_OpenDialog
101
	jmp	still
102
;-----------------------------------------------------------------------------
1351 art_zh 103
button: 				; button
475 Ghost 104
	mcall	17			; get id
1982 mario79 105
	cmp	ah,2
106
	je	call_OpenDialog
475 Ghost 107
	cmp	ah, 1			; button id = 1 ?
108
	jne	still
1982 mario79 109
.exit:
475 Ghost 110
	mcall	-1			; close this program
1982 mario79 111
;-----------------------------------------------------------------------------
112
call_OpenDialog:
113
	mov	[OpenDialog_data.type],1	; Save
3630 fedesco 114
 
1982 mario79 115
	push    dword OpenDialog_data
116
	call    [OpenDialog_Start]
132 diamond 117
 
1982 mario79 118
	cmp	[OpenDialog_data.status],2	; OpenDialog does not start
119
	je	.save_file_default_path
3630 fedesco 120
 
1982 mario79 121
	cmp	[OpenDialog_data.status],1
122
	jne	still
3630 fedesco 123
 
1982 mario79 124
	call	store_data
125
	jmp	still
3630 fedesco 126
;----------------------------------------
1982 mario79 127
.save_file_default_path:
128
	mov	edi,file_name
129
	mov	esi,file_default_path
130
	call	copy_file_name_path
131
	call	store_data
132
	jmp	still
3630 fedesco 133
;----------------------------------------
1982 mario79 134
copy_file_name_path:
135
	xor	eax,eax
136
	cld
137
@@:
138
	lodsb
139
	stosb
140
	test	eax,eax
141
	jnz	@r
142
	ret
143
;-----------------------------------------------------------------------------
144
prepare_text_area:
145
	mov	edi,[store_text_area_start]
146
 
147
	push	edi
1984 mario79 148
	mov	ecx,4096 ; 16 Kb - I hope this will be enough for store of data
1982 mario79 149
	mov	eax,dword '    '
150
	cld
151
	rep	stosd
152
	pop	edi
3630 fedesco 153
 
1982 mario79 154
	mov	esi,PCIWin
155
	xor	ecx,ecx
156
@@:
157
	mov	cl,[esi]
158
	inc	esi
159
	rep	movsb
160
	mov	al,0Ah ; CR - carriage return
161
	stosb
162
	cmp	[esi],byte 0xFF
3630 fedesco 163
	jne	@r
1982 mario79 164
 
165
	mov	[store_text_area_end],edi
3630 fedesco 166
 
1982 mario79 167
	xor	edi,edi
168
	ret
3630 fedesco 169
;-----------------------------------------------------------------------------
2057 mario79 170
get_window_param:
3630 fedesco 171
	mcall	9, Proc_Info, -1	; window redraw requested so get
2057 mario79 172
					; new window coordinates and size
173
	ret
3630 fedesco 174
;-----------------------------------------------------------------------------
132 diamond 175
draw_window:
1982 mario79 176
	call	prepare_text_area
3630 fedesco 177
 
475 Ghost 178
	mov	byte [total], 0
179
	mcall	12, 1			; start of draw
180
	; DRAW WINDOW
1982 mario79 181
	mcall	0,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title
3630 fedesco 182
 
2057 mario79 183
	call	get_window_param
3630 fedesco 184
 
2057 mario79 185
	mov	eax,[Proc_Info+70] ;status of window
186
	test	eax,100b
187
	jne	.end
3630 fedesco 188
 
1982 mario79 189
	mcall	8,<450,100>,<25,25>,2,0xC0C0C0
190
	shr	ecx,16
191
	mov	bx,cx
192
	add	ebx,13 shl 16+4
193
	mcall	4,,0x80000000,text_save_button
194
	add	bx,11
195
	mcall	,,,text_save_button.1
475 Ghost 196
	; Insert horizontal bars  in list area
1351 art_zh 197
	mov	eax, 13 		; draw bar system function
198
	mov	ebx, 18 		; set Xstart position of bar
199
	shl	ebx, 16 		;
200
	mov	bx, word [Form] ; get width of window
475 Ghost 201
	sub	bx, 32			; bar is 32 pixels shorter then window width
202
	mov	ecx, 119 * 65536 + 10	; set Ystart(109) and Height(10) of bar   109
203
	mov	edx, 0xC0C0C0		; set color of bar
2057 mario79 204
.again:	;begin draw bar loop
475 Ghost 205
	mcall				; draw bar to window area
1351 art_zh 206
	shr	ecx, 16 		; move the Ystart position to working area
207
	add	ecx, 34 		; add 34 pixels to Y Start (moves bar down)
475 Ghost 208
	cmp	cx, word [Form + 4]	; is the Ystart position outside of window area
2057 mario79 209
	jae	.nomo			; if so stop drawing bars
1351 art_zh 210
	sub	ecx, 14 		; if not, we only need 20 pixels between bar tops
211
	shl	ecx, 16 		; set that values as Ystart
212
	add	ecx, 10 		; Bar Height is always 10 pixels
2057 mario79 213
	jmp	.again			; draw another bar
1982 mario79 214
;-----------------------------------------------------------------------------
2057 mario79 215
.nomo:					;done drawing bars here
475 Ghost 216
	; start PCI stuff
217
	call	Get_PCI_Info		; get pci version and last bus, scan for and draw each pci device
132 diamond 218
 
475 Ghost 219
	; Window inteface
220
	mov	cx, [PCI_Version]
221
	add	ch, '0'
1351 art_zh 222
	mov	[PCIWin + 85], ch	; 0xBADCODE but it works !
475 Ghost 223
	mov	ch, cl
224
	shr	cl, 4
225
	and	ch, 0x0f
226
	add	cx, '00'
227
	mov	[PCIWin + 87], cx
1351 art_zh 228
	mov	cl, [PCI_LastBus]	; will only work if [PCI_LastBus] < 10
475 Ghost 229
	add	cl, '0'
1351 art_zh 230
	mov	[PCIWin + 106], cl
231
 
475 Ghost 232
	mov	edx, PCIWin
233
	mov	ebx, 20 * 65536 + 25	; x start, ystart of text
234
	mov	ecx, 0x224466		; color of text
235
	mov	eax, 4
1982 mario79 236
@@:
237
	movzx	esi, byte[edx]
475 Ghost 238
	inc	edx
239
	mcall
240
	add	ebx, 10
241
	add	edx, esi
242
	cmp	byte[edx], -1
243
	jne	@b
244
	; Quantity of devices...
245
	movzx	ecx, byte [total]	; number to draw
246
	mcall	47, 0x00020000,,150 * 65536 + 65, 0x224466
3630 fedesco 247
 
1995 mario79 248
	mov	ebx,ecx
249
	mov	ecx,2
250
	mov	edi,[store_text_area_start]
251
	add	edi,157
252
	push	edi
253
	call	binary_to_hex_string
254
	pop	edi
255
	mov	[edi+2],byte 'h'
3630 fedesco 256
 
1386 art_zh 257
	mov	ah, [MMIO_allowed]
258
	or 	ah, ah
259
	jz 	@f
260
	mov	ah, [MMIO_Bus]	; =255 if MMIO disabled / not found
261
	and	ah, 0x7f
262
	inc	ah
3630 fedesco 263
	jo	@f
1351 art_zh 264
	call	Try_MMIO
1386 art_zh 265
@@:
2057 mario79 266
.end:
475 Ghost 267
	mcall	12, 2			; end of draw
268
	ret
1982 mario79 269
;-----------------------------------------------------------------------------
270
store_data:
271
	mov	eax,[store_text_area_start]
272
	mov	[fileinfo.return],eax
273
	mov	ebx,[store_text_area_end]
274
	sub	ebx,eax
275
	inc	ebx
276
	mov	[fileinfo.size],ebx
277
	mcall	70,fileinfo
278
	ret
279
;-----------------------------------------------------------------------------
205 heavyiron 280
;* Gets the PCI Version and Last Bus
132 diamond 281
Get_PCI_Info:
475 Ghost 282
	mcall	62, 0
283
	mov	word [PCI_Version], ax
284
	mcall	62, 1
285
	mov	byte [PCI_LastBus], al
286
	;----------------------------------------------------------
287
	;* Get all devices on PCI Bus
288
	cmp	al, 0xff		; 0xFF means no pci bus found
289
	jne	Pci_Exists		;
290
	ret				; if no bus then leave
3630 fedesco 291
;-----------------------------------------------------------------------------
132 diamond 292
Pci_Exists:
1351 art_zh 293
	mov	byte [V_Bus], 0 	; reset varibles
294
	mov	byte [V_Dev], 0 	;
475 Ghost 295
	mov	edx,  20 * 65536 + 110	; set start write position
132 diamond 296
Start_Enum:
475 Ghost 297
	mov	bl, 6			; get a dword
298
	mov	bh, byte [V_Bus]	; bus of pci device
299
	mov	ch, byte [V_Dev]	; device number/function
300
	mov	cl, 0			; offset to device/vendor id
301
	mcall	62			; get ID's
132 diamond 302
 
475 Ghost 303
	cmp	ax, 0			; Vendor ID should not be 0 or 0xFFFF
1351 art_zh 304
	je	nextDev 		; check next device if nothing exists here
3630 fedesco 305
 
475 Ghost 306
	cmp	ax, 0xffff		;
1351 art_zh 307
	je	nextDev 		;
132 diamond 308
 
475 Ghost 309
	mov	word [PCI_Vendor], ax	; There is a device here, save the ID's
1351 art_zh 310
	shr	eax, 16 		;
475 Ghost 311
	mov	word [PCI_Device], ax	;
312
	mov	bl, 4			; Read config byte
313
	mov	bh, byte [V_Bus]	; Bus #
314
	mov	ch, byte [V_Dev]	; Device # on bus
315
	mov	cl, 0x08		; Register to read (Get Revision)
316
	mcall	62			; Read it
3630 fedesco 317
 
475 Ghost 318
	mov	byte [PCI_Rev], al	; Save it
319
	mov	cl, 0x0b		; Register to read (Get class)
320
	mcall	62			; Read it
1351 art_zh 321
 
475 Ghost 322
	mov	byte [PCI_Class], al	; Save it
323
	mov	cl, 0x0a		; Register to read (Get Subclass)
324
	mcall	62			; Read it
325
	mov	byte [PCI_SubClass], al; Save it
1351 art_zh 326
; by Mario79 august 2006
475 Ghost 327
	mov	cl, 0x09		; Register to read (Get Interface)
328
	mcall	62			; Read it
3630 fedesco 329
 
475 Ghost 330
	mov  [PCI_Interface], al	; Save it
205 heavyiron 331
;
1351 art_zh 332
; by Ghost april 2007
475 Ghost 333
	mov	cl, 0x3c		; Register to read (Get IRQ)
1982 mario79 334
@@:
335
	mcall	62			; Read it
3630 fedesco 336
 
475 Ghost 337
	mov	[PCI_IRQ], al		; Save it
1946 clevermous 338
; by CleverMouse juny 2011
339
	mov	cl, 0x0e
340
	mcall	62
3630 fedesco 341
 
1946 clevermous 342
	push	eax
475 Ghost 343
	inc	byte [total]		; one more device found
344
	call	Print_New_Device	; print device info to screen
1946 clevermous 345
; don't scan for nonzero functions if zero function says "not multifunction device"
346
	pop	eax
347
	test	al, al
348
	js	nextDev
3630 fedesco 349
 
1946 clevermous 350
	test	byte [V_Dev], 7
1947 clevermous 351
	jnz	nextDev
3630 fedesco 352
 
1946 clevermous 353
	or	byte [V_Dev], 7
132 diamond 354
nextDev:
475 Ghost 355
	inc	byte [V_Dev]		; next device on this bus
356
	jnz	Start_Enum		; jump until we reach zero
357
	;(used to be JNO which caused bug!!! 30-4-2006, JMD)
1351 art_zh 358
	mov	byte [V_Dev], 0 	; reset device number
475 Ghost 359
	inc	byte [V_Bus]		; next bus
360
	mov	al, byte [PCI_LastBus]	; get last bus
361
	cmp	byte [V_Bus], al	; was it last bus
362
	jbe	Start_Enum		; if not jump to keep searching
363
	ret
1982 mario79 364
;-----------------------------------------------------------------------------
1386 art_zh 365
no_ummio_allowed:
366
	xor 	al,al
367
	mov 	[MMIO_allowed],al		; re-enter the subroutine
475 Ghost 368
;------------------------------------------------------------------
132 diamond 369
;* Print device info to screen
1386 art_zh 370
 
132 diamond 371
Print_New_Device:
1386 art_zh 372
	xor 	esi, esi	    	; default text color
373
	mov 	cl, [MMIO_allowed]
374
	or	cl,cl
375
	jz	no_ummio_here
376
	mov 	ch, byte [V_Bus]
377
	mov 	cl, byte [V_Dev]
1351 art_zh 378
	mcall	62, 11		; detect uMMIO
3630 fedesco 379
 
1386 art_zh 380
	and	ax,0x7fff
381
	inc 	ax			; -1 returned?
382
	jo 	no_ummio_allowed
3630 fedesco 383
 
1386 art_zh 384
	inc 	ax			; -2 returned?
385
	jo 	no_ummio_here
3630 fedesco 386
 
1386 art_zh 387
	inc 	ax			; -3 returned?
388
	jo 	no_ummio_here
3630 fedesco 389
 
1386 art_zh 390
	mov 	esi, 0x990033   ; highlighted text color
391
	mov 	bh, byte [V_Bus]
392
	mov 	bl, byte [V_Dev]
393
	mov 	byte [MMIO_Bus], bh
394
	mov 	byte [MMIO_Dev], bl
395
	add 	bh,'0'
396
	mov 	[PCIWin + 129], bh	; uMMIO bus
397
	mov 	al, bl
398
	shr 	al, 1
399
	shr 	al, 1
400
	shr 	al, 1
401
	add 	al,'0'
402
	mov 	[PCIWin + 131], al	; uMMIO device
403
	and 	bl, 7
404
	add 	bl, '0'
405
	mov 	[PCIWin + 133], bl	; uMMIO function
1351 art_zh 406
 
407
no_ummio_here:
475 Ghost 408
	movzx	ecx,word [PCI_Vendor]	; Pointer to number to be written
409
	mcall	47, 0x00040100		; Write Vendor ID
3630 fedesco 410
 
1982 mario79 411
	call	store_4_digits
3630 fedesco 412
 
475 Ghost 413
	and	edx, 0xFFFF		;*****************************************
1351 art_zh 414
	or	edx, 54 * 65536 ; X start becomes 54
475 Ghost 415
	movzx	ecx, word [PCI_Device]	; get Vendor ID
416
	mcall				; Draw Vendor ID to Window
1982 mario79 417
 
418
	call	store_4_digits
3630 fedesco 419
 
475 Ghost 420
	and	edx, 0xFFFF		;*****************************************
1351 art_zh 421
	or	edx, 98 * 65536 ; X start becomes 98
475 Ghost 422
	movzx	ecx, byte [V_Bus]	; get bus number
423
	mcall	,0x00020100		; draw bus number to screen
1982 mario79 424
 
425
	call	store_2_digits
3630 fedesco 426
 
475 Ghost 427
	and	edx, 0xFFFF		;*****************************************
428
	or	edx, 128 * 65536	; X start becomes 128
429
	movzx	ecx, byte [V_Dev]	; get device number
430
	shr	ecx, 3			; device number is bits 3-7
431
	mcall				; Draw device Number To Window
1351 art_zh 432
 
1982 mario79 433
	call	store_2_digits
3630 fedesco 434
 
475 Ghost 435
	and	edx, 0xFFFF		;*****************************************
436
	or	edx, 155 * 65536	; X start becomes 155
437
	movzx	ecx, byte [V_Dev]	; get Function number
438
	and	ecx, 7			; function is first 3 bits
439
	mcall				; Draw Function Number To Window
3630 fedesco 440
 
1982 mario79 441
	call	store_2_digits
3630 fedesco 442
 
475 Ghost 443
	and	edx, 0xFFFF		;*****************************************
444
	or	edx, 179 * 65536	; X start becomes 179
445
	movzx	ecx, byte [PCI_Rev]	; get revision number
446
	mcall				; Draw Revision to screen
3630 fedesco 447
 
1982 mario79 448
	call	store_2_digits
3630 fedesco 449
 
475 Ghost 450
	and	edx, 0xFFFF		;*****************************************
451
	or	edx, 215*65536		; X start becomes 215
452
	movzx	ecx, byte [PCI_Class]	; get PCI_Class
453
	mcall				; Draw Class to screen
3630 fedesco 454
 
1982 mario79 455
	call	store_2_digits
3630 fedesco 456
 
475 Ghost 457
	and	edx, 0xFFFF		;*****************************************
458
	or	edx, 250*65536		; X start becomes 250
459
	movzx	ecx, byte [PCI_SubClass]; get sub class
460
	mcall				; Draw Sub Class to screen
3630 fedesco 461
 
1982 mario79 462
	call	store_2_digits
3630 fedesco 463
 
205 heavyiron 464
; from Mario79 august 2006
475 Ghost 465
	and	edx, 0xFFFF		;*****************************************
466
	or	edx, 280 * 65536	; X start becomes 280
467
	movzx	ecx, [PCI_Interface]	; get Interface
468
	mcall
3630 fedesco 469
 
1982 mario79 470
	call	store_2_digits
3630 fedesco 471
 
205 heavyiron 472
;
1351 art_zh 473
; from Ghost april 2007                 ;*****************************************
1993 mario79 474
	and	edx, 0xFFFF
475
	or	edx, 310 * 65536	; X start becomes 310
475 Ghost 476
	movzx	ecx, [PCI_IRQ]		; get Interface
7732 dunkaist 477
	cmp	cl, 63   		; IRQ between 0..63
475 Ghost 478
	ja	@f
1993 mario79 479
 
475 Ghost 480
	mcall
1993 mario79 481
 
1982 mario79 482
	call	store_2_digits
1993 mario79 483
	jmp	.PCI_Vendor
3630 fedesco 484
@@:
1993 mario79 485
	call	store_NA
486
.PCI_Vendor:
475 Ghost 487
	;Write Names
1351 art_zh 488
	movzx	ebx, dx 	; Set y position
475 Ghost 489
	or	ebx, 340 * 65536	; set Xposition to 340
132 diamond 490
 
475 Ghost 491
;------------------------------------------------------------------
492
; Prints the Vendor's Name based on Vendor ID
132 diamond 493
;
475 Ghost 494
; Modified on ??-04-2007 by Ghost for size
495
;------------------------------------------------------------------
496
	mov	edx, VendorsTab
497
	mov	cx, word[PCI_Vendor]
1351 art_zh 498
 
1982 mario79 499
.fn:
500
	mov	ax, [edx]
475 Ghost 501
	add	edx, 6
502
	test	ax, ax
503
	jz	.find
3630 fedesco 504
 
475 Ghost 505
	cmp	ax, cx
506
	jne	.fn
3630 fedesco 507
 
1982 mario79 508
.find:
509
	mov	edx, [edx - 4]
475 Ghost 510
	mcall	4,, 0x80000000		; lets print the vendor Name
3630 fedesco 511
 
1982 mario79 512
	mov	[store_text_size],42
513
	call	store_text
132 diamond 514
;------------------------------------------------------------------
475 Ghost 515
; Get description based on Class/Subclass
516
;
517
; Modified on ??-04-2007 by Ghost for size
518
;------------------------------------------------------------------
519
	mov	eax, dword [PCI_Class]
520
	and	eax, 0xffffff
521
	xor	edx, edx
522
	xor	esi, esi
1982 mario79 523
.fnc:
524
	inc	esi
475 Ghost 525
	mov	ecx, [Classes + esi * 8 - 8]
526
	cmp	cx, 0xffff
527
	je	.endfc
3630 fedesco 528
 
475 Ghost 529
	cmp	cx, ax
530
	jne	.fnc
3630 fedesco 531
 
475 Ghost 532
	test	ecx, 0xff000000
533
	jz	@f
3630 fedesco 534
 
475 Ghost 535
	mov	edx, [Classes + esi * 8 - 4]
536
	jmp	.fnc
1982 mario79 537
@@:
538
	cmp	eax, ecx
475 Ghost 539
	jne	.fnc
3630 fedesco 540
 
475 Ghost 541
	xor	edx, edx
1982 mario79 542
.endfc:
543
	test	edx, edx
475 Ghost 544
	jnz	@f
3630 fedesco 545
 
475 Ghost 546
	mov	edx, [Classes + esi * 8 - 4]
1351 art_zh 547
@@:
548
	and	ebx, 0x0000FFFF 	; clear X position
475 Ghost 549
	or	ebx, 0x24E0000		; set X position to 590 pixels
550
	mcall	4,, 0x80000000,, 32	; draw the text
3630 fedesco 551
 
1982 mario79 552
	mov	[store_text_size],0
553
	call	store_text
554
	call	store_CR
3630 fedesco 555
 
1351 art_zh 556
	movzx	edx, bx 	; get y coordinate
557
	add	edx, 0x0014000A 	; add 10 to y coordinate and set x coordinate to 20
558
	mov	[gr_pos], edx
475 Ghost 559
	ret
1351 art_zh 560
;------------------------------------------------------------------
561
; Get the user-MMIO related info
562
;
563
; Added on ??-12-2009 by art_zh
564
;------------------------------------------------------------------
565
Try_MMIO:
566
	xor	ebx, ebx
567
	mov	edx, ebx
1358 art_zh 568
	mov	bh, [MMIO_BAR]
1351 art_zh 569
	or	bx, 12			; function 12
570
	mov	ecx, 4096		; =1 page to map
571
	mcall	62
3630 fedesco 572
 
1358 art_zh 573
	mov	[MMIO_Map], eax 	; store MMIO lin.addr.
1351 art_zh 574
	mov	ecx, 0x80990022 	; print color : red
575
	add	bh, '0'
576
	cmp	eax, -3
577
	jne	@f
3630 fedesco 578
 
1351 art_zh 579
	mov	[bar_um+3], bh
580
	mov	ebx, [gr_pos]
581
	mov	edx, bar_um
582
	mcall	4
3630 fedesco 583
 
1351 art_zh 584
	jmp	mmio_next_bar
585
@@:
586
	cmp	eax, -4
587
	jne	@f
588
	mov	[bar_io+3], bh
589
	mov	ebx, [gr_pos]
590
	mov	edx, bar_io
591
	mcall	4
3630 fedesco 592
 
1351 art_zh 593
	jmp	mmio_next_bar
594
@@:
1358 art_zh 595
	cmp	bh, '6' 	; expansion ROM ?
596
	je	@f
1351 art_zh 597
	mov	[bar_ram+3], bh
598
	mov	ebx, [gr_pos]
599
	mov	edx, bar_ram
600
	mcall	4
3630 fedesco 601
 
1358 art_zh 602
	jmp	mmio_dump
1982 mario79 603
;-----------------------------------------------------------------------------
1353 art_zh 604
@@:
605
	mov	ebx, [gr_pos]
606
	mov	edx, bar_rom
607
	mcall	4
205 heavyiron 608
 
1353 art_zh 609
mmio_dump:
1358 art_zh 610
	mov	edx, [MMIO_Map]
1351 art_zh 611
	mov	esi, 64
612
	mov	ecx, 0x099		; dump color : blue
613
	add	ebx, 10
614
	mov	[gr_pos], ebx
615
	mcall	4
3630 fedesco 616
 
1358 art_zh 617
	mov	ecx, [MMIO_Map] 	; release the tried page
1351 art_zh 618
	mcall	62,13
619
 
620
mmio_next_bar:
621
	mov	bh, [MMIO_BAR]
622
	inc	bh
1353 art_zh 623
	cmp	bh,7
1351 art_zh 624
	je	@f
3630 fedesco 625
 
1351 art_zh 626
	mov	[MMIO_BAR], bh
627
	add	[gr_pos], 10
628
	jmp	Try_MMIO
1982 mario79 629
;-----------------------------------------------------------------------------
1351 art_zh 630
@@:
631
	xor	bh,bh
632
	mov	[MMIO_BAR], bh
633
	ret
1982 mario79 634
;-----------------------------------------------------------------------------
635
store_CR:
636
	pusha
637
	mov	edi,[store_text_area_end]
638
	mov	[edi],word 0A20h ; CR (carriage return) + SPACE
639
	add	dword [store_text_area_end],2
640
	popa
3630 fedesco 641
	ret
1982 mario79 642
;-----------------------------------------------------------------------------
643
store_text:
644
	pusha
645
	inc	dword [store_text_area_end]
3630 fedesco 646
	mov	esi,edx
1982 mario79 647
	mov	edi,[store_text_area_end]
648
	push	edi
649
	xor	eax,eax
650
	cld
651
@@:
652
	lodsb
653
	test	eax,eax
654
	jz	@f
655
	stosb
656
	inc	dword [store_text_area_end]
657
	jmp	@r
658
@@:
659
	pop	esi
660
	mov	eax,[store_text_size]
661
	test	eax,eax
662
	jz	@f
663
	sub	edi,esi
664
	sub	eax,edi
665
	add	[store_text_area_end],eax
666
@@:
667
	popa
3630 fedesco 668
	ret
1982 mario79 669
;-----------------------------------------------------------------------------
1993 mario79 670
store_NA:
1982 mario79 671
	pusha
1993 mario79 672
	mov	ebx,edx
673
	mcall	4,,0x80000000,text_NA
1982 mario79 674
	mov	edi,[store_text_area_end]
1993 mario79 675
	mov	ax,[edx]
676
	mov	[edi+1],ax
1995 mario79 677
	add	[store_text_area_end],dword 5
678
	popa
679
	ret
1982 mario79 680
;-----------------------------------------------------------------------------
681
store_2_digits:
682
	pusha
683
	inc	[store_text_area_end]
684
	mov	ebx,ecx
685
	mov	ecx,2
686
	mov	edi,[store_text_area_end]
687
	call	binary_to_hex_string
688
	add	[store_text_area_end],dword 4
689
	popa
690
	ret
691
;-----------------------------------------------------------------------------
1993 mario79 692
store_4_digits:
693
	pusha
694
	mov	ebx,ecx
695
	mov	ecx,4
696
	mov	edi,[store_text_area_end]
697
	call	binary_to_hex_string
698
	add	[store_text_area_end],dword 6
699
	popa
700
	ret
701
;-----------------------------------------------------------------------------
1982 mario79 702
; ebx - value
703
; ecx - digits
704
; edi - output string
705
binary_to_hex_string:
706
	add	edi,ecx
707
	dec	edi
708
	std
709
.1:
710
	mov	al,bl
711
	and	al,0xf
712
	shr	ebx,4
713
	cmp	al,9
714
	jbe	@f
1351 art_zh 715
 
1982 mario79 716
	add	al,0x27
717
@@:
718
	add	al,0x30
719
	stosb
720
	dec	ecx
721
	jnz	.1
722
	cld
723
	ret
724
;-----------------------------------------------------------------------------
1728 clevermous 725
include 'vendors.inc'
1982 mario79 726
;-----------------------------------------------------------------------------
132 diamond 727
; DATA AREA
475 Ghost 728
DATA
132 diamond 729
 
475 Ghost 730
Form:	dw 800 ; window width (no more, special for 800x600)
731
	dw 100 ; window x start
1358 art_zh 732
	dw 620 ; window height
733
	dw 20 ; window y start
205 heavyiron 734
 
1985 mario79 735
title	db 'PCI Device Enumerator v 2.3', 0
205 heavyiron 736
 
3630 fedesco 737
if lang eq it
475 Ghost 738
PCIWin mls \
1351 art_zh 739
	'   Don`t forget to enable PCI Access to Applications in Setup Menu.',\
475 Ghost 740
	'',\
3630 fedesco 741
	'Versione PCI = x.xx; Ultimo Bus PCI = x',\
742
	'User MMIO channel = 0F.F:F ',\
743
	'Numbero di unità PCI =    ',\
744
	'',\
745
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Compania                    Descrizzione',\
746
	'                                      Interfaccia',\
747
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ --------------------------------'
748
 
749
bar_ram db 'BARx: MMIO block', 0
750
bar_io	db 'BARx: porte IO',0
751
bar_um	db 'BARx: unmapped',0
752
bar_rom db 'BAR6: Expansion ROM', 0
753
 
754
text_save_button:
755
	db 'Salva lista PCI',0
756
.1:	db '(Premere S)',0
757
else
758
PCIWin mls \
759
	'   Don`t forget to enable PCI Access to Applications in Setup Menu.',\
760
	'',\
1351 art_zh 761
	'PCI Version  = x.xx; Last PCI Bus = x',\
762
	'User MMIO channel = 0F.F:F ',\
1995 mario79 763
	'Number of PCI units =    ',\
475 Ghost 764
	'',\
765
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
766
	'                                      Interface',\
1982 mario79 767
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ --------------------------------'
205 heavyiron 768
 
1351 art_zh 769
bar_ram db 'BARx: MMIO block', 0
770
bar_io	db 'BARx: IO ports',0
771
bar_um	db 'BARx: unmapped',0
1358 art_zh 772
bar_rom db 'BAR6: Expansion ROM', 0
1351 art_zh 773
 
1982 mario79 774
text_save_button:
775
	db 'Save PCI list',0
776
.1:	db '(Press S key)',0
3630 fedesco 777
end if
1993 mario79 778
 
779
text_NA:
1995 mario79 780
	db '--',0
1982 mario79 781
;---------------------------------------------------------------------
782
system_dir_ProcLib	db '/sys/lib/proc_lib.obj',0
783
 
784
err_message_found_lib2	db 'proc_lib.obj - Not found!',0
785
 
786
err_message_import2	db 'proc_lib.obj - Wrong import!',0
787
 
788
head_f_i:
789
head_f_l	db 'error',0
790
;---------------------------------------------------------------------
791
l_libs_start:
792
 
793
library02  l_libs system_dir_ProcLib+9, path, library_path, system_dir_ProcLib, \
794
err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
795
 
796
end_l_libs:
797
;---------------------------------------------------------------------
798
align 4
799
ProcLib_import:
800
OpenDialog_Init		dd aOpenDialog_Init
801
OpenDialog_Start	dd aOpenDialog_Start
802
;OpenDialog__Version	dd aOpenDialog_Version
803
        dd      0
804
        dd      0
805
aOpenDialog_Init	db 'OpenDialog_init',0
806
aOpenDialog_Start	db 'OpenDialog_start',0
807
;aOpenDialog_Version	db 'Version_OpenDialog',0
808
;---------------------------------------------------------------------
809
align 4
810
OpenDialog_data:
811
.type			dd 0
812
.procinfo		dd Proc_Info	;+4
813
.com_area_name		dd communication_area_name	;+8
814
.com_area		dd 0	;+12
815
.opendir_pach		dd temp_dir_pach	;+16
816
.dir_default_pach	dd communication_area_default_pach	;+20
817
.start_path		dd open_dialog_path	;+24
818
.draw_window		dd draw_window	;+28
819
.status			dd 0	;+32
820
.openfile_pach 		dd file_name	;+36
821
.filename_area		dd filename_area	;+40
822
.filter_area		dd Filter
823
.x:
824
.x_size			dw 420 ;+48 ; Window X size
825
.x_start		dw 10 ;+50 ; Window X position
826
.y:
827
.y_size			dw 320 ;+52 ; Window y size
828
.y_start		dw 10 ;+54 ; Window Y position
829
 
830
communication_area_name:
831
	db 'FFFFFFFF_open_dialog',0
832
open_dialog_path:
833
	db '/sys/File Managers/opendial',0
834
communication_area_default_pach:
835
	db '/sys',0
836
Filter:
837
dd	Filter.end - Filter.1
838
.1:
839
db	'TXT',0
840
db	'LOG',0
841
.end:
842
dd	0
843
 
844
file_default_path:
845
	db '/sys/'
3630 fedesco 846
start_temp_file_name:
1982 mario79 847
	db 'pcidev.txt',0
848
;---------------------------------------------------------------------
849
align	4
850
fileinfo:
851
.subfunction	dd 2
852
.Offset		dd 0
853
.Offset_1	dd 0
854
.size		dd 4096
855
.return		dd 0
856
		db 0
857
.name:		dd file_name
858
;-----------------------------------------------------------------------------
859
 
475 Ghost 860
; UNINITIALIZED DATA AREA
1982 mario79 861
IM_END:
475 Ghost 862
total		db ?
863
V_Bus		db ?
864
V_Dev		db ?
865
PCI_Version	dw ?
866
PCI_LastBus	db ?
867
PCI_Device	dw ?
868
PCI_Vendor	dw ?
1351 art_zh 869
PCI_Bus 	db ?
870
PCI_Dev 	db ?
871
PCI_Rev 	db ?
475 Ghost 872
; don`t change order!!!
873
PCI_Class	db ?
874
PCI_SubClass	db ?
875
PCI_Interface	db ?
1351 art_zh 876
PCI_IRQ 	db ?
205 heavyiron 877
 
1351 art_zh 878
align 4
1386 art_zh 879
MMIO_Bus	db 255
880
MMIO_Dev	db 255
1351 art_zh 881
MMIO_BAR	db 0
1386 art_zh 882
MMIO_allowed	db 1
1351 art_zh 883
MMIO_Map	rd 8
884
 
885
gr_pos		dd ?
886
 
1982 mario79 887
store_text_area_start	dd ?
888
store_text_area_end	dd ?
889
store_text_size		dd ?
890
 
891
extended_key 	rb 1
892
;---------------------------------------------------------------------
893
library_path:
894
	rb 4096
895
;---------------------------------------------------------------------
896
path:
897
	rb 4096
898
;---------------------------------------------------------------------
899
temp_dir_pach:
900
	rb 4096
901
;---------------------------------------------------------------------
902
file_name:
903
	rb 4096
904
;---------------------------------------------------------------------
905
file_name_1:
906
	rb 4096
907
;---------------------------------------------------------------------
908
filename_area:
909
	rb 256
910
;---------------------------------------------------------------------
911
	rb 4096
912
stacktop:
913
;---------------------------------------------------------------------
475 Ghost 914
Proc_Info	process_information
1982 mario79 915
;---------------------------------------------------------------------
916
I_END:
917
;-----------------------------------------------------------------------------