summaryrefslogtreecommitdiffstats
path: root/private/ntos/nthals/halxlt/alpha/pcibus.c
blob: 3ce95ed54d330da03b683d99f691b4df1c8ac3bc (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*++

Copyright (c) 1993 Microsoft Corporation, Digital Equipment Corporation


Module Name:

    pcibus.c

Abstract:

    Platform-specific PCI bus routines

Author:

    Steve Brooks    30-Jun-1994
    Joe Notarangelo 30-Jun-1994

Environment:

    Kernel mode

Revision History:

--*/

#include "halp.h"
#include "pci.h"
#include "pcip.h"
#include "machdep.h"


extern ULONG PCIMaxBus;


PCI_CONFIGURATION_TYPES
HalpPCIConfigCycleType (
    IN PBUS_HANDLER BusHandler
    )
{
    if (BusHandler->BusNumber == 0) {
        return PciConfigType0;
    } else {
        return PciConfigType1;
    }
}


VOID
HalpPCIConfigAddr (
    IN PBUS_HANDLER BusHandler,
    IN PCI_SLOT_NUMBER  Slot,
    PPCI_CFG_CYCLE_BITS pPciAddr
    )
{
    PCI_CONFIGURATION_TYPES ConfigType;

    ConfigType = HalpPCIConfigCycleType(BusHandler);

#if HALDBG

    DbgPrint( "PCI Config Access: Bus = %d, Device = %d, Type = %d\n",
            BusNumber, Slot.u.bits.DeviceNumber, ConfigType );

#endif //HALDBG

    if (ConfigType == PciConfigType0) {

        //
        // Initialize PciAddr for a type 0 configuration cycle
        //
        // Note that HalpValidPCISlot has already done bounds checking 
        // on DeviceNumber.
        //
        // PciAddr can be intialized for different bus numbers
        // with distinct configuration spaces here.
        //

        pPciAddr->u.AsULONG =  (ULONG) CIA_PCI_CONFIG_BASE_QVA;

        //
        // Encoding of the configuration addresses differs between
        // passes of the CIA.  Use the pre-determined global HalpCiaRevision
        // to decide which encoding to use.
        //

        if( HalpCiaRevision == CIA_REVISION_1 ){

            //
            // CIA Pass 1
            //

            pPciAddr->u.AsULONG += ( 1 << (Slot.u.bits.DeviceNumber + 11) );

        } else {

            //
            // CIA Pass 2 or later.
            //

            pPciAddr->u.AsULONG += ( (Slot.u.bits.DeviceNumber) << 11 );

        }

        pPciAddr->u.bits0.FunctionNumber = Slot.u.bits.FunctionNumber;
        pPciAddr->u.bits0.Reserved1 = PciConfigType0;

    } else {

        //
        // Initialize PciAddr for a type 1 configuration cycle
        //
        //

        pPciAddr->u.AsULONG = (ULONG) CIA_PCI_CONFIG_BASE_QVA;
        pPciAddr->u.bits1.BusNumber = BusHandler->BusNumber;
        pPciAddr->u.bits1.FunctionNumber = Slot.u.bits.FunctionNumber;
        pPciAddr->u.bits1.DeviceNumber = Slot.u.bits.DeviceNumber;
        pPciAddr->u.bits1.Reserved1 = PciConfigType1;
        
    }

    return;
}