none
(WINCE - x86 - Shared IRQ) How to share 1 IRQ for 2 com port RRS feed

  • 問題

  • Dear Sir,

     

    我的platfrom是 x86 , 利用 WINCE 5.0 / 6.0 .

    在我的 platform 裡 , 有 3 各 com port , 而系統只有 2 各 IRQ.

    因此我必須將其中兩個 com port , 利用 shared IRQ , 來達成 2 各不同的 SYSINTR.

    以下是我原本的設定 , 在這樣的設定下 "IOBase-0x2F8" and "IOBase-0x3E8" 是 OK 的 , 但 "IOBase-0x3F8" 不能使用.

     

    Code Snippet

    //===========================
    // BIOS , support shared IRQ
    //===========================
    COM1 - 0x3F8 - IRQ4
    COM2 - 0x2F8 - IRQ3
    COM3 - 0x3E8 - IRQ4
    COM4 - 0x2E8 - IRQ3

     

     

    Code Snippet
    //===========================
    // IRQ to SYSINTR Table
    //===========================
    // COM1 - 0x3F8-0x3FF, IRQ4
    // COM2 - 0x2F8-0x3FF, IRQ3
    // COM3 - 0x3E8-0x3EF, IRQ4
    // COM4 - 0x2E8-0x2EF, IRQ3
    //
    // IRQ3 - COM2 or COM4
    OALIntrStaticTranslate(SYSINTR_FIRMWARE + 3, 3);
    // IRQ4 - COM1 or COM3
    OALIntrStaticTranslate(SYSINTR_FIRMWARE + 4, 4);

     

     

    Code Snippet

    //===========================
    // Platform.reg
    //===========================
    IF BSP_NOSERIAL !
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial]
       "SysIntr"=dword:13
       "IoBase"=dword:02F8
       "IoLen"=dword:8
       "DeviceArrayIndex"=dword:0
       "Prefix"="COM"
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "Dll"="Com16550.Dll"
       "Order"=dword:0
       "Priority"=dword:0
    ; Turn on follows for Installable ISR (isr16550 supporting SOFTWARE FIFO
    ;   "Irq"=dword:3
    ;   "IsrDll"="isr16550.dll"
    ;   "IsrHandler"="ISRHandler"

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial\Unimodem]
       "Tsp"="Unimodem.dll"
       "DeviceType"=dword:0
       "FriendlyName"=LOC_FRIENDLYNAME_SERIAL
       "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
    ENDIF BSP_NOSERIAL !

    IF BSP_SERIAL2
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2]
       "SysIntr"=dword:14
       "IoBase"=dword:03E8
       "IoLen"=dword:8
       "DeviceArrayIndex"=dword:1
       "Prefix"="COM"
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "Dll"="Com16550.Dll"
       "Order"=dword:0

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2\Unimodem]
       "Tsp"="Unimodem.dll"
       "DeviceType"=dword:0
       "FriendlyName"=LOC_FRIENDLYNAME_SERIAL2
       "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
    ENDIF BSP_SERIAL2

    IF BSP_SERIAL3
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial3]
       "SysIntr"=dword:15
       "IoBase"=dword:03F8
      
       "IoLen"=dword:8
       "DeviceArrayIndex"=dword:2
       "Prefix"="COM"
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "Dll"="Com16550.Dll"
       "Order"=dword:0

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial3\Unimodem]
       "Tsp"="Unimodem.dll"
       "DeviceType"=dword:0
       "FriendlyName"=LOC_FRIENDLYNAME_SERIAL3
       "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
    ENDIF BSP_SERIAL3

     

     

    我後來在網路上有參考以前大家討論的文章, 但我還是不太懂.

    而在 MSDN 上有談到如何實現 shared IRQ , http://msdn2.microsoft.com/en-us/library/aa927957.aspx .

    其中一個方法是

    "Hard-code the Sysintr values into your OAL. Multiple Sysintr values can correspond to one IRQ. IRQ values and Sysintr values can have a one-to-one relationship, which defines the default Sysintr value for the IRQ. For examples, see SETUP_INTERRUPT_MAP and OEMRequestSysIntr. You can add the hard-coded Sysintr values, beginning at SYSINTR_FIRMWARE + 16, to OEMInit, immediately after the last SETUP_INTERRUPT_MAP. You cannot use SETUP_INTERRUPT_MAP directly because it includes instances of DEBUGCHK, which ensure that the same IRQ is not mapped twice. Although this method is not as flexible as the one above, after you have configured the OAL, you can update the registry to inform the serial drivers about which Sysintr to use."

     

    因此我修改了, 一些設定 , 但是 "IOBase-0x2F8" and "IOBase-0x3E8" 還是 OK 的 , 但 "IOBase-0x3F8" 依然不能使用.

     

    Code Snippet

    //===========================
    // IRQ to SYSINTR Table
    //===========================
    // COM1 - 0x3F8-0x3FF, IRQ4
    // COM2 - 0x2F8-0x3FF, IRQ3
    // COM3 - 0x3E8-0x3EF, IRQ4
    // COM4 - 0x2E8-0x2EF, IRQ3
    //
    // IRQ3 - COM2 or COM4
    OALIntrStaticTranslate(SYSINTR_FIRMWARE + 3, 3);
    // IRQ4 - COM1 or COM3
    OALIntrStaticTranslate(SYSINTR_FIRMWARE + 4, 4);
    OALIntrStaticTranslate(SYSINTR_FIRMWARE + 16, 4);

     

     

    Code Snippet

    //===========================
    // Platform.reg
    //===========================
    ; @CESYSGEN IF CE_MODULES_SERIAL
    IF BSP_NOSERIAL !
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial]
       "SysIntr"=dword:13
       "IoBase"=dword:02F8
       "IoLen"=dword:8
       "DeviceArrayIndex"=dword:0
       "Prefix"="COM"
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "Dll"="Com16550.Dll"
       "Order"=dword:0
       "Priority"=dword:0
    ; Turn on follows for Installable ISR (isr16550 supporting SOFTWARE FIFO
    ;   "Irq"=dword:3
    ;   "IsrDll"="isr16550.dll"
    ;   "IsrHandler"="ISRHandler"

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial\Unimodem]
       "Tsp"="Unimodem.dll"
       "DeviceType"=dword:0
       "FriendlyName"=LOC_FRIENDLYNAME_SERIAL
       "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
    ENDIF BSP_NOSERIAL !

    IF BSP_SERIAL2
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2]
       "SysIntr"=dword:14
       "IoBase"=dword:03E8
       "IoLen"=dword:8
       "DeviceArrayIndex"=dword:1
       "Prefix"="COM"
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "Dll"="Com16550.Dll"
       "Order"=dword:0

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial2\Unimodem]
       "Tsp"="Unimodem.dll"
       "DeviceType"=dword:0
       "FriendlyName"=LOC_FRIENDLYNAME_SERIAL2
       "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
    ENDIF BSP_SERIAL2

    IF BSP_SERIAL3
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial3]
       "SysIntr"=dword:20
       "IoBase"=dword:03F8
      
       "IoLen"=dword:8
       "DeviceArrayIndex"=dword:2
       "Prefix"="COM"
       "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
       "Dll"="Com16550.Dll"
       "Order"=dword:0

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial3\Unimodem]
       "Tsp"="Unimodem.dll"
       "DeviceType"=dword:0
       "FriendlyName"=LOC_FRIENDLYNAME_SERIAL3
       "DevConfig"=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00
    ENDIF BSP_SERIAL3

     

     

     

    想請問我這樣的作法是對的嗎? 可否給我一點建議.

     

    此外 MSDN 也有描述另一個方法.

    "Use IOCTL_HAL_REQUEST_SYSINTR and pass the OAL your IRQ and the OAL returns a Sysintr value that you can use. If your driver unloads, use IOCTL_HAL_RELEASE_SYSINTR."

    這又該如何 implement ?

     

    非常感謝大家的幫忙.

     

    BR,

    Wiles

     

    2008年4月3日 下午 06:09