Subversion Repositories Kolibri OS

Rev

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

Rev 387 Rev 413
Line 3... Line 3...
3
format MS COFF
3
format MS COFF
Line 4... Line 4...
4
 
4
 
-
 
5
 
Line 5... Line 6...
5
 
6
include 'proc32.inc'
Line 6... Line 7...
6
include 'proc32.inc'
7
include 'imports.inc'
Line 50... Line 51...
50
BIT29 EQU 0x20000000
51
BIT29 EQU 0x20000000
51
BIT30 EQU 0x40000000
52
BIT30 EQU 0x40000000
52
BIT31 EQU 0x80000000
53
BIT31 EQU 0x80000000
53
 
54
 
Line 54... Line -...
54
VID_INTEL	  equ 0x8086
-
 
55
VID_NVIDIA        equ 0x10DE
-
 
56
 
-
 
57
CTRL_ICH	  equ 0x2415
-
 
58
CTRL_ICH0	  equ 0x2425
-
 
59
CTRL_ICH2	  equ 0x2435
-
 
60
CTRL_ICH3	  equ 0x2445
-
 
61
CTRL_ICH4	  equ 0x24C5
-
 
62
CTRL_ICH5	  equ 0x24D5
-
 
63
CTRL_ICH6	  equ 0x266E
-
 
64
CTRL_ICH7	  equ 0x27DE
-
 
65
 
-
 
66
CTRL_NFORCE       equ 0x01B1
-
 
67
CTRL_NFORCE2      equ 0x006A
-
 
68
CTRL_NFORCE3      equ 0x00DA
-
 
69
 
-
 
Line 70... Line 55...
70
 
55
 
71
PCM_OUT_BDL	  equ  0x10	 ; PCM out buffer descriptors list
56
PCM_OUT_BDL	  equ  0x10	 ; PCM out buffer descriptors list
72
PCM_OUT_CR_REG	  equ  0x1b	 ; PCM out Control Register
57
PCM_OUT_CR_REG	  equ  0x1b	 ; PCM out Control Register
73
PCM_OUT_LVI_REG   equ  0x15	 ; PCM last valid index
58
PCM_OUT_LVI_REG   equ  0x15	 ; PCM last valid index
Line 264... Line 249...
264
end virtual
249
end virtual
265
 
250
 
Line 266... Line 251...
266
EVENT_NOTIFY	      equ 0x00000200
251
EVENT_NOTIFY	      equ 0x00000200
Line 267... Line 252...
267
 
252
 
268
OS_BASE 	      equ 0;  0x80400000
253
OS_BASE         equ 0;
269
new_app_base	      equ 0x60400000;   0x01000000
254
SLOT_BASE       equ OS_BASE+0x0080000
Line 270... Line 255...
270
PROC_BASE	      equ OS_BASE+0x0080000
255
new_app_base    equ 0x80000000
271
 
-
 
272
public START
256
 
273
public STOP
-
 
274
public service_proc
-
 
275
 
-
 
276
extrn AttachIntHandler
-
 
277
extrn SysMsgBoardStr
-
 
278
extrn PciApi
-
 
279
extrn PciRead32
-
 
280
extrn PciRead8
-
 
281
extrn PciWrite8
-
 
282
extrn AllocKernelSpace
257
public START
283
extrn MapPage
-
 
284
extrn RegService
-
 
285
extrn KernelAlloc
-
 
Line 286... Line 258...
286
extrn GetPgAddr
258
public service_proc
Line -... Line 259...
-
 
259
public version
-
 
260
 
-
 
261
section '.flat' code readable align 16
-
 
262
 
287
extrn GetCurrentTask
263
proc START stdcall, state:dword
288
 
264
 
289
section '.flat' code readable align 16
265
           cmp [state], 1
290
 
266
           jne .stop
291
START:
267
 
Line 292... Line 268...
292
     if DEBUG
268
     if DEBUG
293
	   mov esi, msgInit
269
           mov esi, msgDetect
Line 304... Line 280...
304
	   mov	  esi, [ctrl.ctrl_ids]
280
           mov   esi, [ctrl.ctrl_ids]
305
           call SysMsgBoardStr
281
           call SysMsgBoardStr
306
 
282
 
Line 307... Line 283...
307
     end if
283
     end if
308
 
-
 
309
           call init_controller
284
           call init_controller
310
           test eax, eax
285
           test eax, eax
311
           jz .fail
286
           jz .fail
Line -... Line 287...
-
 
287
 
-
 
288
           jmp .fail      ;force fail
312
 
289
 
313
     if DEBUG
290
     if DEBUG
314
           mov esi, msgInitCodec
291
           mov esi, msgInitCodec
315
           call SysMsgBoardStr
292
           call SysMsgBoardStr
Line 334... Line 311...
334
           call SysMsgBoardStr
311
           call SysMsgBoardStr
335
 
312
 
Line 336... Line 313...
336
           call create_primary_buff
313
           call create_primary_buff
Line 337... Line -...
337
 
-
 
338
;     if REMAP_IRQ
-
 
339
 
-
 
340
;           call get_LPC_bus
-
 
341
;           cmp eax, -1
-
 
342
;           jz .fail
-
 
343
 
-
 
344
;           mov [lpc_bus], 0  ;eax
-
 
345
;           call remap_irq
-
 
346
;     end if
-
 
347
 
314
 
348
           mov eax, VALID_IRQ
315
           mov eax, VALID_IRQ
349
           mov ebx, [ctrl.int_line]
316
           mov ebx, [ctrl.int_line]
350
           mov esi, msgInvIRQ
317
           mov esi, msgInvIRQ
351
           bt eax, ebx
318
           bt eax, ebx
Line 363... Line 330...
363
	   mov esi, msgFail
330
           mov esi, msgFail
364
           call SysMsgBoardStr
331
           call SysMsgBoardStr
365
     end if
332
     end if
366
	   xor eax, eax
333
           xor eax, eax
367
STOP:
334
           ret
368
           ret
-
 
369
 
335
.stop:
-
 
336
           call stop
-
 
337
           xor eax, eax
-
 
338
           ret
-
 
339
endp
-
 
340
 
Line 370... Line 341...
370
handle     equ  IOCTL.handle
341
handle     equ  IOCTL.handle
371
io_code    equ  IOCTL.io_code
342
io_code    equ  IOCTL.io_code
372
input      equ  IOCTL.input
343
input      equ  IOCTL.input
373
inp_size   equ  IOCTL.inp_size
344
inp_size   equ  IOCTL.inp_size
Line 404... Line 375...
404
	   ret
375
           ret
405
@@:
376
@@:
406
	   cmp eax, DEV_SET_MASTERVOL
377
           cmp eax, DEV_SET_MASTERVOL
407
	   jne @F
378
           jne @F
408
           mov ebx, [edi+input]
379
           mov eax, [edi+input]
409
           stdcall set_master_vol, [ebx]
380
           mov eax, [eax]
-
 
381
           call set_master_vol      ;eax= vol
410
	   ret
382
           ret
411
@@:
383
@@:
412
	   cmp eax, DEV_GET_MASTERVOL
384
           cmp eax, DEV_GET_MASTERVOL
413
	   jne @F
385
           jne @F
414
           mov ebx, [edi+output]
386
           mov ebx, [edi+output]
415
           test ebx, ebx
387
           add ebx, new_app_base
416
           jz .fail
388
           stdcall get_master_vol, ebx
417
 
-
 
418
           stdcall get_master_vol, ebx
-
 
419
	   ret
389
           ret
420
@@:
390
;@@:
421
	   cmp eax, DEV_GET_INFO
391
;           cmp eax, DEV_GET_INFO
422
	   jne @F
392
;           jne @F
423
           mov ebx, [edi+output]
393
;           mov ebx, [edi+output]
424
	   stdcall get_dev_info, ebx
394
;           stdcall get_dev_info, ebx
425
	   ret
395
;           ret
426
@@:
396
@@:
427
.fail:
397
.fail:
428
	   xor eax, eax
398
           or eax, -1
429
	   ret
399
           ret
430
endp
400
endp
431
 
401
 
Line 432... Line 402...
432
restore   handle
402
restore   handle
433
restore   io_code
403
restore   io_code
Line 437... Line 407...
437
restore   out_size
407
restore   out_size
438
 
408
 
Line 439... Line 409...
439
 
409
 
440
align 4
-
 
441
proc remap_irq                         ;for Intel chipsets ONLY !!!
-
 
442
	   mov eax, VALID_IRQ
-
 
443
	   bt eax, IRQ_LINE
-
 
444
	   jnc .exit
-
 
445
 
-
 
446
	   mov edx, 0x4D0
-
 
447
	   in ax,dx
-
 
448
	   bts ax, IRQ_LINE
-
 
449
	   out dx, aX
-
 
450
 
-
 
451
           stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
-
 
452
	   mov [ctrl.int_line], IRQ_LINE
-
 
453
 
-
 
454
.exit:
-
 
455
	   ret
-
 
456
endp
-
 
457
 
-
 
458
align 4
410
align 4
Line 459... Line 411...
459
proc ac97_irq
411
proc ac97_irq
460
 
412
 
461
;     if DEBUG
413
;     if DEBUG
462
;           mov esi, msgIRQ
414
;           mov esi, msgIRQ
Line 463... Line -...
463
;           call SysMsgBoardStr
-
 
464
;     end if
-
 
465
 
-
 
466
	   mov edx, PCM_OUT_CR_REG
-
 
467
	   mov al, 0x14
-
 
468
	   call [ctrl.ctrl_write8]
-
 
469
 
-
 
470
	   mov ax, 0x1c
-
 
471
	   mov edx, PCM_OUT_SR_REG
-
 
472
	   call [ctrl.ctrl_write16]
-
 
473
 
-
 
474
	   mov edx, PCM_OUT_CIV_REG
-
 
475
	   call [ctrl.ctrl_read8]
-
 
476
 
-
 
477
	   and eax, 0x1F
-
 
478
	   cmp eax, [civ_val]
-
 
479
	   je .skip
-
 
480
 
-
 
481
	   mov [civ_val], eax
-
 
482
	   dec eax
-
 
483
	   and eax, 0x1F
-
 
484
	   mov [ctrl.lvi_reg], eax
-
 
485
 
-
 
486
	   mov edx, PCM_OUT_LVI_REG
-
 
487
	   call [ctrl.ctrl_write8]
-
 
488
 
-
 
489
	   mov edx, PCM_OUT_CR_REG
-
 
490
	   mov ax, 0x1D
-
 
491
	   call [ctrl.ctrl_write8]
-
 
492
 
-
 
493
	   mov eax, [civ_val]
-
 
Line 494... Line 415...
494
	   add eax, 2
415
;           call SysMsgBoardStr
495
	   and eax, 31
416
;     end if
Line 496... Line 417...
496
	   mov ebx, dword [buff_list+eax*4]
417
 
497
 
418
 
498
	   cmp [ctrl.user_callback], 0
419
           cmp [ctrl.user_callback], 0
Line 499... Line 420...
499
	   je @f
420
           je @f
500
 
421
 
501
	   stdcall [ctrl.user_callback], ebx
422
           stdcall [ctrl.user_callback], ebx
502
@@:
423
@@:
503
	   ret
424
           ret
504
 
425
 
Line 505... Line 426...
505
.skip:
426
.skip:
Line 520... Line 441...
520
	   xor eax, eax
441
           xor eax, eax
521
           cld
442
           cld
522
	   rep stosd
443
           rep stosd
523
 
444
 
Line 524... Line 445...
524
           stdcall GetPgAddr, [ctrl.buffer]
445
           mov eax, [ctrl.buffer]
-
 
446
           call GetPgAddr
Line 525... Line 447...
525
 
447
 
526
	   mov ebx, 0xC0002000
448
           mov ebx, 0xC0002000
527
	   mov ecx, 4
449
           mov ecx, 4
528
	   mov edi, pcmout_bdl
450
           mov edi, pcmout_bdl
Line 571... Line 493...
571
	   add eax, 0x4000
493
           add eax, 0x4000
572
	   add edi, 4
494
           add edi, 4
573
	   loop @B
495
           loop @B
Line 574... Line 496...
574
 
496
 
-
 
497
           mov eax, pcmout_bdl
575
	   mov ecx, pcmout_bdl
498
           mov ebx, eax
576
           stdcall GetPgAddr, ecx
499
           call GetPgAddr     ;eax
577
	   and ecx, 0xFFF
500
           and ebx, 0xFFF
Line 578... Line 501...
578
	   add eax, ecx
501
           add eax, ebx
579
 
502
 
Line 580... Line 503...
580
	   mov edx, PCM_OUT_BDL
503
           mov edx, PCM_OUT_BDL
581
	   call [ctrl.ctrl_write32]
504
           call [ctrl.ctrl_write32]
582
 
505
 
583
	   mov eax, 16
506
           mov eax, 16
584
	   mov [ctrl.lvi_reg], eax
-
 
585
	   mov edx, PCM_OUT_LVI_REG
507
           mov [ctrl.lvi_reg], eax
586
	   call [ctrl.ctrl_write8]
508
           mov edx, PCM_OUT_LVI_REG
Line 587... Line 509...
587
 
509
           call [ctrl.ctrl_write8]
588
	   ret
510
           ret
Line 600... Line 522...
600
	   mov [bus], eax
522
           mov [bus], eax
601
	   inc eax
523
           inc eax
602
           call PciApi
524
           call PciApi
603
	   cmp eax, -1
525
           cmp eax, -1
604
           je .no_pci
526
           je .err
605
 
527
 
Line 606... Line 528...
606
	   mov [last_bus], eax
528
           mov [last_bus], eax
Line 607... Line 529...
607
 
529
 
608
.next_bus:
530
.next_bus:
Line 624... Line 546...
624
	   je .found
546
           je .found
625
	   add edi, 12
547
           add edi, 12
626
	   jmp @B
548
           jmp @B
627
 
549
 
Line -... Line 550...
-
 
550
.next:
628
.next:	   inc [devfn]
551
           inc [devfn]
629
	   cmp [devfn], 256
552
           cmp [devfn], 256
630
	   jb  .next_dev
553
           jb  .next_dev
631
	   mov eax, [bus]
554
           mov eax, [bus]
632
	   inc eax
555
           inc eax
633
	   mov [bus], eax
556
           mov [bus], eax
Line 652... Line 575...
652
	   mov [ctrl.ctrl_ids], ebx
575
           mov [ctrl.ctrl_ids], ebx
653
	   mov esi, [edi+8]
576
           mov esi, [edi+8]
654
	   mov [ctrl.ctrl_setup], esi
577
           mov [ctrl.ctrl_setup], esi
655
 
578
 
Line 656... Line -...
656
           cmp ebx, VID_INTEL
-
 
657
           jne @F
-
 
658
	   mov [ctrl.vendor_ids], msg_Intel
-
 
659
           ret
-
 
660
@@:
-
 
661
           cmp ebx, VID_NVIDIA
-
 
662
           jne @F
-
 
663
           mov [ctrl.vendor_ids], msg_NVidia
-
 
664
@@:
-
 
665
           cmp ebx, 0x1274
579
           cmp ebx, 0x1274
666
           jne @F
580
           jne @F
667
           mov [ctrl.vendor_ids], msgEnsoniq
581
           mov [ctrl.vendor_ids], msgEnsoniq
668
           ret
582
           ret
669
@@:
583
@@:
670
           mov [ctrl.vendor_ids], 0     ;something  wrong ?
584
           mov [ctrl.vendor_ids], 0     ;something  wrong ?
671
	   ret
585
           ret
672
.no_pci:
-
 
673
           mov esi, msgPCI
-
 
674
           call SysMsgBoardStr
-
 
675
.err:
586
.err:
676
	   xor eax, eax
587
           xor eax, eax
677
	   ret
588
           ret
678
endp
589
endp
Line 679... Line 590...
679
 
590
 
680
align 4
-
 
681
proc get_LPC_bus                ;for Intel chipsets ONLY !!!
-
 
682
	   locals
-
 
683
	     last_bus dd ?
-
 
684
	     bus      dd ?
-
 
685
	   endl
-
 
686
 
-
 
687
	   xor eax, eax
-
 
688
	   mov [bus], eax
-
 
689
	   inc eax
-
 
690
	   call [PciApi]
-
 
691
	   cmp eax, -1
-
 
692
	   je .err
-
 
693
 
-
 
694
	   mov [last_bus], eax
-
 
695
.next_bus:
-
 
696
           stdcall PciRead32, [bus], dword 0xF8, dword 0
-
 
697
	   test eax, eax
-
 
698
	   jz .next
-
 
699
	   cmp eax, -1
-
 
700
	   je .next
-
 
701
 
-
 
702
	   cmp eax, 0x24D08086
-
 
703
	   je .found
-
 
704
.next:
-
 
705
	   mov eax, [bus]
-
 
706
	   inc eax
-
 
707
	   cmp eax, [last_bus]
-
 
708
	   mov [bus], eax
-
 
709
	   jna .next_bus
-
 
710
.err:
-
 
711
	   xor eax, eax
-
 
712
	   dec eax
-
 
713
	   ret
-
 
714
.found:
-
 
715
	   mov eax, [bus]
-
 
716
	   ret
-
 
717
endp
-
 
718
 
-
 
719
align 4
591
align 4
Line -... Line 592...
-
 
592
proc init_controller
-
 
593
 
-
 
594
           mov esi, msgPCIcmd
720
proc init_controller
595
           call SysMsgBoardStr
721
 
596
 
722
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
597
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
723
	   mov ebx, eax
598
           mov ebx, eax
724
	   and eax, 0xFFFF
599
           and eax, 0xFFFF
725
	   mov [ctrl.pci_cmd], eax
600
           mov [ctrl.pci_cmd], eax
Line -... Line 601...
-
 
601
           shr ebx, 16
726
	   shr ebx, 16
602
           mov [ctrl.pci_stat], ebx
-
 
603
 
727
	   mov [ctrl.pci_stat], ebx
604
           call dword2str
728
 
605
           call SysMsgBoardStr
Line 729... Line 606...
729
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
606
 
730
	   and eax,0xFFFE
607
           mov esi, msgIObase
731
	   mov [ctrl.codec_io_base], eax
608
           call SysMsgBoardStr
Line 732... Line 609...
732
 
609
 
733
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
610
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
Line 734... Line 611...
734
	   and eax, 0xFFC0
611
;           and eax, -16
735
	   mov [ctrl.ctrl_io_base], eax
612
           mov [ctrl.ctrl_io_base], eax
Line 736... Line 613...
736
 
613
 
737
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
614
           call dword2str
738
	   mov [ctrl.codec_mem_base], eax
615
           call SysMsgBoardStr
Line 739... Line -...
739
 
-
 
740
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
616
 
741
	   mov [ctrl.ctrl_mem_base], eax
617
           mov esi, msgIRQline
Line 742... Line 618...
742
 
618
           call SysMsgBoardStr
743
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
619
 
744
	   and eax, 0xFF
620
           stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
745
	   mov [ctrl.int_line], eax
621
           and eax, 0xFF
Line 768... Line 644...
768
	   mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
644
           mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
769
	   ret
645
           ret
770
endp
646
endp
771
 
647
 
Line 772... Line -...
772
PG_SW                equ 0x003
-
 
773
PG_NOCACHE           equ 0x018
-
 
774
 
-
 
775
align 4
-
 
776
proc set_ICH4
-
 
777
           stdcall AllocKernelSpace, dword 0x2000
-
 
778
	   mov edi, eax
-
 
779
           stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
-
 
780
	   mov [ctrl.codec_mem_base], edi
-
 
781
	   add edi, 0x1000
-
 
782
           stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
-
 
783
	   mov [ctrl.ctrl_mem_base], edi
-
 
784
 
-
 
785
	   mov [ctrl.codec_read16],  codec_mem_r16    ;virtual
-
 
786
	   mov [ctrl.codec_write16], codec_mem_w16    ;virtual
-
 
787
 
-
 
788
	   mov [ctrl.ctrl_read8 ],  ctrl_mem_r8       ;virtual
-
 
789
	   mov [ctrl.ctrl_read16],  ctrl_mem_r16      ;virtual
-
 
790
	   mov [ctrl.ctrl_read32],  ctrl_mem_r32      ;virtual
-
 
791
 
-
 
792
	   mov [ctrl.ctrl_write8 ], ctrl_mem_w8       ;virtual
-
 
793
	   mov [ctrl.ctrl_write16], ctrl_mem_w16      ;virtual
-
 
794
	   mov [ctrl.ctrl_write32], ctrl_mem_w32      ;virtual
-
 
795
	   ret
-
 
796
endp
-
 
797
 
-
 
798
align 4
648
align 4
799
proc reset_controller
649
proc reset_controller
Line 800... Line 650...
800
 
650
 
801
	   xor eax, eax
651
           xor eax, eax
Line 816... Line 666...
816
	   call [ctrl.ctrl_write8]
666
           call [ctrl.ctrl_write8]
817
 
667
 
Line 818... Line 668...
818
	   mov	edx, MC_IN_CR_REG
668
           mov edx, MC_IN_CR_REG
819
	   call [ctrl.ctrl_write8]
669
           call [ctrl.ctrl_write8]
820
 
-
 
821
	   ret
670
           ret
822
endp
671
endp
Line 823... Line 672...
823
 
672
 
824
align 4
673
align 4
825
proc init_codec
674
proc init_codec
826
	   locals
675
         locals
827
	     counter dd ?
676
           counter dd ?
Line -... Line 677...
-
 
677
         endl
-
 
678
 
-
 
679
           mov esi, msgControl
-
 
680
           call SysMsgBoardStr
-
 
681
 
-
 
682
           mov edx, GLOB_CTRL
-
 
683
           call [ctrl.ctrl_read32]
-
 
684
           call dword2str
-
 
685
           call SysMsgBoardStr
-
 
686
 
-
 
687
           mov esi, msgStatus
-
 
688
           call SysMsgBoardStr
-
 
689
 
-
 
690
           mov edx, CTRL_STAT
-
 
691
           call [ctrl.ctrl_read32]
-
 
692
 
-
 
693
           call dword2str
-
 
694
           call SysMsgBoardStr
-
 
695
 
-
 
696
           test eax, CTRL_ST_CREADY
828
	   endl
697
           jnz .ready
829
 
698
 
830
	   call reset_codec
699
           call reset_codec
Line 831... Line 700...
831
	   and eax, eax
700
           and eax, eax
Line 990... Line 859...
990
	   ret
859
	   ret
991
endp
860
endp
992
 
861
 
Line 993... Line 862...
993
align 4
862
align 4
994
proc play
863
play:
995
 
-
 
996
	   mov eax, 16
864
           mov eax, 16
997
	   mov [ctrl.lvi_reg], eax
865
           mov [ctrl.lvi_reg], eax
998
	   mov edx, PCM_OUT_LVI_REG
866
           mov edx, PCM_OUT_LVI_REG
999
	   call [ctrl.ctrl_write8]
867
           call [ctrl.ctrl_write8]
Line 1000... Line 868...
1000
 
868
 
1001
	   mov edx, PCM_OUT_CR_REG
869
           mov edx, PCM_OUT_CR_REG
1002
	   mov ax, 0x1D
870
           mov ax, 0x1D
-
 
871
           call [ctrl.ctrl_write8]
1003
	   call [ctrl.ctrl_write8]
872
           xor eax, eax
1004
	   ret
-
 
Line 1005... Line 873...
1005
endp
873
           ret
1006
 
874
 
1007
align 4
875
align 4
1008
proc stop
876
stop:
1009
	   mov edx, PCM_OUT_CR_REG
-
 
1010
	   mov ax, 0x14
-
 
1011
	   call [ctrl.ctrl_write8]
-
 
1012
 
-
 
1013
	   mov eax, 16
-
 
1014
	   mov [ctrl.lvi_reg], eax
877
           mov edx, PCM_OUT_CR_REG
Line -... Line 878...
-
 
878
           mov ax, 0x0
-
 
879
           call [ctrl.ctrl_write8]
-
 
880
 
-
 
881
           mov ax, 0x1c
1015
	   mov edx, PCM_OUT_LVI_REG
882
           mov edx, PCM_OUT_SR_REG
1016
	   call [ctrl.ctrl_write8]
-
 
Line 1017... Line 883...
1017
 
883
           call [ctrl.ctrl_write16]
1018
	   ret
884
           xor eax, eax
1019
endp
885
	   ret
1020
 
886
 
Line 1049... Line 915...
1049
	   mov [CTRL_INFO.glob_sta], eax
915
	   mov [CTRL_INFO.glob_sta], eax
1050
 
916
 
Line 1051... Line 917...
1051
	   mov ebx, [ctrl.pci_cmd]
917
	   mov ebx, [ctrl.pci_cmd]
1052
	   mov [CTRL_INFO.pci_cmd], ebx
918
	   mov [CTRL_INFO.pci_cmd], ebx
1053
 
-
 
1054
	   ret
919
	   ret
1055
endp
920
endp
Line 1056... Line 921...
1056
 
921
 
1057
align 4
922
align 4
Line 1125... Line 990...
1125
 
990
 
Line 1126... Line 991...
1126
	  xor eax, wax
991
           xor eax, wax
1127
	  inc eax
992
           inc eax
1128
	  ret
993
           ret
1129
 
-
 
1130
align 4
-
 
1131
.not_ready:
994
.not_ready:
1132
	  xor eax, eax
995
           xor eax, eax
1133
	  ret
996
           ret
1134
endp
997
endp
Line 1174... Line 1037...
1174
@@:
1037
@@:
1175
	   rdtsc
1038
	   rdtsc
1176
	   sub eax, ebx
1039
	   sub eax, ebx
1177
	   sbb edx, ecx
1040
	   sbb edx, ecx
1178
	   jb @B
1041
           js @B
1179
 
1042
 
Line 1180... Line 1043...
1180
	   pop eax
1043
	   pop eax
1181
	   pop ebx
1044
	   pop ebx
1182
	   pop edx
1045
	   pop edx
1183
	   pop ecx
1046
	   pop ecx
Line 1188... Line 1051...
1188
;          CONTROLLER IO functions
1051
;          CONTROLLER IO functions
1189
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1052
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1190
 
1053
 
Line 1191... Line 1054...
1191
align 4
1054
align 4
1192
proc codec_io_r16
1055
codec_io_r16:
1193
	add edx, [ctrl.codec_io_base]
1056
           add edx, [ctrl.codec_io_base]
1194
	in  ax, dx
1057
           in  ax, dx
1195
	ret
1058
           ret
1196
endp
-
 
Line 1197... Line 1059...
1197
 
1059
 
1198
align 4
1060
align 4
1199
proc codec_io_w16
1061
codec_io_w16:
1200
	add edx, [ctrl.codec_io_base]
1062
           add edx, [ctrl.codec_io_base]
1201
	out dx, ax
1063
           out dx, ax
1202
	ret
-
 
Line 1203... Line 1064...
1203
endp
1064
           ret
1204
 
1065
 
1205
align 4
1066
align 4
1206
proc ctrl_io_r8
1067
ctrl_io_r8:
1207
	add edx, [ctrl.ctrl_io_base]
1068
           add edx, [ctrl.ctrl_io_base]
1208
	in  al, dx
-
 
Line 1209... Line 1069...
1209
	ret
1069
           in  al, dx
1210
endp
1070
           ret
1211
 
1071
 
1212
align 4
1072
align 4
1213
proc ctrl_io_r16
1073
ctrl_io_r16:
1214
	add edx, [ctrl.ctrl_io_base]
-
 
Line 1215... Line 1074...
1215
	in  ax, dx
1074
          add edx, [ctrl.ctrl_io_base]
1216
	ret
1075
          in  ax, dx
1217
endp
1076
          ret
1218
 
1077
 
1219
align 4
1078
align 4
1220
proc ctrl_io_r32
-
 
Line 1221... Line 1079...
1221
	add edx, [ctrl.ctrl_io_base]
1079
ctrl_io_r32:
1222
	in  eax, dx
1080
          add edx, [ctrl.ctrl_io_base]
1223
	ret
1081
          in  eax, dx
1224
endp
1082
          ret
1225
 
1083
 
1226
align 4
-
 
Line 1227... Line 1084...
1227
proc ctrl_io_w8
1084
align 4
1228
	add edx, [ctrl.ctrl_io_base]
1085
ctrl_io_w8:
1229
	out dx, al
1086
          add edx, [ctrl.ctrl_io_base]
1230
	ret
1087
          out dx, al
1231
endp
1088
          ret
1232
 
-
 
Line 1233... Line 1089...
1233
align 4
1089
 
1234
proc ctrl_io_w16
1090
align 4
1235
	add edx, [ctrl.ctrl_io_base]
1091
ctrl_io_w16:
1236
	out dx, ax
1092
          add edx, [ctrl.ctrl_io_base]
1237
	ret
1093
          out dx, ax
1238
endp
-
 
1239
 
-
 
1240
align 4
-
 
1241
proc ctrl_io_w32
-
 
1242
	add edx, [ctrl.ctrl_io_base]
-
 
1243
	out dx, eax
-
 
1244
	ret
-
 
1245
endp
-
 
1246
 
-
 
1247
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
1248
;         MEMORY MAPPED IO    (os depended)
-
 
1249
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
1250
 
-
 
1251
align 4
-
 
1252
proc codec_mem_r16
-
 
1253
	add edx, [ctrl.codec_mem_base]
-
 
1254
	mov ax, word [edx]
-
 
1255
	ret
-
 
1256
endp
-
 
1257
 
-
 
1258
align 4
-
 
1259
proc codec_mem_w16
-
 
1260
	add edx, [ctrl.codec_mem_base]
-
 
1261
	mov word [edx], ax
-
 
1262
	ret
-
 
1263
endp
-
 
1264
 
-
 
1265
align 4
-
 
1266
proc ctrl_mem_r8
-
 
1267
	add edx, [ctrl.ctrl_mem_base]
-
 
1268
	mov al, [edx]
-
 
1269
	ret
-
 
1270
endp
-
 
Line 1271... Line -...
1271
 
-
 
1272
align 4
-
 
1273
proc ctrl_mem_r16
-
 
1274
	add edx, [ctrl.ctrl_mem_base]
-
 
1275
	mov ax, [edx]
-
 
1276
	ret
-
 
Line 1277... Line 1094...
1277
endp
1094
          ret
1278
 
1095
 
1279
align 4
1096
align 4
1280
proc ctrl_mem_r32
1097
ctrl_io_w32:
1281
	add edx, [ctrl.ctrl_mem_base]
1098
          add edx, [ctrl.ctrl_io_base]
-
 
1099
          out dx, eax
-
 
1100
          ret
-
 
1101
 
-
 
1102
 
-
 
1103
align 4
-
 
1104
dword2str:
-
 
1105
          mov  esi, hex_buff
1282
	mov eax, [edx]
1106
          mov ecx, -8
1283
	ret
-
 
Line 1284... Line -...
1284
endp
-
 
1285
 
-
 
1286
align 4
1107
@@:
1287
proc ctrl_mem_w8
-
 
1288
	add edx, [ctrl.ctrl_mem_base]
-
 
1289
	mov [edx], al
-
 
1290
 
-
 
1291
	ret
-
 
1292
endp
-
 
1293
 
1108
          rol eax, 4
1294
align 4
-
 
1295
proc ctrl_mem_w16
-
 
1296
	add edx, [ctrl.ctrl_mem_base]
-
 
Line 1297... Line 1109...
1297
	mov [edx], ax
1109
          mov ebx, eax
Line 1298... Line 1110...
1298
	ret
1110
          and ebx, 0x0F
1299
endp
1111
          mov bl, [ebx+hexletters]
1300
 
-
 
1301
align 4
-
 
1302
proc ctrl_mem_w32
-
 
1303
	add edx, [ctrl.ctrl_mem_base]
-
 
1304
	mov [edx], eax
-
 
1305
	ret
-
 
1306
endp
-
 
1307
 
-
 
1308
 
-
 
1309
include "codec.inc"
-
 
1310
 
-
 
1311
align 4
1112
          mov [8+esi+ecx], bl
1312
devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
-
 
1313
	dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
1113
          inc ecx
Line 1314... Line -...
1314
	dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
-
 
1315
	dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
-
 
1316
        dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
-
 
1317
        dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
-
 
1318
        dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
-
 
1319
        dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
-
 
1320
 
-
 
1321
        dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
-
 
1322
        dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
-
 
1323
        dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
-
 
1324
        dd (0x5000 shl 16)+0x1274,msgEnsoniq,set_ICH
-
 
1325
 
-
 
1326
        dd 0    ;terminator
-
 
1327
 
1114
          jnz @B
Line 1328... Line 1115...
1328
msg_ICH      db 'Intel ICH',  13,10, 0
1115
          ret
-
 
1116
 
Line 1329... Line -...
1329
msg_ICH0     db 'Intel ICH0', 13,10, 0
-
 
1330
msg_ICH2     db 'Intel ICH2', 13,10, 0
1117
hexletters   db '0123456789ABCDEF'
Line 1331... Line 1118...
1331
msg_ICH3     db 'Intel ICH3', 13,10, 0
1118
hex_buff     db 8 dup(0),13,10,0
1332
msg_ICH4     db 'Intel ICH4', 13,10, 0
-
 
1333
msg_ICH5     db 'Intel ICH5', 13,10, 0
1119
 
1334
msg_ICH6     db 'Intel ICH6', 13,10, 0
1120
 
1335
msg_ICH7     db 'Intel ICH7', 13,10, 0
1121
include "codec.inc"
1336
msg_Intel    db 'Intel Corp. ', 0
1122
 
1337
 
1123
align 4
Line 1364... Line 1150...
1364
msgWRFail    db 'warm reset failed',13,10,0
1150
msgWRFail    db 'warm reset failed',13,10,0
1365
msgCRFail    db 'cold reset failed',13,10,0
1151
msgCRFail    db 'cold reset failed',13,10,0
1366
msgCFail     db 'codec not ready',13,10,0
1152
msgCFail     db 'codec not ready',13,10,0
1367
msgResetOk   db 'reset complete',13,10,0
1153
msgResetOk   db 'reset complete',13,10,0
1368
 
1154
msgStatus    db 'global status   ',0
-
 
1155
msgControl   db 'global control  ',0
-
 
1156
msgPCIcmd    db 'PCI command     ',0
-
 
1157
msgIObase    db 'IO base         ',0
-
 
1158
msgIRQline   db 'IRQ line        ',0
-
 
1159
 
Line 1369... Line 1160...
1369
section '.data' data readable writable align 16
1160
section '.data' data readable writable align 16
Line 1370... Line 1161...
1370
 
1161
 
1371
pcmout_bdl       rq 32
1162
pcmout_bdl       rq 32