2 Copyright 2010, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
10 #include <aros/debug.h>
12 #include "agp_private.h"
14 #undef HiddAGPBridgeDeviceAttrBase
15 #define HiddAGPBridgeDeviceAttrBase (SD(cl)->hiddAGPBridgeDeviceAB)
17 /* NON-PUBLIC METHODS */
18 VOID
METHOD(Agp3BridgeDevice
, Hidd_AGPBridgeDevice
, FlushGattTable
)
20 struct HIDDGenericBridgeDeviceData
* gbddata
=
21 OOP_INST_DATA(SD(cl
)->genericBridgeDeviceClass
, o
);
23 OOP_Object
* bridgedev
= gbddata
->bridge
->PciDevice
;
24 UBYTE bridgeagpcap
= gbddata
->bridge
->AgpCapability
;
26 ctrlreg
= readconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
);
27 writeconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
, ctrlreg
& ~AGP_CTRL_REG_GTBLEN
);
28 writeconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
, ctrlreg
);
32 OOP_Object
* METHOD(Agp3BridgeDevice
, Root
, New
)
34 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
39 VOID
Agp3BridgeDevice__Root__Dispose(OOP_Class
* cl
, OOP_Object
* o
, OOP_Msg msg
)
41 struct HIDDGenericBridgeDeviceData
* gbddata
=
42 OOP_INST_DATA(SD(cl
)->genericBridgeDeviceClass
, o
);
44 if (gbddata
->state
!= STATE_UNKNOWN
)
46 OOP_Object
* bridgedev
= gbddata
->bridge
->PciDevice
;
47 UBYTE bridgeagpcap
= gbddata
->bridge
->AgpCapability
;
49 ctrlreg
= readconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
);
50 writeconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
, ctrlreg
& ~AGP_CTRL_REG_APEREN
);
53 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
56 BOOL
METHOD(Agp3BridgeDevice
, Hidd_AGPBridgeDevice
, Initialize
)
58 struct HIDDGenericBridgeDeviceData
* gbddata
=
59 OOP_INST_DATA(SD(cl
)->genericBridgeDeviceClass
, o
);
61 /* Subclass is required to perform the detection */
65 OOP_Object
* bridgedev
= gbddata
->bridge
->PciDevice
;
66 UBYTE bridgeagpcap
= gbddata
->bridge
->AgpCapability
;
67 UWORD aperture_size_value
= 0;
70 /* Getting GART size */
71 aperture_size_value
= readconfigword(bridgedev
, bridgeagpcap
+ AGP_APER_SIZE_REG
);
72 D(bug("[AGP] Reading aperture size value: %x\n", aperture_size_value
));
74 switch(aperture_size_value
)
76 case(0xf3f): gbddata
->bridgeapersize
= 4; break;
77 case(0xf3e): gbddata
->bridgeapersize
= 8; break;
78 case(0xf3c): gbddata
->bridgeapersize
= 16; break;
79 case(0xf38): gbddata
->bridgeapersize
= 32; break;
80 case(0xf30): gbddata
->bridgeapersize
= 64; break;
81 case(0xf20): gbddata
->bridgeapersize
= 128; break;
82 case(0xf00): gbddata
->bridgeapersize
= 256; break;
83 case(0xe00): gbddata
->bridgeapersize
= 512; break;
84 case(0xc00): gbddata
->bridgeapersize
= 1024; break;
85 case(0x800): gbddata
->bridgeapersize
= 2048; break;
86 default: gbddata
->bridgeapersize
= 0; break;
89 D(bug("[AGP] Calculated aperture size: %d MB\n", (ULONG
)gbddata
->bridgeapersize
));
91 /* Creation of GATT table */
92 struct pHidd_AGPBridgeDevice_CreateGattTable cgtmsg
= {
93 mID
: OOP_GetMethodID(IID_Hidd_AGPBridgeDevice
, moHidd_AGPBridgeDevice_CreateGattTable
)
95 if (!OOP_DoMethod(o
, (OOP_Msg
)&cgtmsg
))
98 /* Getting GART base */
99 gbddata
->bridgeaperbase
= (IPTR
)readconfiglong(bridgedev
, AGP_APER_BASE
);
100 gbddata
->bridgeaperbase
&= (~0x0fUL
) /* PCI_BASE_ADDRESS_MEM_MASK */;
101 D(bug("[AGP] Reading aperture base: 0x%x\n", (ULONG
)gbddata
->bridgeaperbase
));
103 /* Set GATT pointer */
104 writeconfiglong(bridgedev
, bridgeagpcap
+ AGP_GATT_CTRL_LO_REG
,
105 (ULONG
)(IPTR
)gbddata
->gatttable
);
106 D(bug("[AGP] Set GATT pointer to 0x%x\n", (ULONG
)gbddata
->gatttable
));
108 /* Enabled GART and GATT */
109 ctrlreg
= readconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
);
110 writeconfiglong(bridgedev
, bridgeagpcap
+ AGP_CTRL_REG
,
111 ctrlreg
| AGP_CTRL_REG_APEREN
| AGP_CTRL_REG_GTBLEN
);
113 D(bug("[AGP] Enabled GART and GATT\n"));