Subversion Repositories Kolibri OS

Rev

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

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