Subversion Repositories Kolibri OS

Rev

Rev 5071 | Rev 5170 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3171 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
5070 hidnplayr 8
format PE DLL native 0.05
9
entry START
3171 hidnplayr 10
 
5070 hidnplayr 11
        DEBUG = 1
3171 hidnplayr 12
 
5070 hidnplayr 13
section '.flat' code readable writable executable
14
include '../proc32.inc'
3766 Serge 15
include '../struct.inc'
5070 hidnplayr 16
include '../macros.inc'
5077 clevermous 17
include '../peimport.inc'
3171 hidnplayr 18
 
19
VID_INTEL         = 0x8086
20
VID_NVIDIA        = 0x10DE
21
VID_VIA           = 0x1106
22
VID_SIS           = 0x1039
23
VID_FM801         = 0x1319
24
VID_CREATIVE      = 0x1102
25
VID_ATI           = 0x1002
26
VID_AMD           = 0x1022
27
VID_ULI           = 0x10B9
28
VID_TERA          = 0x6549
29
VID_RDC           = 0x17F3
30
VID_VMWARE        = 0x15AD
31
 
32
CTRL_ICH          = 0x2415
33
CTRL_ICH0         = 0x2425
34
CTRL_ICH2         = 0x2435
35
CTRL_ICH3         = 0x2445
36
CTRL_ICH4         = 0x24C5
37
CTRL_ICH5         = 0x24D5
38
CTRL_ICH6         = 0x266E
39
CTRL_ICH7         = 0x27DE
40
 
41
CTRL_NFORCE       = 0x01B1
42
CTRL_NFORCE2      = 0x006A
43
CTRL_NFORCE3      = 0x00DA
44
CTRL_MCP04        = 0x003A
45
CTRL_CK804        = 0x0059
46
CTRL_CK8          = 0x008A
47
CTRL_CK8S         = 0x00EA
48
CTRL_MCP51        = 0x026B
49
 
50
CTRL_VT82C686     = 0x3058
51
CTRL_VT8233_5     = 0x3059
52
 
53
CTRL_SIS          = 0x7012
54
 
55
CTRL_FM801        = 0x0801
56
 
57
CTRL_CT0200       = 0x0006  ; Dell OEM version (EMU10K1X)
58
 
59
CTRL_INTEL_SCH2          =  0x080a
60
CTRL_INTEL_HPT           =  0x0c0c
61
CTRL_INTEL_CPT           =  0x1c20
62
CTRL_INTEL_PGB           =  0x1d20
63
CTRL_INTEL_PPT1          =  0x1e20
64
CTRL_INTEL_82801F        =  0x2668
65
CTRL_INTEL_63XXESB       =  0x269a
66
CTRL_INTEL_82801G        =  0x27d8
67
CTRL_INTEL_82801H        =  0x284b
68
CTRL_INTEL_82801_UNK1    =  0x2911
69
CTRL_INTEL_82801I        =  0x293e
70
CTRL_INTEL_82801_UNK2    =  0x293f
71
CTRL_INTEL_82801JI       =  0x3a3e
72
CTRL_INTEL_82801JD       =  0x3a6e
73
CTRL_INTEL_PCH           =  0x3b56
74
CTRL_INTEL_PCH2          =  0x3b57
75
CTRL_INTEL_SCH           =  0x811b
76
CTRL_INTEL_LPT           =  0x8c20
77
 
78
CTRL_NVIDIA_MCP51        =  0x026c
79
CTRL_NVIDIA_MCP55        =  0x0371
80
CTRL_NVIDIA_MCP61_1      =  0x03e4
81
CTRL_NVIDIA_MCP61_2      =  0x03f0
82
CTRL_NVIDIA_MCP65_1      =  0x044a
83
CTRL_NVIDIA_MCP65_2      =  0x044b
84
CTRL_NVIDIA_MCP67_1      =  0x055c
85
CTRL_NVIDIA_MCP67_2      =  0x055d
86
CTRL_NVIDIA_MCP78_1      =  0x0774
87
CTRL_NVIDIA_MCP78_2      =  0x0775
88
CTRL_NVIDIA_MCP78_3      =  0x0776
89
CTRL_NVIDIA_MCP78_4      =  0x0777
90
CTRL_NVIDIA_MCP73_1      =  0x07fc
91
CTRL_NVIDIA_MCP73_2      =  0x07fd
92
CTRL_NVIDIA_MCP79_1      =  0x0ac0
93
CTRL_NVIDIA_MCP79_2      =  0x0ac1
94
CTRL_NVIDIA_MCP79_3      =  0x0ac2
95
CTRL_NVIDIA_MCP79_4      =  0x0ac3
96
CTRL_NVIDIA_0BE2         =  0x0be2
97
CTRL_NVIDIA_0BE3         =  0x0be3
98
CTRL_NVIDIA_0BE4         =  0x0be4
99
CTRL_NVIDIA_GT100        =  0x0be5
100
CTRL_NVIDIA_GT106        =  0x0be9
101
CTRL_NVIDIA_GT108        =  0x0bea
102
CTRL_NVIDIA_GT104        =  0x0beb
103
CTRL_NVIDIA_GT116        =  0x0bee
104
CTRL_NVIDIA_MCP89_1      =  0x0d94
105
CTRL_NVIDIA_MCP89_2      =  0x0d95
106
CTRL_NVIDIA_MCP89_3      =  0x0d96
107
CTRL_NVIDIA_MCP89_4      =  0x0d97
108
CTRL_NVIDIA_GF119        =  0x0e08
109
CTRL_NVIDIA_GF110_1      =  0x0e09
110
CTRL_NVIDIA_GF110_2      =  0x0e0c
111
 
112
CTRL_ATI_SB450           =  0x437b
113
CTRL_ATI_SB600           =  0x4383
114
 
115
CTRL_ATI_RS600           =  0x793b
116
CTRL_ATI_RS690           =  0x7919
117
CTRL_ATI_RS780           =  0x960f
118
CTRL_ATI_RS_UNK1         =  0x970f
119
CTRL_ATI_R600            =  0xaa00
120
CTRL_ATI_RV630           =  0xaa08
121
CTRL_ATI_RV610           =  0xaa10
122
CTRL_ATI_RV670           =  0xaa18
123
CTRL_ATI_RV635           =  0xaa20
124
CTRL_ATI_RV620           =  0xaa28
125
CTRL_ATI_RV770           =  0xaa30
126
CTRL_ATI_RV730           =  0xaa38
127
CTRL_ATI_RV710           =  0xaa40
128
CTRL_ATI_RV740           =  0xaa48
129
 
130
CTRL_AMD_HUDSON          =  0x780d
131
 
132
CTRL_VIA_VT82XX          =  0x3288
133
CTRL_VIA_VT61XX          =  0x9140
134
CTRL_VIA_VT71XX          =  0x9170
135
 
136
CTRL_SIS_966             =  0x7502
137
 
138
CTRL_ULI_M5461           =  0x5461
139
 
140
CTRL_CREATIVE_CA0110_IBG     =  0x0009
141
CTRL_CREATIVE_SOUND_CORE3D_1 =  0x0010
142
CTRL_CREATIVE_SOUND_CORE3D_2 =  0x0012
143
 
144
CTRL_TERA_UNK1           =  0x1200
145
 
146
CTRL_RDC_R3010           =  0x3010
147
 
148
CTRL_VMWARE_UNK1         =  0x1977
149
 
3765 Serge 150
struct  SRV
151
        srv_name        rb 16    ;ASCIIZ string
152
        magic           dd ?     ;+0x10 ;'SRV '
153
        size            dd ?     ;+0x14 ;size of structure SRV
154
        fd              dd ?     ;+0x18 ;next SRV descriptor
155
        bk              dd ?     ;+0x1C ;prev SRV descriptor
156
        base            dd ?     ;+0x20 ;service base address
157
        entry           dd ?     ;+0x24 ;service START function
158
        srv_proc        dd ?     ;+0x28 ;user mode service handler
159
        srv_proc_ex     dd ?     ;+0x2C ;kernel mode service handler
160
ends
161
 
162
 
5077 clevermous 163
proc START c uses ebx esi edi, state:dword, cmdline:dword
3171 hidnplayr 164
 
5077 clevermous 165
        mov     eax, [srv_entry]
3171 hidnplayr 166
        cmp     [state], 1
5077 clevermous 167
        jne     .stop
3171 hidnplayr 168
 
169
     if DEBUG
170
        mov     esi, msgInit
5070 hidnplayr 171
        invoke  SysMsgBoardStr
3171 hidnplayr 172
     end if
173
 
5077 clevermous 174
        test    eax, eax
175
        jnz     .done
3171 hidnplayr 176
        call    detect_controller
177
        ret
5077 clevermous 178
.stop:
179
        test    eax, eax
180
        jz      .done
181
        leave
182
        jmp     eax
183
.done:
3171 hidnplayr 184
        xor     eax, eax
185
        ret
186
endp
187
 
188
proc service_proc stdcall, ioctl:dword
189
 
190
        or      eax, -1
191
        ret
192
endp
193
 
194
proc detect_controller
195
 
5070 hidnplayr 196
locals
197
        last_bus dd ?
198
        bus      dd ?
199
        devfn    dd ?
200
endl
3171 hidnplayr 201
 
202
        xor     eax, eax
203
        mov     [bus], eax
204
        inc     eax
5070 hidnplayr 205
        invoke  PciApi
3171 hidnplayr 206
        cmp     eax, -1
207
        je      .err
208
 
209
        mov     [last_bus], eax
210
 
211
  .next_bus:
212
        and     [devfn], 0
213
  .next_dev:
5070 hidnplayr 214
        invoke  PciRead32, [bus], [devfn], dword 0
3171 hidnplayr 215
        test    eax, eax
216
        jz      .next
217
        cmp     eax, -1
218
        je      .next
219
 
220
        mov     edi, devices
221
  @@:
222
        mov     ebx, [edi]
223
        test    ebx, ebx
224
        jz      .next
225
 
226
        cmp     eax, ebx
227
        je      .found
228
        add     edi, 8
229
        jmp     @B
230
  .next:
231
        inc     [devfn]
232
        cmp     [devfn], 256
233
        jb      .next_dev
234
        mov     eax, [bus]
235
        inc     eax
236
        mov     [bus], eax
237
        cmp     eax, [last_bus]
238
        jna     .next_bus
239
        xor     eax, eax
240
        ret
241
  .found:
242
 
243
     if DEBUG
244
        mov     esi, msgLoading
5070 hidnplayr 245
        invoke  SysMsgBoardStr
3171 hidnplayr 246
 
247
        mov     esi, dword[edi+4]
5070 hidnplayr 248
        invoke  SysMsgBoardStr
3171 hidnplayr 249
 
250
        mov     esi, msgNewline
5070 hidnplayr 251
        invoke  SysMsgBoardStr
3171 hidnplayr 252
     end if
253
 
5070 hidnplayr 254
        invoke  GetService, dword[edi+4]
3765 Serge 255
        test    eax, eax
256
        jz      .err
3171 hidnplayr 257
 
3765 Serge 258
        mov     edx, [eax+SRV.entry]
259
        mov     [srv_entry], edx
3171 hidnplayr 260
        ret
261
 
262
  .err:
263
     if DEBUG
264
        mov     esi, msgFail
5070 hidnplayr 265
        invoke  SysMsgBoardStr
3171 hidnplayr 266
     end if
267
 
268
        xor     eax, eax
269
        ret
270
 
271
endp
272
 
273
align 4
3765 Serge 274
devices         dd (CTRL_ICH  shl 16)+VID_INTEL, intelac97
275
                dd (CTRL_ICH0 shl 16)+VID_INTEL, intelac97
276
                dd (CTRL_ICH2 shl 16)+VID_INTEL, intelac97
277
                dd (CTRL_ICH3 shl 16)+VID_INTEL, intelac97
278
                dd (CTRL_ICH4 shl 16)+VID_INTEL, intelac97
279
                dd (CTRL_ICH5 shl 16)+VID_INTEL, intelac97
280
                dd (CTRL_ICH6 shl 16)+VID_INTEL, intelac97
281
                dd (CTRL_ICH7 shl 16)+VID_INTEL, intelac97
3171 hidnplayr 282
 
3765 Serge 283
                dd (CTRL_NFORCE  shl 16)+VID_NVIDIA, intelac97
284
                dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA, intelac97
285
                dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA, intelac97
286
                dd (CTRL_MCP04   shl 16)+VID_NVIDIA, intelac97
287
                dd (CTRL_CK804   shl 16)+VID_NVIDIA, intelac97
288
                dd (CTRL_CK8     shl 16)+VID_NVIDIA, intelac97
289
                dd (CTRL_CK8S    shl 16)+VID_NVIDIA, intelac97
290
                dd (CTRL_MCP51   shl 16)+VID_NVIDIA, intelac97
3171 hidnplayr 291
 
3765 Serge 292
                dd (CTRL_VT82C686  shl 16)+VID_VIA, vt823x
293
                dd (CTRL_VT8233_5  shl 16)+VID_VIA, vt823x
3171 hidnplayr 294
 
3765 Serge 295
                dd (CTRL_SIS  shl 16)+VID_SIS, sis
3171 hidnplayr 296
 
3765 Serge 297
                dd (CTRL_FM801 shl 16)+VID_FM801, fm801
3171 hidnplayr 298
 
3765 Serge 299
                dd (0x5000 shl 16)+0x1274, ensoniq
300
                dd (0x5880 shl 16)+0x1274, ensoniq
3171 hidnplayr 301
 
3765 Serge 302
                dd (CTRL_CT0200 shl 16)+VID_CREATIVE, emu10k1x
3171 hidnplayr 303
; Intel
3765 Serge 304
                dd (CTRL_INTEL_SCH2    shl 16)+VID_INTEL, intelhda
305
                dd (CTRL_INTEL_HPT     shl 16)+VID_INTEL, intelhda
306
                dd (CTRL_INTEL_CPT     shl 16)+VID_INTEL, intelhda
307
                dd (CTRL_INTEL_PGB     shl 16)+VID_INTEL, intelhda
308
                dd (CTRL_INTEL_PPT1    shl 16)+VID_INTEL, intelhda
309
                dd (CTRL_INTEL_82801F  shl 16)+VID_INTEL, intelhda
310
                dd (CTRL_INTEL_63XXESB shl 16)+VID_INTEL, intelhda
311
                dd (CTRL_INTEL_82801G  shl 16)+VID_INTEL, intelhda
312
                dd (CTRL_INTEL_82801H  shl 16)+VID_INTEL, intelhda
313
                dd (CTRL_INTEL_82801_UNK1  shl 16)+VID_INTEL, intelhda
314
                dd (CTRL_INTEL_82801I  shl 16)+VID_INTEL, intelhda
315
                dd (CTRL_INTEL_82801_UNK2  shl 16)+VID_INTEL, intelhda
316
                dd (CTRL_INTEL_82801JI shl 16)+VID_INTEL, intelhda
317
                dd (CTRL_INTEL_82801JD shl 16)+VID_INTEL, intelhda
318
                dd (CTRL_INTEL_PCH     shl 16)+VID_INTEL, intelhda
319
                dd (CTRL_INTEL_PCH2    shl 16)+VID_INTEL, intelhda
320
                dd (CTRL_INTEL_SCH     shl 16)+VID_INTEL, intelhda
321
                dd (CTRL_INTEL_LPT     shl 16)+VID_INTEL, intelhda
3171 hidnplayr 322
; Nvidia
3765 Serge 323
                dd (CTRL_NVIDIA_MCP51    shl 16)+VID_NVIDIA, intelhda
324
                dd (CTRL_NVIDIA_MCP55    shl 16)+VID_NVIDIA, intelhda
325
                dd (CTRL_NVIDIA_MCP61_1  shl 16)+VID_NVIDIA, intelhda
326
                dd (CTRL_NVIDIA_MCP61_2  shl 16)+VID_NVIDIA, intelhda
327
                dd (CTRL_NVIDIA_MCP65_1  shl 16)+VID_NVIDIA, intelhda
328
                dd (CTRL_NVIDIA_MCP65_2  shl 16)+VID_NVIDIA, intelhda
329
                dd (CTRL_NVIDIA_MCP67_1  shl 16)+VID_NVIDIA, intelhda
330
                dd (CTRL_NVIDIA_MCP67_2  shl 16)+VID_NVIDIA, intelhda
331
                dd (CTRL_NVIDIA_MCP73_1  shl 16)+VID_NVIDIA, intelhda
332
                dd (CTRL_NVIDIA_MCP73_2  shl 16)+VID_NVIDIA, intelhda
333
                dd (CTRL_NVIDIA_MCP78_1  shl 16)+VID_NVIDIA, intelhda
334
                dd (CTRL_NVIDIA_MCP78_2  shl 16)+VID_NVIDIA, intelhda
335
                dd (CTRL_NVIDIA_MCP78_3  shl 16)+VID_NVIDIA, intelhda
336
                dd (CTRL_NVIDIA_MCP78_4  shl 16)+VID_NVIDIA, intelhda
337
                dd (CTRL_NVIDIA_MCP79_1  shl 16)+VID_NVIDIA, intelhda
338
                dd (CTRL_NVIDIA_MCP79_2  shl 16)+VID_NVIDIA, intelhda
339
                dd (CTRL_NVIDIA_MCP79_3  shl 16)+VID_NVIDIA, intelhda
340
                dd (CTRL_NVIDIA_MCP79_4  shl 16)+VID_NVIDIA, intelhda
341
                dd (CTRL_NVIDIA_0BE2     shl 16)+VID_NVIDIA, intelhda
342
                dd (CTRL_NVIDIA_0BE3     shl 16)+VID_NVIDIA, intelhda
343
                dd (CTRL_NVIDIA_0BE4     shl 16)+VID_NVIDIA, intelhda
344
                dd (CTRL_NVIDIA_GT100    shl 16)+VID_NVIDIA, intelhda
345
                dd (CTRL_NVIDIA_GT106    shl 16)+VID_NVIDIA, intelhda
346
                dd (CTRL_NVIDIA_GT108    shl 16)+VID_NVIDIA, intelhda
347
                dd (CTRL_NVIDIA_GT104    shl 16)+VID_NVIDIA, intelhda
348
                dd (CTRL_NVIDIA_GT116    shl 16)+VID_NVIDIA, intelhda
349
                dd (CTRL_NVIDIA_MCP89_1  shl 16)+VID_NVIDIA, intelhda
350
                dd (CTRL_NVIDIA_MCP89_2  shl 16)+VID_NVIDIA, intelhda
351
                dd (CTRL_NVIDIA_MCP89_3  shl 16)+VID_NVIDIA, intelhda
352
                dd (CTRL_NVIDIA_MCP89_4  shl 16)+VID_NVIDIA, intelhda
353
                dd (CTRL_NVIDIA_GF119    shl 16)+VID_NVIDIA, intelhda
354
                dd (CTRL_NVIDIA_GF110_1  shl 16)+VID_NVIDIA, intelhda
355
                dd (CTRL_NVIDIA_GF110_2  shl 16)+VID_NVIDIA, intelhda
3171 hidnplayr 356
; ATI
3765 Serge 357
                dd (CTRL_ATI_SB450   shl 16)+VID_ATI, intelhda
358
                dd (CTRL_ATI_SB600   shl 16)+VID_ATI, intelhda
359
                dd (CTRL_ATI_RS600   shl 16)+VID_ATI, intelhda
360
                dd (CTRL_ATI_RS690   shl 16)+VID_ATI, intelhda
361
                dd (CTRL_ATI_RS780   shl 16)+VID_ATI, intelhda
362
                dd (CTRL_ATI_RS_UNK1 shl 16)+VID_ATI, intelhda
363
                dd (CTRL_ATI_R600    shl 16)+VID_ATI, intelhda
364
                dd (CTRL_ATI_RV610   shl 16)+VID_ATI, intelhda
365
                dd (CTRL_ATI_RV620   shl 16)+VID_ATI, intelhda
366
                dd (CTRL_ATI_RV630   shl 16)+VID_ATI, intelhda
367
                dd (CTRL_ATI_RV635   shl 16)+VID_ATI, intelhda
368
                dd (CTRL_ATI_RV670   shl 16)+VID_ATI, intelhda
369
                dd (CTRL_ATI_RV710   shl 16)+VID_ATI, intelhda
370
                dd (CTRL_ATI_RV730   shl 16)+VID_ATI, intelhda
371
                dd (CTRL_ATI_RV740   shl 16)+VID_ATI, intelhda
372
                dd (CTRL_ATI_RV770   shl 16)+VID_ATI, intelhda
3171 hidnplayr 373
; AMD
3765 Serge 374
                dd (CTRL_AMD_HUDSON shl 16)+VID_AMD, intelhda
3171 hidnplayr 375
; VIA
3765 Serge 376
                dd (CTRL_VIA_VT82XX shl 16)+VID_VIA, intelhda
377
                dd (CTRL_VIA_VT61XX shl 16)+VID_VIA, intelhda
378
                dd (CTRL_VIA_VT71XX shl 16)+VID_VIA, intelhda
3171 hidnplayr 379
; SiS
3765 Serge 380
                dd (CTRL_SIS_966    shl 16)+VID_SIS, intelhda
3171 hidnplayr 381
; ULI
3765 Serge 382
                dd (CTRL_ULI_M5461  shl 16)+VID_ULI, intelhda
3171 hidnplayr 383
; Teradici
3765 Serge 384
                dd (CTRL_TERA_UNK1  shl 16)+VID_ULI, intelhda
3171 hidnplayr 385
; Creative
3765 Serge 386
                dd (CTRL_CREATIVE_CA0110_IBG     shl 16)+VID_CREATIVE, intelhda
387
                dd (CTRL_CREATIVE_SOUND_CORE3D_1 shl 16)+VID_CREATIVE, intelhda
388
                dd (CTRL_CREATIVE_SOUND_CORE3D_2 shl 16)+VID_CREATIVE, intelhda
3171 hidnplayr 389
; RDC Semiconductor
3765 Serge 390
                dd (CTRL_RDC_R3010  shl 16)+VID_RDC, intelhda
3171 hidnplayr 391
; VMware
3765 Serge 392
                dd (CTRL_VMWARE_UNK1  shl 16)+VID_VMWARE, intelhda
3171 hidnplayr 393
 
5070 hidnplayr 394
                dd 0    ; terminator
3171 hidnplayr 395
 
396
 
3765 Serge 397
srv_entry       dd 0
398
 
3171 hidnplayr 399
intelac97       db 'INTELAC97', 0
400
vt823x          db 'VT823X', 0
401
sis             db 'SIS', 0
402
fm801           db 'FM801', 0
403
ensoniq         db 'ENSONIQ', 0
404
emu10k1x        db 'EMU10K1X', 0
405
intelhda        db 'INTEL_HDA', 0
406
 
407
msgInit         db 'Detecting hardware...',13,10,0
5077 clevermous 408
msgFail         db 'No compatible soundcard found!',13,10,0
3171 hidnplayr 409
msgLoading      db 'Loading ',0
410
msgNewline      db 13,10,0
411
 
5070 hidnplayr 412
align 4
413
data fixups
5071 hidnplayr 414
end data