Subversion Repositories Kolibri OS

Rev

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