summaryrefslogtreecommitdiff
path: root/system/alpha/h/pci.h
blob: 17bae06d801c02b1e86155e8310d654a56d075a2 (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef __PCI_H_LOADED
#define __PCI_H_LOADED
/*****************************************************************************

       Copyright © 1993, 1994 Digital Equipment Corporation,
                       Maynard, Massachusetts.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the copyright notice and this permission notice appear in all copies
of software and supporting documentation, and that the name of Digital not
be used in advertising or publicity pertaining to distribution of the software
without specific, written prior permission. Digital grants this permission
provided that you prominently mark, as not part of the original, any
modifications made to this software or documentation.

Digital Equipment Corporation disclaims all warranties and/or guarantees
with regard to this software, including all implied warranties of fitness for
a particular purpose and merchantability, and makes no representations
regarding the use of, or the results of the use of, the software and
documentation in terms of correctness, accuracy, reliability, currentness or
otherwise; and you rely on the software, documentation and results solely at
your own risk.

******************************************************************************/

/*
 *  $Id:
 *
 *  This file contains all of the PCI specific definitions required for
 *  the PCI bus support within the debug monitor.
 */

/*
 * $Log: pci.h,v $
 * Revision 1.1.1.1  1997/10/30 23:27:17  verghese
 * current 10/29/97
 *
 * Revision 1.1  1996/04/15 16:26:54  berc
 * Initial revision
 *
 * Revision 1.11  1994/11/01  11:30:18  rusling
 * Added PCI-PCI bridge support.
 *
 * Revision 1.10  1994/08/05  20:13:47  fdh
 * Updated Copyright header and RCS $Id: identifier.
 *
 * $Log: pci.h,v $
 * Revision 1.1.1.1  1997/10/30 23:27:17  verghese
 * current 10/29/97
 *
 * Revision 1.1  1996/04/15 16:26:54  berc
 * Initial revision
 *
 * Revision 1.11  1994/11/01  11:30:18  rusling
 * Added PCI-PCI bridge support.
 *
 * Revision 1.9  1994/06/20  14:18:59  fdh
 * Fixup header file preprocessor #include conditionals.
 *
 * Revision 1.8  1994/06/19  15:48:04  fdh
 * Changed PCI_H to __PCI_H_LOADED
 *
 * Revision 1.7  1994/06/17  19:34:01  fdh
 * Clean-up...
 *
 * Revision 1.6  1994/01/19  10:22:28  rusling
 * Ported to ALpha Windows NT.
 *
 * Revision 1.5  1993/11/29  14:58:42  rusling
 * Added PCI address checking and conversion routines,
 * PCIMapAddress() and PCIValidAddress().
 *
 * Revision 1.4  1993/11/24  15:23:29  rusling
 * Added PCI_CFG_REG_VENDOR_DEVICE for offset to
 * first longword of the PCI configuration header.
 *
 * Revision 1.3  1993/11/23  10:43:50  rusling
 * Remove per system information.
 *
 * Revision 1.2  1993/11/22  13:17:13  rusling
 * Merged with PCI/21040 changes.
 *
 * Revision 1.1  1993/11/22  12:16:56  rusling
 * Initial revision
 *
 *
 */

#ifdef NEEDPCI


/*
 *  Define the PCI device data structure.
 */
typedef struct PCIDevice {
    struct PCIBus *parent;		/* parent bus */
    struct PCIDevice *next;		/* in device chain */
    struct PCIDevice *sibling;		/* for this bus */
    ui slot;
    uw vendor;
    uw device;
    ui class;

    ui PCI_IO_Reg;
    ui PCI_IO_Base;
    ui PCI_IO_Size;
    ui PCI_Mem_Reg;
    ui PCI_Mem_Base;
    ui PCI_Mem_Size;

    void (*print)(struct PCIDevice *device);
    struct {
        ui IO : 1;
        ui MEM : 1;
        ui bridge : 1;
        ui allocated : 1;
    } flags;
} PCIDevice_t;

typedef struct PCIBus {
    struct PCIBus *parent;
    struct PCIBus *next;
    struct PCIDevice *bridge;
    struct PCIDevice *devices;
    struct PCIBus *children;

    ui PCI_IO_Reg;
    ui PCI_IO_Base;
    ui PCI_IO_Size;
    ui PCI_Mem_Reg;
    ui PCI_Mem_Base;
    ui PCI_Mem_Size;

    unsigned char number;
    unsigned char primary;
    unsigned char secondary;
    unsigned char subordinate;
} PCIBus_t;


/*
 *  Define some macros for getting at fields in the
 *  PCIDevice_t and PCIBus_t typedefs.
 */
#define _PCI_IO_Base(device)  (device)->PCI_IO_Base
#define _PCI_IO_Size(device)  (device)->PCI_IO_Size
#define _PCI_Mem_Base(device) (device)->PCI_Mem_Base
#define _PCI_Mem_Size(device) (device)->PCI_Mem_Size
#define _PCI_Slot(device)     (device)->slot
#define _PCI_Print(device)    (device)->print
#define _PCI_Bus(device)      (device)->parent->number

/*
 *  Declare some maximums.
 */
#define PCI_MAX_DEVICES   	6	/* bits 31:11 of type 0 */
#define PCI_21050_MAX_DEVICES 	16	/* bits 14:11 of type 1 */
#define PCI_MAX_BRIDGES	   	6

/*
 *  The PCI configuration registers.
 */
#define PCI_CFG_REG_VENDOR_DEVICE         0x0
#define PCI_CFG_REG_STATUS_COMMAND        0x4
                                        /* LONG */
#define PCI_CFG_REG_REVISION_ID           0x8
                                        /* BYTE */
#define PCI_CFG_REG_CLASS_CODE		  0x9
#define PCI_CFG_REG_LATENCY_TIMER         0xD
                                        /* BYTE */
#define PCI_CFG_REG_BAR0                  0x10
                                        /* Long */
#define PCI_CFG_REG_BRIDGE_PRIMARY	  0x18
#define PCI_CFG_REG_BRIDGE_SECONDARY	  0x19
#define PCI_CFG_REG_BRIDGE_SUBORDINATE	  0x1a

#define PCI_CFG_REG_EROM_BASE             0x30
                                        /* Long */

/*
 *  PCI Vendors and devices.
 */
#define DIGITAL                        0x1011
#define DECCHIP_21040                  0x0002
#define DECCHIP_21030                  0x0004

#define PCI_BRIDGE_CLASS		       0x060400
/*
 *  Declare all of the externally visible routines in pci.c
 */
extern void PCIShow(void);
extern ui PCIValidAddress(ub * address);
extern ui PCIMapAddress(ub * address);
extern void PCIInit(void);
extern PCIDevice_t *PCIDeviceFind(uw vendor, uw device);
extern PCIDevice_t *PCIDeviceFindNext(PCIDevice_t *device);
extern void PCISetDeviceConfig(PCIDevice_t *device);

#endif /* NEEDPCI */
#endif /* __PCI_H_LOADED */