
@@@@@@@@@@@obh@cnrłɂā@@@@@@@@@@@@@


\[XhCȏgݍ

 \[XhCȏgݍ݂ɂ́APDCONFIG.SYSɒǉAQDDOSvvg
R}hsÂQ̕@܂B


PDlr|cnr̂bnmehfDrxrt@CɈȉ̍sǉĂB


  DEVICE=x:\PATH\APIC21DV.EXE     


QDlr|cnrvvgŃhCo풓ꍇ͈ȉ̂悤ɍs܂B


  x:>APIC21DV /I                  



\[XhCõIvVɂ

@\[XhCõIvV́Aȉ̒ʂłB

@@@APIC21DV [] [߼]

@@@
@@@  /I       APIC21DV.EXEذɏ풓܂D
@@@  /R       APIC21DV.EXȄ풓܂D
@@@  /Ddddd[,vvvv]
@@@           w肳ꂽaPCIްނؿ\܂D
@@@             dddd = PCIްނ޲ID
@@@             vvvv = PCIްނID
@@@  /Xdddd[,vvvv]
@@@           w肳ꂽaPCIްނؿ\܂D
@@@           PCI۰ׂؿ\܂D
@@@             dddd = PCIްނ޲ID
@@@             vvvv = PCIްނID
@@@  /?       gp@\܂D
@@@߼
@@@  /P       ʖɕ\ꎞ~܂D
@@@  /J       {ŕ\܂D
@@@  /E       pŕ\܂D

@obh{[h̃\[X\ꍇAu/DvIvVgpB
@obh{[hɂA\[X\́uI/O Port addressvQ\ꍇ
܂B
@Pڂ́uI/O Port addressvInterrupt Control AddressA
@Qڂ́uI/O Port addressvI/O Control Address܂B
@P̂ݕ\ꍇ͂obĥh^ñ|[gAhXɂȂ܂B

Ӂ
@\[XhCo͂lr|cnrł̂ݓ\łB
@v̂lr|cnrvvgł͕̓ۏ؂܂B




@@@@@@@obh@lr|cnrŃTvvO@@@@@@@@@


@lr|cnrœ삷AvP[VvO̍쐬@ƃTvvO
ɂĂ܂B
@ۂ̂lr|cnrł̃vO~OɂẮAYtfBXŃucnrvfB
NĝbTvvOB
@ȉł́AfoCXhCoւ̃ANZX@̏LqĂ܂B
@ꂩ鏈́ATv́uAPCICTRL.Cvt@CɊ֐ƂĂ܂Ƃ
Ă܂B܂AfoCXhCoƒʐMf[^\́uAPCISRVS.Hvɒ`
Ă܂B

Ӂ
@lr|cnrŃTvvOTC++4.0/MS-C7.0œmFsĂ܂B
̑RpCgp̏ꍇ̓TvvȌCKvɂȂꍇL
܂B
@ucnrvfBNg̃TvvO͂lr|cnrœ\Ȏs
t@C𐶐łRpCł̂݃RpC\łB


obh̃foCX擾

PjfoCXhCoI[v

@obhp̃foCXhCob́uopen()v֐gpăI[v܂B
hCoI[vꍇ́At@Cł͂ȂfoCXŃI[v܂B
@foCX "APCIINF$" łB

၄
void main( void ){
{
int     handle;

    handle = open("APCIINF$",O_CREAT | O_RDWR | O_BINARY,S_IWRITE | S_IREAD ) ;
    if ( -1 != handle ){
        //
        //  AvP[V̏
        //
        close( handle );
    }
}

@foCXhCoɑgݍ܂ĂȂꍇ́AI[vG[܂B
G[ꍇuCONFIG.SYSvLqĂ邩AĊmFĂB

@ۂ̃foCXhCõI[v@ɂẮAlr|cnrpbTv
vOuAPCICTRL.Cv́uApciGetDriverFunc()v֐B


Qjh^nRg[[hŃfoCXhCõT[rX[`AhX擾

@h^nRg[[hsAfoCXhCõT[rX[`̃Ah
X擾܂B
@h^nRg[[hɂẮAlr|cnr̉B
@ۂ̂h^nRg[[h̎s@ɂẮAlr|cnrpbT
vvOuAPCICTRL.Cv́uioctrlRead()v֐B


RjfoCXhCõT[rX[`̌Ăяo

@h^nRg[[hŎ擾foCXhCõT[rX[`ĂсA
foCXhCõo[WfoCX̂h^nAhXȂǂ̏ǂݏo܂B

@foCXhCõT[rX[`ɓnR}h͈ȉ̒ʂłB
@ĂяoɁuAXvWX^ɐݒ肵܂B

#define APCIC_GET_VERSION       0u      /* ްޮݔԍ擾 */
#define APCIC_FIND_RESOURCE     1u      /* ؿT */

@`ohbQPڂ̂obh{[hł́A荞ݐp̃|[g擾邽
߂ɉL̃R}hpӂĂ܂B

#define APCIC_GET_ADAPTER_PORT  2u      /* ؿ擾 */

@foCXhCõT[rX[`Ԃsʂ͈ȉ̒ʂłB
@sIɁuAXvWX^ɐݒ肳܂B

#define CMD_COMPLETE            0u      /* ނ͐I */
#define INVALID_CMD             1u      /* ŶȂނł */
#define INVALID_PTR             2u      /* үނ܂ڽݽ߲ */

@foCXhCõT[rX[`ɓn\͈̂ȉ̒ʂłB
@ĂяoɁuES:DIvWX^ɍ\̂̃AhXݒ肵܂B

typedef struct _APCI_CMD_PACKET {
    void far    *lpMessage;             /* ײĂүޯ̧ւ߲ */
    void far    *lpResponse;            /* ײĂւڽݽޯ̧ւ߲ */
} APCI_CMD_PACKET, far *LPAPCI_CMD_PACKET;

@L̒`́Alr|cnrpbTvvOuAPCISRVS.Hvɒ`
L܂B

@T[rX[`̌ĂяóuAPCI_CMD_PACKETv\̂ɁAT[rX[`
΂Ȃǂ̍\̂̃|C^ƃT[rX[`f[^擾邽߂
f[^\̃|C^ݒ肵AWX^ɃR}hƁuAPCI_CMD_PACKETv\̂
|C^ݒ肵T[rX[`s܂B

@ۂ̃foCXhCõT[rX[`Ăяo@ɂẮAlr|cnr
pbTvvOuAPCICTRL.Cv́uServiceFunc()v֐B


SjfoCXhCõo[Wǂݏo

@h^nRg[[hŎ擾foCXhCõT[rX[`ĂсA
foCXhCõo[Wǂݏo܂B
@foCXhCõT[rX[`ɓnR}h́uAPCISRVS.Hvɒ`
uAPCIC_GET_VERSIONvgp܂B
@foCXhCõo[W͉L̍\̂ɐݒ肳܂B
@ȉ̍\̂́uAPCISRVS.Hvɒ`ėL܂B

typedef struct _APCI_VER_RES {
    ushort      wPciBiosVersion;    /* PCI BIOSްޮݔԍ */
    ushort      wDriverVersion;     /* {ײންޮݔԍ */
} APCI_VER_RES, far *LPAPCI_VER_RES;

uAPCI_CMD_PACKETv\̂Ƀo[Wԍݒ肷\̂̃|C^ݒ肵
T[rX[`Ăт܂B

၄
ushort getPciVer( void )
{
APCI_VER_RES        ver;
APCI_CMD_PACKET     pkt;
ushort              pkt_seg,
                    pkt_ofs,
                    res;
void far            *ptr;

    pkt.lpMessage  = NULL;
    pkt.lpResponse = &ver;          // ްޮ݂ݒ肷\߲̂
    ptr = (void far *)&pkt;
    pkt_seg = FP_SEG( ptr );        // ıڽ擾
    pkt_ofs = FP_OFF( ptr );        // ̾ıڽ擾
    asm {
        push    es
        mov     ax,pkt_seg
        mov     es,ax                       // es <- ıڽ
        mov     di,pkt_ofs                  // di <- ̾ıڽ
        mov     ax,APCIC_GET_VERSION        // ax <- 
        call    dword ptr T[rX[`  // ޽ٰ݂ق
        pop     es
        mov     res,ax
    }
    return res;                             // sʂԂ
}

@ۂ̃foCXhCõo[Wǂݍݕ@ɂẮAlr|cnrpb
TvvOuAPCICTRL.Cv́uApciGetVersion()v֐B


TjfoCXhCõT[rX[`ĂяoăfoCX̏ǂݏo

@h^nRg[[hŎ擾foCXhCõT[rX[`ĂсA
foCX̂h^nAhXȂǂ̏ǂݏo܂B
@foCXhCõT[rX[`ɓnR}h́uAPCISRVS.Hvɒ`
uAPCIC_FIND_RESOURCEvgp܂B

@foCXݒ̏̐ݒ͉L̍\̂ɐݒ肵܂B

typedef struct _APCI_FIND_MES {
    ushort  wIndex;             /* ޯ */
    ushort  wDeviceID;          /* ޲ID */
} APCI_FIND_MES, far *LPAPCI_FIND_MES;

@foCX͉̏L̍\̂ɐݒ肳܂B

typedef struct _APCI_FIND_RES {
    ushort  wIndex;             /* ޯ */
    ushort  wVendorID;          /* ID */
    ushort  wDeviceID;          /* ޲ID */
    ushort  wNumMemWindows;     /* ذީ */
    ulong   dMemBase;           /* ذީ ް ڽ */
    ulong   dMemLength;         /* ذީ */
    ushort  wNumIOPort;         /* I/Oީ */
    ushort  wIOPortBase;        /* I/Oީ ް ڽ */
    ushort  wIOPortLength;      /* I/Oީ */
    ushort  wNumIRQs;           /* IRQ */
    uchar   bIRQRegisters;      /* gpIRQ */
} APCI_FIND_RES, far *LPAPCI_FIND_RES;

@foCXݒ̏ݒ肷邽߂̍\̂ւ̃|C^ƃfoCX
ݒ肷\̂ւ̃|C^uAPCI_CMD_PACKETv\̂ɐݒ肵T[rX[`
Ăт܂B

@L̃f[^̂Aobh̃AvP[VŎgp͈̂ȉ̍ڂłB

@EI/OީiwNumIOPortj
@@@I[vh^nEChEBobh͂PŒB
@EI/Oީ ް ڽiwIOPortBasej
@@@I[vh^nEChẼx[XAhXB
@EI/OީiwIOPortLengthj
@@@I[vh^nEChÊh^nB
@EIRQiwNumIRQsj
@@@荞ݐB
@EgpIRQibIRQRegistersj
@@@蓖Ăꂽ荞ݔԍB

@\̂̓oCgACgŎgpĂB

၄
ushort getInfo( ushort wDeviceID, ushort wNum )
{
APCI_FIND_MES       msg;
LPAPCI_FIND_RES     inf;
APCI_CMD_PACKET     pkt;
ushort              pkt_seg,
                    pkt_ofs,
                    res;
void far            *ptr;

    msg.wDeviceID  = wDeviceID;         // ޲ID
    msg.wIndex     = wNum;              // ޯ#
    pkt.lpMessage  = &msg;
    pkt.lpResponse = &inf;              // ޲ݒ肷\߲̂
    ptr = (void far *)&pkt;
    pkt_seg = FP_SEG( ptr );            // ıڽ擾
    pkt_ofs = FP_OFF( ptr );            // ̾ıڽ擾
    asm {
        push    es
        mov     ax,pkt_seg
        mov     es,ax                       // es <- ıڽ
        mov     di,pkt_ofs                  // di <- ̾ıڽ
        mov     ax, APCIC_FIND_RESOURCE     // ax <- 
        call    dword ptr T[rX[`  // ޽ٰ݂ق
        pop     es
        mov     res,ax
    }
    return res;                             // sʂԂ
}

@ۂ̃foCX̏ǂݍݖ@ɂẮAlr|cnrpbTvvO
uAPCICTRL.Cv́uApciGetDeviceInfo()v֐B


|[g̓o͂ɂ

@foCXhCõT[rX[`ĂяoăfoCX̏擾
uAPCI_FIND_RESv\̂̃ouwIOPortBasevx[XAhXƂ
o͂s܂B

၄
void inout( LPAPCI_FIND_RES Rsp )
{
uchar   dat;

    dat = inportb( Rsp->wIOPortBase + 0u );     //ްڽ + 0
    outportb( Rsp->wIOPortBase + 0u, dat );     //ްڽ + 0o
    dat = inportb( Rsp->wIOPortBase + 1u );     //ްڽ + 1
    outportb( Rsp->wIOPortBase + 1u, dat );     //ްڽ + 1o
}

@ۂ̃foCX̓o͂ɂẮAlr|cnrpbTvvO
uAPCICTRL.Cv́uApciInPort()vƁuApciOutPort()v֐B


荞ݐɂ

Pj`ohbQP𓋍ڂĂȂobh{[h̊荞ݐ

@`ohbQPڂĂȂobh{[hł́A荞ݐL̂悤
@@s܂B

@foCXhCõT[rX[`ĂяoăfoCX̏擾
uAPCI_FIND_RESv\̂̃ouwIOPortBasevx[XAhXƂ
L̃|[ggp܂B

@@荞ݐ䃌WX^@@@@@ްڽ + 0xf
@@荞݃Xe[^XWX^@@ްڽ + 0xf

@荞ݐ䃌WX^̃rbgATCLɋL܂B

@@BIT0    1 IRQ0 荞݋
@@BIT1    1 IRQ1 荞݋
@@BIT2    1 IRQ2 荞݋
@@BIT3    1 IRQ3 荞݋
@@BIT4    1Ŋ荞݃tONA

@荞݃Xe[^XWX^̃rbgATCLɋL܂B

@@BIT0    1 IRQ0 荞݃T[rX󂯂
@@BIT1    1 IRQ1 荞݃T[rX󂯂
@@BIT2    1 IRQ2 荞݃T[rX󂯂
@@BIT3    1 IRQ3 荞݃T[rX󂯂

@ۂ̃foCX̊荞ݐẮAlr|cnrpbTvvO
uAPCICTRL.Cv́uApciGetIrq()vƁuApciSetIen()v֐B


Qj`ohbQPڂobh{[h̊荞ݐ

@`ohbQPڂ̂obh{[hł́A荞ݐL̂悤ɍs܂B

@h^nRg[[hŎ擾foCXhCõT[rX[`ĂсA
foCX Interrupt Control Address ߰ ǂݏo܂B
@foCXhCõT[rX[`ɓnR}h́uAPCISRVS.Hvɒ`
uAPCIC_GET_ADAPTER_PORTvgp܂B

@foCXݒ̏̐ݒ͉L̍\̂ɐݒ肵܂B

typedef struct _APCI_GET_ADP_MES {
    ushort  wIndex;             /* ޯ */
    ushort  wDeviceID;          /* ޲ID */
} APCI_GET_ADP_MES, far *LPAPCI_GET_ADP_MES;

@foCX Interrupt Control Address ߰ ͉L̍\̂ɐݒ肳܂B

typedef struct _APCI_GET_ADP_RES {
    ushort  wIndex;             /* ޯ */
    ushort  wVendorID;          /* ID */
    ushort  wDeviceID;          /* ޲ID */
    ushort  wNumIOPort;         /* I/Oީ */
    ushort  wIOPortBase;        /* I/Oީ ް ڽ */
    ushort  wIOPortLength;      /* I/Oީ */
} APCI_GET_ADP_RES, far *LPAPCI_GET_ADP_RES;

@foCXݒ̏ݒ肷邽߂̍\̂ւ̃|C^ƃfoCX
Interrupt Control Address ߰ ݒ肷\̂ւ̃|C^
uAPCI_CMD_PACKETv\̂ɐݒ肵T[rX[`Ăт܂B

@Interrupt Control Address ߰  ް ڽ ́uwIOPortBasevɐݒ肳܂

@\̂̓oCgACgŎgpĂB

၄
ushort getAdapterInfo( ushort wDeviceID, ushort wNum )
{
APCI_GET_ADP_MES    msg;
APCI_GET_ADP_RES    inf;
APCI_CMD_PACKET     pkt;
ushort              pkt_seg,
                    pkt_ofs,
                    res;
void far            *ptr;

    msg.wDeviceID  = wDeviceID;         // ޲ID
    msg.wIndex     = wNum;              // ޯ#
    pkt.lpMessage  = &msg;
    pkt.lpResponse = &inf;              // ޲ݒ肷\߲̂
    ptr = (void far *)&pkt;
    pkt_seg = FP_SEG( ptr );            // ıڽ擾
    pkt_ofs = FP_OFF( ptr );            // ̾ıڽ擾
    asm {
        push    es
        mov     ax,pkt_seg
        mov     es,ax                       // es <- ıڽ
        mov     di,pkt_ofs                  // di <- ̾ıڽ
        mov     ax, APCIC_GET_ADAPTER_PORT  // ax <- 
        call    dword ptr T[rX[`  // ޽ٰ݂ق
        pop     es
        mov     res,ax
    }
    return res;                             // sʂԂ
}

@ۂ̃foCX̊荞ݐẮAlr|cnrpbTvvO
uAPCICTRL.Cv́uApciGetAdapterInfo()v֐B


@foCXhCõT[rX[`ĂяoăfoCX̏擾
uAPCI_GET_ADP_RESv\̂̃ouwIOPortBasevx[XAhXƂ
L̃|[ggp܂B

@@荞݃Xe[^XWX^@@ްڽ + 0x2
@@荞ݗvNAWX^@@ްڽ + 0x3
@@荞ݐݒ背WX^@@@@@ްڽ + 0xe
@듮邽ߏLȊÕ|[gɂ͐΂ɃANZXȂŉB

@e|[g̃rbgATĆA{[h̃}jAQƂĉB

@ۂ̃foCX̊荞ݐẮAlr|cnrpbTvvO
uAPCICTRL.Cv́uApciGetIfr()vƁuApciClrIrq()vƁuApciSetIrq()v֐
B


TvvOɂ

@lr|cnrœ삳邽ߎQl\tgusamplex.cvYtĂ܂B
@eQl\tg̓̓\[XvÕRgQƂĉB

