Subversion Repositories Kolibri OS

Rev

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, 0x10;               0x10
  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, 0x11              ;0x1D
  491.            call [ctrl.ctrl_write8]
  492.  
  493.            mov eax, [civ_val]
  494.            add eax, 1
  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, 0x11               ;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.            mov eax, [ctrl.buffer]
  525.            call GetPgAddr
  526.  
  527.            mov ebx, 0xC0002000
  528.            mov ecx, 4
  529.            mov edi, pcmout_bdl
  530. @@:
  531.            mov [edi], eax
  532.            mov [edi+4], ebx
  533.  
  534.            mov [edi+32], eax
  535.            mov [edi+4+32], ebx
  536.  
  537.            mov [edi+64], eax
  538.            mov [edi+4+64], ebx
  539.  
  540.            mov [edi+96], eax
  541.            mov [edi+4+96], ebx
  542.  
  543.            mov [edi+128], eax
  544.            mov [edi+4+128], ebx
  545.  
  546.            mov [edi+160], eax
  547.            mov [edi+4+160], ebx
  548.  
  549.            mov [edi+192], eax
  550.            mov [edi+4+192], ebx
  551.  
  552.            mov [edi+224], eax
  553.            mov [edi+4+224], ebx
  554.  
  555.            add eax, 0x4000
  556.            add edi, 8
  557.            loop @B
  558.  
  559.            mov edi, buff_list
  560.            mov eax, [ctrl.buffer]
  561.            mov ecx, 4
  562. @@:
  563.            mov [edi], eax
  564.            mov [edi+16], eax
  565.            mov [edi+32], eax
  566.            mov [edi+48], eax
  567.            mov [edi+64], eax
  568.            mov [edi+80], eax
  569.            mov [edi+96], eax
  570.            mov [edi+112], eax
  571.  
  572.            add eax, 0x4000
  573.            add edi, 4
  574.            loop @B
  575.  
  576.            mov eax, pcmout_bdl
  577.            mov ebx, eax
  578.            call GetPgAddr     ;eax
  579.            and ebx, 0xFFF
  580.            add eax, ebx
  581.  
  582.            mov edx, PCM_OUT_BDL
  583.            call [ctrl.ctrl_write32]
  584.  
  585.            mov eax, 16
  586.            mov [ctrl.lvi_reg], eax
  587.            mov edx, PCM_OUT_LVI_REG
  588.            call [ctrl.ctrl_write8]
  589.            ret
  590. endp
  591.  
  592. align 4
  593. proc detect_controller
  594.            locals
  595.              last_bus dd ?
  596.              bus      dd ?
  597.              devfn    dd ?
  598.            endl
  599.  
  600.            xor eax, eax
  601.            mov [bus], eax
  602.            inc eax
  603.            call PciApi
  604.            cmp eax, -1
  605.            je .err
  606.  
  607.            mov [last_bus], eax
  608.  
  609. .next_bus:
  610.            and [devfn], 0
  611. .next_dev:
  612.            stdcall PciRead32, [bus], [devfn], dword 0
  613.            test eax, eax
  614.            jz .next
  615.            cmp eax, -1
  616.            je .next
  617.  
  618.            mov edi, devices
  619. @@:
  620.            mov ebx, [edi]
  621.            test ebx, ebx
  622.            jz .next
  623.  
  624.            cmp eax, ebx
  625.            je .found
  626.            add edi, 12
  627.            jmp @B
  628.  
  629. .next:
  630.            inc [devfn]
  631.            cmp [devfn], 256
  632.            jb .next_dev
  633.            mov eax, [bus]
  634.            inc eax
  635.            mov [bus], eax
  636.            cmp eax, [last_bus]
  637.            jna .next_bus
  638.            xor eax, eax
  639.            ret
  640. .found:
  641.            mov ebx, [bus]
  642.            mov [ctrl.bus], ebx
  643.  
  644.            mov ecx, [devfn]
  645.            mov [ctrl.devfn], ecx
  646.  
  647.            mov edx, eax
  648.            and edx, 0xFFFF
  649.            mov [ctrl.vendor], edx
  650.            shr eax, 16
  651.            mov [ctrl.dev_id], eax
  652.  
  653.            mov ebx, [edi+4]
  654.            mov [ctrl.ctrl_ids], ebx
  655.            mov esi, [edi+8]
  656.            mov [ctrl.ctrl_setup], esi
  657.  
  658.            cmp ebx, VID_INTEL
  659.            jne @F
  660.            mov [ctrl.vendor_ids], msg_Intel
  661.            ret
  662. @@:
  663.            cmp ebx, VID_NVIDIA
  664.            jne @F
  665.            mov [ctrl.vendor_ids], msg_NVidia
  666. @@:
  667.            mov [ctrl.vendor_ids], 0     ;something  wrong ?
  668.            ret
  669. .err:
  670.            xor eax, eax
  671.            ret
  672. endp
  673.  
  674. align 4
  675. proc get_LPC_bus                ;for Intel chipsets ONLY !!!
  676.            locals
  677.              last_bus dd ?
  678.              bus      dd ?
  679.            endl
  680.  
  681.            xor eax, eax
  682.            mov [bus], eax
  683.            inc eax
  684.            call [PciApi]
  685.            cmp eax, -1
  686.            je .err
  687.  
  688.            mov [last_bus], eax
  689. .next_bus:
  690.            stdcall PciRead32, [bus], dword 0xF8, dword 0
  691.            test eax, eax
  692.            jz .next
  693.            cmp eax, -1
  694.            je .next
  695.  
  696.            cmp eax, 0x24D08086
  697.            je .found
  698. .next:
  699.            mov eax, [bus]
  700.            inc eax
  701.            cmp eax, [last_bus]
  702.            mov [bus], eax
  703.            jna .next_bus
  704. .err:
  705.            xor eax, eax
  706.            dec eax
  707.            ret
  708. .found:
  709.            mov eax, [bus]
  710.            ret
  711. endp
  712.  
  713. align 4
  714. proc init_controller
  715.  
  716.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
  717.            mov ebx, eax
  718.            and eax, 0xFFFF
  719.            mov [ctrl.pci_cmd], eax
  720.            shr ebx, 16
  721.            mov [ctrl.pci_stat], ebx
  722.  
  723.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
  724.            and eax,0xFFFE
  725.            mov [ctrl.codec_io_base], eax
  726.  
  727.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
  728.            and eax, 0xFFC0
  729.            mov [ctrl.ctrl_io_base], eax
  730.  
  731.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
  732.            mov [ctrl.codec_mem_base], eax
  733.  
  734.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
  735.            mov [ctrl.ctrl_mem_base], eax
  736.  
  737.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
  738.            and eax, 0xFF
  739.            mov [ctrl.int_line], eax
  740.  
  741.            stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
  742.            and eax, 0xFF
  743.            mov [ctrl.cfg_reg], eax
  744.  
  745.            call [ctrl.ctrl_setup]
  746.            xor eax, eax
  747.            inc eax
  748.            ret
  749. endp
  750.  
  751. align 4
  752. proc set_ICH
  753.            mov [ctrl.codec_read16],  codec_io_r16    ;virtual
  754.            mov [ctrl.codec_write16], codec_io_w16    ;virtual
  755.  
  756.            mov [ctrl.ctrl_read8 ],  ctrl_io_r8      ;virtual
  757.            mov [ctrl.ctrl_read16],  ctrl_io_r16      ;virtual
  758.            mov [ctrl.ctrl_read32],  ctrl_io_r32      ;virtual
  759.  
  760.            mov [ctrl.ctrl_write8 ], ctrl_io_w8      ;virtual
  761.            mov [ctrl.ctrl_write16], ctrl_io_w16      ;virtual
  762.            mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
  763.            ret
  764. endp
  765.  
  766. PG_SW                equ 0x003
  767. PG_NOCACHE           equ 0x018
  768.  
  769. align 4
  770. proc set_ICH4
  771.            stdcall AllocKernelSpace, dword 0x2000
  772.            mov edi, eax
  773.            stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
  774.            mov [ctrl.codec_mem_base], edi
  775.            add edi, 0x1000
  776.            stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
  777.            mov [ctrl.ctrl_mem_base], edi
  778.  
  779.            mov [ctrl.codec_read16],  codec_mem_r16    ;virtual
  780.            mov [ctrl.codec_write16], codec_mem_w16    ;virtual
  781.  
  782.            mov [ctrl.ctrl_read8 ],  ctrl_mem_r8       ;virtual
  783.            mov [ctrl.ctrl_read16],  ctrl_mem_r16      ;virtual
  784.            mov [ctrl.ctrl_read32],  ctrl_mem_r32      ;virtual
  785.  
  786.            mov [ctrl.ctrl_write8 ], ctrl_mem_w8       ;virtual
  787.            mov [ctrl.ctrl_write16], ctrl_mem_w16      ;virtual
  788.            mov [ctrl.ctrl_write32], ctrl_mem_w32      ;virtual
  789.            ret
  790. endp
  791.  
  792. align 4
  793. proc reset_controller
  794.  
  795.            xor eax, eax
  796.            mov edx, PCM_IN_CR_REG
  797.            call [ctrl.ctrl_write8]
  798.  
  799.            mov edx, PCM_OUT_CR_REG
  800.            call [ctrl.ctrl_write8]
  801.  
  802.            mov edx, MC_IN_CR_REG
  803.            call [ctrl.ctrl_write8]
  804.  
  805.            mov eax, RR
  806.            mov edx, PCM_IN_CR_REG
  807.            call [ctrl.ctrl_write8]
  808.  
  809.            mov edx, PCM_OUT_CR_REG
  810.            call [ctrl.ctrl_write8]
  811.  
  812.            mov edx, MC_IN_CR_REG
  813.            call [ctrl.ctrl_write8]
  814.            ret
  815. endp
  816.  
  817. align 4
  818. proc init_codec
  819.            locals
  820.              counter dd ?
  821.            endl
  822.  
  823.            mov esi, msgControl
  824.            call SysMsgBoardStr
  825.  
  826.            mov edx, GLOB_CTRL
  827.            call [ctrl.ctrl_read32]
  828.            call dword2str
  829.            call SysMsgBoardStr
  830.  
  831.            mov esi, msgStatus
  832.            call SysMsgBoardStr
  833.  
  834.            mov edx, CTRL_STAT
  835.            call [ctrl.ctrl_read32]
  836.  
  837.            call dword2str
  838.            call SysMsgBoardStr
  839.  
  840.            test eax, CTRL_ST_CREADY
  841.            jnz .ready
  842.  
  843.            call reset_codec
  844.            and eax, eax
  845.            jz .err
  846.  
  847.            xor edx, edx     ;ac_reg_0
  848.            call [ctrl.codec_write16]
  849.  
  850.            xor eax, eax
  851.            mov edx, CODEC_REG_POWERDOWN
  852.            call [ctrl.codec_write16]
  853.  
  854.            mov [counter], 200     ; total 200*5 ms = 1s
  855. .wait:
  856.            mov edx, CODEC_REG_POWERDOWN
  857.            call [ctrl.codec_read16]
  858.            and eax, 0x0F
  859.            cmp eax, 0x0F
  860.            jz .ready
  861.  
  862.            mov eax, 5000   ; wait 5 ms
  863.            call StallExec
  864.            sub [counter] , 1
  865.            jnz .wait
  866. .err:
  867.            xor eax, eax        ; timeout error
  868.            ret
  869. .ready:
  870.            call detect_codec
  871.  
  872.            xor eax, eax
  873.            inc eax
  874.            ret
  875. endp
  876.  
  877. align 4
  878. proc reset_codec
  879.            mov edx, GLOB_CTRL
  880.            call [ctrl.ctrl_read32]
  881.  
  882.            test eax, 0x02
  883.            jz .cold
  884.  
  885.            call warm_reset
  886.            jnc .ok
  887. .cold:
  888.            call cold_reset
  889.            jnc .ok
  890.  
  891.      if DEBUG
  892.            mov esi, msgCFail
  893.            call SysMsgBoardStr
  894.            end if
  895.            xor eax, eax     ; timeout error
  896.            ret
  897. .ok:
  898.      if DEBUG
  899.            mov esi, msgResetOk
  900.            call SysMsgBoardStr
  901.      end if
  902.  
  903.            xor eax, eax
  904.            inc eax
  905.            ret
  906. endp
  907.  
  908. align 4
  909. proc warm_reset
  910.            locals
  911.              counter dd ?
  912.            endl
  913.  
  914.            mov eax, 0x06
  915.            mov edx, GLOB_CTRL
  916.            call [ctrl.ctrl_write32]
  917.  
  918.      if DEBUG
  919.            mov esi, msgWarm
  920.            call SysMsgBoardStr
  921.      end if
  922.  
  923.            mov [counter], 10    ; total 10*100 ms = 1s
  924. .wait:
  925.            mov eax, 100000    ; wait 100 ms
  926.            call StallExec
  927.  
  928.            mov edx, GLOB_CTRL
  929.            call [ctrl.ctrl_read32]
  930.            test eax, 4
  931.            jz .ok
  932.            sub [counter], 1
  933.            jnz .wait
  934.  
  935.      if DEBUG
  936.            mov esi, msgWRFail
  937.            call SysMsgBoardStr
  938.      end if
  939.  
  940.            stc
  941.            ret
  942. .ok:
  943.            mov edx, CTRL_STAT
  944.            call [ctrl.ctrl_read32]
  945.            and eax, CTRL_ST_CREADY
  946.            jz .fail
  947.            clc
  948.            ret
  949. .fail:
  950.            stc
  951.            ret
  952. endp
  953.  
  954. align 4
  955. proc cold_reset
  956.            locals
  957.              counter dd ?
  958.            endl
  959.  
  960.            xor eax, eax
  961.            mov edx, GLOB_CTRL
  962.            call [ctrl.ctrl_write32]
  963.  
  964.      if DEBUG
  965.            mov esi, msgCold
  966.            call SysMsgBoardStr
  967.      end if
  968.  
  969.            mov eax, 1000000    ; wait 1 s
  970.            call StallExec
  971.  
  972.            mov eax, 2
  973.            mov edx, GLOB_CTRL
  974.            call [ctrl.ctrl_write32]
  975.  
  976.            mov [counter], 10    ; total 10*100 ms = 1s
  977. .wait:
  978.            mov eax, 100000    ; wait 100 ms
  979.            call StallExec
  980.  
  981.            mov edx, GLOB_CTRL
  982.            call [ctrl.ctrl_read32]
  983.            test eax, 4
  984.            jz .ok
  985.            sub [counter], 1
  986.            jnz .wait
  987.  
  988.      if DEBUG
  989.            mov esi, msgCRFail
  990.            call SysMsgBoardStr
  991.      end if
  992.            stc
  993.            ret
  994. .ok:
  995.            mov edx, CTRL_STAT
  996.            call [ctrl.ctrl_read32]
  997.            and eax, CTRL_ST_CREADY
  998.            jz .fail
  999.            clc
  1000.            ret
  1001. .fail:
  1002.            stc
  1003.            ret
  1004. endp
  1005.  
  1006. align 4
  1007. proc play
  1008.  
  1009.            mov eax, 16
  1010.            mov [ctrl.lvi_reg], eax
  1011.            mov edx, PCM_OUT_LVI_REG
  1012.            call [ctrl.ctrl_write8]
  1013.  
  1014.            mov edx, PCM_OUT_CR_REG
  1015.            mov ax, 0x1D
  1016.            call [ctrl.ctrl_write8]
  1017.            ret
  1018. endp
  1019.  
  1020. align 4
  1021. proc stop
  1022.            mov edx, PCM_OUT_CR_REG
  1023.            mov ax, 0x0
  1024.            call [ctrl.ctrl_write8]
  1025.  
  1026.            mov ax, 0x1c
  1027.            mov edx, PCM_OUT_SR_REG
  1028.            call [ctrl.ctrl_write16]
  1029.            ret
  1030. endp
  1031.  
  1032. align 4
  1033. proc get_dev_info stdcall, p_info:dword
  1034.            virtual at esi
  1035.              CTRL_INFO CTRL_INFO
  1036.            end virtual
  1037.  
  1038.            mov esi, [p_info]
  1039.            mov eax, [ctrl.int_line]
  1040.            mov ebx, [ctrl.codec_io_base]
  1041.            mov ecx, [ctrl.ctrl_io_base]
  1042.            mov edx, [ctrl.codec_mem_base]
  1043.            mov edi, [ctrl.ctrl_mem_base]
  1044.  
  1045.            mov [CTRL_INFO.irq], eax
  1046.            mov [CTRL_INFO.codec_io_base], ebx
  1047.            mov [CTRL_INFO.ctrl_io_base], ecx
  1048.            mov [CTRL_INFO.codec_mem_base], edx
  1049.            mov [CTRL_INFO.ctrl_mem_base], edi
  1050.  
  1051.            mov eax, [codec.chip_id]
  1052.            mov [CTRL_INFO.codec_id], eax
  1053.  
  1054.            mov edx, GLOB_CTRL
  1055.            call [ctrl.ctrl_read32]
  1056.            mov [CTRL_INFO.glob_cntrl], eax
  1057.  
  1058.            mov edx, CTRL_STAT
  1059.            call [ctrl.ctrl_read32]
  1060.            mov [CTRL_INFO.glob_sta], eax
  1061.  
  1062.            mov ebx, [ctrl.pci_cmd]
  1063.            mov [CTRL_INFO.pci_cmd], ebx
  1064.            ret
  1065. endp
  1066.  
  1067. align 4
  1068. proc set_callback stdcall, handler:dword
  1069.            mov eax, [handler]
  1070.            mov [ctrl.user_callback], eax
  1071.            ret
  1072. endp
  1073.  
  1074. align 4
  1075. proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
  1076.  
  1077.            mov edx, [ac_reg]
  1078.  
  1079.            mov ebx, edx
  1080.            shr ebx, 1
  1081.            bt [codec.shadow_flag], ebx
  1082.            jc .use_shadow
  1083.  
  1084.            call [ctrl.codec_read16]  ;change edx !!!
  1085.            mov ecx, eax
  1086.  
  1087.            mov edx, CTRL_STAT
  1088.            call [ctrl.ctrl_read32]
  1089.            test eax, CTRL_ST_RCS
  1090.            jz .read_ok
  1091.  
  1092.            mov edx, CTRL_STAT
  1093.            call [ctrl.ctrl_write32]
  1094.            xor eax,eax
  1095.            not eax  ;timeout
  1096.            ret
  1097. .read_ok:
  1098.            mov edx, [ac_reg]
  1099.            mov [codec.regs+edx], cx
  1100.            bts [codec.shadow_flag], ebx
  1101.            mov eax, ecx
  1102.            ret
  1103. .use_shadow:
  1104.            movzx eax, word [codec.regs+edx]
  1105.            ret
  1106. endp
  1107.  
  1108. align 4
  1109. proc codec_write stdcall, ac_reg:dword
  1110.            push eax
  1111.            call check_semafore
  1112.            and eax, eax
  1113.            jz .err
  1114.            pop eax
  1115.  
  1116.            mov esi, [ac_reg]
  1117.            mov edx, esi
  1118.            call [ctrl.codec_write16]
  1119.            mov [codec.regs+esi], ax
  1120.            shr esi, 1
  1121.            bts [codec.shadow_flag], esi
  1122.            ret
  1123. .err:
  1124.            pop eax
  1125.            ret
  1126. endp
  1127.  
  1128. align 4
  1129. proc codec_check_ready
  1130.  
  1131.            mov edx, CTRL_ST
  1132.            call [ctrl.ctrl_read32]
  1133.            and eax, CTRL_ST_CREADY
  1134.            jz .not_ready
  1135.  
  1136.            xor eax, wax
  1137.            inc eax
  1138.            ret
  1139. .not_ready:
  1140.            xor eax, eax
  1141.            ret
  1142. endp
  1143.  
  1144. align 4
  1145. proc check_semafore
  1146.            local counter:DWORD
  1147.  
  1148.            mov [counter], 100
  1149. .l1:
  1150.            mov edx, CTRL_CAS
  1151.            call [ctrl.ctrl_read8]
  1152.            and eax, CAS_FLAG
  1153.            jz .ok
  1154.  
  1155.            mov eax, 1
  1156.            call StallExec
  1157.            sub [counter], 1
  1158.            jnz .l1
  1159.            xor eax, eax
  1160.            ret
  1161. align 4
  1162. .ok:
  1163.            xor eax,eax
  1164.            inc eax
  1165.            ret
  1166. endp
  1167.  
  1168. align 4
  1169. proc StallExec
  1170.            push ecx
  1171.            push edx
  1172.            push ebx
  1173.            push eax
  1174.  
  1175.            mov ecx, CPU_FREQ
  1176.            mul ecx
  1177.            mov ebx, eax       ;low
  1178.            mov ecx, edx       ;high
  1179.            rdtsc
  1180.            add ebx, eax
  1181.            adc ecx,edx
  1182. @@:
  1183.            rdtsc
  1184.            sub eax, ebx
  1185.            sbb edx, ecx
  1186.            js @B
  1187.  
  1188.            pop eax
  1189.            pop ebx
  1190.            pop edx
  1191.            pop ecx
  1192.            ret
  1193. endp
  1194.  
  1195. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1196. ;          CONTROLLER IO functions
  1197. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1198.  
  1199. align 4
  1200. proc codec_io_r16
  1201.            add edx, [ctrl.codec_io_base]
  1202.            in  ax, dx
  1203.            ret
  1204. endp
  1205.  
  1206. align 4
  1207. proc codec_io_w16
  1208.            add edx, [ctrl.codec_io_base]
  1209.            out dx, ax
  1210.            ret
  1211. endp
  1212.  
  1213. align 4
  1214. proc ctrl_io_r8
  1215.            add edx, [ctrl.ctrl_io_base]
  1216.            in  al, dx
  1217.            ret
  1218. endp
  1219.  
  1220. align 4
  1221. proc ctrl_io_r16
  1222.            add edx, [ctrl.ctrl_io_base]
  1223.            in  ax, dx
  1224.            ret
  1225. endp
  1226.  
  1227. align 4
  1228. proc ctrl_io_r32
  1229.            add edx, [ctrl.ctrl_io_base]
  1230.            in  eax, dx
  1231.            ret
  1232. endp
  1233.  
  1234. align 4
  1235. proc ctrl_io_w8
  1236.            add edx, [ctrl.ctrl_io_base]
  1237.            out dx, al
  1238.            ret
  1239. endp
  1240.  
  1241. align 4
  1242. proc ctrl_io_w16
  1243.            add edx, [ctrl.ctrl_io_base]
  1244.            out dx, ax
  1245.            ret
  1246. endp
  1247.  
  1248. align 4
  1249. proc ctrl_io_w32
  1250.            add edx, [ctrl.ctrl_io_base]
  1251.            out dx, eax
  1252.            ret
  1253. endp
  1254.  
  1255. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1256. ;         MEMORY MAPPED IO    (os depended)
  1257. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1258.  
  1259. align 4
  1260. proc codec_mem_r16
  1261.            add edx, [ctrl.codec_mem_base]
  1262.            mov ax, word [edx]
  1263.            ret
  1264. endp
  1265.  
  1266. align 4
  1267. proc codec_mem_w16
  1268.            add edx, [ctrl.codec_mem_base]
  1269.            mov word [edx], ax
  1270.            ret
  1271. endp
  1272.  
  1273. align 4
  1274. proc ctrl_mem_r8
  1275.            add edx, [ctrl.ctrl_mem_base]
  1276.            mov al, [edx]
  1277.            ret
  1278. endp
  1279.  
  1280. align 4
  1281. proc ctrl_mem_r16
  1282.            add edx, [ctrl.ctrl_mem_base]
  1283.            mov ax, [edx]
  1284.            ret
  1285. endp
  1286.  
  1287. align 4
  1288. proc ctrl_mem_r32
  1289.            add edx, [ctrl.ctrl_mem_base]
  1290.            mov eax, [edx]
  1291.            ret
  1292. endp
  1293.  
  1294. align 4
  1295. proc ctrl_mem_w8
  1296.            add edx, [ctrl.ctrl_mem_base]
  1297.            mov [edx], al
  1298.            ret
  1299. endp
  1300.  
  1301. align 4
  1302. proc ctrl_mem_w16
  1303.            add edx, [ctrl.ctrl_mem_base]
  1304.            mov [edx], ax
  1305.            ret
  1306. endp
  1307.  
  1308. align 4
  1309. proc ctrl_mem_w32
  1310.            add edx, [ctrl.ctrl_mem_base]
  1311.            mov [edx], eax
  1312.            ret
  1313. endp
  1314.  
  1315. align 4
  1316. dword2str:
  1317.       mov  esi, hex_buff
  1318.       mov ecx, -8
  1319. @@:
  1320.       rol eax, 4
  1321.       mov ebx, eax
  1322.       and ebx, 0x0F
  1323.       mov bl, [ebx+hexletters]
  1324.       mov [8+esi+ecx], bl
  1325.       inc ecx
  1326.       jnz @B
  1327.       ret
  1328.  
  1329. hexletters   db '0123456789ABCDEF'
  1330. hex_buff     db 8 dup(0),13,10,0
  1331.  
  1332.  
  1333. include "codec.inc"
  1334.  
  1335. align 4
  1336. devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
  1337.         dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
  1338.         dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
  1339.         dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
  1340.         dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
  1341.         dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
  1342.         dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
  1343.         dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
  1344.  
  1345.         dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
  1346.         dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
  1347.         dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
  1348.         dd (CTRL_MCP04   shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
  1349.         dd (CTRL_CK804   shl 16)+VID_NVIDIA,msg_CK804,set_ICH
  1350.         dd (CTRL_CK8     shl 16)+VID_NVIDIA,msg_CK8,set_ICH
  1351.         dd (CTRL_CK8S    shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
  1352.         dd (CTRL_MCP51   shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
  1353.  
  1354.         dd 0    ;terminator
  1355.  
  1356. version      dd 0x00030003
  1357.  
  1358. msg_ICH      db 'Intel ICH',  13,10, 0
  1359. msg_ICH0     db 'Intel ICH0', 13,10, 0
  1360. msg_ICH2     db 'Intel ICH2', 13,10, 0
  1361. msg_ICH3     db 'Intel ICH3', 13,10, 0
  1362. msg_ICH4     db 'Intel ICH4', 13,10, 0
  1363. msg_ICH5     db 'Intel ICH5', 13,10, 0
  1364. msg_ICH6     db 'Intel ICH6', 13,10, 0
  1365. msg_ICH7     db 'Intel ICH7', 13,10, 0
  1366. msg_Intel    db 'Intel Corp. ', 0
  1367.  
  1368. msg_NForce   db 'NForce',      13,10, 0
  1369. msg_NForce2  db 'NForce 2',    13,10, 0
  1370. msg_NForce3  db 'NForce 3',    13,10, 0
  1371. msg_MCP04    db 'NForce MCP04',13,10, 0
  1372. msg_CK804    db 'NForce CK804',13,10, 0
  1373. msg_CK8      db 'NForce CK8',  13,10, 0
  1374. msg_CK8S     db 'NForce CK8S', 13,10, 0
  1375. msg_MCP51    db 'NForce MCP51',13,10, 0
  1376.  
  1377. msg_NVidia   db 'NVidia', 0
  1378.  
  1379. szKernel            db 'KERNEL', 0
  1380. sz_sound_srv        db 'SOUND',0
  1381.  
  1382. msgInit      db 'detect hardware...',13,10,0
  1383. msgFail      db 'device not found',13,10,0
  1384. msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
  1385. msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
  1386. msgPlay      db 'start play', 13,10,0
  1387. msgStop      db 'stop play',  13,10,0
  1388. msgNotify    db 'call notify',13,10,0
  1389. msgIRQ       db 'AC97 IRQ', 13,10,0
  1390. msgInitCtrl  db 'init controller',13,10,0
  1391. msgInitCodec db 'init codec',13,10,0
  1392. msgPrimBuff  db 'create primary buffer',13,10,0
  1393. msgReg       db 'set service handler',13,10,0
  1394. msgOk        db 'service installed',13,10,0
  1395. msgCold      db 'cold reset',13,10,0
  1396. msgWarm      db 'warm reset',13,10,0
  1397. msgWRFail    db 'warm reset failed',13,10,0
  1398. msgCRFail    db 'cold reset failed',13,10,0
  1399. msgCFail     db 'codec not ready',13,10,0
  1400. msgResetOk   db 'reset complete',13,10,0
  1401. msgStatus    db 'global status   ',0
  1402. msgControl   db 'global control  ',0
  1403.  
  1404. section '.data' data readable writable align 16
  1405.  
  1406. pcmout_bdl       rq 32
  1407. buff_list        rd 32
  1408.  
  1409. codec CODEC
  1410. ctrl AC_CNTRL
  1411.  
  1412. lpc_bus  rd 1
  1413. civ_val  rd 1
  1414.  
  1415.  
  1416.