summaryrefslogtreecommitdiffstats
path: root/private/ntos/miniport/trantor/source/cardutil.c
blob: ef0a4b151ab42a989bfe60ce9c0a6ca8d971f0a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//-----------------------------------------------------------------------
//
//  CARDUTIL.C 
//
//  Utility File for all common card routines.
//
//  History:
//
//      02-20-93 KJB/SG First, Placed SG's CardGetNumber function here.
//      03-25-93  JAP   Fixed up typedef and prototype inconsistencies
//      05-12-93  JAP   Added version control information.
//                          This file should be updated changing the version numbers
//                          on EACH significant change to ANY low-level driver. 
//                          The cause of upping a version should be placed in this
//                          files history. (currently Version 1.0)
//      05-12-93  KJB   Moved code from cardtxxx.c to here.
//      05-12-93  KJB   Fixed bugs in CardGetVersion.
//      05-15-93  KJB   Fixed warnings in CardGetNumber.
//
//-------------------------------------------------------------------------

#include CARDTXXX_H

#define CDRIVER_MAJOR_VERSION  1
#define CDRIVER_MINOR_VERSION  0

//
//  Static constant arrays defined in cardtxxx.c
//
extern PBASE_REGISTER AdapterAddresses[];
extern USHORT AdapterInterrupts[];

//-----------------------------------------------------------------------
//  CardGetVersion()
//
//  Return the CDRIVER version number values.
//
//  Input:  Pointer to ULONG to be filled with major version number
//              Pointer to ULONG to be filled with minor version number
//
//  Output: None.  Major and minor version variables are filled.
//-----------------------------------------------------------------------

VOID CardGetVersion (PULONG pMajorVersion, PULONG pMinorVersion)
{
    *pMajorVersion = CDRIVER_MAJOR_VERSION;
    *pMinorVersion = CDRIVER_MINOR_VERSION;
}


//-----------------------------------------------------------------------
//  CardGetNumber ()
//
//  Returns the index number of the given adapter address from the 
//   AdapterAddresses table.
//  Return -1, if the address is not found in the table.
//-----------------------------------------------------------------------

USHORT CardGetNumber (PBASE_REGISTER basePort)
{
    USHORT i;

    for (i = 0; AdapterAddresses [i] != 0; i++) { 
        if (AdapterAddresses [i] == basePort)
            return i;
    }

    return 0xffff;
}

//-----------------------------------------------------------------------
//
//  CardGetWorkspaceSize
//
//-----------------------------------------------------------------------
USHORT CardGetWorkspaceSize(void )
{
    return sizeof (ADAPTER_INFO);
}

//------------------------------------------------------------------------
//  CardGetIRQ
//
//  Returns the nth possible adapter interrupt.
//  Returns 0 when the last possible interrupt has been exceeded.
//------------------------------------------------------------------------

USHORT CardGetIRQ (USHORT i)
{
    return  AdapterInterrupts [i];
}


//------------------------------------------------------------------------
//  CardAddress
//
//  Returns the nth adapter address.
//  Returns 0 when the last address has been exceeded.
//------------------------------------------------------------------------

PBASE_REGISTER CardAddress (USHORT i)
{
    return ((PBASE_REGISTER)AdapterAddresses [i]);
}

//-----------------------------------------------------------------------
//      End Of File.
//-----------------------------------------------------------------------