Subversion Repositories Kolibri OS

Rev

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