Subversion Repositories Kolibri OS

Rev

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

Rev 3539 Rev 5077
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
-
 
8
format PE DLL native 0.05
Line 8... Line 9...
8
format MS COFF
9
entry START
9
 
10
 
Line 10... Line -...
10
DEBUG           equ 1
-
 
11
DEBUG_IRQ       equ 0
-
 
12
 
-
 
13
include 'proc32.inc'
11
DEBUG           equ 1
Line 14... Line 12...
14
include 'imports.inc'
12
DEBUG_IRQ       equ 0
Line 15... Line 13...
15
 
13
 
Line 274... Line 272...
274
    .codec_mem_base   dd ?
272
    .codec_mem_base   dd ?
275
    .ctrl_mem_base    dd ?
273
    .ctrl_mem_base    dd ?
276
    .codec_id         dd ?
274
    .codec_id         dd ?
277
}
275
}
Line 278... Line -...
278
 
-
 
279
struc IOCTL
-
 
280
{  .handle            dd ?
-
 
281
   .io_code           dd ?
-
 
282
   .input             dd ?
-
 
283
   .inp_size          dd ?
-
 
284
   .output            dd ?
-
 
285
   .out_size          dd ?
-
 
286
}
-
 
287
 
-
 
288
virtual at 0
-
 
289
  IOCTL IOCTL
-
 
290
end virtual
-
 
291
 
276
 
Line -... Line 277...
-
 
277
EVENT_NOTIFY      equ 0x00000200
292
EVENT_NOTIFY      equ 0x00000200
278
 
293
 
279
section '.flat' code readable writable executable
294
public START
280
include '../struct.inc'
295
public service_proc
-
 
296
public version
281
include '../macros.inc'
Line 297... Line 282...
297
 
282
include '../proc32.inc'
Line 298... Line 283...
298
section '.flat' code readable align 16
283
include '../peimport.inc'
299
 
284
 
Line 300... Line 285...
300
proc START stdcall, state:dword
285
proc START c uses ebx esi edi, state:dword, cmdline:dword
301
 
286
 
302
        cmp     [state], 1
287
        cmp     [state], 1
303
        jne     .stop
288
        jne     .stop
304
 
289
 
305
     if DEBUG
290
     if DEBUG
306
        mov     eax, START
291
        mov     eax, START
Line 307... Line 292...
307
        call    dword2str
292
        call    dword2str
308
        call    SysMsgBoardStr
293
        invoke  SysMsgBoardStr
309
        mov     esi, msgInit
294
        mov     esi, msgInit
Line 310... Line 295...
310
        call    SysMsgBoardStr
295
        invoke  SysMsgBoardStr
311
     end if
296
     end if
312
 
297
 
313
        call    detect_controller
298
        call    detect_controller
314
        test    eax, eax
299
        test    eax, eax
Line 315... Line 300...
315
        jz      .fail
300
        jz      .fail
Line 316... Line 301...
316
 
301
 
317
     if DEBUG
302
     if DEBUG
Line 332... Line 317...
332
 
317
 
333
        call    reset_controller
318
        call    reset_controller
Line 334... Line 319...
334
        call    setup_codec
319
        call    setup_codec
335
 
320
 
336
        mov     esi, msgPrimBuff
321
        mov     esi, msgPrimBuff
Line 337... Line 322...
337
        call    SysMsgBoardStr
322
        invoke  SysMsgBoardStr
338
        call    create_primary_buff
323
        call    create_primary_buff
Line 339... Line 324...
339
 
324
 
340
        mov     esi, msgDone
325
        mov     esi, msgDone
341
        call    SysMsgBoardStr
326
        invoke  SysMsgBoardStr
342
 
327
 
Line 348... Line 333...
348
        mov     eax, ATTCH_IRQ
333
        mov     eax, ATTCH_IRQ
349
        mov     esi, msgAttchIRQ
334
        mov     esi, msgAttchIRQ
350
        bt      eax, ebx
335
        bt      eax, ebx
351
        jnc     .fail_msg
336
        jnc     .fail_msg
Line 352... Line 337...
352
 
337
 
353
        stdcall AttachIntHandler, ebx, ac97_irq, dword 0
338
        invoke  AttachIntHandler, ebx, ac97_irq, dword 0
Line 354... Line 339...
354
.reg:
339
.reg:
355
 
340
 
356
        stdcall RegService, sz_sound_srv, service_proc
341
        invoke  RegService, sz_sound_srv, service_proc
357
        ret
342
        ret
358
.fail:
343
.fail:
359
   if DEBUG
344
   if DEBUG
360
        mov     esi, msgFail
345
        mov     esi, msgFail
361
        call    SysMsgBoardStr
346
        invoke  SysMsgBoardStr
362
   end if
347
   end if
363
        xor     eax, eax
348
        xor     eax, eax
364
        ret
349
        ret
365
.fail_msg:
350
.fail_msg:
366
        call    SysMsgBoardStr
351
        invoke  SysMsgBoardStr
367
        xor     eax, eax
352
        xor     eax, eax
368
        ret
353
        ret
369
.stop:
354
.stop:
Line 398... Line 383...
398
@@:
383
@@:
399
        cmp     eax, DEV_PLAY
384
        cmp     eax, DEV_PLAY
400
        jne     @F
385
        jne     @F
401
     if DEBUG
386
     if DEBUG
402
        mov     esi, msgPlay
387
        mov     esi, msgPlay
403
        call    SysMsgBoardStr
388
        invoke  SysMsgBoardStr
404
     end if
389
     end if
405
        call    play
390
        call    play
406
        ret
391
        ret
407
@@:
392
@@:
408
        cmp     eax, DEV_STOP
393
        cmp     eax, DEV_STOP
409
        jne     @F
394
        jne     @F
410
     if DEBUG
395
     if DEBUG
411
        mov     esi, msgStop
396
        mov     esi, msgStop
412
        call    SysMsgBoardStr
397
        invoke  SysMsgBoardStr
413
     end if
398
     end if
414
        call    stop
399
        call    stop
415
        ret
400
        ret
416
@@:
401
@@:
417
        cmp     eax, DEV_CALLBACK
402
        cmp     eax, DEV_CALLBACK
Line 483... Line 468...
483
align 4
468
align 4
484
proc ac97_irq
469
proc ac97_irq
Line 485... Line 470...
485
 
470
 
486
     if DEBUG_IRQ
471
     if DEBUG_IRQ
487
        mov     esi, msgIRQ
472
        mov     esi, msgIRQ
488
        call    SysMsgBoardStr
473
        invoke  SysMsgBoardStr
Line 489... Line 474...
489
     end if
474
     end if
490
 
475
 
Line 506... Line 491...
506
endp
491
endp
Line 507... Line 492...
507
 
492
 
508
align 4
493
align 4
Line 509... Line 494...
509
proc create_primary_buff
494
proc create_primary_buff
510
 
495
 
Line 511... Line 496...
511
        stdcall KernelAlloc, 0x10000
496
        invoke  KernelAlloc, 0x10000
512
        mov     [ctrl.buffer], eax
497
        mov     [ctrl.buffer], eax
513
 
498
 
514
        mov     edi, eax
499
        mov     edi, eax
515
        mov     ecx, 0x10000/4
500
        mov     ecx, 0x10000/4
Line 516... Line 501...
516
        xor     eax, eax
501
        xor     eax, eax
517
        cld
502
        cld
518
        rep stosd
503
        rep stosd
Line 519... Line 504...
519
 
504
 
520
        mov     eax, [ctrl.buffer]
505
        mov     eax, [ctrl.buffer]
Line 533... Line 518...
533
           endl
518
           endl
Line 534... Line 519...
534
 
519
 
535
        xor     eax, eax
520
        xor     eax, eax
536
        mov     [bus], eax
521
        mov     [bus], eax
537
        inc     eax
522
        inc     eax
538
        call    PciApi
523
        invoke  PciApi
539
        cmp     eax, -1
524
        cmp     eax, -1
Line 540... Line 525...
540
        je      .err
525
        je      .err
Line 541... Line 526...
541
 
526
 
542
        mov     [last_bus], eax
527
        mov     [last_bus], eax
543
 
528
 
544
.next_bus:
529
.next_bus:
545
        and     [devfn], 0
530
        and     [devfn], 0
546
.next_dev:
531
.next_dev:
547
        stdcall PciRead32, [bus], [devfn], dword 0
532
        invoke  PciRead32, [bus], [devfn], dword 0
548
        test    eax, eax
533
        test    eax, eax
Line 549... Line 534...
549
        jz      .next
534
        jz      .next
550
        cmp     eax, -1
535
        cmp     eax, -1
551
        je      .next
536
        je      .next
552
 
537
 
553
        push    eax
538
        push    eax
Line 554... Line 539...
554
        stdcall PciRead32, [bus], [devfn], dword 0x09
539
        invoke  PciRead32, [bus], [devfn], dword 0x09
Line 610... Line 595...
610
endp
595
endp
Line 611... Line 596...
611
 
596
 
612
align 4
597
align 4
Line 613... Line 598...
613
proc init_controller
598
proc init_controller
614
 
599
 
615
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
600
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 4
616
        mov     ebx, eax
601
        mov     ebx, eax
617
        and     eax, 0xFFFF
602
        and     eax, 0xFFFF
618
        mov     [ctrl.pci_cmd], eax
603
        mov     [ctrl.pci_cmd], eax
Line 619... Line 604...
619
        shr     ebx, 16
604
        shr     ebx, 16
620
        mov     [ctrl.pci_stat], ebx
605
        mov     [ctrl.pci_stat], ebx
621
 
606
 
622
        mov     esi, msgPciCmd
607
        mov     esi, msgPciCmd
Line 623... Line 608...
623
        call    SysMsgBoardStr
608
        invoke  SysMsgBoardStr
624
        call    dword2str
609
        call    dword2str
625
        call    SysMsgBoardStr
610
        invoke  SysMsgBoardStr
626
 
611
 
627
        mov     esi, msgPciStat
612
        mov     esi, msgPciStat
Line 628... Line 613...
628
        call    SysMsgBoardStr
613
        invoke  SysMsgBoardStr
629
        mov     eax, [ctrl.pci_stat]
614
        mov     eax, [ctrl.pci_stat]
Line 630... Line 615...
630
        call    dword2str
615
        call    dword2str
Line 631... Line 616...
631
        call    SysMsgBoardStr
616
        invoke  SysMsgBoardStr
632
 
617
 
Line 633... Line 618...
633
        mov     esi, msgCtrlIsaIo
618
        mov     esi, msgCtrlIsaIo
634
        call    SysMsgBoardStr
619
        invoke  SysMsgBoardStr
Line 635... Line 620...
635
 
620
 
636
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
621
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
Line 637... Line 622...
637
 
622
 
638
        call    dword2str
623
        call    dword2str
639
        call    SysMsgBoardStr
624
        invoke  SysMsgBoardStr
Line 640... Line 625...
640
 
625
 
641
        and     eax, 0xFFFE
626
        and     eax, 0xFFFE
Line 642... Line 627...
642
        mov     [ctrl.ctrl_io_base], eax
627
        mov     [ctrl.ctrl_io_base], eax
643
 
628
 
644
        mov     esi, msgIrqNum
629
        mov     esi, msgIrqNum
645
        call    SysMsgBoardStr
630
        invoke  SysMsgBoardStr
Line 674... Line 659...
674
 
659
 
675
align 4
660
align 4
Line 676... Line 661...
676
proc reset_controller
661
proc reset_controller
677
 
662
 
Line 678... Line 663...
678
        mov     esi, msgInitCtrl
663
        mov     esi, msgInitCtrl
679
        call    SysMsgBoardStr
664
        invoke  SysMsgBoardStr
680
 
665
 
681
        mov     edx, FM_CARD_CTL
666
        mov     edx, FM_CARD_CTL
Line 717... Line 702...
717
 
702
 
718
align 4
703
align 4
Line 719... Line 704...
719
proc init_codec
704
proc init_codec
720
 
705
 
Line 721... Line 706...
721
        mov     esi, msgInitCodec
706
        mov     esi, msgInitCodec
722
        call    SysMsgBoardStr
707
        invoke  SysMsgBoardStr
723
 
708
 
Line 1022... Line 1007...
1022
 
1007
 
1023
align 4
1008
align 4
1024
devices dd (CTRL_FM801 shl 16)+VID_FM801, msg_FM801, set_FM
1009
devices dd (CTRL_FM801 shl 16)+VID_FM801, msg_FM801, set_FM
Line 1025... Line -...
1025
        dd 0
-
 
1026
 
-
 
1027
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
1010
        dd 0
1028
 
1011
 
Line 1029... Line 1012...
1029
msg_FM801    db 'FM801 AC97 controller',13,10, 0
1012
msg_FM801    db 'FM801 AC97 controller',13,10, 0
Line 1051... Line 1034...
1051
msgPciStat    db 'PCI status      ',0
1034
msgPciStat    db 'PCI status      ',0
1052
msgCtrlIsaIo  db 'controller io base   ',0
1035
msgCtrlIsaIo  db 'controller io base   ',0
1053
msgIrqNum     db 'IRQ default          ',0
1036
msgIrqNum     db 'IRQ default          ',0
1054
;msgIrqMap    db 'AC97 irq map as      ',0
1037
;msgIrqMap    db 'AC97 irq map as      ',0
Line -... Line 1038...
-
 
1038
 
-
 
1039
align 4
1055
 
1040
data fixups
Line 1056... Line 1041...
1056
section '.data' data readable writable align 16
1041
end data
1057
 
1042
 
Line 1058... Line 1043...
1058
codec CODEC
1043
codec CODEC