Subversion Repositories Kolibri OS

Rev

Rev 247 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. format MS COFF
  3.  
  4.  
  5. include 'proc32.inc'
  6. include 'imports.inc'
  7.  
  8. DEBUG       equ 1
  9.  
  10. REMAP_IRQ   equ 0
  11.  
  12. ;irq 0,1,2,8,12,13 íåäîñòóïíû
  13. ;               FEDCBA9876543210
  14. VALID_IRQ   equ 1100111011111000b
  15. ATTCH_IRQ   equ 0000111010101000b
  16.  
  17. IRQ_LINE    equ 0
  18.  
  19. CPU_FREQ    equ  2600d
  20.  
  21. BIT0  EQU 0x00000001
  22. BIT1  EQU 0x00000002
  23. BIT2  EQU 0x00000004
  24. BIT3  EQU 0x00000008
  25. BIT4  EQU 0x00000010
  26. BIT5  EQU 0x00000020
  27. BIT6  EQU 0x00000040
  28. BIT7  EQU 0x00000080
  29. BIT8  EQU 0x00000100
  30. BIT9  EQU 0x00000200
  31. BIT10 EQU 0x00000400
  32. BIT11 EQU 0x00000800
  33. BIT12 EQU 0x00001000
  34. BIT13 EQU 0x00002000
  35. BIT14 EQU 0x00004000
  36. BIT15 EQU 0x00008000
  37. BIT16 EQU 0x00010000
  38. BIT17 EQU 0x00020000
  39. BIT18 EQU 0x00040000
  40. BIT19 EQU 0x00080000
  41. BIT20 EQU 0x00100000
  42. BIT21 EQU 0x00200000
  43. BIT22 EQU 0x00400000
  44. BIT23 EQU 0x00800000
  45. BIT24 EQU 0x00100000
  46. BIT25 EQU 0x02000000
  47. BIT26 EQU 0x04000000
  48. BIT27 EQU 0x08000000
  49. BIT28 EQU 0x10000000
  50. BIT29 EQU 0x20000000
  51. BIT30 EQU 0x40000000
  52. BIT31 EQU 0x80000000
  53.  
  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. CTRL_MCP04        equ 0x003A
  70. CTRL_CK804        equ 0x0059
  71. CTRL_CK8          equ 0x008A
  72. CTRL_CK8S         equ 0x00EA
  73. CTRL_MCP51        equ 0x026B
  74.  
  75.  
  76. PCM_OUT_BDL       equ  0x10      ; PCM out buffer descriptors list
  77. PCM_OUT_CR_REG    equ  0x1b      ; PCM out Control Register
  78. PCM_OUT_LVI_REG   equ  0x15      ; PCM last valid index
  79. PCM_OUT_SR_REG    equ  0x16      ; PCM out Status register
  80. PCM_OUT_PIV_REG   equ  0x1a
  81. PCM_OUT_CIV_REG   equ  0x14      ; PCM out current index
  82.  
  83. PCM_IN_CR_REG     equ  0x0b      ; PCM in Control Register
  84. MC_IN_CR_REG      equ  0x2b      ; MIC in Control Register
  85. RR                equ  BIT1      ; reset registers.  Nukes all regs
  86.  
  87. CODEC_MASTER_VOL_REG            equ     0x02
  88. CODEC_AUX_VOL                   equ     0x04    ;
  89. CODEC_PCM_OUT_REG               equ     18h     ; PCM output volume
  90. CODEC_EXT_AUDIO_REG             equ     28h     ; extended audio
  91. CODEC_EXT_AUDIO_CTRL_REG        equ     2ah     ; extended audio control
  92. CODEC_PCM_FRONT_DACRATE_REG     equ     2ch     ; PCM out sample rate
  93. CODEC_PCM_SURND_DACRATE_REG     equ     2eh     ; surround sound sample rate
  94. CODEC_PCM_LFE_DACRATE_REG       equ     30h     ; LFE sample rate
  95.  
  96. GLOB_CTRL      equ  0x2C        ;   Global Control
  97. CTRL_STAT       equ  0x30        ;   Global Status
  98. CTRL_CAS        equ  0x34        ;   Codec Access Semiphore
  99.  
  100. CAS_FLAG        equ  0x01        ;   Codec Access Semiphore Bit
  101.  
  102. CTRL_ST_CREADY  equ  BIT8+BIT9+BIT28 ;   Primary Codec Ready
  103.  
  104. CTRL_ST_RCS     equ  0x00008000  ;   Read Completion Status
  105.  
  106. CTRL_CNT_CRIE   equ  BIT4+BIT5+BIT6  ;   Codecs Resume Interrupt Enable
  107. CTRL_CNT_AC_OFF equ  0x00000008  ;   ACLINK Off
  108. CTRL_CNT_WARM   equ  0x00000004  ;   AC97 Warm Reset
  109. CTRL_CNT_COLD   equ  0x00000002  ;   AC97 Cold Reset
  110. CTRL_CNT_GIE    equ  0x00000001  ;   GPI Interrupt Enable
  111.  
  112. CODEC_REG_POWERDOWN   equ 0x26
  113. CODEC_REG_ST          equ 0x26
  114.  
  115. DEV_PLAY              equ  1
  116. DEV_STOP              equ  2
  117. DEV_CALLBACK          equ  3
  118. DEV_SET_BUFF          equ  4
  119. DEV_NOTIFY            equ  5
  120. DEV_SET_MASTERVOL     equ  6
  121. DEV_GET_MASTERVOL     equ  7
  122. DEV_GET_INFO          equ  8
  123.  
  124. struc AC_CNTRL              ;AC controller base class
  125. { .bus                dd ?
  126.   .devfn              dd ?
  127.  
  128.   .vendor             dd ?
  129.   .dev_id             dd ?
  130.   .pci_cmd            dd ?
  131.   .pci_stat           dd ?
  132.  
  133.   .codec_io_base      dd ?
  134.   .codec_mem_base     dd ?
  135.  
  136.   .ctrl_io_base       dd ?
  137.   .ctrl_mem_base      dd ?
  138.   .cfg_reg            dd ?
  139.   .int_line           dd ?
  140.  
  141.   .vendor_ids         dd ?    ;vendor id string
  142.   .ctrl_ids           dd ?    ;hub id string
  143.  
  144.   .buffer             dd ?
  145.  
  146.   .notify_pos         dd ?
  147.   .notify_task        dd ?
  148.  
  149.   .lvi_reg            dd ?
  150.   .ctrl_setup         dd ?
  151.   .user_callback      dd ?
  152.   .codec_read16       dd ?
  153.   .codec_write16      dd ?
  154.  
  155.   .ctrl_read8         dd ?
  156.   .ctrl_read16        dd ?
  157.   .ctrl_read32        dd ?
  158.  
  159.   .ctrl_write8        dd ?
  160.   .ctrl_write16       dd ?
  161.   .ctrl_write32       dd ?
  162. }
  163.  
  164. struc CODEC                ;Audio Chip base class
  165. {
  166.   .chip_id            dd ?
  167.   .flags              dd ?
  168.   .status             dd ?
  169.  
  170.   .ac_vendor_ids      dd ?    ;ac vendor id string
  171.   .chip_ids           dd ?    ;chip model string
  172.  
  173.   .shadow_flag        dd ?
  174.                       dd ?
  175.  
  176.   .regs               dw ?     ; codec registers
  177.   .reg_master_vol     dw ?     ;0x02
  178.   .reg_aux_out_vol    dw ?     ;0x04
  179.   .reg_mone_vol       dw ?     ;0x06
  180.   .reg_master_tone    dw ?     ;0x08
  181.   .reg_beep_vol       dw ?     ;0x0A
  182.   .reg_phone_vol      dw ?     ;0x0C
  183.   .reg_mic_vol        dw ?     ;0x0E
  184.   .reg_line_in_vol    dw ?     ;0x10
  185.   .reg_cd_vol         dw ?     ;0x12
  186.   .reg_video_vol      dw ?     ;0x14
  187.   .reg_aux_in_vol     dw ?     ;0x16
  188.   .reg_pcm_out_vol    dw ?     ;0x18
  189.   .reg_rec_select     dw ?     ;0x1A
  190.   .reg_rec_gain       dw ?     ;0x1C
  191.   .reg_rec_gain_mic   dw ?     ;0x1E
  192.   .reg_gen            dw ?     ;0x20
  193.   .reg_3d_ctrl        dw ?     ;0X22
  194.   .reg_page           dw ?     ;0X24
  195.   .reg_powerdown      dw ?     ;0x26
  196.   .reg_ext_audio      dw ?     ;0x28
  197.   .reg_ext_st         dw ?     ;0x2a
  198.   .reg_pcm_front_rate dw ?     ;0x2c
  199.   .reg_pcm_surr_rate  dw ?     ;0x2e
  200.   .reg_lfe_rate       dw ?     ;0x30
  201.   .reg_pcm_in_rate    dw ?     ;0x32
  202.                       dw ?     ;0x34
  203.   .reg_cent_lfe_vol   dw ?     ;0x36
  204.   .reg_surr_vol       dw ?     ;0x38
  205.   .reg_spdif_ctrl     dw ?     ;0x3A
  206.                       dw ?     ;0x3C
  207.                       dw ?     ;0x3E
  208.                       dw ?     ;0x40
  209.                       dw ?     ;0x42
  210.                       dw ?     ;0x44
  211.                       dw ?     ;0x46
  212.                       dw ?     ;0x48
  213.                       dw ?     ;0x4A
  214.                       dw ?     ;0x4C
  215.                       dw ?     ;0x4E
  216.                       dw ?     ;0x50
  217.                       dw ?     ;0x52
  218.                       dw ?     ;0x54
  219.                       dw ?     ;0x56
  220.                       dw ?     ;0x58
  221.                       dw ?     ;0x5A
  222.                       dw ?     ;0x5C
  223.                       dw ?     ;0x5E
  224.   .reg_page_0         dw ?     ;0x60
  225.   .reg_page_1         dw ?     ;0x62
  226.   .reg_page_2         dw ?     ;0x64
  227.   .reg_page_3         dw ?     ;0x66
  228.   .reg_page_4         dw ?     ;0x68
  229.   .reg_page_5         dw ?     ;0x6A
  230.   .reg_page_6         dw ?     ;0x6C
  231.   .reg_page_7         dw ?     ;0x6E
  232.                       dw ?     ;0x70
  233.                       dw ?     ;0x72
  234.                       dw ?     ;0x74
  235.                       dw ?     ;0x76
  236.                       dw ?     ;0x78
  237.                       dw ?     ;0x7A
  238.   .reg_vendor_id_1    dw ?     ;0x7C
  239.   .reg_vendor_id_2    dw ?     ;0x7E
  240.  
  241.  
  242.   .reset              dd ?    ;virual
  243.   .set_master_vol     dd ?
  244. }
  245.  
  246. struc CTRL_INFO
  247. {   .pci_cmd         dd ?
  248.     .irq             dd ?
  249.     .glob_cntrl      dd ?
  250.     .glob_sta        dd ?
  251.     .codec_io_base   dd ?
  252.     .ctrl_io_base    dd ?
  253.     .codec_mem_base  dd ?
  254.     .ctrl_mem_base   dd ?
  255.     .codec_id        dd ?
  256. }
  257.  
  258. struc IOCTL
  259. {  .handle           dd ?
  260.    .io_code          dd ?
  261.    .input            dd ?
  262.    .inp_size         dd ?
  263.    .output           dd ?
  264.    .out_size         dd ?
  265. }
  266.  
  267. virtual at 0
  268.   IOCTL IOCTL
  269. end virtual
  270.  
  271. EVENT_NOTIFY    equ 0x00000200
  272.  
  273. OS_BASE         equ 0;
  274. new_app_base    equ 0x60400000
  275. PROC_BASE             equ OS_BASE+0x0080000
  276.  
  277. public START
  278. public service_proc
  279. public version
  280.  
  281. section '.flat' code readable align 16
  282.  
  283. proc START stdcall, state:dword
  284.  
  285.            cmp [state], 1
  286.            jne .stop
  287.  
  288.      if DEBUG
  289.            mov esi, msgInit
  290.            call SysMsgBoardStr
  291.      end if
  292.  
  293.            call detect_controller
  294.            test eax, eax
  295.            jz .fail
  296.  
  297.      if DEBUG
  298.            mov esi,[ctrl.vendor_ids]
  299.            call SysMsgBoardStr
  300.            mov esi, [ctrl.ctrl_ids]
  301.            call SysMsgBoardStr
  302.  
  303.      end if
  304.  
  305.            call init_controller
  306.            test eax, eax
  307.            jz .fail
  308.  
  309.      if DEBUG
  310.            mov esi, msgInitCodec
  311.            call SysMsgBoardStr
  312.      end if
  313.  
  314.            call init_codec
  315.            test eax, eax
  316.            jz .fail
  317.  
  318.      if DEBUG
  319.            mov esi, [codec.ac_vendor_ids]
  320.            call SysMsgBoardStr
  321.  
  322.            mov esi, [codec.chip_ids]
  323.            call SysMsgBoardStr
  324.      end if
  325.  
  326.            call reset_controller
  327.            call setup_codec
  328.  
  329.            mov esi, msgPrimBuff
  330.            call SysMsgBoardStr
  331.  
  332.            call create_primary_buff
  333.  
  334. ;     if REMAP_IRQ
  335.  
  336. ;           call get_LPC_bus
  337. ;           cmp eax, -1
  338. ;           jz .fail
  339.  
  340. ;           mov [lpc_bus], 0  ;eax
  341. ;           call remap_irq
  342. ;     end if
  343.  
  344.            mov eax, VALID_IRQ
  345.            mov ebx, [ctrl.int_line]
  346.            mov esi, msgInvIRQ
  347.            bt eax, ebx
  348.            jnc .fail
  349.            mov eax, ATTCH_IRQ
  350.            mov esi, msgAttchIRQ
  351.            bt eax, ebx
  352.            jnc .fail
  353.  
  354.            stdcall AttachIntHandler, ebx, ac97_irq
  355.            stdcall RegService, sz_sound_srv, service_proc
  356.            ret
  357. .fail:
  358.      if DEBUG
  359.            mov esi, msgFail
  360.            call SysMsgBoardStr
  361.      end if
  362.            xor eax, eax
  363.            ret
  364. .stop:
  365.            call stop
  366.            xor eax, eax
  367.            ret
  368. endp
  369.  
  370. handle     equ  IOCTL.handle
  371. io_code    equ  IOCTL.io_code
  372. input      equ  IOCTL.input
  373. inp_size   equ  IOCTL.inp_size
  374. output     equ  IOCTL.output
  375. out_size   equ  IOCTL.out_size
  376.  
  377. align 4
  378. proc service_proc stdcall, ioctl:dword
  379.  
  380.            mov edi, [ioctl]
  381.            mov eax, [edi+io_code]
  382.            cmp eax, DEV_PLAY
  383.            jne @F
  384.      if DEBUG
  385.            mov esi, msgPlay
  386.            call SysMsgBoardStr
  387.      end if
  388.            call play
  389.            ret
  390. @@:
  391.            cmp eax, DEV_STOP
  392.            jne @F
  393.      if DEBUG
  394.            mov esi, msgStop
  395.            call SysMsgBoardStr
  396.      end if
  397.            call stop
  398.            ret
  399. @@:
  400.            cmp eax, DEV_CALLBACK
  401.            jne @F
  402.            mov ebx, [edi+input]
  403.            stdcall set_callback, [ebx]
  404.            ret
  405. @@:
  406.            cmp eax, DEV_SET_MASTERVOL
  407.            jne @F
  408.            mov ebx, [edi+input]
  409.            stdcall set_master_vol, [ebx]
  410.            ret
  411. @@:
  412.            cmp eax, DEV_GET_MASTERVOL
  413.            jne @F
  414.            mov ebx, [edi+output]
  415.            test ebx, ebx
  416.            jz .fail
  417.  
  418.            stdcall get_master_vol, ebx
  419.            ret
  420. @@:
  421.            cmp eax, DEV_GET_INFO
  422.            jne @F
  423.            mov ebx, [edi+output]
  424.            stdcall get_dev_info, ebx
  425.            ret
  426. @@:
  427. .fail:
  428.            xor eax, eax
  429.            ret
  430. endp
  431.  
  432. restore   handle
  433. restore   io_code
  434. restore   input
  435. restore   inp_size
  436. restore   output
  437. restore   out_size
  438.  
  439.  
  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
  459. proc ac97_irq
  460.  
  461. ;     if DEBUG
  462. ;           mov esi, msgIRQ
  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]
  494.            add eax, 2
  495.            and eax, 31
  496.            mov ebx, dword [buff_list+eax*4]
  497.  
  498.            cmp [ctrl.user_callback], 0
  499.            je @f
  500.  
  501.            stdcall [ctrl.user_callback], ebx
  502. @@:
  503.            ret
  504.  
  505. .skip:
  506.            mov edx, PCM_OUT_CR_REG
  507.            mov ax, 0x1D
  508.            call [ctrl.ctrl_write8]
  509.            ret
  510. endp
  511.  
  512. align 4
  513. proc create_primary_buff
  514.  
  515.            stdcall KernelAlloc, 0x10000
  516.            mov [ctrl.buffer], eax
  517.  
  518.            mov edi, eax
  519.            mov ecx, 0x10000/4
  520.            xor eax, eax
  521.            cld
  522.            rep stosd
  523.  
  524.            stdcall GetPgAddr, [ctrl.buffer]
  525.  
  526.            mov ebx, 0xC0002000
  527.            mov ecx, 4
  528.            mov edi, pcmout_bdl
  529. @@:
  530.            mov [edi], eax
  531.            mov [edi+4], ebx
  532.  
  533.            mov [edi+32], eax
  534.            mov [edi+4+32], ebx
  535.  
  536.            mov [edi+64], eax
  537.            mov [edi+4+64], ebx
  538.  
  539.            mov [edi+96], eax
  540.            mov [edi+4+96], ebx
  541.  
  542.            mov [edi+128], eax
  543.            mov [edi+4+128], ebx
  544.  
  545.            mov [edi+160], eax
  546.            mov [edi+4+160], ebx
  547.  
  548.            mov [edi+192], eax
  549.            mov [edi+4+192], ebx
  550.  
  551.            mov [edi+224], eax
  552.            mov [edi+4+224], ebx
  553.  
  554.            add eax, 0x4000
  555.            add edi, 8
  556.            loop @B
  557.  
  558.            mov edi, buff_list
  559.            mov eax, [ctrl.buffer]
  560.            mov ecx, 4
  561. @@:
  562.            mov [edi], eax
  563.            mov [edi+16], eax
  564.            mov [edi+32], eax
  565.            mov [edi+48], eax
  566.            mov [edi+64], eax
  567.            mov [edi+80], eax
  568.            mov [edi+96], eax
  569.            mov [edi+112], eax
  570.  
  571.            add eax, 0x4000
  572.            add edi, 4
  573.            loop @B
  574.  
  575.            mov ecx, pcmout_bdl
  576.            stdcall GetPgAddr, ecx
  577.            and ecx, 0xFFF
  578.            add eax, ecx
  579.  
  580.            mov edx, PCM_OUT_BDL
  581.            call [ctrl.ctrl_write32]
  582.  
  583.            mov eax, 16
  584.            mov [ctrl.lvi_reg], eax
  585.            mov edx, PCM_OUT_LVI_REG
  586.            call [ctrl.ctrl_write8]
  587.            ret
  588. endp
  589.  
  590. align 4
  591. proc detect_controller
  592.            locals
  593.              last_bus dd ?
  594.              bus      dd ?
  595.              devfn    dd ?
  596.            endl
  597.  
  598.            xor eax, eax
  599.            mov [bus], eax
  600.            inc eax
  601.            call PciApi
  602.            cmp eax, -1
  603.            je .err
  604.  
  605.            mov [last_bus], eax
  606.  
  607. .next_bus:
  608.            and [devfn], 0
  609. .next_dev:
  610.            stdcall PciRead32, [bus], [devfn], dword 0
  611.            test eax, eax
  612.            jz .next
  613.            cmp eax, -1
  614.            je .next
  615.  
  616.            mov edi, devices
  617. @@:
  618.            mov ebx, [edi]
  619.            test ebx, ebx
  620.            jz .next
  621.  
  622.            cmp eax, ebx
  623.            je .found
  624.            add edi, 12
  625.            jmp @B
  626.  
  627. .next:
  628.            inc [devfn]
  629.            cmp [devfn], 256
  630.            jb .next_dev
  631.            mov eax, [bus]
  632.            inc eax
  633.            mov [bus], eax
  634.            cmp eax, [last_bus]
  635.            jna .next_bus
  636.            xor eax, eax
  637.            ret
  638. .found:
  639.            mov ebx, [bus]
  640.            mov [ctrl.bus], ebx
  641.  
  642.            mov ecx, [devfn]
  643.            mov [ctrl.devfn], ecx
  644.  
  645.            mov edx, eax
  646.            and edx, 0xFFFF
  647.            mov [ctrl.vendor], edx
  648.            shr eax, 16
  649.            mov [ctrl.dev_id], eax
  650.  
  651.            mov ebx, [edi+4]
  652.            mov [ctrl.ctrl_ids], ebx
  653.            mov esi, [edi+8]
  654.            mov [ctrl.ctrl_setup], esi
  655.  
  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.            mov [ctrl.vendor_ids], 0     ;something  wrong ?
  666.            ret
  667. .err:
  668.            xor eax, eax
  669.            ret
  670. endp
  671.  
  672. align 4
  673. proc get_LPC_bus                ;for Intel chipsets ONLY !!!
  674.            locals
  675.              last_bus dd ?
  676.              bus      dd ?
  677.            endl
  678.  
  679.            xor eax, eax
  680.            mov [bus], eax
  681.            inc eax
  682.            call [PciApi]
  683.            cmp eax, -1
  684.            je .err
  685.  
  686.            mov [last_bus], eax
  687. .next_bus:
  688.            stdcall PciRead32, [bus], dword 0xF8, dword 0
  689.            test eax, eax
  690.            jz .next
  691.            cmp eax, -1
  692.            je .next
  693.  
  694.            cmp eax, 0x24D08086
  695.            je .found
  696. .next:
  697.            mov eax, [bus]
  698.            inc eax
  699.            cmp eax, [last_bus]
  700.            mov [bus], eax
  701.            jna .next_bus
  702. .err:
  703.            xor eax, eax
  704.            dec eax
  705.            ret
  706. .found:
  707.            mov eax, [bus]
  708.            ret
  709. endp
  710.  
  711. align 4
  712. proc init_controller
  713.  
  714.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
  715.            mov ebx, eax
  716.            and eax, 0xFFFF
  717.            mov [ctrl.pci_cmd], eax
  718.            shr ebx, 16
  719.            mov [ctrl.pci_stat], ebx
  720.  
  721.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
  722.            and eax,0xFFFE
  723.            mov [ctrl.codec_io_base], eax
  724.  
  725.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
  726.            and eax, 0xFFC0
  727.            mov [ctrl.ctrl_io_base], eax
  728.  
  729.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
  730.            mov [ctrl.codec_mem_base], eax
  731.  
  732.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
  733.            mov [ctrl.ctrl_mem_base], eax
  734.  
  735.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
  736.            and eax, 0xFF
  737.            mov [ctrl.int_line], eax
  738.  
  739.            stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
  740.            and eax, 0xFF
  741.            mov [ctrl.cfg_reg], eax
  742.  
  743.            call [ctrl.ctrl_setup]
  744.            xor eax, eax
  745.            inc eax
  746.            ret
  747. endp
  748.  
  749. align 4
  750. proc set_ICH
  751.            mov [ctrl.codec_read16],  codec_io_r16    ;virtual
  752.            mov [ctrl.codec_write16], codec_io_w16    ;virtual
  753.  
  754.            mov [ctrl.ctrl_read8 ],  ctrl_io_r8      ;virtual
  755.            mov [ctrl.ctrl_read16],  ctrl_io_r16      ;virtual
  756.            mov [ctrl.ctrl_read32],  ctrl_io_r32      ;virtual
  757.  
  758.            mov [ctrl.ctrl_write8 ], ctrl_io_w8      ;virtual
  759.            mov [ctrl.ctrl_write16], ctrl_io_w16      ;virtual
  760.            mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
  761.            ret
  762. endp
  763.  
  764. PG_SW                equ 0x003
  765. PG_NOCACHE           equ 0x018
  766.  
  767. align 4
  768. proc set_ICH4
  769.            stdcall AllocKernelSpace, dword 0x2000
  770.            mov edi, eax
  771.            stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
  772.            mov [ctrl.codec_mem_base], edi
  773.            add edi, 0x1000
  774.            stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
  775.            mov [ctrl.ctrl_mem_base], edi
  776.  
  777.            mov [ctrl.codec_read16],  codec_mem_r16    ;virtual
  778.            mov [ctrl.codec_write16], codec_mem_w16    ;virtual
  779.  
  780.            mov [ctrl.ctrl_read8 ],  ctrl_mem_r8       ;virtual
  781.            mov [ctrl.ctrl_read16],  ctrl_mem_r16      ;virtual
  782.            mov [ctrl.ctrl_read32],  ctrl_mem_r32      ;virtual
  783.  
  784.            mov [ctrl.ctrl_write8 ], ctrl_mem_w8       ;virtual
  785.            mov [ctrl.ctrl_write16], ctrl_mem_w16      ;virtual
  786.            mov [ctrl.ctrl_write32], ctrl_mem_w32      ;virtual
  787.            ret
  788. endp
  789.  
  790. align 4
  791. proc reset_controller
  792.  
  793.            xor eax, eax
  794.            mov edx, PCM_IN_CR_REG
  795.            call [ctrl.ctrl_write8]
  796.  
  797.            mov edx, PCM_OUT_CR_REG
  798.            call [ctrl.ctrl_write8]
  799.  
  800.            mov edx, MC_IN_CR_REG
  801.            call [ctrl.ctrl_write8]
  802.  
  803.            mov eax, RR
  804.            mov edx, PCM_IN_CR_REG
  805.            call [ctrl.ctrl_write8]
  806.  
  807.            mov edx, PCM_OUT_CR_REG
  808.            call [ctrl.ctrl_write8]
  809.  
  810.            mov edx, MC_IN_CR_REG
  811.            call [ctrl.ctrl_write8]
  812.            ret
  813. endp
  814.  
  815. align 4
  816. proc init_codec
  817.            locals
  818.              counter dd ?
  819.            endl
  820.  
  821.            mov esi, msgControl
  822.            call SysMsgBoardStr
  823.  
  824.            mov edx, GLOB_CTRL
  825.            call [ctrl.ctrl_read32]
  826.            call dword2str
  827.            call SysMsgBoardStr
  828.  
  829.            mov esi, msgStatus
  830.            call SysMsgBoardStr
  831.  
  832.            mov edx, CTRL_STAT
  833.            call [ctrl.ctrl_read32]
  834.  
  835.            call dword2str
  836.            call SysMsgBoardStr
  837.  
  838.            test eax, CTRL_ST_CREADY
  839.            jnz .ready
  840.  
  841.            call reset_codec
  842.            and eax, eax
  843.            jz .err
  844.  
  845.            xor edx, edx     ;ac_reg_0
  846.            call [ctrl.codec_write16]
  847.  
  848.            xor eax, eax
  849.            mov edx, CODEC_REG_POWERDOWN
  850.            call [ctrl.codec_write16]
  851.  
  852.            mov [counter], 200     ; total 200*5 ms = 1s
  853. .wait:
  854.            mov edx, CODEC_REG_POWERDOWN
  855.            call [ctrl.codec_read16]
  856.            and eax, 0x0F
  857.            cmp eax, 0x0F
  858.            jz .ready
  859.  
  860.            mov eax, 5000   ; wait 5 ms
  861.            call StallExec
  862.            sub [counter] , 1
  863.            jnz .wait
  864. .err:
  865.            xor eax, eax        ; timeout error
  866.            ret
  867. .ready:
  868.            call detect_codec
  869.  
  870.            xor eax, eax
  871.            inc eax
  872.            ret
  873. endp
  874.  
  875. align 4
  876. proc reset_codec
  877.            mov edx, GLOB_CTRL
  878.            call [ctrl.ctrl_read32]
  879.  
  880.            test eax, 0x02
  881.            jz .cold
  882.  
  883.            call warm_reset
  884.            jnc .ok
  885. .cold:
  886.            call cold_reset
  887.            jnc .ok
  888.  
  889.      if DEBUG
  890.            mov esi, msgCFail
  891.            call SysMsgBoardStr
  892.            end if
  893.            xor eax, eax     ; timeout error
  894.            ret
  895. .ok:
  896.      if DEBUG
  897.            mov esi, msgResetOk
  898.            call SysMsgBoardStr
  899.      end if
  900.  
  901.            xor eax, eax
  902.            inc eax
  903.            ret
  904. endp
  905.  
  906. align 4
  907. proc warm_reset
  908.            locals
  909.              counter dd ?
  910.            endl
  911.  
  912.            mov eax, 0x06
  913.            mov edx, GLOB_CTRL
  914.            call [ctrl.ctrl_write32]
  915.  
  916.      if DEBUG
  917.            mov esi, msgWarm
  918.            call SysMsgBoardStr
  919.      end if
  920.  
  921.            mov [counter], 10    ; total 10*100 ms = 1s
  922. .wait:
  923.            mov eax, 100000    ; wait 100 ms
  924.            call StallExec
  925.  
  926.            mov edx, GLOB_CTRL
  927.            call [ctrl.ctrl_read32]
  928.            test eax, 4
  929.            jz .ok
  930.            sub [counter], 1
  931.            jnz .wait
  932.  
  933.      if DEBUG
  934.            mov esi, msgWRFail
  935.            call SysMsgBoardStr
  936.      end if
  937.  
  938.            stc
  939.            ret
  940. .ok:
  941.            mov edx, CTRL_STAT
  942.            call [ctrl.ctrl_read32]
  943.            and eax, CTRL_ST_CREADY
  944.            jz .fail
  945.            clc
  946.            ret
  947. .fail:
  948.            stc
  949.            ret
  950. endp
  951.  
  952. align 4
  953. proc cold_reset
  954.            locals
  955.              counter dd ?
  956.            endl
  957.  
  958.            xor eax, eax
  959.            mov edx, GLOB_CTRL
  960.            call [ctrl.ctrl_write32]
  961.  
  962.      if DEBUG
  963.            mov esi, msgCold
  964.            call SysMsgBoardStr
  965.      end if
  966.  
  967.            mov eax, 1000000    ; wait 1 s
  968.            call StallExec
  969.  
  970.            mov eax, 2
  971.            mov edx, GLOB_CTRL
  972.            call [ctrl.ctrl_write32]
  973.  
  974.            mov [counter], 10    ; total 10*100 ms = 1s
  975. .wait:
  976.            mov eax, 100000    ; wait 100 ms
  977.            call StallExec
  978.  
  979.            mov edx, GLOB_CTRL
  980.            call [ctrl.ctrl_read32]
  981.            test eax, 4
  982.            jz .ok
  983.            sub [counter], 1
  984.            jnz .wait
  985.  
  986.      if DEBUG
  987.            mov esi, msgCRFail
  988.            call SysMsgBoardStr
  989.      end if
  990.            stc
  991.            ret
  992. .ok:
  993.            mov edx, CTRL_STAT
  994.            call [ctrl.ctrl_read32]
  995.            and eax, CTRL_ST_CREADY
  996.            jz .fail
  997.            clc
  998.            ret
  999. .fail:
  1000.            stc
  1001.            ret
  1002. endp
  1003.  
  1004. align 4
  1005. proc play
  1006.  
  1007.            mov eax, 16
  1008.            mov [ctrl.lvi_reg], eax
  1009.            mov edx, PCM_OUT_LVI_REG
  1010.            call [ctrl.ctrl_write8]
  1011.  
  1012.            mov edx, PCM_OUT_CR_REG
  1013.            mov ax, 0x1D
  1014.            call [ctrl.ctrl_write8]
  1015.            ret
  1016. endp
  1017.  
  1018. align 4
  1019. proc stop
  1020.            mov edx, PCM_OUT_CR_REG
  1021.            mov ax, 0x0
  1022.            call [ctrl.ctrl_write8]
  1023.  
  1024.            mov ax, 0x1c
  1025.            mov edx, PCM_OUT_SR_REG
  1026.            call [ctrl.ctrl_write16]
  1027.            ret
  1028. endp
  1029.  
  1030. align 4
  1031. proc get_dev_info stdcall, p_info:dword
  1032.            virtual at esi
  1033.              CTRL_INFO CTRL_INFO
  1034.            end virtual
  1035.  
  1036.            mov esi, [p_info]
  1037.            mov eax, [ctrl.int_line]
  1038.            mov ebx, [ctrl.codec_io_base]
  1039.            mov ecx, [ctrl.ctrl_io_base]
  1040.            mov edx, [ctrl.codec_mem_base]
  1041.            mov edi, [ctrl.ctrl_mem_base]
  1042.  
  1043.            mov [CTRL_INFO.irq], eax
  1044.            mov [CTRL_INFO.codec_io_base], ebx
  1045.            mov [CTRL_INFO.ctrl_io_base], ecx
  1046.            mov [CTRL_INFO.codec_mem_base], edx
  1047.            mov [CTRL_INFO.ctrl_mem_base], edi
  1048.  
  1049.            mov eax, [codec.chip_id]
  1050.            mov [CTRL_INFO.codec_id], eax
  1051.  
  1052.            mov edx, GLOB_CTRL
  1053.            call [ctrl.ctrl_read32]
  1054.            mov [CTRL_INFO.glob_cntrl], eax
  1055.  
  1056.            mov edx, CTRL_STAT
  1057.            call [ctrl.ctrl_read32]
  1058.            mov [CTRL_INFO.glob_sta], eax
  1059.  
  1060.            mov ebx, [ctrl.pci_cmd]
  1061.            mov [CTRL_INFO.pci_cmd], ebx
  1062.            ret
  1063. endp
  1064.  
  1065. align 4
  1066. proc set_callback stdcall, handler:dword
  1067.            mov eax, [handler]
  1068.            mov [ctrl.user_callback], eax
  1069.            ret
  1070. endp
  1071.  
  1072. align 4
  1073. proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
  1074.  
  1075.            mov edx, [ac_reg]
  1076.  
  1077.            mov ebx, edx
  1078.            shr ebx, 1
  1079.            bt [codec.shadow_flag], ebx
  1080.            jc .use_shadow
  1081.  
  1082.            call [ctrl.codec_read16]  ;change edx !!!
  1083.            mov ecx, eax
  1084.  
  1085.            mov edx, CTRL_STAT
  1086.            call [ctrl.ctrl_read32]
  1087.            test eax, CTRL_ST_RCS
  1088.            jz .read_ok
  1089.  
  1090.            mov edx, CTRL_STAT
  1091.            call [ctrl.ctrl_write32]
  1092.            xor eax,eax
  1093.            not eax  ;timeout
  1094.            ret
  1095. .read_ok:
  1096.            mov edx, [ac_reg]
  1097.            mov [codec.regs+edx], cx
  1098.            bts [codec.shadow_flag], ebx
  1099.            mov eax, ecx
  1100.            ret
  1101. .use_shadow:
  1102.            movzx eax, word [codec.regs+edx]
  1103.            ret
  1104. endp
  1105.  
  1106. align 4
  1107. proc codec_write stdcall, ac_reg:dword
  1108.            push eax
  1109.            call check_semafore
  1110.            and eax, eax
  1111.            jz .err
  1112.            pop eax
  1113.  
  1114.            mov esi, [ac_reg]
  1115.            mov edx, esi
  1116.            call [ctrl.codec_write16]
  1117.            mov [codec.regs+esi], ax
  1118.            shr esi, 1
  1119.            bts [codec.shadow_flag], esi
  1120.            ret
  1121. .err:
  1122.            pop eax
  1123.            ret
  1124. endp
  1125.  
  1126. align 4
  1127. proc codec_check_ready
  1128.  
  1129.            mov edx, CTRL_ST
  1130.            call [ctrl.ctrl_read32]
  1131.            and eax, CTRL_ST_CREADY
  1132.            jz .not_ready
  1133.  
  1134.            xor eax, wax
  1135.            inc eax
  1136.            ret
  1137. .not_ready:
  1138.            xor eax, eax
  1139.            ret
  1140. endp
  1141.  
  1142. align 4
  1143. proc check_semafore
  1144.            local counter:DWORD
  1145.  
  1146.            mov [counter], 100
  1147. .l1:
  1148.            mov edx, CTRL_CAS
  1149.            call [ctrl.ctrl_read8]
  1150.            and eax, CAS_FLAG
  1151.            jz .ok
  1152.  
  1153.            mov eax, 1
  1154.            call StallExec
  1155.            sub [counter], 1
  1156.            jnz .l1
  1157.            xor eax, eax
  1158.            ret
  1159. align 4
  1160. .ok:
  1161.            xor eax,eax
  1162.            inc eax
  1163.            ret
  1164. endp
  1165.  
  1166. align 4
  1167. proc StallExec
  1168.            push ecx
  1169.            push edx
  1170.            push ebx
  1171.            push eax
  1172.  
  1173.            mov ecx, CPU_FREQ
  1174.            mul ecx
  1175.            mov ebx, eax       ;low
  1176.            mov ecx, edx       ;high
  1177.            rdtsc
  1178.            add ebx, eax
  1179.            adc ecx,edx
  1180. @@:
  1181.            rdtsc
  1182.            sub eax, ebx
  1183.            sbb edx, ecx
  1184.            js @B
  1185.  
  1186.            pop eax
  1187.            pop ebx
  1188.            pop edx
  1189.            pop ecx
  1190.            ret
  1191. endp
  1192.  
  1193. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1194. ;          CONTROLLER IO functions
  1195. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1196.  
  1197. align 4
  1198. proc codec_io_r16
  1199.            add edx, [ctrl.codec_io_base]
  1200.            in  ax, dx
  1201.            ret
  1202. endp
  1203.  
  1204. align 4
  1205. proc codec_io_w16
  1206.            add edx, [ctrl.codec_io_base]
  1207.            out dx, ax
  1208.            ret
  1209. endp
  1210.  
  1211. align 4
  1212. proc ctrl_io_r8
  1213.            add edx, [ctrl.ctrl_io_base]
  1214.            in  al, dx
  1215.            ret
  1216. endp
  1217.  
  1218. align 4
  1219. proc ctrl_io_r16
  1220.            add edx, [ctrl.ctrl_io_base]
  1221.            in  ax, dx
  1222.            ret
  1223. endp
  1224.  
  1225. align 4
  1226. proc ctrl_io_r32
  1227.            add edx, [ctrl.ctrl_io_base]
  1228.            in  eax, dx
  1229.            ret
  1230. endp
  1231.  
  1232. align 4
  1233. proc ctrl_io_w8
  1234.            add edx, [ctrl.ctrl_io_base]
  1235.            out dx, al
  1236.            ret
  1237. endp
  1238.  
  1239. align 4
  1240. proc ctrl_io_w16
  1241.            add edx, [ctrl.ctrl_io_base]
  1242.            out dx, ax
  1243.            ret
  1244. endp
  1245.  
  1246. align 4
  1247. proc ctrl_io_w32
  1248.            add edx, [ctrl.ctrl_io_base]
  1249.            out dx, eax
  1250.            ret
  1251. endp
  1252.  
  1253. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1254. ;         MEMORY MAPPED IO    (os depended)
  1255. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1256.  
  1257. align 4
  1258. proc codec_mem_r16
  1259.            add edx, [ctrl.codec_mem_base]
  1260.            mov ax, word [edx]
  1261.            ret
  1262. endp
  1263.  
  1264. align 4
  1265. proc codec_mem_w16
  1266.            add edx, [ctrl.codec_mem_base]
  1267.            mov word [edx], ax
  1268.            ret
  1269. endp
  1270.  
  1271. align 4
  1272. proc ctrl_mem_r8
  1273.            add edx, [ctrl.ctrl_mem_base]
  1274.            mov al, [edx]
  1275.            ret
  1276. endp
  1277.  
  1278. align 4
  1279. proc ctrl_mem_r16
  1280.            add edx, [ctrl.ctrl_mem_base]
  1281.            mov ax, [edx]
  1282.            ret
  1283. endp
  1284.  
  1285. align 4
  1286. proc ctrl_mem_r32
  1287.            add edx, [ctrl.ctrl_mem_base]
  1288.            mov eax, [edx]
  1289.            ret
  1290. endp
  1291.  
  1292. align 4
  1293. proc ctrl_mem_w8
  1294.            add edx, [ctrl.ctrl_mem_base]
  1295.            mov [edx], al
  1296.            ret
  1297. endp
  1298.  
  1299. align 4
  1300. proc ctrl_mem_w16
  1301.            add edx, [ctrl.ctrl_mem_base]
  1302.            mov [edx], ax
  1303.            ret
  1304. endp
  1305.  
  1306. align 4
  1307. proc ctrl_mem_w32
  1308.            add edx, [ctrl.ctrl_mem_base]
  1309.            mov [edx], eax
  1310.            ret
  1311. endp
  1312.  
  1313. align 4
  1314. dword2str:
  1315.       mov  esi, hex_buff
  1316.       mov ecx, -8
  1317. @@:
  1318.       rol eax, 4
  1319.       mov ebx, eax
  1320.       and ebx, 0x0F
  1321.       mov bl, [ebx+hexletters]
  1322.       mov [8+esi+ecx], bl
  1323.       inc ecx
  1324.       jnz @B
  1325.       ret
  1326.  
  1327. hexletters   db '0123456789ABCDEF'
  1328. hex_buff     db 8 dup(0),13,10,0
  1329.  
  1330.  
  1331. include "codec.inc"
  1332.  
  1333. align 4
  1334. devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
  1335.         dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
  1336.         dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
  1337.         dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
  1338.         dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
  1339.         dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
  1340.         dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
  1341.         dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
  1342.  
  1343.         dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
  1344.         dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
  1345.         dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
  1346.         dd (CTRL_MCP04   shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
  1347.         dd (CTRL_CK804   shl 16)+VID_NVIDIA,msg_CK804,set_ICH
  1348.         dd (CTRL_CK8     shl 16)+VID_NVIDIA,msg_CK8,set_ICH
  1349.         dd (CTRL_CK8S    shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
  1350.         dd (CTRL_MCP51   shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
  1351.  
  1352.         dd 0    ;terminator
  1353.  
  1354. version      dd 0x00020002
  1355.  
  1356. msg_ICH      db 'Intel ICH',  13,10, 0
  1357. msg_ICH0     db 'Intel ICH0', 13,10, 0
  1358. msg_ICH2     db 'Intel ICH2', 13,10, 0
  1359. msg_ICH3     db 'Intel ICH3', 13,10, 0
  1360. msg_ICH4     db 'Intel ICH4', 13,10, 0
  1361. msg_ICH5     db 'Intel ICH5', 13,10, 0
  1362. msg_ICH6     db 'Intel ICH6', 13,10, 0
  1363. msg_ICH7     db 'Intel ICH7', 13,10, 0
  1364. msg_Intel    db 'Intel Corp. ', 0
  1365.  
  1366. msg_NForce   db 'NForce',      13,10, 0
  1367. msg_NForce2  db 'NForce 2',    13,10, 0
  1368. msg_NForce3  db 'NForce 3',    13,10, 0
  1369. msg_MCP04    db 'NForce MCP04',13,10, 0
  1370. msg_CK804    db 'NForce CK804',13,10, 0
  1371. msg_CK8      db 'NForce CK8',  13,10, 0
  1372. msg_CK8S     db 'NForce CK8S', 13,10, 0
  1373. msg_MCP51    db 'NForce MCP51',13,10, 0
  1374.  
  1375. msg_NVidia   db 'NVidia', 0
  1376.  
  1377. szKernel            db 'KERNEL', 0
  1378. sz_sound_srv        db 'SOUND',0
  1379.  
  1380. msgInit      db 'detect hardware...',13,10,0
  1381. msgFail      db 'device not found',13,10,0
  1382. msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
  1383. msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
  1384. msgPlay      db 'start play', 13,10,0
  1385. msgStop      db 'stop play',  13,10,0
  1386. msgNotify    db 'call notify',13,10,0
  1387. msgIRQ       db 'AC97 IRQ', 13,10,0
  1388. msgInitCtrl  db 'init controller',13,10,0
  1389. msgInitCodec db 'init codec',13,10,0
  1390. msgPrimBuff  db 'create primary buffer',13,10,0
  1391. msgReg       db 'set service handler',13,10,0
  1392. msgOk        db 'service installed',13,10,0
  1393. msgCold      db 'cold reset',13,10,0
  1394. msgWarm      db 'warm reset',13,10,0
  1395. msgWRFail    db 'warm reset failed',13,10,0
  1396. msgCRFail    db 'cold reset failed',13,10,0
  1397. msgCFail     db 'codec not ready',13,10,0
  1398. msgResetOk   db 'reset complete',13,10,0
  1399. msgStatus    db 'global status   ',0
  1400. msgControl   db 'global control  ',0
  1401.  
  1402. section '.data' data readable writable align 16
  1403.  
  1404. pcmout_bdl       rq 32
  1405. buff_list        rd 32
  1406.  
  1407. codec CODEC
  1408. ctrl AC_CNTRL
  1409.  
  1410. lpc_bus  rd 1
  1411. civ_val  rd 1
  1412.  
  1413.  
  1414.