5 Copyright 2010, The AROS Development Team. All rights reserved.
9 #include <exec/lists.h>
11 #include <exec/semaphores.h>
13 #include LC_LIBDEFS_FILE
17 struct List classes
; /* List of AGPBridgeDevice classes */
23 OOP_Class
*genericBridgeDeviceClass
;
24 OOP_Class
*agp3BridgeDeviceClass
;
25 OOP_Class
*sisAgp3BridgeDeviceClass
;
26 OOP_Class
*sisBridgeDeviceClass
;
27 OOP_Class
*viaBridgeDeviceClass
;
28 OOP_Class
*viaAgp3BridgeDeviceClass
;
29 OOP_Class
*i8XXBridgeDeviceClass
;
30 OOP_Class
*i845BridgeDeviceClass
;
31 OOP_Class
*i7505BridgeDeviceClass
;
32 OOP_Class
*i915BridgeDeviceClass
;
33 OOP_Class
*i965BridgeDeviceClass
;
34 OOP_Class
*g33BridgeDeviceClass
;
36 OOP_AttrBase hiddAGPBridgeDeviceAB
;
37 OOP_AttrBase hiddPCIDeviceAB
;
39 OOP_Object
*bridgedevice
;
45 struct Library LibNode
;
46 struct agpstaticdata sd
;
49 #define METHOD(base, id, name) \
50 base ## __ ## id ## __ ## name (OOP_Class *cl, OOP_Object *o, struct p ## id ## _ ## name *msg)
52 #define BASE(lib) ((LIBBASETYPEPTR)(lib))
54 #define SD(cl) (&BASE(cl->UserData)->sd)
56 /* Non-public methods of AGPBridgeDevice interface*/
59 moHidd_AGPBridgeDevice_ScanAndDetectDevices
= NUM_AGPBRIDGEDEVICE_METHODS
,
60 moHidd_AGPBridgeDevice_CreateGattTable
,
61 moHidd_AGPBridgeDevice_FlushGattTable
,
64 struct pHidd_AGPBridgeDevice_ScanAndDetectDevices
69 struct pHidd_AGPBridgeDevice_CreateGattTable
74 struct pHidd_AGPBridgeDevice_FlushGattTable
79 /* This is an abstract class. Contains usefull code but is not functional */
80 #define CLID_Hidd_GenericBridgeDevice "hidd.agp.genericbridgedevice"
85 OOP_Object
*PciDevice
;
86 UBYTE AgpCapability
; /* Offset to AGP capability in config */
92 struct HIDDGenericBridgeDeviceData
94 struct SignalSemaphore lock
; /* Lock for device operations */
95 struct List devices
; /* Bridges and AGP devices in system */
98 struct PciAgpDevice
*bridge
; /* Selected AGP bridge */
99 ULONG bridgemode
; /* Mode of AGP bridge */
100 IPTR bridgeaperbase
; /* Base address for aperture */
101 IPTR bridgeapersize
; /* Size of aperture */
102 APTR gatttablebuffer
;/* Buffer for gatt table */
103 ULONG
*gatttable
; /* 4096 aligned gatt table */
104 APTR scratchmembuffer
;/* Buffer for scratch mem */
105 ULONG
*scratchmem
; /* 4096 aligned scratch mem */
106 ULONG memmask
; /* Mask for binded memorory */
108 ULONG state
; /* State of the device */
110 /* Video card data */
111 struct PciAgpDevice
*videocard
; /* Selected AGP card */
114 #define STATE_UNKNOWN 0x00
115 #define STATE_INITIALIZED 0x01
116 #define STATE_ENABLED 0x02
118 /* This is an abstract class. Contains usefull code but is not functional */
119 #define CLID_Hidd_Agp3BridgeDevice "hidd.agp.agp3bridgedevice"
121 struct HIDDAgp3BridgeDeviceData
125 /* Supports SiS chipsets compatible with AGP3 */
126 #define CLID_Hidd_SiSAgp3BridgeDevice "hidd.agp.sisagp3bridgedevice"
128 struct HIDDSiSAgp3BridgeDeviceData
132 /* Supports SiS chipsets not compatible with AGP3 */
133 #define CLID_Hidd_SiSBridgeDevice "hidd.agp.sisbridgedevice"
135 struct HIDDSiSBridgeDeviceData
139 /* Supports VIA chipsets not compatible with AGP3 */
140 #define CLID_Hidd_VIABridgeDevice "hidd.agp.viabridgedevice"
142 struct HIDDVIABridgeDeviceData
146 /* Supports VIA chipsets compatible with AGP3 */
147 #define CLID_Hidd_VIAAgp3BridgeDevice "hidd.agp.viaagp3bridgedevice"
149 struct HIDDVIAAgp3BridgeDeviceData
153 /* Abstract class with support for most i8XX chipsets */
154 #define CLID_Hidd_i8XXBridgeDevice "hidd.agp.i8xxbridgedevice"
156 struct HIDDi8XXBridgeDeviceData
160 /* Supports i845 chipsets */
161 #define CLID_Hidd_i845BridgeDevice "hidd.agp.i845bridgedevice"
163 struct HIDDi845BridgeDeviceData
167 /* Supports i7505 chipsets */
168 #define CLID_Hidd_i7505BridgeDevice "hidd.agp.i7505bridgedevice"
170 struct HIDDi7505BridgeDeviceData
174 /* Intel IGPs support: i915, i965, g33 */
175 /* These classes implement the AGPBridgeDevice interface but do not
176 * inherit from GenericBridgeDevice */
178 /* FIXME: these classes are not completly implemented and are not tested.
179 * They are also not registered with the AGP class. */
181 #define CLID_Hidd_i915BridgeDevice "hidd.agp.i915bridgedevice"
183 struct HIDDi915BridgeDeviceData
185 struct SignalSemaphore lock
; /* Lock for device operations */
188 ULONG bridgemode
; /* Mode of AGP bridge */
189 IPTR bridgeaperbase
; /* Base address for aperture */
190 IPTR bridgeapersize
; /* Size of aperture */
193 APTR scratchmembuffer
;/* Buffer for scratch mem */
194 ULONG
*scratchmem
; /* 4096 aligned scratch mem */
196 ULONG firstgattentry
;
198 ULONG state
; /* State of the device */
202 OOP_Object
*igp
; /* IGP video device */
205 #define CLID_Hidd_i965BridgeDevice "hidd.agp.i965bridgedevice"
207 struct HIDDi965BridgeDeviceData
211 #define CLID_Hidd_g33BridgeDevice "hidd.agp.g33bridgedevice"
213 struct HIDDg33BridgeDeviceData
216 /* Registers defines */
217 #define AGP_APER_BASE 0x10 /* BAR0 */
218 #define AGP_VERSION_REG 0x02
219 #define AGP_STATUS_REG 0x04
220 #define AGP_STATUS_REG_AGP_3_0 (1<<3)
221 #define AGP_STATUS_REG_FAST_WRITES (1<<4)
222 #define AGP_STATUS_REG_AGP_ENABLED (1<<8)
223 #define AGP_STATUS_REG_SBA (1<<9)
224 #define AGP_STATUS_REG_CAL_MASK (1<<12|1<<11|1<<10)
225 #define AGP_STATUS_REG_ARQSZ_MASK (1<<15|1<<14|1<<13)
226 #define AGP_STATUS_REG_RQ_DEPTH_MASK 0xff000000
227 #define AGP_STATUS_REG_AGP2_X1 (1<<0)
228 #define AGP_STATUS_REG_AGP2_X2 (1<<1)
229 #define AGP_STATUS_REG_AGP2_X4 (1<<2)
230 #define AGP_STATUS_REG_AGP3_X4 (1<<0)
231 #define AGP_STATUS_REG_AGP3_X8 (1<<1)
232 #define AGP_COMMAND_REG 0x08
233 #define AGP_CTRL_REG 0x10
234 #define AGP_CTRL_REG_GTBLEN (1<<7)
235 #define AGP_CTRL_REG_APEREN (1<<8)
236 #define AGP_APER_SIZE_REG 0x14
237 #define AGP_GATT_CTRL_LO_REG 0x18
239 #define AGP2_RESERVED_MASK 0x00fffcc8
240 #define AGP3_RESERVED_MASK 0x00ff00c4
243 #define ALIGN(val, align) (val + align - 1) & (~(align - 1))
245 #define writel(val, addr) (*(volatile ULONG*)(addr) = (val))
246 #define readl(addr) (*(volatile ULONG*)(addr))
247 #define min(a,b) ((a) < (b) ? (a) : (b))
248 #define max(a,b) ((a) > (b) ? (a) : (b))
250 /* Note: Both Linux and BSD codes use full wbinvd. CacheClearU gurantees a full flush */
251 #define flushcpucache() CacheClearU()
253 /* Config area access */
254 UBYTE
readconfigbyte(OOP_Object
* pciDevice
, UBYTE where
);
255 UWORD
readconfigword(OOP_Object
* pciDevice
, UBYTE where
);
256 ULONG
readconfiglong(OOP_Object
* pciDevice
, UBYTE where
);
257 VOID
writeconfigbyte(OOP_Object
* pciDevice
, UBYTE where
, UBYTE val
);
258 VOID
writeconfigword(OOP_Object
* pciDevice
, UBYTE where
, UWORD val
);
259 VOID
writeconfiglong(OOP_Object
* pciDevice
, UBYTE where
, ULONG val
);