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 MS COFF
8
format PE DLL native 0.05
Line 9... Line 9...
9
 
9
entry START
Line 10... Line -...
10
 
-
 
11
DEBUG           equ 1
-
 
12
 
-
 
13
include 'proc32.inc'
10
 
14
include 'imports.inc'
11
DEBUG           equ 1
Line 15... Line 12...
15
 
12
 
16
API_VERSION     equ 0x01000100
13
API_VERSION     equ 0x01000100
Line 28... Line 25...
28
 
25
 
29
if USE_COM_IRQ
26
if USE_COM_IRQ
30
ATTCH_IRQ       equ 0000111010111000b
27
ATTCH_IRQ       equ 0000111010111000b
Line 31... Line 28...
31
end if
28
end if
Line 32... Line 29...
32
 
29
 
33
CPU_FREQ        equ  2600d
30
CPU_FREQ        equ  2000d
34
 
31
 
35
BIT0  EQU 0x00000001
32
BIT0  EQU 0x00000001
Line 249... Line 246...
249
    .codec_mem_base   dd ?
246
    .codec_mem_base   dd ?
250
    .ctrl_mem_base    dd ?
247
    .ctrl_mem_base    dd ?
251
    .codec_id         dd ?
248
    .codec_id         dd ?
252
}
249
}
Line 253... Line -...
253
 
-
 
254
struc IOCTL
-
 
255
{  .handle            dd ?
-
 
256
   .io_code           dd ?
-
 
257
   .input             dd ?
-
 
258
   .inp_size          dd ?
-
 
259
   .output            dd ?
-
 
260
   .out_size          dd ?
-
 
261
}
-
 
262
 
-
 
263
virtual at 0
-
 
264
  IOCTL IOCTL
-
 
265
end virtual
-
 
266
 
250
 
Line -... Line 251...
-
 
251
EVENT_NOTIFY          equ 0x00000200
267
EVENT_NOTIFY          equ 0x00000200
252
 
268
 
253
section '.flat' code readable writable executable
269
public START
254
include '../struct.inc'
-
 
255
include '../macros.inc'
Line 270... Line -...
270
public service_proc
-
 
Line 271... Line 256...
271
public version
256
include '../proc32.inc'
Line 272... Line 257...
272
 
257
include '../peimport.inc'
273
section '.flat' code readable align 16
258
 
Line 274... Line 259...
274
 
259
 
275
proc START stdcall, state:dword
260
proc START c uses ebx esi edi, state:dword, cmdline:dword
276
 
261
 
277
        cmp     [state], 1
262
        cmp     [state], 1
Line 278... Line 263...
278
        jne     .stop
263
        jne     .stop
279
 
264
 
280
     if DEBUG
265
     if DEBUG
Line 281... Line 266...
281
        mov     esi, msgInit
266
        mov     esi, msgInit
282
        call    SysMsgBoardStr
267
        invoke  SysMsgBoardStr
283
     end if
268
     end if
284
 
269
 
285
        call    detect_controller
270
        call    detect_controller
Line 286... Line 271...
286
        test    eax, eax
271
        test    eax, eax
Line 287... Line 272...
287
        jz      .fail
272
        jz      .fail
288
 
273
 
Line 304... Line 289...
304
 
289
 
305
        call    reset_controller
290
        call    reset_controller
Line 306... Line 291...
306
        call    setup_codec
291
        call    setup_codec
307
 
292
 
308
        mov     esi, msgPrimBuff
293
        mov     esi, msgPrimBuff
309
        call    SysMsgBoardStr
294
        invoke  SysMsgBoardStr
310
        call    create_primary_buff
295
        call    create_primary_buff
Line 311... Line 296...
311
        mov     esi, msgDone
296
        mov     esi, msgDone
312
        call    SysMsgBoardStr
297
        invoke  SysMsgBoardStr
313
 
298
 
Line 320... Line 305...
320
        mov     ah, al
305
        mov     ah, al
321
        in      al, 0x21
306
        in      al, 0x21
322
        test    ebx, ebx
307
        test    ebx, ebx
323
        jz      .skip
308
        jz      .skip
324
        bts     ax, bx                     ;mask old line
309
        bts     ax, bx                     ;mask old line
325
.skip
310
.skip:
326
        bts     ax, IRQ_LINE               ;mask new ine
311
        bts     ax, IRQ_LINE               ;mask new ine
327
        out     0x21, al
312
        out     0x21, al
328
        mov     al, ah
313
        mov     al, ah
329
        out     0xA1, al
314
        out     0xA1, al
330
                                           ;remap IRQ
315
                                           ;remap IRQ
331
        stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
316
        invoke  PciWrite8, 0, 0xF8, 0x61, IRQ_LINE
Line 332... Line 317...
332
 
317
 
333
        mov     dx, 0x4d0                  ;8259 ELCR1
318
        mov     dx, 0x4d0                  ;8259 ELCR1
334
        in      al, dx
319
        in      al, dx
335
        bts     ax, IRQ_LINE
320
        bts     ax, IRQ_LINE
336
        out     dx, al                     ;set level-triggered mode
321
        out     dx, al                     ;set level-triggered mode
337
        mov     [ctrl.int_line], IRQ_LINE
322
        mov     [ctrl.int_line], IRQ_LINE
338
        popf
323
        popf
339
        mov     esi, msgRemap
324
        mov     esi, msgRemap
340
        call    SysMsgBoardStr
325
        invoke  SysMsgBoardStr
Line 341... Line 326...
341
  end if
326
  end if
342
 
327
 
343
        mov     eax, VALID_IRQ
328
        mov     eax, VALID_IRQ
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, 0
354
.reg:
339
.reg:
355
        stdcall RegService, sz_sound_srv, service_proc
340
        invoke  RegService, sz_sound_srv, service_proc
356
        ret
341
        ret
357
.fail:
342
.fail:
358
   if DEBUG
343
   if DEBUG
359
        mov     esi, msgFail
344
        mov     esi, msgFail
360
        call    SysMsgBoardStr
345
        invoke  SysMsgBoardStr
361
   end if
346
   end if
362
        xor     eax, eax
347
        xor     eax, eax
363
        ret
348
        ret
364
.fail_msg:
349
.fail_msg:
365
        call    SysMsgBoardStr
350
        invoke  SysMsgBoardStr
366
        xor     eax, eax
351
        xor     eax, eax
367
        ret
352
        ret
368
.stop:
353
.stop:
369
        call    stop
354
        call    stop
Line 397... Line 382...
397
@@:
382
@@:
398
        cmp     eax, DEV_PLAY
383
        cmp     eax, DEV_PLAY
399
        jne     @F
384
        jne     @F
400
     if DEBUG
385
     if DEBUG
401
        mov     esi, msgPlay
386
        mov     esi, msgPlay
402
        call    SysMsgBoardStr
387
        invoke  SysMsgBoardStr
403
     end if
388
     end if
404
        call    play
389
        call    play
405
        ret
390
        ret
406
@@:
391
@@:
407
        cmp     eax, DEV_STOP
392
        cmp     eax, DEV_STOP
408
        jne     @F
393
        jne     @F
409
     if DEBUG
394
     if DEBUG
410
        mov     esi, msgStop
395
        mov     esi, msgStop
411
        call    SysMsgBoardStr
396
        invoke  SysMsgBoardStr
412
     end if
397
     end if
413
        call    stop
398
        call    stop
414
        ret
399
        ret
415
@@:
400
@@:
416
        cmp     eax, DEV_CALLBACK
401
        cmp     eax, DEV_CALLBACK
Line 453... Line 438...
453
align 4
438
align 4
454
proc ac97_irq
439
proc ac97_irq
Line 455... Line 440...
455
 
440
 
456
     if DEBUG_IRQ
441
     if DEBUG_IRQ
457
        mov     esi, msgIRQ
442
        mov     esi, msgIRQ
458
        call    SysMsgBoardStr
443
        invoke  SysMsgBoardStr
Line 459... Line 444...
459
     end if
444
     end if
460
 
445
 
461
        mov     edx, PCM_OUT_CR_REG
446
        mov     edx, PCM_OUT_CR_REG
Line 505... Line 490...
505
endp
490
endp
Line 506... Line 491...
506
 
491
 
507
align 4
492
align 4
Line 508... Line 493...
508
proc create_primary_buff
493
proc create_primary_buff
509
 
494
 
Line 510... Line 495...
510
        stdcall KernelAlloc, 0x10000
495
        invoke  KernelAlloc, 0x10000
511
        mov     [ctrl.buffer], eax
496
        mov     [ctrl.buffer], eax
512
 
497
 
513
        mov     edi, eax
498
        mov     edi, eax
514
        mov     ecx, 0x10000/4
499
        mov     ecx, 0x10000/4
Line 515... Line 500...
515
        xor     eax, eax
500
        xor     eax, eax
516
        cld
501
        cld
Line 517... Line 502...
517
        rep stosd
502
        rep stosd
518
 
503
 
519
        mov     eax, [ctrl.buffer]
504
        mov     eax, [ctrl.buffer]
520
        call    GetPgAddr
505
        invoke  GetPgAddr
Line 568... Line 553...
568
        add     edi, 4
553
        add     edi, 4
569
        loop    @B
554
        loop    @B
Line 570... Line 555...
570
 
555
 
571
        mov     eax, pcmout_bdl
556
        mov     eax, pcmout_bdl
572
        mov     ebx, eax
557
        mov     ebx, eax
573
        call    GetPgAddr     ;eax
558
        invoke  GetPgAddr     ;eax
574
        and     ebx, 0xFFF
559
        and     ebx, 0xFFF
Line 575... Line 560...
575
        add     eax, ebx
560
        add     eax, ebx
576
 
561
 
Line 591... Line 576...
591
        ret
576
        ret
592
endp
577
endp
Line 593... Line 578...
593
 
578
 
594
align 4
579
align 4
595
proc detect_controller
-
 
596
           locals
-
 
597
             last_bus dd ?
-
 
598
             bus      dd ?
-
 
599
             devfn    dd ?
-
 
600
           endl
-
 
601
 
-
 
602
        xor     eax, eax
-
 
603
        mov     [bus], eax
580
proc detect_controller
604
        inc     eax
581
        push    ebx
605
        call    PciApi
582
        invoke  GetPCIList
606
        cmp     eax, -1
-
 
607
        je      .err
-
 
608
 
-
 
609
        mov     [last_bus], eax
-
 
610
 
-
 
611
.next_bus:
-
 
612
        and     [devfn], 0
583
        mov     ebx, eax
613
.next_dev:
-
 
614
        stdcall PciRead32, [bus], [devfn], dword 0
-
 
615
        test    eax, eax
-
 
616
        jz      .next
-
 
617
        cmp     eax, -1
-
 
618
        je      .next
-
 
619
 
-
 
620
        mov     edi, devices
-
 
621
@@:
584
.next_dev:
622
        mov     ebx, [edi]
-
 
623
        test    ebx, ebx
-
 
624
        jz      .next
-
 
625
 
585
        mov     eax, [eax+PCIDEV.fd]
626
        cmp     eax, ebx
586
        cmp     eax, ebx
-
 
587
        je      .err
627
        je      .found
588
        cmp     [eax+PCIDEV.class], 0x060100  ;pci-isa
-
 
589
        jne     .no_bridge
628
        add     edi, 12
590
        movzx   edx, [eax+PCIDEV.bus]
-
 
591
        mov     [brg_bus], edx
-
 
592
        movzx   edx, [eax+PCIDEV.devfn]
629
        jmp     @B
593
        mov     [brg_devfn], edx
-
 
594
.no_bridge:
630
.next:
595
        mov     edx, [eax+PCIDEV.vendor_device_id]
-
 
596
        mov     esi, devices
631
        inc     [devfn]
597
@@:
632
        cmp     [devfn], 256
598
        cmp     dword [esi], 0
633
        jb      .next_dev
599
        jz      .next_dev
634
        mov     eax, [bus]
600
        cmp     dword [esi], edx
635
        inc     eax
601
        jz      .found
636
        mov     [bus], eax
602
        add     esi, 12
637
        cmp     eax, [last_bus]
603
        jmp     @b
638
        jna     .next_bus
604
.err:
-
 
605
        xor     eax, eax
639
        xor     eax, eax
606
        pop     ebx
640
        ret
607
        ret
641
.found:
608
.found:
642
        mov     ebx, [bus]
609
        movzx   ebx, [eax+PCIDEV.bus]
Line 643... Line 610...
643
        mov     [ctrl.bus], ebx
610
        mov     [ctrl.bus], ebx
644
 
611
 
Line 645... Line 612...
645
        mov     ecx, [devfn]
612
        movzx   ecx, [eax+PCIDEV.devfn]
646
        mov     [ctrl.devfn], ecx
613
        mov     [ctrl.devfn], ecx
647
 
614
 
648
        mov     edx, eax
615
        mov     eax, edx
649
        and     edx, 0xFFFF
616
        and     edx, 0xFFFF
Line 650... Line 617...
650
        mov     [ctrl.vendor], edx
617
        mov     [ctrl.vendor], edx
651
        shr     eax, 16
618
        shr     eax, 16
652
        mov     [ctrl.dev_id], eax
619
        mov     [ctrl.dev_id], eax
Line 653... Line 620...
653
 
620
 
654
        mov     ebx, [edi+4]
621
        mov     ebx, [esi+4]
655
        mov     [ctrl.ctrl_ids], ebx
-
 
656
        mov     [ctrl.vendor_ids], msg_SIS
-
 
657
 
622
        mov     [ctrl.ctrl_ids], ebx
658
        mov     esi, [edi+8]
623
        mov     [ctrl.vendor_ids], msg_SIS
659
        mov     [ctrl.ctrl_setup], esi
624
 
Line 660... Line 625...
660
        ret
625
        mov     eax, [esi+8]
661
.err:
626
        mov     [ctrl.ctrl_setup], eax
Line 662... Line 627...
662
        xor     eax, eax
627
        pop     ebx
663
        ret
628
        ret
-
 
629
endp
-
 
630
 
664
endp
631
align 4
665
 
632
proc init_controller
666
align 4
633
 
667
proc init_controller
634
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 4
Line 668... Line 635...
668
 
635
        mov     ebx, eax
669
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
636
        or      al, 5
670
        mov     ebx, eax
637
        invoke  PciWrite16, [ctrl.bus], [ctrl.devfn], 4, eax
671
        and     eax, 0xFFFF
638
        movzx   eax, bx
Line 672... Line 639...
672
        mov     [ctrl.pci_cmd], eax
639
        mov     [ctrl.pci_cmd], eax
673
        shr     ebx, 16
640
        shr     ebx, 16
674
        mov     [ctrl.pci_stat], ebx
641
        mov     [ctrl.pci_stat], ebx
675
 
642
 
676
        mov     esi, msgPciCmd
643
        mov     esi, msgPciCmd
Line 677... Line 644...
677
        call    SysMsgBoardStr
644
        invoke  SysMsgBoardStr
678
        call    dword2str
645
        call    dword2str
Line 679... Line 646...
679
        call    SysMsgBoardStr
646
        invoke  SysMsgBoardStr
Line 680... Line 647...
680
 
647
 
681
        mov     esi, msgPciStat
648
        mov     esi, msgPciStat
Line 682... Line 649...
682
        call    SysMsgBoardStr
649
        invoke  SysMsgBoardStr
683
        mov     eax, [ctrl.pci_stat]
650
        mov     eax, [ctrl.pci_stat]
Line 684... Line 651...
684
        call    dword2str
651
        call    dword2str
685
        call    SysMsgBoardStr
652
        invoke  SysMsgBoardStr
Line 686... Line 653...
686
 
653
 
Line 687... Line 654...
687
        mov     esi, msgMixIsaIo
654
        mov     esi, msgMixIsaIo
688
        call    SysMsgBoardStr
655
        invoke  SysMsgBoardStr
Line 689... Line 656...
689
 
656
 
690
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
657
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x10
Line 691... Line 658...
691
 
658
 
692
        call    dword2str
659
        call    dword2str
Line 693... Line 660...
693
        call    SysMsgBoardStr
660
        invoke  SysMsgBoardStr
694
 
661
 
Line 695... Line 662...
695
        and     eax, 0xFFFE
662
        and     eax, 0xFFFE
696
        mov     [ctrl.codec_io_base], eax
663
        mov     [ctrl.codec_io_base], eax
Line 697... Line 664...
697
 
664
 
698
        mov     esi, msgCtrlIsaIo
665
        mov     esi, msgCtrlIsaIo
Line 699... Line 666...
699
        call    SysMsgBoardStr
666
        invoke  SysMsgBoardStr
700
 
667
 
Line 701... Line 668...
701
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
668
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x14
702
 
669
 
703
        call    dword2str
670
        call    dword2str
704
        call    SysMsgBoardStr
671
        invoke  SysMsgBoardStr
-
 
672
 
-
 
673
        and     eax, 0xFFC0
-
 
674
        mov     [ctrl.ctrl_io_base], eax
705
 
675
 
-
 
676
        mov     esi, msgMixMMIo
-
 
677
        invoke  SysMsgBoardStr
-
 
678
 
706
        and     eax, 0xFFC0
679
        invoke  PciRead32, [ctrl.bus], [ctrl.devfn], 0x18
-
 
680
        mov     [ctrl.codec_mem_base], eax
707
        mov     [ctrl.ctrl_io_base], eax
681
 
Line 708... Line 682...
708
 
682
        call    dword2str
709
        mov     esi, msgMixMMIo
683
        invoke  SysMsgBoardStr
710
        call    SysMsgBoardStr
684
 
Line 711... Line 685...
711
 
685
        mov     esi, msgCtrlMMIo
712
        stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
686
        invoke  SysMsgBoardStr
Line 784... Line 758...
784
           locals
758
           locals
785
             counter dd ?
759
             counter dd ?
786
           endl
760
           endl
Line 787... Line 761...
787
 
761
 
788
        mov     esi, msgControl
762
        mov     esi, msgControl
Line 789... Line 763...
789
        call    SysMsgBoardStr
763
        invoke  SysMsgBoardStr
790
 
764
 
791
        mov     edx, GLOB_CTRL
765
        mov     edx, GLOB_CTRL
792
        call    [ctrl.ctrl_read32]
766
        call    [ctrl.ctrl_read32]
Line 793... Line 767...
793
        call    dword2str
767
        call    dword2str
794
        call    SysMsgBoardStr
768
        invoke  SysMsgBoardStr
Line 795... Line 769...
795
 
769
 
796
        mov     esi, msgStatus
770
        mov     esi, msgStatus
797
        call    SysMsgBoardStr
771
        invoke  SysMsgBoardStr
798
 
772
 
799
        mov     edx, CTRL_STAT
773
        mov     edx, CTRL_STAT
800
        call    [ctrl.ctrl_read32]
774
        call    [ctrl.ctrl_read32]
801
        push    eax
775
        push    eax
802
        call    dword2str
776
        call    dword2str
Line 803... Line 777...
803
        call    SysMsgBoardStr
777
        invoke  SysMsgBoardStr
804
        pop     eax
778
        pop     eax
Line 805... Line 779...
805
        cmp     eax, 0xFFFFFFFF
779
        cmp     eax, 0xFFFFFFFF
806
        je      .err
780
        je      .err
807
 
781
 
Line 864... Line 838...
864
        call    cold_reset
838
        call    cold_reset
865
        jnc     .ok
839
        jnc     .ok
Line 866... Line 840...
866
 
840
 
867
     if DEBUG
841
     if DEBUG
868
        mov     esi, msgCFail
842
        mov     esi, msgCFail
869
        call    SysMsgBoardStr
843
        invoke  SysMsgBoardStr
870
     end if
844
     end if
871
        xor     eax, eax    ; timeout error
845
        xor     eax, eax    ; timeout error
872
        ret
846
        ret
873
.ok:
847
.ok:
Line 886... Line 860...
886
        mov     edx, GLOB_CTRL
860
        mov     edx, GLOB_CTRL
887
        call    [ctrl.ctrl_write32]
861
        call    [ctrl.ctrl_write32]
Line 888... Line 862...
888
 
862
 
889
     if DEBUG
863
     if DEBUG
890
        mov     esi, msgWarm
864
        mov     esi, msgWarm
891
        call    SysMsgBoardStr
865
        invoke  SysMsgBoardStr
Line 892... Line 866...
892
     end if
866
     end if
893
 
867
 
894
        mov     [counter], 10   ; total 10*100 ms = 1s
868
        mov     [counter], 10   ; total 10*100 ms = 1s
Line 904... Line 878...
904
        dec     [counter]
878
        dec     [counter]
905
        jnz     .wait
879
        jnz     .wait
Line 906... Line 880...
906
 
880
 
907
     if DEBUG
881
     if DEBUG
908
        mov     esi, msgWRFail
882
        mov     esi, msgWRFail
909
        call    SysMsgBoardStr
883
        invoke  SysMsgBoardStr
910
     end if
884
     end if
911
.fail:
885
.fail:
912
        stc
886
        stc
913
        ret
887
        ret
Line 926... Line 900...
926
        mov     edx, GLOB_CTRL
900
        mov     edx, GLOB_CTRL
927
        call    [ctrl.ctrl_write32]
901
        call    [ctrl.ctrl_write32]
Line 928... Line 902...
928
 
902
 
929
     if DEBUG
903
     if DEBUG
930
        mov     esi, msgCold
904
        mov     esi, msgCold
931
        call    SysMsgBoardStr
905
        invoke  SysMsgBoardStr
Line 932... Line 906...
932
     end if
906
     end if
933
 
907
 
Line 948... Line 922...
948
        dec     [counter]
922
        dec     [counter]
949
        jnz     .wait
923
        jnz     .wait
Line 950... Line 924...
950
 
924
 
951
     if DEBUG
925
     if DEBUG
952
        mov     esi, msgCRFail
926
        mov     esi, msgCRFail
953
        call    SysMsgBoardStr
927
        invoke  SysMsgBoardStr
Line 954... Line 928...
954
     end if
928
     end if
955
 
929
 
956
.fail:
930
.fail:
957
        stc
931
        stc
958
        ret
932
        ret
959
.ok:
933
.ok:
Line 960... Line 934...
960
        mov     esi, msgControl
934
        mov     esi, msgControl
961
        call    SysMsgBoardStr
935
        invoke  SysMsgBoardStr
962
 
936
 
963
        mov     edx, GLOB_CTRL
937
        mov     edx, GLOB_CTRL
Line 964... Line 938...
964
        call    [ctrl.ctrl_read32]
938
        call    [ctrl.ctrl_read32]
965
        call    dword2str
939
        call    dword2str
Line 966... Line 940...
966
        call    SysMsgBoardStr
940
        invoke  SysMsgBoardStr
967
 
941
 
968
        mov     esi, msgStatus
942
        mov     esi, msgStatus
969
        call    SysMsgBoardStr
943
        invoke  SysMsgBoardStr
970
 
944
 
971
        mov     edx, CTRL_STAT
945
        mov     edx, CTRL_STAT
Line 972... Line 946...
972
        call    [ctrl.ctrl_read32]
946
        call    [ctrl.ctrl_read32]
973
        push    eax
947
        push    eax
974
        call    dword2str
948
        call    dword2str
Line 1087... Line 1061...
1087
        ret
1061
        ret
1088
endp
1062
endp
Line 1089... Line 1063...
1089
 
1063
 
1090
align 4
1064
align 4
1091
proc codec_write stdcall, ac_reg:dword
-
 
1092
        push    eax
-
 
1093
        call    check_semafore
-
 
1094
        and     eax, eax
-
 
1095
        jz      .err
-
 
1096
        pop     eax
-
 
1097
 
1065
proc codec_write stdcall, ac_reg:dword
1098
        mov     esi, [ac_reg]
1066
        mov     esi, [ac_reg]
1099
        mov     edx, esi
1067
        mov     edx, esi
1100
        call    [ctrl.codec_write16]
1068
        call    [ctrl.codec_write16]
1101
        mov     [codec.regs+esi], ax
1069
        mov     [codec.regs+esi], ax
1102
        shr     esi, 1
1070
        shr     esi, 1
1103
        bts     [codec.shadow_flag], esi
1071
        bts     [codec.shadow_flag], esi
1104
        ret
-
 
1105
.err:
-
 
1106
        pop     eax
-
 
1107
        ret
1072
        ret
Line 1108... Line 1073...
1108
endp
1073
endp
1109
 
1074
 
Line 1122... Line 1087...
1122
        xor     eax, eax
1087
        xor     eax, eax
1123
        ret
1088
        ret
1124
endp
1089
endp
Line 1125... Line 1090...
1125
 
1090
 
1126
align 4
1091
align 4
1127
proc check_semafore
1092
proc check_semaphore
Line 1128... Line 1093...
1128
           local counter:DWORD
1093
           local counter:DWORD
1129
 
1094
 
1130
        mov     [counter], 100
1095
        mov     [counter], 100
Line 1178... Line 1143...
1178
;          CONTROLLER IO functions
1143
;          CONTROLLER IO functions
1179
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1144
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 1180... Line 1145...
1180
 
1145
 
1181
align 4
1146
align 4
-
 
1147
proc codec_io_r16
-
 
1148
        push    eax edx
-
 
1149
        call    check_semaphore
-
 
1150
        test    eax, eax
-
 
1151
        pop     edx eax
1182
proc codec_io_r16
1152
        jz      .err
1183
        add     edx, [ctrl.codec_io_base]
1153
        add     edx, [ctrl.codec_io_base]
-
 
1154
        in      ax, dx
1184
        in      ax, dx
1155
.err:
1185
        ret
1156
        ret
Line 1186... Line 1157...
1186
endp
1157
endp
1187
 
1158
 
-
 
1159
align 4
-
 
1160
proc codec_io_w16
-
 
1161
        push    eax edx
-
 
1162
        call    check_semaphore
-
 
1163
        test    eax, eax
1188
align 4
1164
        pop     edx eax
1189
proc codec_io_w16
1165
        jz      .err
-
 
1166
        add     edx, [ctrl.codec_io_base]
1190
        add     edx, [ctrl.codec_io_base]
1167
        out     dx, ax
1191
        out     dx, ax
1168
.err:
Line 1192... Line 1169...
1192
        ret
1169
        ret
1193
endp
1170
endp
Line 1255... Line 1232...
1255
 
1232
 
1256
align 4
1233
align 4
1257
devices dd (CTRL_SIS  shl 16)+VID_SIS,msg_AC, set_SIS
1234
devices dd (CTRL_SIS  shl 16)+VID_SIS,msg_AC, set_SIS
Line 1258... Line -...
1258
        dd 0
-
 
1259
 
-
 
1260
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
1235
        dd 0
1261
 
1236
 
Line 1262... Line 1237...
1262
msg_AC       db '7012 AC97 controller',13,10, 0
1237
msg_AC       db '7012 AC97 controller',13,10, 0
Line 1293... Line 1268...
1293
msgMixIsaIo  db 'codec io base        ',0
1268
msgMixIsaIo  db 'codec io base        ',0
1294
msgCtrlMMIo  db 'controller mmio base ',0
1269
msgCtrlMMIo  db 'controller mmio base ',0
1295
msgMixMMIo   db 'codec mmio base      ',0
1270
msgMixMMIo   db 'codec mmio base      ',0
1296
msgIrqMap    db 'AC97 irq map as      ',0
1271
msgIrqMap    db 'AC97 irq map as      ',0
Line -... Line 1272...
-
 
1272
 
-
 
1273
align 4
1297
 
1274
data fixups
Line -... Line 1275...
-
 
1275
end data
1298
section '.data' data readable writable align 16
1276
 
1299
 
1277
align 8
Line 1300... Line 1278...
1300
pcmout_bdl       rq 32
1278
pcmout_bdl       rq 32
1301
buff_list        rd 32
1279
buff_list        rd 32
Line 1302... Line 1280...
1302
 
1280
 
1303
codec CODEC
1281
codec CODEC
-
 
1282
ctrl AC_CNTRL
-
 
1283
 
-
 
1284
lpc_bus  rd 1