Subversion Repositories Kolibri OS

Rev

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

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