Subversion Repositories Kolibri OS

Rev

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