xref: /haiku/headers/private/graphics/AGP.h (revision 8195a5a835117ab2da405e0d477153570b75d921)
1 /*
2  * Copyright 2004-2008, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _AGP_H_
6 #define _AGP_H_
7 
8 
9 #include <bus_manager.h>
10 
11 
12 typedef struct agp_info {
13 	ushort	vendor_id;			/* vendor id */
14 	ushort	device_id;			/* device id */
15 	uchar	bus;				/* bus number */
16 	uchar	device;				/* device number on bus */
17 	uchar	function;			/* function number in device */
18 	uchar	class_sub;			/* specific device function */
19 	uchar	class_base;			/* device type (display vs host bridge) */
20 	struct {
21 		uint32	capability_id;	/* AGP capability register as defined in the AGP standard */
22 		uint32	status;			/* AGP STATUS register as defined in the AGP standard */
23 		uint32	command;		/* AGP COMMAND register as defined in the AGP standard */
24 	} interface;
25 } agp_info;
26 
27 typedef struct aperture_info {
28 	addr_t	physical_base;
29 	addr_t	base;
30 	size_t	size;
31 	size_t	reserved_size;
32 } aperture_info;
33 
34 /* flags for allocate_memory */
35 enum {
36 	B_APERTURE_NON_RESERVED		= 0x01,
37 	B_APERTURE_NEED_PHYSICAL	= 0x02,
38 };
39 
40 typedef int32 aperture_id;
41 typedef struct gart_bus_module_info gart_bus_module_info;
42 
43 typedef struct agp_gart_module_info {
44 	bus_manager_info info;
45 
46 	// AGP functionality
47 	status_t	(*get_nth_agp_info)(uint32 index, agp_info *info);
48 	status_t	(*acquire_agp)(void);
49 	void		(*release_agp)(void);
50 	uint32		(*set_agp_mode)(uint32 command);
51 
52 	// GART functionality
53 	aperture_id	(*map_aperture)(uint8 bus, uint8 device, uint8 function,
54 					size_t size, addr_t *_apertureBase);
55 	aperture_id	(*map_custom_aperture)(gart_bus_module_info *module,
56 					addr_t *_apertureBase);
57 	status_t	(*unmap_aperture)(aperture_id id);
58 	status_t	(*get_aperture_info)(aperture_id id, aperture_info *info);
59 
60 	status_t	(*allocate_memory)(aperture_id id, size_t size,
61 					size_t alignment, uint32 flags, addr_t *_apertureBase,
62 					addr_t *_physicalBase);
63 	status_t	(*free_memory)(aperture_id id, addr_t apertureBase);
64 	status_t	(*reserve_aperture)(aperture_id id, size_t size,
65 					addr_t *_apertureBase);
66 	status_t	(*unreserve_aperture)(aperture_id id, addr_t apertureBase);
67 	status_t	(*bind_aperture)(aperture_id id, area_id area, addr_t base,
68 					size_t size, size_t alignment, addr_t reservedBase,
69 					addr_t *_apertureBase);
70 	status_t	(*unbind_aperture)(aperture_id id, addr_t apertureBase);
71 } agp_gart_module_info;
72 
73 #define	B_AGP_GART_MODULE_NAME "bus_managers/agp_gart/v0"
74 
75 struct agp_gart_for_bus_module_info {
76 	module_info info;
77 };
78 
79 #define B_AGP_GART_FOR_BUS_MODULE_NAME "bus_managers/agp_gart/bus/v0"
80 
81 struct agp_gart_bus_module_info {
82 	module_info info;
83 
84 	// TODO: add some stuff for non-generic AGP support as well
85 
86 	status_t	(*create_aperture)(uint8 bus, uint8 device, uint8 function,
87 					size_t size, void **_aperture);
88 	void		(*delete_aperture)(void *aperture);
89 
90 	status_t	(*get_aperture_info)(void *aperture, aperture_info *info);
91 	status_t	(*set_aperture_size)(void *aperture, size_t size);
92 	status_t	(*bind_page)(void *aperture, uint32 offset,
93 					addr_t physicalAddress);
94 	status_t	(*unbind_page)(void *aperture, uint32 offset);
95 	void		(*flush_tlbs)(void *aperture);
96 };
97 
98 /* defines for capability ID register bits */
99 #define AGP_REV_MINOR		0x000f0000	/* AGP Revision minor number reported */
100 #define AGP_REV_MINOR_SHIFT	16
101 #define AGP_REV_MAJOR		0x00f00000	/* AGP Revision major number reported */
102 #define AGP_REV_MAJOR_SHIFT	20
103 
104 /* defines for status and command register bits */
105 #define AGP_2_1x			0x00000001	/* AGP Revision 2.0 1x speed transfer mode */
106 #define AGP_2_2x			0x00000002	/* AGP Revision 2.0 2x speed transfer mode */
107 #define AGP_2_4x			0x00000004	/* AGP Revision 2.0 4x speed transfer mode */
108 #define AGP_3_4x			0x00000001	/* AGP Revision 3.0 4x speed transfer mode */
109 #define AGP_3_8x			0x00000002	/* AGP Revision 3.0 8x speed transfer mode */
110 #define AGP_RATE_MASK		0x00000007	/* mask for supported rates info */
111 #define AGP_3_MODE			0x00000008	/* 0 if AGP Revision 2.0 or earlier rate scheme,
112 										 * 1 if AGP Revision 3.0 rate scheme */
113 #define AGP_FAST_WRITE		0x00000010	/* 1 if fast write transfers supported */
114 #define AGP_ABOVE_4G		0x00000020	/* 1 if adresses above 4G bytes supported */
115 #define AGP_SBA				0x00000200	/* 1 if side band adressing supported */
116 #define AGP_REQUEST			0xff000000	/* max. number of enqueued AGP command requests
117 										 * supported, minus one */
118 #define AGP_REQUEST_SHIFT	24
119 
120 /* masks for command register bits */
121 #define AGP_ENABLE			0x00000100	/* set to 1 if AGP should be enabled */
122 
123 #endif	/* _AGP_H_ */
124