Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 485 Rev 1351
Line 1... Line 1...
1
;***************************************************************
1
;***************************************************************
2
; project name:    PCI Device Enumeration
2
; project name:    PCI Device Enumeration
3
; target platform: KolibriOS
3
; target platform: KolibriOS
4
; compiler:        flat assmebler 1.66
4
; compiler:        flat assembler 1.68
5
; version:         2.1
5
; version:         2.2
6
; last update:     April 2007
6
; last update:     December 2007
7
; maintained by:   Jason Delozier (cordata51@hotmail.com)
7
; maintained by:   Jason Delozier (cordata51@hotmail.com)
8
;                  Sergey Kuzmin (kuzmin_serg@list.ru)
8
;                  Sergey Kuzmin (kuzmin_serg@list.ru)
9
;                  Mihailov Ilia (ghost.nsk@gmail.com)
9
;                  Mihailov Ilia (ghost.nsk@gmail.com)
-
 
10
;                  Artem Jerdev  (art_zh@yahoo.com)
10
; project site:    http://www.coolthemes.narod.ru/pcidev.html
11
; project site:    http://www.coolthemes.narod.ru/pcidev.html
11
;***************************************************************
12
;***************************************************************
12
;Summary: This program will attempt to scan the PCI Bus
13
;Summary: This program will attempt to scan the PCI Bus
13
;        and display basic information about each device
14
;        and display basic information about each device
14
;        connected to the PCI Bus.
15
;        connected to the PCI Bus.
Line 23... Line 24...
23
; Subsystem id and Subsystem vendor id detection
24
; Subsystem id and Subsystem vendor id detection
Line 24... Line 25...
24
 
25
 
25
; Full device detection (like "ATI Radeon 9200") will increase app
26
; Full device detection (like "ATI Radeon 9200") will increase app
26
; size a lot and probably it is function of particular drivers
27
; size a lot and probably it is function of particular drivers
-
 
28
;----------------------------------------------------------------
-
 
29
;2.2: PCIDEV   31/12/2009
-
 
30
;Author:    Artem Jerdev 
-
 
31
;Features:
-
 
32
;           fixed
-
 
33
;                 * English in some comments ;)
-
 
34
;           added
-
 
35
;                 * ! user-accessible PCI memory channels detection
-
 
36
;                 * ! ASCII-dump as PCI memory access demonstration
-
 
37
;           optimization
-
 
38
;                 * (yet needed)
27
;----------------------------------------------------------------
39
;----------------------------------------------------------------
28
;2.1: PCIDEV   ??/04/2007
40
;2.1: PCIDEV   ??/04/2007
29
;Author:    Mihailov Ilia aka Ghost 
41
;Author:    Mihailov Ilia aka Ghost 
30
;Features:
42
;Features:
31
;           fixed
43
;           fixed
32
;                 * Same little bugs
44
;                 * Some little bugs
33
;                 * Source code formating
45
;                 * Source code formating
34
;                 * PCI version normalized 0210 -> 2.10
46
;                 * PCI version normalized 0210 -> 2.10
35
;           added
47
;           added
36
;                 * + 13 vendor (total now 1000!)
48
;                 * + 13 vendor (total now 1000!)
Line 134... Line 146...
134
;                 * quantity of PCI buses,
146
;                 * quantity of PCI buses,
135
;                 * Vendor&Device ID for appropriate Device on Bus;
147
;                 * Vendor&Device ID for appropriate Device on Bus;
136
;                 * detect Revision, Class and Subclass of Device,
148
;                 * detect Revision, Class and Subclass of Device,
137
;                 * and make Description based on Class
149
;                 * and make Description based on Class
138
;-------------------------------------------------------------
150
;-------------------------------------------------------------
139
include	'..\..\..\macros.inc'
151
;include '..\..\macros.inc'
-
 
152
include 'macros.inc'
-
 
153
 
140
MEOS_APP_START
154
MEOS_APP_START
141
CODE
155
CODE
142
	call draw_window
156
	call draw_window
Line 143... Line 157...
143
 
157
 
Line 200... Line 214...
200
	call	Get_PCI_Info		; get pci version and last bus, scan for and draw each pci device
214
	call	Get_PCI_Info		; get pci version and last bus, scan for and draw each pci device
Line 201... Line 215...
201
 
215
 
202
	; Window inteface
216
	; Window inteface
203
	mov	cx, [PCI_Version]
217
	mov	cx, [PCI_Version]
204
	add	ch, '0'
218
	add	ch, '0'
205
	mov	[PCIWin + 85], ch	; 0xBADCODE but it work !
219
	mov	[PCIWin + 85], ch	; 0xBADCODE but it works !
206
	mov	ch, cl
220
	mov	ch, cl
207
	shr	cl, 4
221
	shr	cl, 4
208
	and	ch, 0x0f
222
	and	ch, 0x0f
209
	add	cx, '00'
223
	add	cx, '00'
210
	mov	[PCIWin + 87], cx
224
	mov	[PCIWin + 87], cx
211
	mov	cl, [PCI_LastBus]
225
	mov	cl, [PCI_LastBus]	; will only work if [PCI_LastBus] < 10
212
	add	cl, '0'
226
	add	cl, '0'
Line 213... Line 227...
213
	mov	[PCIWin + 105], cl
227
	mov	[PCIWin + 106], cl
214
	
228
 
215
	mov	edx, PCIWin
229
	mov	edx, PCIWin
216
	mov	ebx, 20 * 65536 + 25	; x start, ystart of text
230
	mov	ebx, 20 * 65536 + 25	; x start, ystart of text
Line 225... Line 239...
225
	jne	@b
239
	jne	@b
226
	; Quantity of devices...
240
	; Quantity of devices...
227
	movzx	ecx, byte [total]	; number to draw
241
	movzx	ecx, byte [total]	; number to draw
228
	mcall	47, 0x00020000,,150 * 65536 + 65, 0x224466
242
	mcall	47, 0x00020000,,150 * 65536 + 65, 0x224466
Line -... Line 243...
-
 
243
 
229
 
244
	call	Try_MMIO
230
	mcall	12, 2			; end of draw
245
	mcall	12, 2			; end of draw
Line 231... Line 246...
231
	ret
246
	ret
232
 
247
 
Line 272... Line 287...
272
	
287
 
273
	mov	byte [PCI_Class], al	; Save it
288
	mov	byte [PCI_Class], al	; Save it
274
	mov	cl, 0x0a		; Register to read (Get Subclass)
289
	mov	cl, 0x0a		; Register to read (Get Subclass)
275
	mcall	62			; Read it
290
	mcall	62			; Read it
276
	mov	byte [PCI_SubClass], al; Save it
291
	mov	byte [PCI_SubClass], al; Save it
277
; from Mario79 august 2006
292
; by Mario79 august 2006
278
	mov	cl, 0x09		; Register to read (Get Interface)
293
	mov	cl, 0x09		; Register to read (Get Interface)
279
	mcall	62			; Read it
294
	mcall	62			; Read it
280
	mov  [PCI_Interface], al	; Save it
295
	mov  [PCI_Interface], al	; Save it
281
;
296
;
282
; from Ghost april 2007
297
; by Ghost april 2007
283
	mov	cl, 0x3c		; Register to read (Get IRQ)
298
	mov	cl, 0x3c		; Register to read (Get IRQ)
284
@@:	mcall	62			; Read it
299
@@:	mcall	62			; Read it
285
	mov	[PCI_IRQ], al		; Save it
300
	mov	[PCI_IRQ], al		; Save it
286
;
301
;
Line 298... Line 313...
298
	ret
313
	ret
Line 299... Line 314...
299
 
314
 
300
;------------------------------------------------------------------
315
;------------------------------------------------------------------
301
;* Print device info to screen
316
;* Print device info to screen
302
Print_New_Device:
317
Print_New_Device:
-
 
318
	xor esi, esi	    ; default text color
-
 
319
; by art_zh December 2009
-
 
320
	mov ch, byte [V_Bus]
-
 
321
	mov cl, byte [V_Dev]
-
 
322
	mcall	62, 11		; detect uMMIO
-
 
323
	cmp eax, -2
-
 
324
	je no_ummio_here
-
 
325
	mov esi, 0x990033   ; highlighted text color
-
 
326
	mov bh, byte [V_Bus]
-
 
327
	mov bl, byte [V_Dev]
-
 
328
	mov byte [MMIO_Bus], bh
-
 
329
	mov byte [MMIO_Dev], bl
-
 
330
	add bh,'0'
-
 
331
	mov [PCIWin + 129], bh	; uMMIO bus
-
 
332
	mov al, bl
-
 
333
	shr al, 1
-
 
334
	shr al, 1
-
 
335
	shr al, 1
-
 
336
	add al,'0'
-
 
337
	mov [PCIWin + 131], al	; uMMIO device
-
 
338
	and bl, 7
-
 
339
	add bl, '0'
-
 
340
	mov [PCIWin + 133], bl	; uMMIO function
-
 
341
 
303
	xor	esi, esi		; Color of text
342
no_ummio_here:
304
	movzx	ecx,word [PCI_Vendor]	; Pointer to number to be written
343
	movzx	ecx,word [PCI_Vendor]	; Pointer to number to be written
305
	mcall	47, 0x00040100		; Write Vendor ID
344
	mcall	47, 0x00040100		; Write Vendor ID
306
	and	edx, 0xFFFF		;*****************************************
345
	and	edx, 0xFFFF		;*****************************************
307
	or	edx, 54 * 65536	; X start becomes 54
346
	or	edx, 54 * 65536 ; X start becomes 54
Line 399... Line 438...
399
	and	ebx, 0x0000FFFF		; clear X position
438
	and	ebx, 0x0000FFFF 	; clear X position
400
	or	ebx, 0x24E0000		; set X position to 590 pixels
439
	or	ebx, 0x24E0000		; set X position to 590 pixels
401
	mcall	4,, 0x80000000,, 32	; draw the text
440
	mcall	4,, 0x80000000,, 32	; draw the text
402
	movzx	edx, bx		; get y coordinate
441
	movzx	edx, bx 	; get y coordinate
403
	add	edx, 0x0014000A		; add 10 to y coordinate and set x coordinate to 20
442
	add	edx, 0x0014000A 	; add 10 to y coordinate and set x coordinate to 20
-
 
443
	mov	[gr_pos], edx
-
 
444
	ret
-
 
445
;------------------------------------------------------------------
-
 
446
; Get the user-MMIO related info
-
 
447
;
-
 
448
; Added on ??-12-2009 by art_zh
-
 
449
;------------------------------------------------------------------
-
 
450
Try_MMIO:
-
 
451
	xor	ebx, ebx
-
 
452
	mov	edx, ebx
-
 
453
	mov	bh, byte [MMIO_BAR]
-
 
454
	or	bx, 12			; function 12
-
 
455
	mov	ecx, 4096		; =1 page to map
-
 
456
	mcall	62
-
 
457
	mov	ecx, 0x80990022 	; print color : red
-
 
458
	mov	bh, byte [MMIO_BAR]
-
 
459
	add	bh, '0'
-
 
460
	cmp	eax, -3
-
 
461
	jne	@f
-
 
462
	mov	[bar_um+3], bh
-
 
463
	mov	ebx, [gr_pos]
-
 
464
	mov	edx, bar_um
-
 
465
	mcall	4
-
 
466
	jmp	mmio_next_bar
-
 
467
@@:
-
 
468
	cmp	eax, -4
-
 
469
	jne	@f
-
 
470
	mov	[bar_io+3], bh
-
 
471
	mov	ebx, [gr_pos]
-
 
472
	mov	edx, bar_io
-
 
473
	mcall	4
-
 
474
	jmp	mmio_next_bar
-
 
475
@@:
-
 
476
	mov	[bar_ram+3], bh
-
 
477
	mov	ebx, [gr_pos]
-
 
478
	mov	edx, bar_ram
-
 
479
	mcall	4
-
 
480
 
-
 
481
	mov	edx, eax
-
 
482
	mov	esi, 64
-
 
483
	mov	ecx, 0x099		; dump color : blue
-
 
484
	add	ebx, 10
-
 
485
	mov	[gr_pos], ebx
-
 
486
	mcall	4
-
 
487
	mov	ecx, eax		; release the tried page
-
 
488
	mcall	62,13
-
 
489
 
-
 
490
mmio_next_bar:
-
 
491
	mov	bh, [MMIO_BAR]
-
 
492
	inc	bh
-
 
493
	cmp	bh,6
-
 
494
	je	@f
-
 
495
	mov	[MMIO_BAR], bh
-
 
496
	add	[gr_pos], 10
-
 
497
	jmp	Try_MMIO
-
 
498
 
-
 
499
@@:
-
 
500
	xor	bh,bh
-
 
501
	mov	[MMIO_BAR], bh
404
	ret
502
	ret
Line -... Line 503...
-
 
503
 
405
 
504
 
406
include	'VENDORS.INC'
505
include 'VENDORS.INC'
407
;------------------------------------------------------------------
506
;------------------------------------------------------------------
408
; DATA AREA
507
; DATA AREA
Line 412... Line 511...
412
Form:	dw 800 ; window width (no more, special for 800x600)
511
Form:	dw 800 ; window width (no more, special for 800x600)
413
	dw 100 ; window x start
512
	dw 100 ; window x start
414
	dw 420 ; window height
513
	dw 420 ; window height
415
	dw 100 ; window y start
514
	dw 100 ; window y start
Line 416... Line 515...
416
 
515
 
Line 417... Line 516...
417
title	db 'PCI Device Enumeration v 2.1 by J. Delozier, S. Kuzmin, V. Hanla, M. Zakiyanov', 0
516
title	db 'PCI Device Enumerator v 2.2 by J.Delozier, S.Kuzmin, V.Hanla, M.Zakiyanov, A.Jerdev', 0
418
 
517
 
419
PCIWin mls \
518
PCIWin mls \
420
	'Please remember to enable PCI Access to Applications in Setup Menu.',\
519
	'   Don`t forget to enable PCI Access to Applications in Setup Menu.',\
421
	'',\
520
	'',\
422
	'PCI Version  = x.xx',\
521
	'PCI Version  = x.xx; Last PCI Bus = x',\
423
	'Last PCI Bus = x',\
522
	'User MMIO channel = 0F.F:F ',\
424
	'Quantity of devices =',\
523
	'Number of PCI units =',\
425
	'',\
524
	'',\
426
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
525
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
Line -... Line 526...
-
 
526
	'                                      Interface',\
-
 
527
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ ----------------'
-
 
528
 
-
 
529
bar_ram db 'BARx: MMIO block', 0
-
 
530
bar_io	db 'BARx: IO ports',0
427
	'                                      Interface',\
531
bar_um	db 'BARx: unmapped',0
428
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ ----------------'
532
bar_rom db 'BAR6: Onboard ROM', 0  ; << no ROM test yet
429
 
533
 
Line 430... Line 534...
430
;------------------------------------------------------------------
534
;------------------------------------------------------------------
Line 445... Line 549...
445
PCI_Class	db ?
549
PCI_Class	db ?
446
PCI_SubClass	db ?
550
PCI_SubClass	db ?
447
PCI_Interface	db ?
551
PCI_Interface	db ?
448
PCI_IRQ		db ?
552
PCI_IRQ 	db ?
Line -... Line 553...
-
 
553
 
-
 
554
align 4
-
 
555
MMIO_Bus	db ?
-
 
556
MMIO_Dev	db ?
-
 
557
MMIO_BAR	db 0
-
 
558
MMIO_Blk	db 0
-
 
559
MMIO_Map	rd 8
-
 
560
 
-
 
561
gr_pos		dd ?
449
 
562
 
450
Proc_Info	process_information
563
Proc_Info	process_information
-
 
564
MEOS_APP_END