Subversion Repositories Kolibri OS

Rev

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