Subversion Repositories Kolibri OS

Rev

Rev 417 | 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 0x80000000
  274. SLOT_BASE       equ OS_BASE+0x0080000
  275.  
  276. public START
  277. public service_proc
  278. public version
  279.  
  280. section '.flat' code readable align 16
  281.  
  282. proc START stdcall, state:dword
  283.  
  284.            cmp [state], 1
  285.            jne .stop
  286.  
  287.      if DEBUG
  288.            mov esi, msgInit
  289.            call SysMsgBoardStr
  290.      end if
  291.  
  292.            call detect_controller
  293.            test eax, eax
  294.            jz .fail
  295.  
  296.      if DEBUG
  297.            mov esi,[ctrl.vendor_ids]
  298.            call SysMsgBoardStr
  299.            mov esi, [ctrl.ctrl_ids]
  300.            call SysMsgBoardStr
  301.  
  302.      end if
  303.  
  304.            call init_controller
  305.            test eax, eax
  306.            jz .fail
  307.  
  308.      if DEBUG
  309.            mov esi, msgInitCodec
  310.            call SysMsgBoardStr
  311.      end if
  312.  
  313.            call init_codec
  314.            test eax, eax
  315.            jz .fail
  316.  
  317.      if DEBUG
  318.            mov esi, [codec.ac_vendor_ids]
  319.            call SysMsgBoardStr
  320.  
  321.            mov esi, [codec.chip_ids]
  322.            call SysMsgBoardStr
  323.      end if
  324.  
  325.            call reset_controller
  326.            call setup_codec
  327.  
  328.            mov esi, msgPrimBuff
  329.            call SysMsgBoardStr
  330.  
  331.            call create_primary_buff
  332.  
  333. ;     if REMAP_IRQ
  334.  
  335. ;           call get_LPC_bus
  336. ;           cmp eax, -1
  337. ;           jz .fail
  338.  
  339. ;           mov [lpc_bus], 0  ;eax
  340. ;           call remap_irq
  341. ;     end if
  342.  
  343.            mov eax, VALID_IRQ
  344.            mov ebx, [ctrl.int_line]
  345.            mov esi, msgInvIRQ
  346.            bt eax, ebx
  347.            jnc .fail
  348.            mov eax, ATTCH_IRQ
  349.            mov esi, msgAttchIRQ
  350.            bt eax, ebx
  351.            jnc .fail
  352.  
  353.            stdcall AttachIntHandler, ebx, ac97_irq
  354. .reg:
  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 eax, [edi+input]
  409.            mov eax, [eax]
  410.            call set_master_vol      ;eax= vol
  411.            ret
  412. @@:
  413.            cmp eax, DEV_GET_MASTERVOL
  414.            jne @F
  415.            mov ebx, [edi+output]
  416.            stdcall get_master_vol, ebx
  417.            ret
  418. ;@@:
  419. ;           cmp eax, DEV_GET_INFO
  420. ;           jne @F
  421. ;           mov ebx, [edi+output]
  422. ;           stdcall get_dev_info, ebx
  423. ;           ret
  424. @@:
  425. .fail:
  426.            or eax, -1
  427.            ret
  428. endp
  429.  
  430. restore   handle
  431. restore   io_code
  432. restore   input
  433. restore   inp_size
  434. restore   output
  435. restore   out_size
  436.  
  437.  
  438. align 4
  439. proc remap_irq                         ;for Intel chipsets ONLY !!!
  440.            mov eax, VALID_IRQ
  441.            bt eax, IRQ_LINE
  442.            jnc .exit
  443.  
  444.            mov edx, 0x4D0
  445.            in ax,dx
  446.            bts ax, IRQ_LINE
  447.            out dx, aX
  448.  
  449.            stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
  450.            mov [ctrl.int_line], IRQ_LINE
  451.  
  452. .exit:
  453.            ret
  454. endp
  455.  
  456. align 4
  457. proc ac97_irq
  458.  
  459. ;     if DEBUG
  460. ;           mov esi, msgIRQ
  461. ;           call SysMsgBoardStr
  462. ;     end if
  463.  
  464.            mov edx, PCM_OUT_CR_REG
  465.            mov al, 0x10;               0x10
  466.            call [ctrl.ctrl_write8]
  467.  
  468.            mov ax, 0x1c
  469.            mov edx, PCM_OUT_SR_REG
  470.            call [ctrl.ctrl_write16]
  471.  
  472.            mov edx, PCM_OUT_CIV_REG
  473.            call [ctrl.ctrl_read8]
  474.  
  475.            and eax, 0x1F
  476.            cmp eax, [civ_val]
  477.            je .skip
  478.  
  479.            mov [civ_val], eax
  480.            dec eax
  481.            and eax, 0x1F
  482.            mov [ctrl.lvi_reg], eax
  483.  
  484.            mov edx, PCM_OUT_LVI_REG
  485.            call [ctrl.ctrl_write8]
  486.  
  487.            mov edx, PCM_OUT_CR_REG
  488.            mov ax, 0x11              ;0x1D
  489.            call [ctrl.ctrl_write8]
  490.  
  491.            mov eax, [civ_val]
  492.            add eax, 1
  493.            and eax, 31
  494.            mov ebx, dword [buff_list+eax*4]
  495.  
  496.            cmp [ctrl.user_callback], 0
  497.            je @f
  498.  
  499.            stdcall [ctrl.user_callback], ebx
  500. @@:
  501.            ret
  502.  
  503. .skip:
  504.            mov edx, PCM_OUT_CR_REG
  505.            mov ax, 0x11               ;0x1D
  506.            call [ctrl.ctrl_write8]
  507.            ret
  508. endp
  509.  
  510. align 4
  511. proc create_primary_buff
  512.  
  513.            stdcall KernelAlloc, 0x10000
  514.            mov [ctrl.buffer], eax
  515.  
  516.            mov edi, eax
  517.            mov ecx, 0x10000/4
  518.            xor eax, eax
  519.            cld
  520.            rep stosd
  521.  
  522.            mov eax, [ctrl.buffer]
  523.            call GetPgAddr
  524.  
  525.            mov ebx, 0xC0002000
  526.            mov ecx, 4
  527.            mov edi, pcmout_bdl
  528. @@:
  529.            mov [edi], eax
  530.            mov [edi+4], ebx
  531.  
  532.            mov [edi+32], eax
  533.            mov [edi+4+32], ebx
  534.  
  535.            mov [edi+64], eax
  536.            mov [edi+4+64], ebx
  537.  
  538.            mov [edi+96], eax
  539.            mov [edi+4+96], ebx
  540.  
  541.            mov [edi+128], eax
  542.            mov [edi+4+128], ebx
  543.  
  544.            mov [edi+160], eax
  545.            mov [edi+4+160], ebx
  546.  
  547.            mov [edi+192], eax
  548.            mov [edi+4+192], ebx
  549.  
  550.            mov [edi+224], eax
  551.            mov [edi+4+224], ebx
  552.  
  553.            add eax, 0x4000
  554.            add edi, 8
  555.            loop @B
  556.  
  557.            mov edi, buff_list
  558.            mov eax, [ctrl.buffer]
  559.            mov ecx, 4
  560. @@:
  561.            mov [edi], eax
  562.            mov [edi+16], eax
  563.            mov [edi+32], eax
  564.            mov [edi+48], eax
  565.            mov [edi+64], eax
  566.            mov [edi+80], eax
  567.            mov [edi+96], eax
  568.            mov [edi+112], eax
  569.  
  570.            add eax, 0x4000
  571.            add edi, 4
  572.            loop @B
  573.  
  574.            mov eax, pcmout_bdl
  575.            mov ebx, eax
  576.            call GetPgAddr     ;eax
  577.            and ebx, 0xFFF
  578.            add eax, ebx
  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. play:
  1006.            mov eax, 16
  1007.            mov [ctrl.lvi_reg], eax
  1008.            mov edx, PCM_OUT_LVI_REG
  1009.            call [ctrl.ctrl_write8]
  1010.  
  1011.            mov edx, PCM_OUT_CR_REG
  1012.            mov ax, 0x1D
  1013.            call [ctrl.ctrl_write8]
  1014.            xor eax, eax
  1015.            ret
  1016.  
  1017. align 4
  1018. stop:
  1019.            mov edx, PCM_OUT_CR_REG
  1020.            mov ax, 0x0
  1021.            call [ctrl.ctrl_write8]
  1022.  
  1023.            mov ax, 0x1c
  1024.            mov edx, PCM_OUT_SR_REG
  1025.            call [ctrl.ctrl_write16]
  1026.            xor eax, eax
  1027.            ret
  1028.  
  1029. align 4
  1030. proc get_dev_info stdcall, p_info:dword
  1031.            virtual at esi
  1032.              CTRL_INFO CTRL_INFO
  1033.            end virtual
  1034.  
  1035.            mov esi, [p_info]
  1036.            mov eax, [ctrl.int_line]
  1037.            mov ebx, [ctrl.codec_io_base]
  1038.            mov ecx, [ctrl.ctrl_io_base]
  1039.            mov edx, [ctrl.codec_mem_base]
  1040.            mov edi, [ctrl.ctrl_mem_base]
  1041.  
  1042.            mov [CTRL_INFO.irq], eax
  1043.            mov [CTRL_INFO.codec_io_base], ebx
  1044.            mov [CTRL_INFO.ctrl_io_base], ecx
  1045.            mov [CTRL_INFO.codec_mem_base], edx
  1046.            mov [CTRL_INFO.ctrl_mem_base], edi
  1047.  
  1048.            mov eax, [codec.chip_id]
  1049.            mov [CTRL_INFO.codec_id], eax
  1050.  
  1051.            mov edx, GLOB_CTRL
  1052.            call [ctrl.ctrl_read32]
  1053.            mov [CTRL_INFO.glob_cntrl], eax
  1054.  
  1055.            mov edx, CTRL_STAT
  1056.            call [ctrl.ctrl_read32]
  1057.            mov [CTRL_INFO.glob_sta], eax
  1058.  
  1059.            mov ebx, [ctrl.pci_cmd]
  1060.            mov [CTRL_INFO.pci_cmd], ebx
  1061.            ret
  1062. endp
  1063.  
  1064. align 4
  1065. proc set_callback stdcall, handler:dword
  1066.            mov eax, [handler]
  1067.            mov [ctrl.user_callback], eax
  1068.            ret
  1069. endp
  1070.  
  1071. align 4
  1072. proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
  1073.  
  1074.            mov edx, [ac_reg]
  1075.  
  1076.            mov ebx, edx
  1077.            shr ebx, 1
  1078.            bt [codec.shadow_flag], ebx
  1079.            jc .use_shadow
  1080.  
  1081.            call [ctrl.codec_read16]  ;change edx !!!
  1082.            mov ecx, eax
  1083.  
  1084.            mov edx, CTRL_STAT
  1085.            call [ctrl.ctrl_read32]
  1086.            test eax, CTRL_ST_RCS
  1087.            jz .read_ok
  1088.  
  1089.            mov edx, CTRL_STAT
  1090.            call [ctrl.ctrl_write32]
  1091.            xor eax,eax
  1092.            not eax  ;timeout
  1093.            ret
  1094. .read_ok:
  1095.            mov edx, [ac_reg]
  1096.            mov [codec.regs+edx], cx
  1097.            bts [codec.shadow_flag], ebx
  1098.            mov eax, ecx
  1099.            ret
  1100. .use_shadow:
  1101.            movzx eax, word [codec.regs+edx]
  1102.            ret
  1103. endp
  1104.  
  1105. align 4
  1106. proc codec_write stdcall, ac_reg:dword
  1107.            push eax
  1108.            call check_semafore
  1109.            and eax, eax
  1110.            jz .err
  1111.            pop eax
  1112.  
  1113.            mov esi, [ac_reg]
  1114.            mov edx, esi
  1115.            call [ctrl.codec_write16]
  1116.            mov [codec.regs+esi], ax
  1117.            shr esi, 1
  1118.            bts [codec.shadow_flag], esi
  1119.            ret
  1120. .err:
  1121.            pop eax
  1122.            ret
  1123. endp
  1124.  
  1125. align 4
  1126. proc codec_check_ready
  1127.  
  1128.            mov edx, CTRL_ST
  1129.            call [ctrl.ctrl_read32]
  1130.            and eax, CTRL_ST_CREADY
  1131.            jz .not_ready
  1132.  
  1133.            xor eax, wax
  1134.            inc eax
  1135.            ret
  1136. .not_ready:
  1137.            xor eax, eax
  1138.            ret
  1139. endp
  1140.  
  1141. align 4
  1142. proc check_semafore
  1143.            local counter:DWORD
  1144.  
  1145.            mov [counter], 100
  1146. .l1:
  1147.            mov edx, CTRL_CAS
  1148.            call [ctrl.ctrl_read8]
  1149.            and eax, CAS_FLAG
  1150.            jz .ok
  1151.  
  1152.            mov eax, 1
  1153.            call StallExec
  1154.            sub [counter], 1
  1155.            jnz .l1
  1156.            xor eax, eax
  1157.            ret
  1158. align 4
  1159. .ok:
  1160.            xor eax,eax
  1161.            inc eax
  1162.            ret
  1163. endp
  1164.  
  1165. align 4
  1166. proc StallExec
  1167.            push ecx
  1168.            push edx
  1169.            push ebx
  1170.            push eax
  1171.  
  1172.            mov ecx, CPU_FREQ
  1173.            mul ecx
  1174.            mov ebx, eax       ;low
  1175.            mov ecx, edx       ;high
  1176.            rdtsc
  1177.            add ebx, eax
  1178.            adc ecx,edx
  1179. @@:
  1180.            rdtsc
  1181.            sub eax, ebx
  1182.            sbb edx, ecx
  1183.            js @B
  1184.  
  1185.            pop eax
  1186.            pop ebx
  1187.            pop edx
  1188.            pop ecx
  1189.            ret
  1190. endp
  1191.  
  1192. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1193. ;          CONTROLLER IO functions
  1194. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1195.  
  1196. align 4
  1197. proc codec_io_r16
  1198.            add edx, [ctrl.codec_io_base]
  1199.            in  ax, dx
  1200.            ret
  1201. endp
  1202.  
  1203. align 4
  1204. proc codec_io_w16
  1205.            add edx, [ctrl.codec_io_base]
  1206.            out dx, ax
  1207.            ret
  1208. endp
  1209.  
  1210. align 4
  1211. proc ctrl_io_r8
  1212.            add edx, [ctrl.ctrl_io_base]
  1213.            in  al, dx
  1214.            ret
  1215. endp
  1216.  
  1217. align 4
  1218. proc ctrl_io_r16
  1219.            add edx, [ctrl.ctrl_io_base]
  1220.            in  ax, dx
  1221.            ret
  1222. endp
  1223.  
  1224. align 4
  1225. proc ctrl_io_r32
  1226.            add edx, [ctrl.ctrl_io_base]
  1227.            in  eax, dx
  1228.            ret
  1229. endp
  1230.  
  1231. align 4
  1232. proc ctrl_io_w8
  1233.            add edx, [ctrl.ctrl_io_base]
  1234.            out dx, al
  1235.            ret
  1236. endp
  1237.  
  1238. align 4
  1239. proc ctrl_io_w16
  1240.            add edx, [ctrl.ctrl_io_base]
  1241.            out dx, ax
  1242.            ret
  1243. endp
  1244.  
  1245. align 4
  1246. proc ctrl_io_w32
  1247.            add edx, [ctrl.ctrl_io_base]
  1248.            out dx, eax
  1249.            ret
  1250. endp
  1251.  
  1252. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1253. ;         MEMORY MAPPED IO    (os depended)
  1254. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1255.  
  1256. align 4
  1257. proc codec_mem_r16
  1258.            add edx, [ctrl.codec_mem_base]
  1259.            mov ax, word [edx]
  1260.            ret
  1261. endp
  1262.  
  1263. align 4
  1264. proc codec_mem_w16
  1265.            add edx, [ctrl.codec_mem_base]
  1266.            mov word [edx], ax
  1267.            ret
  1268. endp
  1269.  
  1270. align 4
  1271. proc ctrl_mem_r8
  1272.            add edx, [ctrl.ctrl_mem_base]
  1273.            mov al, [edx]
  1274.            ret
  1275. endp
  1276.  
  1277. align 4
  1278. proc ctrl_mem_r16
  1279.            add edx, [ctrl.ctrl_mem_base]
  1280.            mov ax, [edx]
  1281.            ret
  1282. endp
  1283.  
  1284. align 4
  1285. proc ctrl_mem_r32
  1286.            add edx, [ctrl.ctrl_mem_base]
  1287.            mov eax, [edx]
  1288.            ret
  1289. endp
  1290.  
  1291. align 4
  1292. proc ctrl_mem_w8
  1293.            add edx, [ctrl.ctrl_mem_base]
  1294.            mov [edx], al
  1295.            ret
  1296. endp
  1297.  
  1298. align 4
  1299. proc ctrl_mem_w16
  1300.            add edx, [ctrl.ctrl_mem_base]
  1301.            mov [edx], ax
  1302.            ret
  1303. endp
  1304.  
  1305. align 4
  1306. proc ctrl_mem_w32
  1307.            add edx, [ctrl.ctrl_mem_base]
  1308.            mov [edx], eax
  1309.            ret
  1310. endp
  1311.  
  1312. align 4
  1313. dword2str:
  1314.       mov  esi, hex_buff
  1315.       mov ecx, -8
  1316. @@:
  1317.       rol eax, 4
  1318.       mov ebx, eax
  1319.       and ebx, 0x0F
  1320.       mov bl, [ebx+hexletters]
  1321.       mov [8+esi+ecx], bl
  1322.       inc ecx
  1323.       jnz @B
  1324.       ret
  1325.  
  1326. hexletters   db '0123456789ABCDEF'
  1327. hex_buff     db 8 dup(0),13,10,0
  1328.  
  1329.  
  1330. include "codec.inc"
  1331.  
  1332. align 4
  1333. devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
  1334.         dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
  1335.         dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
  1336.         dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
  1337.         dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
  1338.         dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
  1339.         dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
  1340.         dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
  1341.  
  1342.         dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
  1343.         dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
  1344.         dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
  1345.         dd (CTRL_MCP04   shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
  1346.         dd (CTRL_CK804   shl 16)+VID_NVIDIA,msg_CK804,set_ICH
  1347.         dd (CTRL_CK8     shl 16)+VID_NVIDIA,msg_CK8,set_ICH
  1348.         dd (CTRL_CK8S    shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
  1349.         dd (CTRL_MCP51   shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
  1350.  
  1351.         dd 0    ;terminator
  1352.  
  1353. version      dd 0x00040004
  1354.  
  1355. msg_ICH      db 'Intel ICH',  13,10, 0
  1356. msg_ICH0     db 'Intel ICH0', 13,10, 0
  1357. msg_ICH2     db 'Intel ICH2', 13,10, 0
  1358. msg_ICH3     db 'Intel ICH3', 13,10, 0
  1359. msg_ICH4     db 'Intel ICH4', 13,10, 0
  1360. msg_ICH5     db 'Intel ICH5', 13,10, 0
  1361. msg_ICH6     db 'Intel ICH6', 13,10, 0
  1362. msg_ICH7     db 'Intel ICH7', 13,10, 0
  1363. msg_Intel    db 'Intel Corp. ', 0
  1364.  
  1365. msg_NForce   db 'NForce',      13,10, 0
  1366. msg_NForce2  db 'NForce 2',    13,10, 0
  1367. msg_NForce3  db 'NForce 3',    13,10, 0
  1368. msg_MCP04    db 'NForce MCP04',13,10, 0
  1369. msg_CK804    db 'NForce CK804',13,10, 0
  1370. msg_CK8      db 'NForce CK8',  13,10, 0
  1371. msg_CK8S     db 'NForce CK8S', 13,10, 0
  1372. msg_MCP51    db 'NForce MCP51',13,10, 0
  1373.  
  1374. msg_NVidia   db 'NVidia', 0
  1375.  
  1376. szKernel            db 'KERNEL', 0
  1377. sz_sound_srv        db 'SOUND',0
  1378.  
  1379. msgInit      db 'detect hardware...',13,10,0
  1380. msgFail      db 'device not found',13,10,0
  1381. msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
  1382. msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
  1383. msgPlay      db 'start play', 13,10,0
  1384. msgStop      db 'stop play',  13,10,0
  1385. msgNotify    db 'call notify',13,10,0
  1386. msgIRQ       db 'AC97 IRQ', 13,10,0
  1387. msgInitCtrl  db 'init controller',13,10,0
  1388. msgInitCodec db 'init codec',13,10,0
  1389. msgPrimBuff  db 'create primary buffer',13,10,0
  1390. msgReg       db 'set service handler',13,10,0
  1391. msgOk        db 'service installed',13,10,0
  1392. msgCold      db 'cold reset',13,10,0
  1393. msgWarm      db 'warm reset',13,10,0
  1394. msgWRFail    db 'warm reset failed',13,10,0
  1395. msgCRFail    db 'cold reset failed',13,10,0
  1396. msgCFail     db 'codec not ready',13,10,0
  1397. msgResetOk   db 'reset complete',13,10,0
  1398. msgStatus    db 'global status   ',0
  1399. msgControl   db 'global control  ',0
  1400.  
  1401. section '.data' data readable writable align 16
  1402.  
  1403. pcmout_bdl       rq 32
  1404. buff_list        rd 32
  1405.  
  1406. codec CODEC
  1407. ctrl AC_CNTRL
  1408.  
  1409. lpc_bus  rd 1
  1410. civ_val  rd 1
  1411.