1 diff -ru usr/src/nv/nv-linux.h usr/src/nv.1201042/nv-linux.h
2 --- usr/src/nv/nv-linux.h 2004-11-03 22:53:00.000000000 +0100
3 +++ usr/src/nv.1201042/nv-linux.h 2005-01-22 14:34:35.000000000 +0100
5 #define PCI_CAP_ID_EXP 0x10
8 -#if defined(KERNEL_2_6) && defined(AGPGART)
9 -typedef struct agp_kern_info agp_kern_info;
10 -typedef struct agp_memory agp_memory;
13 #if defined(CONFIG_DEVFS_FS)
14 # if defined(KERNEL_2_6)
15 typedef void* devfs_handle_t;
16 diff -ru usr/src/nv/nv.c usr/src/nv.1201042/nv.c
17 --- usr/src/nv/nv.c 2004-11-03 22:53:00.000000000 +0100
18 +++ usr/src/nv.1201042/nv.c 2005-01-22 14:34:35.000000000 +0100
19 @@ -2987,32 +2987,39 @@
21 if ( (!NV_AGP_ENABLED(nv)) && (config & NVOS_AGP_CONFIG_NVAGP) )
23 - /* make sure the user does not have agpgart loaded */
24 - if (inter_module_get("drm_agp")) {
25 +#if defined(KERNEL_2_4)
26 + if (inter_module_get("drm_agp"))
28 inter_module_put("drm_agp");
29 - nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!!\n");
31 -#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
32 + nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!\n");
35 +#elif defined(AGPGART)
37 + if ((error = agp_backend_acquire()) != -EINVAL)
39 + if (!error) agp_backend_release();
40 nv_printf(NV_DBG_WARNINGS,
41 - "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!!\n");
43 - status = rm_init_agp(nv);
44 - if (status == RM_OK)
46 - nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
47 - nv->agp_status = NV_AGP_STATUS_ENABLED;
49 + "NVRM: not using NVAGP, an AGPGART backend is loaded!\n");
53 +#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
54 + nv_printf(NV_DBG_WARNINGS,
55 + "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!\n");
57 + status = rm_init_agp(nv);
58 + if (status == RM_OK)
60 + nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
61 + nv->agp_status = NV_AGP_STATUS_ENABLED;
66 if (NV_AGP_ENABLED(nv))
67 old_error = 0; /* report new errors */
69 - nv_printf(NV_DBG_SETUP,
70 - "NVRM: agp_init finished with status 0x%x and config %d\n",
71 - status, nv->agp_config);
77 nv->agp_config = NVOS_AGP_CONFIG_DISABLE_AGP;
78 nv->agp_status = NV_AGP_STATUS_DISABLED;
80 - nv_printf(NV_DBG_SETUP, "NVRM: teardown finished with status 0x%x\n",
86 diff -ru usr/src/nv/os-agp.c usr/src/nv.1201042/os-agp.c
87 --- usr/src/nv/os-agp.c 2004-11-03 22:53:00.000000000 +0100
88 +++ usr/src/nv.1201042/os-agp.c 2005-01-22 14:34:35.000000000 +0100
93 +#if defined(KERNEL_2_6)
94 +typedef struct agp_kern_info agp_kern_info;
95 +typedef struct agp_memory agp_memory;
96 +#elif defined(KERNEL_2_4)
97 +const drm_agp_t *drm_agp_p; /* functions */
105 agp_kern_info agpinfo;
107 -const drm_agp_t *drm_agp_p;
109 #if defined(CONFIG_MTRR)
110 #define MTRR_DEL(gart) if ((gart).mtrr > 0) mtrr_del((gart).mtrr, 0, 0);
112 #define MTRR_DEL(gart)
115 +#if defined(KERNEL_2_6)
116 +#define NV_AGPGART_BACKEND_ACQUIRE(o) agp_backend_acquire()
117 +#define NV_AGPGART_BACKEND_ENABLE(o,mode) agp_enable(mode)
118 +#define NV_AGPGART_BACKEND_RELEASE(o) agp_backend_release()
119 +#define NV_AGPGART_COPY_INFO(o,p) agp_copy_info(p)
120 +#define NV_AGPGART_ALLOCATE_MEMORY(o,count,type) agp_allocate_memory(count,type)
121 +#define NV_AGPGART_FREE_MEMORY(o,p) agp_free_memory(p)
122 +#define NV_AGPGART_BIND_MEMORY(o,p,offset) agp_bind_memory(p,offset)
123 +#define NV_AGPGART_UNBIND_MEMORY(o,p) agp_unbind_memory(p)
124 +#elif defined(KERNEL_2_4)
125 +#define NV_AGPGART_BACKEND_ACQUIRE(o) ({ (o)->acquire(); 0; })
126 +#define NV_AGPGART_BACKEND_ENABLE(o,mode) (o)->enable(mode)
127 +#define NV_AGPGART_BACKEND_RELEASE(o) ((o)->release())
128 +#define NV_AGPGART_COPY_INFO(o,p) ({ (o)->copy_info(p); 0; })
129 +#define NV_AGPGART_ALLOCATE_MEMORY(o,count,type) (o)->allocate_memory(count,type)
130 +#define NV_AGPGART_FREE_MEMORY(o,p) (o)->free_memory(p)
131 +#define NV_AGPGART_BIND_MEMORY(o,p,offset) (o)->bind_memory(p,offset)
132 +#define NV_AGPGART_UNBIND_MEMORY(o,p) (o)->unbind_memory(p)
140 memset( (void *) &gart, 0, sizeof(agp_gart));
142 +#if defined(KERNEL_2_4)
143 if (!(drm_agp_p = inter_module_get_request("drm_agp", "agpgart")))
147 /* NOTE: from here down, return an error code of '-1'
148 * that indicates that agpgart is loaded, but we failed to use it
150 * the memory controller.
153 - if (drm_agp_p->acquire())
154 + if (NV_AGPGART_BACKEND_ACQUIRE(drm_agp_p))
156 - nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: backend in use\n");
157 - inter_module_put("drm_agp");
159 + nv_printf(NV_DBG_INFO, "NVRM: AGPGART: no backend available\n");
163 if (rm_read_registry_dword(nv, "NVreg", "ReqAGPRate", &agp_rate) == RM_ERROR)
164 @@ -101,21 +128,12 @@
166 agp_fw &= 0x00000001;
168 -#if defined(KERNEL_2_4)
170 - * The original Linux 2.4 AGP GART driver interface declared copy_info to
171 - * return nothing. This changed in Linux 2.5, which reports unsupported
172 - * chipsets via this function. If this Linux 2.4 kernels behaves the same
173 - * way, we have no way to know.
175 - drm_agp_p->copy_info(&agpinfo);
177 - if (drm_agp_p->copy_info(&agpinfo)) {
178 + if (NV_AGPGART_COPY_INFO(drm_agp_p, &agpinfo))
180 nv_printf(NV_DBG_ERRORS,
181 "NVRM: AGPGART: kernel reports chipset as unsupported\n");
189 if (!(agp_rate & 0x00000004)) agpinfo.mode &= ~0x00000004;
190 if (!(agp_rate & 0x00000002)) agpinfo.mode &= ~0x00000002;
192 - drm_agp_p->enable(agpinfo.mode);
193 + NV_AGPGART_BACKEND_ENABLE(drm_agp_p, agpinfo.mode);
195 *ap_phys_base = (void*) agpinfo.aper_base;
196 *ap_mapped_base = (void*) gart.aperture;
200 MTRR_DEL(gart); /* checks gart.mtrr */
201 - drm_agp_p->release();
202 + NV_AGPGART_BACKEND_RELEASE(drm_agp_p);
204 +#if defined(KERNEL_2_4)
205 inter_module_put("drm_agp");
211 NV_IOUNMAP(gart.aperture, RM_PAGE_SIZE);
214 - drm_agp_p->release();
216 + NV_AGPGART_BACKEND_RELEASE(drm_agp_p);
217 +#if defined(KERNEL_2_4)
218 inter_module_put("drm_agp");
221 if (rm_clear_agp_bitmap(nv, &bitmap))
235 - ptr = drm_agp_p->allocate_memory(PageCount, AGP_NORMAL_MEMORY);
236 + ptr = NV_AGPGART_ALLOCATE_MEMORY(drm_agp_p, PageCount, AGP_NORMAL_MEMORY);
239 *pAddress = (void*) 0;
241 return RM_ERR_NO_FREE_MEM;
244 - err = drm_agp_p->bind_memory(ptr, *Offset);
246 + if (NV_AGPGART_BIND_MEMORY(drm_agp_p, ptr, *Offset))
248 // this happens a lot when the aperture itself fills up..
249 // not a big deal, so don't alarm people with an error message
250 @@ -280,14 +300,11 @@
254 - /* return the agp aperture address */
255 - *pAddress = (void *) (agpinfo.aper_base + (*Offset << PAGE_SHIFT));
257 status = os_alloc_mem((void **)&data, sizeof(agp_priv_data));
260 nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: memory allocation failed\n");
261 - drm_agp_p->unbind_memory(ptr);
262 + NV_AGPGART_UNBIND_MEMORY(drm_agp_p, ptr);
270 - drm_agp_p->free_memory(ptr);
271 + NV_AGPGART_FREE_MEMORY(drm_agp_p, ptr);
272 *pAddress = (void*) 0;
277 nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap %lu pages\n",
278 (unsigned long)agp_data->num_pages);
279 - drm_agp_p->unbind_memory(agp_data->ptr);
280 + NV_AGPGART_UNBIND_MEMORY(drm_agp_p, agp_data->ptr);
286 size_t pages = ptr->page_count;
288 - drm_agp_p->unbind_memory(ptr);
289 - drm_agp_p->free_memory(ptr);
290 + NV_AGPGART_UNBIND_MEMORY(drm_agp_p, ptr);
291 + NV_AGPGART_FREE_MEMORY(drm_agp_p, ptr);
293 nv_printf(NV_DBG_INFO, "NVRM: AGPGART: freed %ld pages\n",
294 (unsigned long)pages);