Subversion Repositories Kolibri OS

Rev

Rev 3630 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3630 Rev 7134
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 assmebler 1.66
5
; version:         2.1
5
; version:         2.1
6
; last update:     April 2007
6
; last update:     April 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
; project site:    http://www.coolthemes.narod.ru/pcidev.html
10
; project site:    http://www.coolthemes.narod.ru/pcidev.html
11
;***************************************************************
11
;***************************************************************
12
;Summary: This program will attempt to scan the PCI Bus
12
;Summary: This program will attempt to scan the PCI Bus
13
;        and display basic information about each device
13
;        and display basic information about each device
14
;        connected to the PCI Bus.
14
;        connected to the PCI Bus.
15
;***************************************************************
15
;***************************************************************
16
;HISTORY:
16
;HISTORY:
17
;keep dates in european format (dd/mm/yyyy), please
17
;keep dates in european format (dd/mm/yyyy), please
18
; '!' means big changes
18
; '!' means big changes
19
;
19
;
20
;to-do:
20
;to-do:
21
; more vendors
21
; more vendors
22
; vendor's website
22
; vendor's website
23
; Subsystem id and Subsystem vendor id detection
23
; Subsystem id and Subsystem vendor id detection
24
 
24
 
25
; Full device detection (like "ATI Radeon 9200") will increase app
25
; Full device detection (like "ATI Radeon 9200") will increase app
26
; size a lot and probably it is function of particular drivers
26
; size a lot and probably it is function of particular drivers
27
;----------------------------------------------------------------
27
;----------------------------------------------------------------
28
;2.1n: PCIDEV   ??/04/2007
28
;2.1n: PCIDEV   ??/04/2007
29
;Author:    Mihailov Ilia aka Ghost 
29
;Author:    Mihailov Ilia aka Ghost 
30
;Features:
30
;Features:
31
;           added
31
;           added
32
;                 * new PCI API
32
;                 * new PCI API
33
;----------------------------------------------------------------
33
;----------------------------------------------------------------
34
;2.1: PCIDEV   ??/04/2007
34
;2.1: PCIDEV   ??/04/2007
35
;Author:    Mihailov Ilia aka Ghost 
35
;Author:    Mihailov Ilia aka Ghost 
36
;Features:
36
;Features:
37
;           fixed
37
;           fixed
38
;                 * Same little bugs
38
;                 * Same little bugs
39
;                 * Source code formating
39
;                 * Source code formating
40
;                 * PCI version normalized 0210 -> 2.10
40
;                 * PCI version normalized 0210 -> 2.10
41
;           added
41
;           added
42
;                 * + 13 vendor (total now 1000!)
42
;                 * + 13 vendor (total now 1000!)
43
;                 * + 3 class type
43
;                 * + 3 class type
44
;                 * Fast call source ready
44
;                 * Fast call source ready
45
;                 * Device IRQ detection
45
;                 * Device IRQ detection
46
;           optimized
46
;           optimized
47
;                 * ! size optimized (61025 -> 32501 see added)
47
;                 * ! size optimized (61025 -> 32501 see added)
48
;                 * easy to add new vendor & class names
48
;                 * easy to add new vendor & class names
49
;----------------------------------------------------------------
49
;----------------------------------------------------------------
50
;2.0: PCIDEV   30/08/2006
50
;2.0: PCIDEV   30/08/2006
51
;(it differs a lot from the version 1.0, which was introduced 19 months ago)
51
;(it differs a lot from the version 1.0, which was introduced 19 months ago)
52
;Author:    Marat Zakiyanov aka Mario79 
52
;Author:    Marat Zakiyanov aka Mario79 
53
;           Sergey Kuzmin aka Wildwest 
53
;           Sergey Kuzmin aka Wildwest 
54
;Features:
54
;Features:
55
;           added
55
;           added
56
;                 * Detection of Interface by Mario79
56
;                 * Detection of Interface by Mario79
57
;                 * 122 vendor id's by Wildwest
57
;                 * 122 vendor id's by Wildwest
58
;                 * Description is based on Class, SubClass and Interface now (PCI 3.0) by Wildwest
58
;                 * Description is based on Class, SubClass and Interface now (PCI 3.0) by Wildwest
59
;----------------------------------------------------------------
59
;----------------------------------------------------------------
60
;1.31: PCIDEV   13/05/2006
60
;1.31: PCIDEV   13/05/2006
61
;Author:    Jason Delozier 
61
;Author:    Jason Delozier 
62
;Features:
62
;Features:
63
;           fixed
63
;           fixed
64
;                 * ! bug in Company Name look up code that would cause Unknown Name errors.
64
;                 * ! bug in Company Name look up code that would cause Unknown Name errors.
65
;                 * ! possible bugs, many instructions missing byte, word, dword prefixes
65
;                 * ! possible bugs, many instructions missing byte, word, dword prefixes
66
;                 * ! possible bug which could have occured after removing  "PREVIOUSVERSIONLIST"
66
;                 * ! possible bug which could have occured after removing  "PREVIOUSVERSIONLIST"
67
;                     entry in loop up code and not fixing jump parameters.
67
;                     entry in loop up code and not fixing jump parameters.
68
;           added
68
;           added
69
;                 *  comments to various parts of the code
69
;                 *  comments to various parts of the code
70
;           optimized
70
;           optimized
71
;                 * various parts of the source, too many to remember and mention.
71
;                 * various parts of the source, too many to remember and mention.
72
;                 * changed entries for Subclasses in vendors.inc to Byte format, saves a little space.
72
;                 * changed entries for Subclasses in vendors.inc to Byte format, saves a little space.
73
;----------------------------------------------------------------
73
;----------------------------------------------------------------
74
;1.30: PCIDEV   11/05/2006
74
;1.30: PCIDEV   11/05/2006
75
;Author:    Sergey Kuzmin aka Wildwest 
75
;Author:    Sergey Kuzmin aka Wildwest 
76
;Features:
76
;Features:
77
;           added
77
;           added
78
;                * 3 new vendor id's (ESS from Madis Kalme and 2 id's
78
;                * 3 new vendor id's (ESS from Madis Kalme and 2 id's
79
;                  forgotten from 1.15 release: Broadcom -SiByte and Chaintech Comp.)
79
;                  forgotten from 1.15 release: Broadcom -SiByte and Chaintech Comp.)
80
;           changed
80
;           changed
81
;                * I don't know why other devs (Jason or Victor) changed window style
81
;                * I don't know why other devs (Jason or Victor) changed window style
82
;                  to old ugly one, so I changed it back to skinned type 3.
82
;                  to old ugly one, so I changed it back to skinned type 3.
83
;                * the same goes to the use of macroc.inc - it is enabled again.
83
;                * the same goes to the use of macroc.inc - it is enabled again.
84
;           deleted
84
;           deleted
85
;                * there is no more label "PREVIOUSVERSIONLIST" - id's moved to the
85
;                * there is no more label "PREVIOUSVERSIONLIST" - id's moved to the
86
;                  appropriate parts of global list.
86
;                  appropriate parts of global list.
87
;----------------------------------------------------------------
87
;----------------------------------------------------------------
88
;1.29: PCIDEV   30/04/2006
88
;1.29: PCIDEV   30/04/2006
89
;Author:    Jason Delozier 
89
;Author:    Jason Delozier 
90
;Features:
90
;Features:
91
;           fixed
91
;           fixed
92
;                 * ! bug that would not allow devices with device
92
;                 * ! bug that would not allow devices with device
93
;                   numbers > 16 to be displayed.
93
;                   numbers > 16 to be displayed.
94
;           added
94
;           added
95
;                 * ! another heading called "FNC" (function) which allows
95
;                 * ! another heading called "FNC" (function) which allows
96
;                   the multipurpose Device/Function varible to be split and
96
;                   the multipurpose Device/Function varible to be split and
97
;                   displayed to the user properly.
97
;                   displayed to the user properly.
98
;                 * horizontal bars to display for easier reading.
98
;                 * horizontal bars to display for easier reading.
99
;           optimized
99
;           optimized
100
;                 * vendor/description search routines for speed and space.
100
;                 * vendor/description search routines for speed and space.
101
;----------------------------------------------------------------
101
;----------------------------------------------------------------
102
;1.25: PCIDEV   02/10/2005
102
;1.25: PCIDEV   02/10/2005
103
;Author:    Sergey Kuzmin aka Wildwest 
103
;Author:    Sergey Kuzmin aka Wildwest 
104
;Features:
104
;Features:
105
;            changed
105
;            changed
106
;                  * ! Description is based on Class and SubClass
106
;                  * ! Description is based on Class and SubClass
107
;                     now (PCI 3.0). The Names of Classes and SubClasses
107
;                     now (PCI 3.0). The Names of Classes and SubClasses
108
;                     are in the end of Vendors.inc
108
;                     are in the end of Vendors.inc
109
;            deleted
109
;            deleted
110
;                  * label "Descriptions" (names of Classes)
110
;                  * label "Descriptions" (names of Classes)
111
;
111
;
112
;----------------------------------------------------------------
112
;----------------------------------------------------------------
113
;1.20: PCIDEV   16/08/2005
113
;1.20: PCIDEV   16/08/2005
114
;Author:    Victor Alberto Gil Hanla a.k.a. vhanla 
114
;Author:    Victor Alberto Gil Hanla a.k.a. vhanla 
115
;Features:
115
;Features:
116
;           added
116
;           added
117
;                  * ! many vendor lists (865)
117
;                  * ! many vendor lists (865)
118
;           deleted
118
;           deleted
119
;                  * previous version's list
119
;                  * previous version's list
120
;           changed
120
;           changed
121
;                  * previous Company Name searching and printing
121
;                  * previous Company Name searching and printing
122
;----------------------------------------------------------------
122
;----------------------------------------------------------------
123
;1.15: PCIDEV   03/06/2005
123
;1.15: PCIDEV   03/06/2005
124
;Author:    Sergey Kuzmin aka Wildwest 
124
;Author:    Sergey Kuzmin aka Wildwest 
125
;Features:
125
;Features:
126
;           added
126
;           added
127
;                 * quantity of devices,
127
;                 * quantity of devices,
128
;                 * ! detection of Company Name based on Vendor ID,
128
;                 * ! detection of Company Name based on Vendor ID,
129
;                 * database of VenID (35 ID's),
129
;                 * database of VenID (35 ID's),
130
;                 * macros.inc for smaller size,
130
;                 * macros.inc for smaller size,
131
;           changed
131
;           changed
132
;                 * interface+(skinned window),
132
;                 * interface+(skinned window),
133
;                 * VenID before DevID in 'table'(was DevID before VenID)
133
;                 * VenID before DevID in 'table'(was DevID before VenID)
134
;----------------------------------------------------------------
134
;----------------------------------------------------------------
135
;1.0: PCIDEV    30/01/2005
135
;1.0: PCIDEV    30/01/2005
136
;Author:    Jason Delozier
136
;Author:    Jason Delozier
137
;Features:
137
;Features:
138
;          able to
138
;          able to
139
;                 * detect PCI version,
139
;                 * detect PCI version,
140
;                 * quantity of PCI buses,
140
;                 * quantity of PCI buses,
141
;                 * Vendor&Device ID for appropriate Device on Bus;
141
;                 * Vendor&Device ID for appropriate Device on Bus;
142
;                 * detect Revision, Class and Subclass of Device,
142
;                 * detect Revision, Class and Subclass of Device,
143
;                 * and make Description based on Class
143
;                 * and make Description based on Class
144
;-------------------------------------------------------------
144
;-------------------------------------------------------------
145
include 'lang.inc'
-
 
146
include	'macros.inc'
145
include	'macros.inc'
147
MEOS_APP_START
146
MEOS_APP_START
148
CODE
147
CODE
149
	call draw_window
148
	call draw_window
150
 
149
 
151
still:	mcall	10			; wait here for event
150
still:	mcall	10			; wait here for event
152
	dec	eax			; redraw request ?
151
	dec	eax			; redraw request ?
153
	jz	red
152
	jz	red
154
	dec	eax			; key in buffer ?
153
	dec	eax			; key in buffer ?
155
	jz	key
154
	jz	key
156
	dec	eax			; button in buffer ?
155
	dec	eax			; button in buffer ?
157
	jz	button
156
	jz	button
158
	jmp	still
157
	jmp	still
159
 
158
 
160
red:					; redraw
159
red:					; redraw
161
	mcall	9, Proc_Info, -1	; window redraw requested so get new window coordinates and size
160
	mcall	9, Proc_Info, -1	; window redraw requested so get new window coordinates and size
162
	mov	eax, [Proc_Info.x_start]; store the window coordinates into the Form Structure
161
	mov	eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure
163
	mov	[Form + 2], ax		; x start position
162
	mov	[Form + 2], ax		; x start position
164
	mov	eax, [Proc_Info.y_start];
163
	mov	eax, [Proc_Info.box.top];
165
	mov	[Form + 6], ax		; ystart position
164
	mov	[Form + 6], ax		; ystart position
166
	mov	eax, [Proc_Info.x_size]	;
165
	mov	eax, [Proc_Info.box.width];
167
	mov	[Form], ax		; window width
166
	mov	[Form], ax		; window width
168
	mov	eax, [Proc_Info.y_size]	;
167
	mov	eax, [Proc_Info.box.height];
169
	mov	[Form + 4] ,ax		; window height
168
	mov	[Form + 4] ,ax		; window height
170
	call	draw_window		; go redraw window now
169
	call	draw_window		; go redraw window now
171
	jmp	still
170
	jmp	still
172
 
171
 
173
key:					; key
172
key:					; key
174
	mcall	2			; just read it and ignore
173
	mcall	2			; just read it and ignore
175
	jmp	still
174
	jmp	still
176
button:					; button
175
button:					; button
177
	mcall	17			; get id
176
	mcall	17			; get id
178
	cmp	ah, 1			; button id = 1 ?
177
	cmp	ah, 1			; button id = 1 ?
179
	jne	still
178
	jne	still
180
	mcall	-1			; close this program
179
	mcall	-1			; close this program
181
 
180
 
182
draw_window:
181
draw_window:
183
	mov	byte [total], 0
182
	mov	byte [total], 0
184
	mcall	12, 1			; start of draw
183
	mcall	12, 1			; start of draw
185
	; DRAW WINDOW
184
	; DRAW WINDOW
186
	mcall	0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title
185
	mcall	0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title
187
	; Insert horizontal bars  in list area
186
	; Insert horizontal bars  in list area
188
	mov	eax, 13			; draw bar system function
187
	mov	eax, 13			; draw bar system function
189
	mov	ebx, 18			; set Xstart position of bar
188
	mov	ebx, 18			; set Xstart position of bar
190
	shl	ebx, 16			;
189
	shl	ebx, 16			;
191
	mov	bx, word [Form]	; get width of window
190
	mov	bx, word [Form]	; get width of window
192
	sub	bx, 32			; bar is 32 pixels shorter then window width
191
	sub	bx, 32			; bar is 32 pixels shorter then window width
193
	mov	ecx, 119 * 65536 + 10	; set Ystart(109) and Height(10) of bar   109
192
	mov	ecx, 119 * 65536 + 10	; set Ystart(109) and Height(10) of bar   109
194
	mov	edx, 0xC0C0C0		; set color of bar
193
	mov	edx, 0xC0C0C0		; set color of bar
195
again:	;begin draw bar loop
194
again:	;begin draw bar loop
196
	mcall				; draw bar to window area
195
	mcall				; draw bar to window area
197
	shr	ecx, 16			; move the Ystart position to working area
196
	shr	ecx, 16			; move the Ystart position to working area
198
	add	ecx, 34			; add 34 pixels to Y Start (moves bar down)
197
	add	ecx, 34			; add 34 pixels to Y Start (moves bar down)
199
	cmp	cx, word [Form + 4]	; is the Ystart position outside of window area
198
	cmp	cx, word [Form + 4]	; is the Ystart position outside of window area
200
	jae	nomo			; if so stop drawing bars
199
	jae	nomo			; if so stop drawing bars
201
	sub	ecx, 14			; if not, we only need 20 pixels between bar tops
200
	sub	ecx, 14			; if not, we only need 20 pixels between bar tops
202
	shl	ecx, 16			; set that values as Ystart
201
	shl	ecx, 16			; set that values as Ystart
203
	add	ecx, 10			; Bar Height is always 10 pixels
202
	add	ecx, 10			; Bar Height is always 10 pixels
204
	jmp	again			; draw another bar
203
	jmp	again			; draw another bar
205
nomo:					;done drawing bars here
204
nomo:					;done drawing bars here
206
	; start PCI stuff
205
	; start PCI stuff
207
	call	Get_PCI_Info		; get pci version and last bus, scan for and draw each pci device
206
	call	Get_PCI_Info		; get pci version and last bus, scan for and draw each pci device
208
 
207
 
209
	; Window inteface
208
	; Window inteface
210
	mov	cx, [PCI_Version]
209
	mov	cx, [PCI_Version]
211
	add	ch, '0'
210
	add	ch, '0'
212
	mov	[PCIWin + 85], ch	; 0xBADCODE but it work !
211
	mov	[PCIWin + 85], ch	; 0xBADCODE but it work !
213
	mov	ch, cl
212
	mov	ch, cl
214
	shr	cl, 4
213
	shr	cl, 4
215
	and	ch, 0x0f
214
	and	ch, 0x0f
216
	add	cx, '00'
215
	add	cx, '00'
217
	mov	[PCIWin + 87], cx
216
	mov	[PCIWin + 87], cx
218
	mov	cl, [PCI_LastBus]
217
	mov	cl, [PCI_LastBus]
219
	add	cl, '0'
218
	add	cl, '0'
220
	mov	[PCIWin + 105], cl
219
	mov	[PCIWin + 105], cl
221
 
220
 
222
	mov	edx, PCIWin
221
	mov	edx, PCIWin
223
	mov	ebx, 20 * 65536 + 25	; x start, ystart of text
222
	mov	ebx, 20 * 65536 + 25	; x start, ystart of text
224
	mov	ecx, 0x224466		; color of text
223
	mov	ecx, 0x224466		; color of text
225
	mov	eax, 4
224
	mov	eax, 4
226
@@:	movzx	esi, byte[edx]
225
@@:	movzx	esi, byte[edx]
227
	inc	edx
226
	inc	edx
228
	mcall
227
	mcall
229
	add	ebx, 10
228
	add	ebx, 10
230
	add	edx, esi
229
	add	edx, esi
231
	cmp	byte[edx], -1
230
	cmp	byte[edx], -1
232
	jne	@b
231
	jne	@b
233
	; Quantity of devices...
232
	; Quantity of devices...
234
	movzx	ecx, byte [total]	; number to draw
233
	movzx	ecx, byte [total]	; number to draw
235
	mcall	47, 0x00020000,,150 * 65536 + 65, 0x224466
234
	mcall	47, 0x00020000,,150 * 65536 + 65, 0x224466
236
 
235
 
237
	mcall	12, 2			; end of draw
236
	mcall	12, 2			; end of draw
238
	ret
237
	ret
239
 
238
 
240
;------------------------------------------------------------------
239
;------------------------------------------------------------------
241
;* Gets the PCI Version and Last Bus
240
;* Gets the PCI Version and Last Bus
242
Get_PCI_Info:
241
Get_PCI_Info:
243
	mov	ebp, 1
242
	mov	ebp, 1
244
	mcall	57
243
	mcall	57
245
	mov	word [PCI_Version], bx
244
	mov	word [PCI_Version], bx
246
	mov	byte [PCI_LastBus], cl
245
	mov	byte [PCI_LastBus], cl
247
	;----------------------------------------------------------
246
	;----------------------------------------------------------
248
	;* Get all devices on PCI Bus
247
	;* Get all devices on PCI Bus
249
	cmp	al, 0xff		; 0xFF means no pci bus found
248
	cmp	al, 0xff		; 0xFF means no pci bus found
250
	jne	Pci_Exists		;
249
	jne	Pci_Exists		;
251
	ret				; if no bus then leave
250
	ret				; if no bus then leave
252
Pci_Exists:
251
Pci_Exists:
253
	mov	byte [V_Bus], 0		; reset varibles
252
	mov	byte [V_Bus], 0		; reset varibles
254
	mov	byte [V_Dev], 0		;
253
	mov	byte [V_Dev], 0		;
255
	mov	edx,  20 * 65536 + 110	; set start write position
254
	mov	edx,  20 * 65536 + 110	; set start write position
256
Start_Enum:
255
Start_Enum:
257
	mov	ebp, 0x0a		; get a dword
256
	mov	ebp, 0x0a		; get a dword
258
	xor	edi, edi		; offset to device/vendor id
257
	xor	edi, edi		; offset to device/vendor id
259
	mov	bh, byte [V_Bus]	; bus of pci device
258
	mov	bh, byte [V_Bus]	; bus of pci device
260
	mov	bl, byte [V_Dev]	; device number/function
259
	mov	bl, byte [V_Dev]	; device number/function
261
	mcall	57			; get ID's
260
	mcall	57			; get ID's
262
	cmp	cx, 0			; Vendor ID should not be 0 or 0xFFFF
261
	cmp	cx, 0			; Vendor ID should not be 0 or 0xFFFF
263
	je	nextDev			; check next device if nothing exists here
262
	je	nextDev			; check next device if nothing exists here
264
	cmp	cx, 0xffff		;
263
	cmp	cx, 0xffff		;
265
	je	nextDev			;
264
	je	nextDev			;
266
	mov	word [PCI_Vendor], cx	; There is a device here, save the ID's
265
	mov	word [PCI_Vendor], cx	; There is a device here, save the ID's
267
	shr	ecx, 16			;
266
	shr	ecx, 16			;
268
	mov	word [PCI_Device], cx	;
267
	mov	word [PCI_Device], cx	;
269
 
268
 
270
 
269
 
271
 
270
 
272
	mov	ebp, 8			; Read config byte
271
	mov	ebp, 8			; Read config byte
273
	mov	bh, byte [V_Bus]	; Bus #
272
	mov	bh, byte [V_Bus]	; Bus #
274
	mov	bl, byte [V_Dev]	; Device # on bus
273
	mov	bl, byte [V_Dev]	; Device # on bus
275
	mov	edi, 0x08		; Register to read (Get Revision)
274
	mov	edi, 0x08		; Register to read (Get Revision)
276
	mcall	57			; Read it
275
	mcall	57			; Read it
277
	mov	byte [PCI_Rev], cl	; Save it
276
	mov	byte [PCI_Rev], cl	; Save it
278
 
277
 
279
	mov	edi, 0x0b		; Register to read (Get class)
278
	mov	edi, 0x0b		; Register to read (Get class)
280
	mcall	57			; Read it
279
	mcall	57			; Read it
281
	mov	byte [PCI_Class], cl	; Save it
280
	mov	byte [PCI_Class], cl	; Save it
282
 
281
 
283
	mov	edi, 0x0a		; Register to read (Get Subclass)
282
	mov	edi, 0x0a		; Register to read (Get Subclass)
284
	mcall	57			; Read it
283
	mcall	57			; Read it
285
	mov	byte [PCI_SubClass], cl; Save it
284
	mov	byte [PCI_SubClass], cl; Save it
286
; from Mario79 august 2006
285
; from Mario79 august 2006
287
	mov	edi, 0x09		; Register to read (Get Interface)
286
	mov	edi, 0x09		; Register to read (Get Interface)
288
	mcall	57			; Read it
287
	mcall	57			; Read it
289
	mov  [PCI_Interface], cl	; Save it
288
	mov  [PCI_Interface], cl	; Save it
290
;
289
;
291
; from Ghost april 2007
290
; from Ghost april 2007
292
	mov	edi, 0x3c		; Register to read (Get IRQ)
291
	mov	edi, 0x3c		; Register to read (Get IRQ)
293
	mcall	57			; Read it
292
	mcall	57			; Read it
294
	mov	[PCI_IRQ], cl		; Save it
293
	mov	[PCI_IRQ], cl		; Save it
295
;
294
;
296
	inc	byte [total]		; one more device found
295
	inc	byte [total]		; one more device found
297
	call	Print_New_Device	; print device info to screen
296
	call	Print_New_Device	; print device info to screen
298
nextDev:
297
nextDev:
299
	inc	byte [V_Dev]		; next device on this bus
298
	inc	byte [V_Dev]		; next device on this bus
300
	jnz	Start_Enum		; jump until we reach zero
299
	jnz	Start_Enum		; jump until we reach zero
301
	;(used to be JNO which caused bug!!! 30-4-2006, JMD)
300
	;(used to be JNO which caused bug!!! 30-4-2006, JMD)
302
	mov	byte [V_Dev], 0		; reset device number
301
	mov	byte [V_Dev], 0		; reset device number
303
	inc	byte [V_Bus]		; next bus
302
	inc	byte [V_Bus]		; next bus
304
	mov	al, byte [PCI_LastBus]	; get last bus
303
	mov	al, byte [PCI_LastBus]	; get last bus
305
	cmp	byte [V_Bus], al	; was it last bus
304
	cmp	byte [V_Bus], al	; was it last bus
306
	jbe	Start_Enum		; if not jump to keep searching
305
	jbe	Start_Enum		; if not jump to keep searching
307
	ret
306
	ret
308
 
307
 
309
;------------------------------------------------------------------
308
;------------------------------------------------------------------
310
;* Print device info to screen
309
;* Print device info to screen
311
Print_New_Device:
310
Print_New_Device:
312
	xor	esi, esi		; Color of text
311
	xor	esi, esi		; Color of text
313
	movzx	ecx,word [PCI_Vendor]	; Pointer to number to be written
312
	movzx	ecx,word [PCI_Vendor]	; Pointer to number to be written
314
	mcall	47, 0x00040100		; Write Vendor ID
313
	mcall	47, 0x00040100		; Write Vendor ID
315
	and	edx, 0xFFFF		;*****************************************
314
	and	edx, 0xFFFF		;*****************************************
316
	or	edx, 54 * 65536	; X start becomes 54
315
	or	edx, 54 * 65536	; X start becomes 54
317
	movzx	ecx, word [PCI_Device]	; get Vendor ID
316
	movzx	ecx, word [PCI_Device]	; get Vendor ID
318
	mcall				; Draw Vendor ID to Window
317
	mcall				; Draw Vendor ID to Window
319
	and	edx, 0xFFFF		;*****************************************
318
	and	edx, 0xFFFF		;*****************************************
320
	or	edx, 98 * 65536	; X start becomes 98
319
	or	edx, 98 * 65536	; X start becomes 98
321
	movzx	ecx, byte [V_Bus]	; get bus number
320
	movzx	ecx, byte [V_Bus]	; get bus number
322
	mcall	,0x00020100		; draw bus number to screen
321
	mcall	,0x00020100		; draw bus number to screen
323
	and	edx, 0xFFFF		;*****************************************
322
	and	edx, 0xFFFF		;*****************************************
324
	or	edx, 128 * 65536	; X start becomes 128
323
	or	edx, 128 * 65536	; X start becomes 128
325
	movzx	ecx, byte [V_Dev]	; get device number
324
	movzx	ecx, byte [V_Dev]	; get device number
326
	shr	ecx, 3			; device number is bits 3-7
325
	shr	ecx, 3			; device number is bits 3-7
327
	mcall				; Draw device Number To Window
326
	mcall				; Draw device Number To Window
328
 
327
 
329
	and	edx, 0xFFFF		;*****************************************
328
	and	edx, 0xFFFF		;*****************************************
330
	or	edx, 155 * 65536	; X start becomes 155
329
	or	edx, 155 * 65536	; X start becomes 155
331
	movzx	ecx, byte [V_Dev]	; get Function number
330
	movzx	ecx, byte [V_Dev]	; get Function number
332
	and	ecx, 7			; function is first 3 bits
331
	and	ecx, 7			; function is first 3 bits
333
	mcall				; Draw Function Number To Window
332
	mcall				; Draw Function Number To Window
334
	and	edx, 0xFFFF		;*****************************************
333
	and	edx, 0xFFFF		;*****************************************
335
	or	edx, 179 * 65536	; X start becomes 179
334
	or	edx, 179 * 65536	; X start becomes 179
336
	movzx	ecx, byte [PCI_Rev]	; get revision number
335
	movzx	ecx, byte [PCI_Rev]	; get revision number
337
	mcall				; Draw Revision to screen
336
	mcall				; Draw Revision to screen
338
	and	edx, 0xFFFF		;*****************************************
337
	and	edx, 0xFFFF		;*****************************************
339
	or	edx, 215*65536		; X start becomes 215
338
	or	edx, 215*65536		; X start becomes 215
340
	movzx	ecx, byte [PCI_Class]	; get PCI_Class
339
	movzx	ecx, byte [PCI_Class]	; get PCI_Class
341
	mcall				; Draw Class to screen
340
	mcall				; Draw Class to screen
342
	and	edx, 0xFFFF		;*****************************************
341
	and	edx, 0xFFFF		;*****************************************
343
	or	edx, 250*65536		; X start becomes 250
342
	or	edx, 250*65536		; X start becomes 250
344
	movzx	ecx, byte [PCI_SubClass]; get sub class
343
	movzx	ecx, byte [PCI_SubClass]; get sub class
345
	mcall				; Draw Sub Class to screen
344
	mcall				; Draw Sub Class to screen
346
; from Mario79 august 2006
345
; from Mario79 august 2006
347
	and	edx, 0xFFFF		;*****************************************
346
	and	edx, 0xFFFF		;*****************************************
348
	or	edx, 280 * 65536	; X start becomes 280
347
	or	edx, 280 * 65536	; X start becomes 280
349
	movzx	ecx, [PCI_Interface]	; get Interface
348
	movzx	ecx, [PCI_Interface]	; get Interface
350
	mcall
349
	mcall
351
;
350
;
352
; from Ghost april 2007			;*****************************************
351
; from Ghost april 2007			;*****************************************
353
	movzx	ecx, [PCI_IRQ]		; get Interface
352
	movzx	ecx, [PCI_IRQ]		; get Interface
354
	cmp	cl, 0x0f		; IRQ between 0..15
353
	cmp	cl, 0x0f		; IRQ between 0..15
355
	ja	@f
354
	ja	@f
356
	and	edx, 0xFFFF
355
	and	edx, 0xFFFF
357
	or	edx, 310 * 65536	; X start becomes 310
356
	or	edx, 310 * 65536	; X start becomes 310
358
	mcall
357
	mcall
359
@@:
358
@@:
360
;
359
;
361
	;Write Names
360
	;Write Names
362
	movzx	ebx, dx		; Set y position
361
	movzx	ebx, dx		; Set y position
363
	or	ebx, 340*65536		; set Xposition to 340
362
	or	ebx, 340*65536		; set Xposition to 340
364
 
363
 
365
;------------------------------------------------------------------
364
;------------------------------------------------------------------
366
; Prints the Vendor's Name based on Vendor ID
365
; Prints the Vendor's Name based on Vendor ID
367
;
366
;
368
; Modified on ??-04-2007 by Ghost for size
367
; Modified on ??-04-2007 by Ghost for size
369
;------------------------------------------------------------------
368
;------------------------------------------------------------------
370
	mov	edx, VendorsTab
369
	mov	edx, VendorsTab
371
	mov	cx, word[PCI_Vendor]
370
	mov	cx, word[PCI_Vendor]
372
 
371
 
373
.fn:	mov	ax, [edx]
372
.fn:	mov	ax, [edx]
374
	add	edx, 6
373
	add	edx, 6
375
	test	ax, ax
374
	test	ax, ax
376
	jz	.find
375
	jz	.find
377
	cmp	ax, cx
376
	cmp	ax, cx
378
	jne	.fn
377
	jne	.fn
379
.find:	mov	edx, [edx - 4]
378
.find:	mov	edx, [edx - 4]
380
	mcall	4,, 0x80000000		; lets print the vendor Name
379
	mcall	4,, 0x80000000		; lets print the vendor Name
381
 
380
 
382
;------------------------------------------------------------------
381
;------------------------------------------------------------------
383
; Get description based on Class/Subclass
382
; Get description based on Class/Subclass
384
;
383
;
385
; Modified on ??-04-2007 by Ghost for size
384
; Modified on ??-04-2007 by Ghost for size
386
;------------------------------------------------------------------
385
;------------------------------------------------------------------
387
	mov	eax, dword [PCI_Class]
386
	mov	eax, dword [PCI_Class]
388
	and	eax, 0xffffff
387
	and	eax, 0xffffff
389
	xor	edx, edx
388
	xor	edx, edx
390
	xor	esi, esi
389
	xor	esi, esi
391
.fnc:	inc	esi
390
.fnc:	inc	esi
392
	mov	ecx, [Classes + esi * 8 - 8]
391
	mov	ecx, [Classes + esi * 8 - 8]
393
	cmp	cx, 0xffff
392
	cmp	cx, 0xffff
394
	je	.endfc
393
	je	.endfc
395
	cmp	cx, ax
394
	cmp	cx, ax
396
	jne	.fnc
395
	jne	.fnc
397
	test	ecx, 0xff000000
396
	test	ecx, 0xff000000
398
	jz	@f
397
	jz	@f
399
	mov	edx, [Classes + esi * 8 - 4]
398
	mov	edx, [Classes + esi * 8 - 4]
400
	jmp	.fnc
399
	jmp	.fnc
401
@@:	cmp	eax, ecx
400
@@:	cmp	eax, ecx
402
	jne	.fnc
401
	jne	.fnc
403
	xor	edx, edx
402
	xor	edx, edx
404
.endfc:	test	edx, edx
403
.endfc:	test	edx, edx
405
	jnz	@f
404
	jnz	@f
406
	mov	edx, [Classes + esi * 8 - 4]
405
	mov	edx, [Classes + esi * 8 - 4]
407
@@:
406
@@:
408
	and	ebx, 0x0000FFFF		; clear X position
407
	and	ebx, 0x0000FFFF		; clear X position
409
	or	ebx, 0x24E0000		; set X position to 590 pixels
408
	or	ebx, 0x24E0000		; set X position to 590 pixels
410
	mcall	4,, 0x80000000,, 32	; draw the text
409
	mcall	4,, 0x80000000,, 32	; draw the text
411
	movzx	edx, bx		; get y coordinate
410
	movzx	edx, bx		; get y coordinate
412
	add	edx, 0x0014000A		; add 10 to y coordinate and set x coordinate to 20
411
	add	edx, 0x0014000A		; add 10 to y coordinate and set x coordinate to 20
413
	ret
412
	ret
414
 
413
 
415
include	'vendors.inc'
414
include	'vendors.inc'
416
;------------------------------------------------------------------
415
;------------------------------------------------------------------
417
; DATA AREA
416
; DATA AREA
418
DATA
417
DATA
419
 
418
 
420
 
419
 
421
Form:	dw 800 ; window width (no more, special for 800x600)
420
Form:	dw 800 ; window width (no more, special for 800x600)
422
	dw 100 ; window x start
421
	dw 100 ; window x start
423
	dw 420 ; window height
422
	dw 420 ; window height
424
	dw 100 ; window y start
423
	dw 100 ; window y start
425
 
424
 
426
if lang eq it
425
if lang eq it
427
title	db 'PCI Device Enumeration v 2.1n new PCI API test', 0
426
title	db 'PCI Device Enumeration v 2.1n new PCI API test', 0
428
PCIWin mls \
427
PCIWin mls \
429
	'Ricordarsi di abilitare l accesso alla PCI per le applicazioni dal menu.',\
428
	'Ricordarsi di abilitare l accesso alla PCI per le applicazioni dal menu.',\
430
	'',\
429
	'',\
431
	'Versione PCI = x.xx',\
430
	'Versione PCI = x.xx',\
432
	'Ultimo Bus PCI = x',\
431
	'Ultimo Bus PCI = x',\
433
	'Numerod di devices =',\
432
	'Numerod di devices =',\
434
	'',\
433
	'',\
435
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Compania                     Descrizione',\
434
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Compania                     Descrizione',\
436
	'                                      Interface',\
435
	'                                      Interface',\
437
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ ----------------'
436
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ ----------------'
438
else
437
else
439
title	db 'PCI Device Enumeration v 2.1n new PCI API test', 0
438
title	db 'PCI Device Enumeration v 2.1n new PCI API test', 0
440
PCIWin mls \
439
PCIWin mls \
441
	'Please remember to enable PCI Access to Applications in Setup Menu.',\
440
	'Please remember to enable PCI Access to Applications in Setup Menu.',\
442
	'',\
441
	'',\
443
	'PCI Version  = x.xx',\
442
	'PCI Version  = x.xx',\
444
	'Last PCI Bus = x',\
443
	'Last PCI Bus = x',\
445
	'Quantity of devices =',\
444
	'Quantity of devices =',\
446
	'',\
445
	'',\
447
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
446
	'VenID DevID Bus# Dev# Fnc Rev  Class  Subclass/ IRQ                 Company                      Description',\
448
	'                                      Interface',\
447
	'                                      Interface',\
449
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ ----------------'
448
	'----- ----- ---- ---- --- ---  -----  --------- --- ------------------------------------------ ----------------'
450
end if
449
end if
451
;------------------------------------------------------------------
450
;------------------------------------------------------------------
452
; UNINITIALIZED DATA AREA
451
; UNINITIALIZED DATA AREA
453
UDATA
452
UDATA
454
 
453
 
455
total		db ?
454
total		db ?
456
V_Bus		db ?
455
V_Bus		db ?
457
V_Dev		db ?
456
V_Dev		db ?
458
PCI_Version	dw ?
457
PCI_Version	dw ?
459
PCI_LastBus	db ?
458
PCI_LastBus	db ?
460
PCI_Device	dw ?
459
PCI_Device	dw ?
461
PCI_Vendor	dw ?
460
PCI_Vendor	dw ?
462
PCI_Bus		db ?
461
PCI_Bus		db ?
463
PCI_Dev		db ?
462
PCI_Dev		db ?
464
PCI_Rev		db ?
463
PCI_Rev		db ?
465
; don`t change order!!!
464
; don`t change order!!!
466
PCI_Class	db ?
465
PCI_Class	db ?
467
PCI_SubClass	db ?
466
PCI_SubClass	db ?
468
PCI_Interface	db ?
467
PCI_Interface	db ?
469
PCI_IRQ		db ?
468
PCI_IRQ		db ?
470
 
469
 
471
Proc_Info	process_information
470
Proc_Info	process_information
472
MEOS_APP_END
471
MEOS_APP_END