Subversion Repositories Kolibri OS

Rev

Rev 378 | 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. SLOT_BASE       equ OS_BASE+0x0080000
  275. new_app_base    equ 0x80000000
  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 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.            add ebx, new_app_base
  417.            stdcall get_master_vol, ebx
  418.            ret
  419. ;@@:
  420. ;           cmp eax, DEV_GET_INFO
  421. ;           jne @F
  422. ;           mov ebx, [edi+output]
  423. ;           stdcall get_dev_info, ebx
  424. ;           ret
  425. @@:
  426. .fail:
  427.            or eax, -1
  428.            ret
  429. endp
  430.  
  431. restore   handle
  432. restore   io_code
  433. restore   input
  434. restore   inp_size
  435. restore   output
  436. restore   out_size
  437.  
  438.  
  439. align 4
  440. proc remap_irq                         ;for Intel chipsets ONLY !!!
  441.            mov eax, VALID_IRQ
  442.            bt eax, IRQ_LINE
  443.            jnc .exit
  444.  
  445.            mov edx, 0x4D0
  446.            in ax,dx
  447.            bts ax, IRQ_LINE
  448.            out dx, aX
  449.  
  450.            stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
  451.            mov [ctrl.int_line], IRQ_LINE
  452.  
  453. .exit:
  454.            ret
  455. endp
  456.  
  457. align 4
  458. proc ac97_irq
  459.  
  460. ;     if DEBUG
  461. ;           mov esi, msgIRQ
  462. ;           call SysMsgBoardStr
  463. ;     end if
  464.  
  465.            mov edx, PCM_OUT_CR_REG
  466.            mov al, 0x10;               0x10
  467.            call [ctrl.ctrl_write8]
  468.  
  469.            mov ax, 0x1c
  470.            mov edx, PCM_OUT_SR_REG
  471.            call [ctrl.ctrl_write16]
  472.  
  473.            mov edx, PCM_OUT_CIV_REG
  474.            call [ctrl.ctrl_read8]
  475.  
  476.            and eax, 0x1F
  477.            cmp eax, [civ_val]
  478.            je .skip
  479.  
  480.            mov [civ_val], eax
  481.            dec eax
  482.            and eax, 0x1F
  483.            mov [ctrl.lvi_reg], eax
  484.  
  485.            mov edx, PCM_OUT_LVI_REG
  486.            call [ctrl.ctrl_write8]
  487.  
  488.            mov edx, PCM_OUT_CR_REG
  489.            mov ax, 0x11              ;0x1D
  490.            call [ctrl.ctrl_write8]
  491.  
  492.            mov eax, [civ_val]
  493.            add eax, 1
  494.            and eax, 31
  495.            mov ebx, dword [buff_list+eax*4]
  496.  
  497.            cmp [ctrl.user_callback], 0
  498.            je @f
  499.  
  500.            stdcall [ctrl.user_callback], ebx
  501. @@:
  502.            ret
  503.  
  504. .skip:
  505.            mov edx, PCM_OUT_CR_REG
  506.            mov ax, 0x11               ;0x1D
  507.            call [ctrl.ctrl_write8]
  508.            ret
  509. endp
  510.  
  511. align 4
  512. proc create_primary_buff
  513.  
  514.            stdcall KernelAlloc, 0x10000
  515.            mov [ctrl.buffer], eax
  516.  
  517.            mov edi, eax
  518.            mov ecx, 0x10000/4
  519.            xor eax, eax
  520.            cld
  521.            rep stosd
  522.  
  523.            mov eax, [ctrl.buffer]
  524.            call GetPgAddr
  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 eax, pcmout_bdl
  576.            mov ebx, eax
  577.            call GetPgAddr     ;eax
  578.            and ebx, 0xFFF
  579.            add eax, ebx
  580.  
  581.            mov edx, PCM_OUT_BDL
  582.            call [ctrl.ctrl_write32]
  583.  
  584.            mov eax, 16
  585.            mov [ctrl.lvi_reg], eax
  586.            mov edx, PCM_OUT_LVI_REG
  587.            call [ctrl.ctrl_write8]
  588.            ret
  589. endp
  590.  
  591. align 4
  592. proc detect_controller
  593.            locals
  594.              last_bus dd ?
  595.              bus      dd ?
  596.              devfn    dd ?
  597.            endl
  598.  
  599.            xor eax, eax
  600.            mov [bus], eax
  601.            inc eax
  602.            call PciApi
  603.            cmp eax, -1
  604.            je .err
  605.  
  606.            mov [last_bus], eax
  607.  
  608. .next_bus:
  609.            and [devfn], 0
  610. .next_dev:
  611.            stdcall PciRead32, [bus], [devfn], dword 0
  612.            test eax, eax
  613.            jz .next
  614.            cmp eax, -1
  615.            je .next
  616.  
  617.            mov edi, devices
  618. @@:
  619.            mov ebx, [edi]
  620.            test ebx, ebx
  621.            jz .next
  622.  
  623.            cmp eax, ebx
  624.            je .found
  625.            add edi, 12
  626.            jmp @B
  627.  
  628. .next:
  629.            inc [devfn]
  630.            cmp [devfn], 256
  631.            jb .next_dev
  632.            mov eax, [bus]
  633.            inc eax
  634.            mov [bus], eax
  635.            cmp eax, [last_bus]
  636.            jna .next_bus
  637.            xor eax, eax
  638.            ret
  639. .found:
  640.            mov ebx, [bus]
  641.            mov [ctrl.bus], ebx
  642.  
  643.            mov ecx, [devfn]
  644.            mov [ctrl.devfn], ecx
  645.  
  646.            mov edx, eax
  647.            and edx, 0xFFFF
  648.            mov [ctrl.vendor], edx
  649.            shr eax, 16
  650.            mov [ctrl.dev_id], eax
  651.  
  652.            mov ebx, [edi+4]
  653.            mov [ctrl.ctrl_ids], ebx
  654.            mov esi, [edi+8]
  655.            mov [ctrl.ctrl_setup], esi
  656.  
  657.            cmp ebx, VID_INTEL
  658.            jne @F
  659.            mov [ctrl.vendor_ids], msg_Intel
  660.            ret
  661. @@:
  662.            cmp ebx, VID_NVIDIA
  663.            jne @F
  664.            mov [ctrl.vendor_ids], msg_NVidia
  665. @@:
  666.            mov [ctrl.vendor_ids], 0     ;something  wrong ?
  667.            ret
  668. .err:
  669.            xor eax, eax
  670.            ret
  671. endp
  672.  
  673. align 4
  674. proc get_LPC_bus                ;for Intel chipsets ONLY !!!
  675.            locals
  676.              last_bus dd ?
  677.              bus      dd ?
  678.            endl
  679.  
  680.            xor eax, eax
  681.            mov [bus], eax
  682.            inc eax
  683.            call [PciApi]
  684.            cmp eax, -1
  685.            je .err
  686.  
  687.            mov [last_bus], eax
  688. .next_bus:
  689.            stdcall PciRead32, [bus], dword 0xF8, dword 0
  690.            test eax, eax
  691.            jz .next
  692.            cmp eax, -1
  693.            je .next
  694.  
  695.            cmp eax, 0x24D08086
  696.            je .found
  697. .next:
  698.            mov eax, [bus]
  699.            inc eax
  700.            cmp eax, [last_bus]
  701.            mov [bus], eax
  702.            jna .next_bus
  703. .err:
  704.            xor eax, eax
  705.            dec eax
  706.            ret
  707. .found:
  708.            mov eax, [bus]
  709.            ret
  710. endp
  711.  
  712. align 4
  713. proc init_controller
  714.  
  715.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
  716.            mov ebx, eax
  717.            and eax, 0xFFFF
  718.            mov [ctrl.pci_cmd], eax
  719.            shr ebx, 16
  720.            mov [ctrl.pci_stat], ebx
  721.  
  722.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
  723.            and eax,0xFFFE
  724.            mov [ctrl.codec_io_base], eax
  725.  
  726.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
  727.            and eax, 0xFFC0
  728.            mov [ctrl.ctrl_io_base], eax
  729.  
  730.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
  731.            mov [ctrl.codec_mem_base], eax
  732.  
  733.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
  734.            mov [ctrl.ctrl_mem_base], eax
  735.  
  736.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
  737.            and eax, 0xFF
  738.            mov [ctrl.int_line], eax
  739.  
  740.            stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
  741.            and eax, 0xFF
  742.            mov [ctrl.cfg_reg], eax
  743.  
  744.            call [ctrl.ctrl_setup]
  745.            xor eax, eax
  746.            inc eax
  747.            ret
  748. endp
  749.  
  750. align 4
  751. proc set_ICH
  752.            mov [ctrl.codec_read16],  codec_io_r16    ;virtual
  753.            mov [ctrl.codec_write16], codec_io_w16    ;virtual
  754.  
  755.            mov [ctrl.ctrl_read8 ],  ctrl_io_r8      ;virtual
  756.            mov [ctrl.ctrl_read16],  ctrl_io_r16      ;virtual
  757.            mov [ctrl.ctrl_read32],  ctrl_io_r32      ;virtual
  758.  
  759.            mov [ctrl.ctrl_write8 ], ctrl_io_w8      ;virtual
  760.            mov [ctrl.ctrl_write16], ctrl_io_w16      ;virtual
  761.            mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
  762.            ret
  763. endp
  764.  
  765. PG_SW            equ 0x003
  766. PG_NOCACHE       equ 0x018
  767.  
  768. align 4
  769. proc set_ICH4
  770.            stdcall AllocKernelSpace, dword 0x2000
  771.            mov edi, eax
  772.            stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
  773.            mov [ctrl.codec_mem_base], edi
  774.            add edi, 0x1000
  775.            stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
  776.            mov [ctrl.ctrl_mem_base], edi
  777.  
  778.            mov [ctrl.codec_read16],  codec_mem_r16    ;virtual
  779.            mov [ctrl.codec_write16], codec_mem_w16    ;virtual
  780.  
  781.            mov [ctrl.ctrl_read8 ],  ctrl_mem_r8       ;virtual
  782.            mov [ctrl.ctrl_read16],  ctrl_mem_r16      ;virtual
  783.            mov [ctrl.ctrl_read32],  ctrl_mem_r32      ;virtual
  784.  
  785.            mov [ctrl.ctrl_write8 ], ctrl_mem_w8       ;virtual
  786.            mov [ctrl.ctrl_write16], ctrl_mem_w16      ;virtual
  787.            mov [ctrl.ctrl_write32], ctrl_mem_w32      ;virtual
  788.            ret
  789. endp
  790.  
  791. align 4
  792. proc reset_controller
  793.  
  794.            xor eax, eax
  795.            mov edx, PCM_IN_CR_REG
  796.            call [ctrl.ctrl_write8]
  797.  
  798.            mov edx, PCM_OUT_CR_REG
  799.            call [ctrl.ctrl_write8]
  800.  
  801.            mov edx, MC_IN_CR_REG
  802.            call [ctrl.ctrl_write8]
  803.  
  804.            mov eax, RR
  805.            mov edx, PCM_IN_CR_REG
  806.            call [ctrl.ctrl_write8]
  807.  
  808.            mov edx, PCM_OUT_CR_REG
  809.            call [ctrl.ctrl_write8]
  810.  
  811.            mov edx, MC_IN_CR_REG
  812.            call [ctrl.ctrl_write8]
  813.            ret
  814. endp
  815.  
  816. align 4
  817. proc init_codec
  818.            locals
  819.              counter dd ?
  820.            endl
  821.  
  822.            mov esi, msgControl
  823.            call SysMsgBoardStr
  824.  
  825.            mov edx, GLOB_CTRL
  826.            call [ctrl.ctrl_read32]
  827.            call dword2str
  828.            call SysMsgBoardStr
  829.  
  830.            mov esi, msgStatus
  831.            call SysMsgBoardStr
  832.  
  833.            mov edx, CTRL_STAT
  834.            call [ctrl.ctrl_read32]
  835.  
  836.            call dword2str
  837.            call SysMsgBoardStr
  838.  
  839.            test eax, CTRL_ST_CREADY
  840.            jnz .ready
  841.  
  842.            call reset_codec
  843.            and eax, eax
  844.            jz .err
  845.  
  846.            xor edx, edx     ;ac_reg_0
  847.            call [ctrl.codec_write16]
  848.  
  849.            xor eax, eax
  850.            mov edx, CODEC_REG_POWERDOWN
  851.            call [ctrl.codec_write16]
  852.  
  853.            mov [counter], 200     ; total 200*5 ms = 1s
  854. .wait:
  855.            mov edx, CODEC_REG_POWERDOWN
  856.            call [ctrl.codec_read16]
  857.            and eax, 0x0F
  858.            cmp eax, 0x0F
  859.            jz .ready
  860.  
  861.            mov eax, 5000   ; wait 5 ms
  862.            call StallExec
  863.            sub [counter] , 1
  864.            jnz .wait
  865. .err:
  866.            xor eax, eax        ; timeout error
  867.            ret
  868. .ready:
  869.            call detect_codec
  870.  
  871.            xor eax, eax
  872.            inc eax
  873.            ret
  874. endp
  875.  
  876. align 4
  877. proc reset_codec
  878.            mov edx, GLOB_CTRL
  879.            call [ctrl.ctrl_read32]
  880.  
  881.            test eax, 0x02
  882.            jz .cold
  883.  
  884.            call warm_reset
  885.            jnc .ok
  886. .cold:
  887.            call cold_reset
  888.            jnc .ok
  889.  
  890.      if DEBUG
  891.            mov esi, msgCFail
  892.            call SysMsgBoardStr
  893.            end if
  894.            xor eax, eax     ; timeout error
  895.            ret
  896. .ok:
  897.      if DEBUG
  898.            mov esi, msgResetOk
  899.            call SysMsgBoardStr
  900.      end if
  901.  
  902.            xor eax, eax
  903.            inc eax
  904.            ret
  905. endp
  906.  
  907. align 4
  908. proc warm_reset
  909.            locals
  910.              counter dd ?
  911.            endl
  912.  
  913.            mov eax, 0x06
  914.            mov edx, GLOB_CTRL
  915.            call [ctrl.ctrl_write32]
  916.  
  917.      if DEBUG
  918.            mov esi, msgWarm
  919.            call SysMsgBoardStr
  920.      end if
  921.  
  922.            mov [counter], 10    ; total 10*100 ms = 1s
  923. .wait:
  924.            mov eax, 100000    ; wait 100 ms
  925.            call StallExec
  926.  
  927.            mov edx, GLOB_CTRL
  928.            call [ctrl.ctrl_read32]
  929.            test eax, 4
  930.            jz .ok
  931.            sub [counter], 1
  932.            jnz .wait
  933.  
  934.      if DEBUG
  935.            mov esi, msgWRFail
  936.            call SysMsgBoardStr
  937.      end if
  938.  
  939.            stc
  940.            ret
  941. .ok:
  942.            mov edx, CTRL_STAT
  943.            call [ctrl.ctrl_read32]
  944.            and eax, CTRL_ST_CREADY
  945.            jz .fail
  946.            clc
  947.            ret
  948. .fail:
  949.            stc
  950.            ret
  951. endp
  952.  
  953. align 4
  954. proc cold_reset
  955.            locals
  956.              counter dd ?
  957.            endl
  958.  
  959.            xor eax, eax
  960.            mov edx, GLOB_CTRL
  961.            call [ctrl.ctrl_write32]
  962.  
  963.      if DEBUG
  964.            mov esi, msgCold
  965.            call SysMsgBoardStr
  966.      end if
  967.  
  968.            mov eax, 1000000    ; wait 1 s
  969.            call StallExec
  970.  
  971.            mov eax, 2
  972.            mov edx, GLOB_CTRL
  973.            call [ctrl.ctrl_write32]
  974.  
  975.            mov [counter], 10    ; total 10*100 ms = 1s
  976. .wait:
  977.            mov eax, 100000    ; wait 100 ms
  978.            call StallExec
  979.  
  980.            mov edx, GLOB_CTRL
  981.            call [ctrl.ctrl_read32]
  982.            test eax, 4
  983.            jz .ok
  984.            sub [counter], 1
  985.            jnz .wait
  986.  
  987.      if DEBUG
  988.            mov esi, msgCRFail
  989.            call SysMsgBoardStr
  990.      end if
  991.            stc
  992.            ret
  993. .ok:
  994.            mov edx, CTRL_STAT
  995.            call [ctrl.ctrl_read32]
  996.            and eax, CTRL_ST_CREADY
  997.            jz .fail
  998.            clc
  999.            ret
  1000. .fail:
  1001.            stc
  1002.            ret
  1003. endp
  1004.  
  1005. align 4
  1006. play:
  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.            xor eax, eax
  1016.            ret
  1017.  
  1018. align 4
  1019. 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.            xor eax, eax
  1028.            ret
  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 0x00040004
  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.