[OT] ATI 64-bit fglrx compile patches for 2.6.15-gitX

From: Martin Drab
Date: Mon Jan 09 2006 - 11:45:51 EST


Hi,

I know this is a little bit OT here, and if you feel irritated by the
binary drivers, just ignore this. But in case anyone is interested, here
are some patches I did that make the the 64-bit fglrx module compile
(cleanly, at least for me) on 2.6.15-git3 and it seems to work here
(Mobile Radeon 9600, Athlon64), no guarantee though, you're just going to
have to try and see yourselfs. ;)

(Compile with the ./c script, clean with the ./b script, don't forget to
make them executable!)

The 32-bit variant may follow later.

Martindiff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/b fglrx-8.20.8-x86_64-kernel-module/b
--- fglrx-8.20.8-x86_64-kernel-module.orig/b 1970-01-01 01:00:00.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/b 2006-01-09 15:50:20.000000000 +0100
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+pushd build_mod
+
+rm -frv *.o *.ko *.log *.a .*.cmd patch
+pushd firegl_agpgart
+rm -frv *.o *.ko *.log *.a .*.cmd .*.d .tmp_versions
+popd
+pushd 2.6.x
+find . ! -name "Makefile" | xargs rm -frv
+popd
+
+popd
+
+rm -fv *.log *.ko
+
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/c fglrx-8.20.8-x86_64-kernel-module/c
--- fglrx-8.20.8-x86_64-kernel-module.orig/c 1970-01-01 01:00:00.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/c 2006-01-09 15:52:38.000000000 +0100
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+pushd build_mod
+
+unset MAKE_OPT_GCC
+if [ -n "$MDKM_GCC" ]; then
+ CC="$MDKM_GCC" ./make.sh
+else
+ ./make.sh
+fi
+
+popd
+
+cp -pf build_mod/*.ko .
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_wrap.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_wrap.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_wrap.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_wrap.c 2006-01-08 21:33:17.000000000 +0100
@@ -118,7 +118,12 @@
#endif

#ifdef __x86_64__
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
#include "asm/ioctl32.h"
+#else
+#define register_ioctl32_conversion(cmd, handler) ({ 0; })
+#define unregister_ioctl32_conversion(cmd) ({ 0; })
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,2)
#include "linux/syscalls.h"
#endif
diff -Napur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/agpgart_be.c fglrx-8.20.8-x86_64-kernel-module/build_mod/agpgart_be.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/agpgart_be.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/agpgart_be.c 2006-01-08 23:55:04.000000000 +0100
@@ -116,6 +116,9 @@
#include <linux/pagemap.h>
#include <linux/miscdevice.h>
#include <linux/pm.h>
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14)
+#include <linux/pm_legacy.h>
+#endif

#if (LINUX_VERSION_CODE >= 0x020400)
#define FGL_PM_PRESENT
diff -Naur orig/build_mod/make.sh new/build_mod/make.sh
--- orig/build_mod/make.sh 2005-12-07 13:38:03.000000000 +0100
+++ new/build_mod/make.sh 2006-01-09 05:14:49.000000000 +0100
@@ -358,75 +358,8 @@

SMP=0

-if [ $DEMAND_BZIMAGE -gt 0 ]
-then
-
-# 1.
-# config/smp.h may contain this: #define CONFIG_SMP 1 | #undef CONFIG_SMP
-src_file=$linuxincludes/config/smp.h
-if [ ! -e $src_file ];
-then
- echo "Warning:" >> $logfile
- echo "kernel includes at $linuxincludes not found or incomplete" >> $logfile
- echo "file: $src_file" >> $logfile
- echo "" >> $logfile
-else
- if [ `cat $src_file | grep "#undef" | grep "CONFIG_SMP" -c` = 0 ]
- then
- SMP=`cat $src_file | grep CONFIG_SMP | cut -d' ' -f3`
- echo "file $src_file says: SMP=$SMP" >> $logfile
- fi
-fi
-
-fi
-
-# 2.
-# grep in OsVersion string for SMP specific keywords
-if [ `echo $OsVersion | grep [sS][mM][pP] -c` -ne 0 ]
-then
- SMP=1
- echo "OsVersion says: SMP=$SMP" >> $logfile
-fi
-
-# 3.1
-# grep in /proc/ksyms for SMP specific kernel symbols
-# use triggerlevel of 10 occurences
-# (UP kernels might have 0-1, SMP kernels might have 32-45 or much more)
-# 3.2
-# grep in /proc/ksyms for the change_page_attr symbol
-PAGE_ATTR_FIX=0
-src_file=/proc/ksyms
-if [ -e $src_file ]
-then
- if [ `fgrep smp $src_file -c` -gt 10 ]
- then
- SMP=1
- echo "file $src_file says: SMP=$SMP" >> $logfile
- fi
- if [ `fgrep " change_page_attr\$" $src_file -c` -gt 0 ]
- then
- PAGE_ATTR_FIX=1
- echo "file $src_file says: PAGE_ATTR_FIX=$PAGE_ATTR_FIX" >> $logfile
- fi
-fi
-
-src_file=/proc/kallsyms
-if [ -e $src_file ]
-then
- if [ `fgrep smp $src_file -c` -gt 10 ]
- then
- SMP=1
- echo "file $src_file says: SMP=$SMP" >> $logfile
- fi
- if [ `fgrep " change_page_attr\$" $src_file -c` -gt 0 ]
- then
- PAGE_ATTR_FIX=1
- echo "file $src_file says: PAGE_ATTR_FIX=$PAGE_ATTR_FIX" >> $logfile
- fi
-fi
-
-# 4.
# linux/autoconf.h may contain this: #define CONFIG_SMP 1
+# If it doesn't, there is no SMP support in the kernel.
src_file=$linuxincludes/linux/autoconf.h
if [ ! -e $src_file ];
then
@@ -435,11 +368,8 @@
echo "file: $src_file" >> $logfile
echo "" >> $logfile
else
- if [ `cat $src_file | grep "#undef" | grep "CONFIG_SMP" -c` = 0 ]
- then
- SMP=`cat $src_file | grep CONFIG_SMP | cut -d' ' -f3`
- echo "file $src_file says: SMP=$SMP" >> $logfile
- fi
+ SMP=`cat $src_file | grep -c -m 1 "^#define CONFIG_SMP[ \t]"`
+ echo "file $src_file says: SMP=$SMP" >> $logfile
fi

if [ $SMP = 0 ]
diff -Naur orig/build_mod/make.sh new/build_mod/make.sh
--- orig/build_mod/make.sh 2006-01-09 05:19:11.000000000 +0100
+++ new/build_mod/make.sh 2006-01-09 05:16:57.000000000 +0100
@@ -33,6 +33,7 @@

# default options
OPTIONS_HINTS=1
+V=1

# sets the GCC to use to the one required by the module (if available)
function set_GCC_version () {
@@ -651,7 +652,7 @@

# ==============================================================
# defines for all targets
-def_for_all="-DATI_AGP_HOOK -DATI -DFGL -D${target_define} -DFGL_CUSTOM_MODULE -DPAGE_ATTR_FIX=$PAGE_ATTR_FIX"
+def_for_all="-Wno-deprecated-declarations -DATI_AGP_HOOK -DATI -DFGL -D${target_define} -DFGL_CUSTOM_MODULE -DPAGE_ATTR_FIX=$PAGE_ATTR_FIX"

# defines for specific os and cpu platforms
if [ "${uname_m}" = "x86_64" ]; then
diff -Naur orig/build_mod/make.sh new/build_mod/make.sh
--- orig/build_mod/make.sh 2006-01-09 05:16:57.000000000 +0100
+++ new/build_mod/make.sh 2006-01-09 05:29:49.000000000 +0100
@@ -354,6 +354,17 @@
echo "assuming default: AGP=$AGP" >> $logfile
fi

+PAGE_ATTR_FIX=0
+src_file=/proc/ksyms
+if [ -e $src_file ]
+then
+ if [ `fgrep " change_page_attr\$" $src_file -c` -gt 0 ]
+ then
+ PAGE_ATTR_FIX=1
+ echo "file $src_file says: PAGE_ATTR_FIX=$PAGE_ATTR_FIX" >> $logfile
+ fi
+fi
+
# ==============================================================
# resolve if we are running a SMP enabled kernel

diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/2.6.x/Makefile fglrx-8.20.8-x86_64-kernel-module/build_mod/2.6.x/Makefile
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/2.6.x/Makefile 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/2.6.x/Makefile 2006-01-09 00:09:47.000000000 +0100
@@ -9,6 +9,8 @@

ifeq ($(PAGE_ATTR_FIX),)
PAGE_ATTR_FIX =1
+else
+PAGE_ATTR_FIX =0
endif

EXTRA_CFLAGS += \
@@ -19,6 +21,7 @@
-DFGL_GART_RESERVED_SLOT \
-DFGL_LINUX253P1_VMA_API \
-DPAGE_ATTR_FIX=$(PAGE_ATTR_FIX) \
+ -DFIREGL_VMA_INFO=1 \

ifeq ($(KERNELRELEASE),)
# on first call from remote location we get into this path
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/agpgart_be.c fglrx-8.20.8-x86_64-kernel-module/build_mod/agpgart_be.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/agpgart_be.c 2006-01-09 00:00:22.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/agpgart_be.c 2006-01-09 04:50:50.000000000 +0100
@@ -6077,7 +6077,7 @@
/* Try to remember gart base because when server shutdown
* it should get reassigned.
*/
-static unsigned int ati_gart_base = 0;
+//static unsigned int ati_gart_base = 0;

static int ati_configure(void)
{
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/drmP.h fglrx-8.20.8-x86_64-kernel-module/build_mod/drmP.h
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/drmP.h 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/drmP.h 2006-01-09 00:27:07.000000000 +0100
@@ -111,6 +111,12 @@
#ifndef __HAVE_DMA_FREELIST
#define __HAVE_DMA_FREELIST 0
#endif
+#ifndef __HAVE_VBL_IRQ
+#define __HAVE_VBL_IRQ 0
+#endif
+#ifndef __HAVE_SG
+#define __HAVE_SG 0
+#endif

#define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
defined(CONFIG_AGP_MODULE)))
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/ali-agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/ali-agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/ali-agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/ali-agp.c 2006-01-09 06:01:59.000000000 +0100
@@ -2,21 +2,24 @@
* ALi AGPGART routines.
*/

-#if 1
+#if 0
#include "firegl_wrapper.h"
+#define __devinit
+#define __devexit
+#define __devexit_p
+#define __devinitdata
#else
#include <linux/types.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/agp_backend.h>
+#define pci_device_id_t pci_device_id
+#define pci_dev_t struct pci_dev
+#define pci_driver_t pci_driver
#endif
#include "agp.h"

-#define __devinit
-#define __devexit
-#define __devexit_p
-#define __devinitdata
#undef THIS_MODULE
#define THIS_MODULE 0

diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/amd64-agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/amd64-agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/amd64-agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/amd64-agp.c 2006-01-09 14:02:29.000000000 +0100
@@ -8,8 +8,11 @@
* work is done in the northbridge(s).
*/

-#if 1
+#if 0
#include "firegl_wrapper.h"
+#define __devinit
+#define __devexit
+#define __devexit_p
#else
#include <linux/config.h>
#include <linux/module.h>
@@ -19,10 +22,6 @@
#endif
#include "agp.h"

-#define __devinit
-#define __devexit
-#define __devexit_p
-
#undef THIS_MODULE
#define THIS_MODULE 0

@@ -61,7 +60,7 @@
static struct pci_dev * hammers[MAX_HAMMER_GARTS];

static struct resource *aperture_resource;
-static int __initdata agp_try_unsupported;
+//static int __initdata agp_try_unsupported;

static int gart_iterator;
#define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
@@ -633,7 +632,7 @@


/* Not static due to IOMMU code calling it early. */
-int __init agp_amd64_init(void)
+int __init fgl_agp_amd64_init(void)
{
int err = 0;
if (agp_off)
@@ -670,7 +669,7 @@
return err;
}

-static void __exit agp_amd64_cleanup(void)
+void __exit fgl_agp_amd64_cleanup(void)
{
if (aperture_resource)
release_resource(aperture_resource);
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/ati-agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/ati-agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/ati-agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/ati-agp.c 2006-01-09 00:18:03.000000000 +0100
@@ -2,7 +2,7 @@
* ATi AGPGART routines.
*/

-#if 1
+#if 0
#include "firegl_wrapper.h"
#else
#include <linux/types.h>
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/backend.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/backend.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/backend.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/backend.c 2006-01-09 05:54:52.000000000 +0100
@@ -26,7 +26,7 @@
* TODO:
* - Allocate more than order 0 pages to avoid too much linear map splitting.
*/
-#if 1
+#if 0
#include "firegl_wrapper.h"
#else
#include <linux/module.h>
@@ -37,6 +37,8 @@
#include <linux/pm.h>
#include <linux/vmalloc.h>
#include <asm/io.h>
+
+#define __ke_printk printk
#endif
#include "agp.h"

@@ -188,7 +190,7 @@
err_out:
if (bridge->driver->needs_scratch_page)
bridge->driver->agp_destroy_page(
- phys_to_virt((void*)(bridge->scratch_page_real)));
+ phys_to_virt((long)((void*)(bridge->scratch_page_real))));
if (got_gatt)
bridge->driver->free_gatt_table();
if (got_keylist) {
@@ -290,7 +292,7 @@
EXPORT_SYMBOL(agp_off);
EXPORT_SYMBOL(agp_try_unsupported_boot);

-static int __init agp_init(void)
+int __init agp_init(void)
{
if (!agp_off)
__ke_printk(KERN_INFO "Linux agpgart interface v%d.%d (c) Dave Jones\n",
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/fglrx_agp.mod.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/fglrx_agp.mod.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/fglrx_agp.mod.c 1970-01-01 01:00:00.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/fglrx_agp.mod.c 2006-01-09 04:39:31.000000000 +0100
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=";
+
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_agp.c 2006-01-09 15:05:20.000000000 +0100
@@ -1,5 +1,4 @@
/****************************************************************************
-/****************************************************************************
* *
* Copyright 1999-2005 ATI Technologies Inc., Markham, Ontario, CANADA. *
* All Rights Reserved. *
@@ -109,9 +108,9 @@
fgl_agp_module_funcs[] =
{
{fgl_agp_intel_init, fgl_agp_intel_cleanup},
-// {fgl_agp_ali_init, fgl_agp_ali_cleanup},
+ {fgl_agp_ali_init, fgl_agp_ali_cleanup},
#ifndef CONFIG_GART_IOMMU
-// {fgl_agp_amd64_init, fgl_agp_amd64_cleanup},
+ {fgl_agp_amd64_init, fgl_agp_amd64_cleanup},
#endif
// {fgl_agp_amdk7_init, fgl_agp_amdk7_cleanup},
// {fgl_agp_ati_init, fgl_agp_ati_cleanup},
@@ -120,14 +119,14 @@
// {fgl_agp_nvidia_init, fgl_agp_nvidia_cleanup},
// {fgl_agp_sis_init, fgl_agp_sis_cleanup},
// {fgl_agp_serverworks_init, fgl_agp_serverworks_cleanup},
-// {fgl_agp_via_init, fgl_agp_via_cleanup},
+ {fgl_agp_via_init, fgl_agp_via_cleanup},
{NULL, NULL},
};


static int firegl_agp_probe(void)
{
- int i = 0;
+// int i = 0;

printk(KERN_INFO "fglrx_agp is probing for an AGP device\n");

diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_agp.h fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_agp.h
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_agp.h 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_agp.h 2006-01-09 05:35:21.000000000 +0100
@@ -752,7 +752,7 @@
#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d
#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e
#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f
-#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b1
+//#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b1
#define PCI_DEVICE_ID_INTEL_ICH7_2 0x27c0
#define PCI_DEVICE_ID_INTEL_ICH7_3 0x27c1
#define PCI_DEVICE_ID_INTEL_ICH7_4 0x27c2
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_wrap.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_wrap.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_wrap.c 2006-01-08 21:42:58.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_wrap.c 2006-01-09 14:59:04.000000000 +0100
@@ -21,6 +21,9 @@
!!! since it requires changes to linux/init/main.c.
#endif /* !MODULE */

+/* Now, this _IS_ ugly(tm)! But, there's no use... :( - due to errno. */
+#define _LINUX_UNISTD_H_
+
// ============================================================
#include <linux/version.h>
#include <linux/autoconf.h>
@@ -129,6 +132,9 @@
#endif
#endif

+#ifndef verify_area
+#define verify_area(T,A,S) (access_ok((T),(A),(S)) ? 0 : -EFAULT)
+#endif

// ============================================================
// pte_offset_map will be used by the kernel (2.4.21-15EL) come with RHEL3.0.
@@ -335,7 +341,7 @@
struct proc_dir_entry *dev_root;
__ke_proc_list_t *proclist;
} firegl_stub_list_t;
-static firegl_stub_list_t firegl_stub_list[FIREGL_STUB_MAXCARDS];
+//static firegl_stub_list_t firegl_stub_list[FIREGL_STUB_MAXCARDS];



@@ -662,7 +668,7 @@

unsigned long ATI_API_CALL __ke_phys_to_virt(void* address)
{
- return phys_to_virt(address);
+ return (unsigned long)phys_to_virt((unsigned long)address);
}

void* ATI_API_CALL __ke_high_memory(void)
@@ -696,12 +702,12 @@
pci_free_consistent( (struct pci_dev*)(void *)dev, size, (void *)cpu_addr,
(unsigned long)dma_handle);
}
-extern struct __ke_pci_dev_t ATI_API_CALL __ke_pci_find_class( unsigned int c, __ke_pci_dev_t *from)
+__ke_pci_dev_t * ATI_API_CALL __ke_pci_find_class( unsigned int c, __ke_pci_dev_t *from)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
return pci_find_class(c, (struct pci_dev*) (void*)from);
#else
- return pci_get_class(c, from);
+ return (__ke_pci_dev_t *)pci_get_class(c, (struct pci_dev *)from);
#endif
}
#endif // __ia64__
@@ -763,9 +769,9 @@

int ATI_API_CALL firegl_get_user_ptr(u32 *src, void **dst)
{
- void *temp=NULL;
+ unsigned long temp;
int err = get_user(temp, src);
- *dst = temp;
+ *dst = (void *)temp;
return err;
}

@@ -795,7 +801,7 @@

int ATI_API_CALL firegl_put_user_ptr(void *src, u32 *dst)
{
- void *temp = src;
+ unsigned long temp = (unsigned long)src;
return put_user(temp, dst);
}

@@ -1358,13 +1364,21 @@
{
unsigned long pte_linear;
pgd_t* pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+ pud_t* pud_p;
+#endif
pmd_t* pmd_p;
pte_t* pte_p;
pte_t pte;

pte_linear = VMALLOC_VMADDR(virtual_addr); // convert to pte linear address (x86 => nop)
pgd_p = pgd_offset(mm, pte_linear);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+ pud_p = pud_offset(pgd_p, pte_linear);
+ pmd_p = pmd_offset(pud_p, pte_linear);
+#else
pmd_p = pmd_offset(pgd_p, pte_linear);
+#endif
#ifndef FGL_ATOMIC_PTE
#if LINUX_VERSION_CODE > 0x020500
pte_p = pte_offset_kernel(pmd_p, pte_linear);
@@ -1814,13 +1828,21 @@
{
unsigned long pte_linear;
pgd_t* pgd_p;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+ pud_t* pud_p;
+#endif
pmd_t* pmd_p;
pte_t* pte_p;
pte_t pte;

pte_linear = VMALLOC_VMADDR(virtual_addr); // convert to pte linear address (x86 => nop)
pgd_p = pgd_offset(vma->vm_mm, pte_linear);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+ pud_p = pud_offset(pgd_p, pte_linear);
+ pmd_p = pmd_offset(pud_p, pte_linear);
+#else
pmd_p = pmd_offset(pgd_p, pte_linear);
+#endif
#ifndef FGL_ATOMIC_PTE
#if LINUX_VERSION_CODE > 0x020500
pte_p = pte_offset_kernel(pmd_p, pte_linear);
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_wrap.h fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_wrap.h
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/firegl_wrap.h 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/firegl_wrap.h 2006-01-09 05:46:15.000000000 +0100
@@ -17,6 +17,8 @@
#ifndef _FIREGL_PUBLIC_H_
#define _FIREGL_PUBLIC_H_

+#include <linux/version.h>
+
#define FGL_DEVICE_SIGNATURE 0x10020000
#define FGL_DEBUG_SIGNATURE "fglrx"

@@ -134,7 +136,6 @@
#define DEVICE_COUNT_RESOURCE 12
#endif

-
typedef struct __ke_pci_dev_t
{
struct __ke_list_head_t global_list;
@@ -186,10 +187,6 @@
struct __ke_pci_dynids_t* dynids;
} __ke_pci_driver_t;

-
-
-
-
/*****************************************************************************/

#if 0
@@ -416,7 +413,7 @@

extern void* ATI_API_CALL __ke_pci_get_drvdata(__ke_pci_dev_t* dev);
extern void ATI_API_CALL __ke_pci_set_drvdata(__ke_pci_dev_t* dev, void* data);
-extern struct __ke_pci_dev_t* ATI_API_CALL __ke_pci_find_class( unsigned int c, struct __ke_pci_dev_t *from);
+extern __ke_pci_dev_t* ATI_API_CALL __ke_pci_find_class( unsigned int c, __ke_pci_dev_t *from);
extern int ATI_API_CALL __ke_pci_find_capability(__ke_pci_dev_t* dev, int data);

/*****************************************************************************/
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/intel-agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/intel-agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/intel-agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/intel-agp.c 2006-01-09 05:56:09.000000000 +0100
@@ -10,8 +10,12 @@
* <alanh@xxxxxxxxxxxxxxxxxxxx>.
*/

-#if 1
+#if 0
#include "firegl_wrapper.h"
+//#include "firegl_agp_module.h"
+#define __devinit
+#define __devexit
+#define __devexit_p
#else
#include <linux/init.h>
#include <linux/module.h>
@@ -20,10 +24,26 @@
#include <linux/pagemap.h>
#endif
#include "agp.h"
-//#include "firegl_agp_module.h"
-#define __devinit
-#define __devexit
-#define __devexit_p
+
+#ifndef pci_dev_t
+#define pci_dev_t struct pci_dev
+#endif
+
+#ifndef __ke_pci_device_id_t
+#define __ke_pci_device_id_t pci_device_id
+#endif
+
+#ifndef pci_device_id_t
+#define pci_device_id_t __ke_pci_device_id_t
+#endif
+
+#ifndef resource_t
+#define resource_t resource
+#endif
+
+#ifndef pci_driver_t
+#define pci_driver_t struct pci_driver
+#endif

#undef THIS_MODULE
#define THIS_MODULE 0
@@ -81,7 +101,7 @@
};

static struct _intel_i810_private {
- struct pci_dev_t *i810_dev; /* device one */
+ pci_dev_t *i810_dev; /* device one */
volatile u8 __iomem *registers;
int num_dcache_entries;
} intel_i810_private;
@@ -171,7 +191,7 @@
/* Exists to support ARGB cursors */
static void *i8xx_alloc_pages(void)
{
- struct page * page;
+ struct page * page = NULL;
#if 0

page = alloc_pages(GFP_KERNEL, 2);
@@ -1510,7 +1530,7 @@

static int find_i810(u16 device)
{
- struct pci_dev_t *i810_dev;
+ pci_dev_t *i810_dev;

i810_dev = pci_find_device(PCI_VENDOR_ID_INTEL, device, NULL);
if (!i810_dev)
@@ -1535,7 +1555,7 @@
return 1;
}

-int __devinit agp_intel_probe(struct pci_dev_t *pdev,
+int __devinit agp_intel_probe(pci_dev_t *pdev,
const struct __ke_pci_device_id_t *ent)
{
struct agp_bridge_data *bridge;
@@ -1741,9 +1761,9 @@
{
struct agp_bridge_data *bridge = pci_get_drvdata(pdev);

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+//#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
//pci_restore_state(pdev);
-#endif
+//#endif

if (bridge->driver == &intel_generic_driver)
intel_configure();
@@ -1758,7 +1778,7 @@
}

#if 1
-pci_device_id_t agp_intel_pci_table[] = {
+struct pci_device_id_t agp_intel_pci_table[] = {
#define ID(x) \
{ \
.class = (PCI_CLASS_BRIDGE_HOST << 8), \
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/Makefile fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/Makefile
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/Makefile 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/Makefile 2006-01-09 15:06:21.000000000 +0100
@@ -1,5 +1,5 @@
obj-m += fglrx_agp.o
-fglrx_agp-objs := backend.o generic.o isoch.o intel-agp.o ali-agp.o firegl_wrap.o firegl_agp.o
+fglrx_agp-objs := backend.o generic.o isoch.o intel-agp.o ali-agp.o amd64-agp.o via-agp.o firegl_wrap.o firegl_agp.o
fglrx_agp-hdrs := agp.h firegl_agp.h firegl_wrap.h firegl_wrapper.h


diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/nvidia-agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/nvidia-agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/nvidia-agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/nvidia-agp.c 2006-01-09 00:18:59.000000000 +0100
@@ -4,7 +4,7 @@
* to work in 2.5 by Dave Jones <davej@xxxxxxxxxxxxxxxxx>
*/

-#if 1
+#if 0
#include "firegl_wrapper.h"
#else
#include <linux/module.h>
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/via-agp.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/via-agp.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_agpgart/via-agp.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_agpgart/via-agp.c 2006-01-09 15:18:54.000000000 +0100
@@ -6,6 +6,7 @@
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
+#include <linux/version.h>
#include <linux/agp_backend.h>
#include "agp.h"

@@ -440,11 +441,15 @@

#ifdef CONFIG_PM

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+static int agp_via_suspend(struct pci_dev *pdev, pm_message_t state)
+#else
static int agp_via_suspend(struct pci_dev *pdev, u32 state)
+#endif
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+//#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
// pci_save_state (pdev);
-#endif
+//#endif
pci_set_power_state (pdev, 3);

return 0;
@@ -455,9 +460,9 @@
struct agp_bridge_data *bridge = pci_get_drvdata(pdev);

pci_set_power_state (pdev, 0);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+//#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
// pci_restore_state(pdev);
-#endif
+//#endif

if (bridge->driver == &via_agp3_driver)
return via_configure_agp3();
@@ -526,18 +531,19 @@
};


-static int __init agp_via_init(void)
+int __init fgl_agp_via_init(void)
{
return pci_module_init(&agp_via_pci_driver);
}

-static void __exit agp_via_cleanup(void)
+void __exit fgl_agp_via_cleanup(void)
{
pci_unregister_driver(&agp_via_pci_driver);
}
-
+#if 0
module_init(agp_via_init);
module_exit(agp_via_cleanup);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Dave Jones <davej@xxxxxxxxxxxxxxxxx>");
+#endif
diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_public.c fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_public.c
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_public.c 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_public.c 2006-01-09 15:02:36.000000000 +0100
@@ -1258,9 +1258,9 @@
/*****************************************************************************/
#ifdef __x86_64__

-int ATI_API_CALL firegl_get_user_ptr(u32 *src, void **dst)
+int ATI_API_CALL firegl_get_user_ptr(void **src, void **dst)
{
- unsigned long temp;
+ void *temp = NULL;
int err = get_user(temp, src);
*dst = (void*) temp;
return err;
@@ -1290,7 +1290,7 @@
return err;
}

-int ATI_API_CALL firegl_put_user_ptr(void *src, u32 *dst)
+int ATI_API_CALL firegl_put_user_ptr(void *src, void **dst)
{
void *temp = src;
return put_user(temp, dst);
@@ -2405,7 +2405,7 @@
void ATI_API_CALL __ke_unregister_ioctl32_conversion(unsigned int cmd)
{
#ifdef FIREGL_IOCTL_COMPAT
- return 0;
+ return;
#else
unregister_ioctl32_conversion(cmd);
#endif
@@ -2621,7 +2621,7 @@

pMmPage = virt_to_page(kaddr);

-#if 0
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
// WARNING WARNINIG WARNNING WARNNING WARNNING WARNNING WARNNING WARNNING
// Don't increment page usage count, cause ctx pages are allocated
// with drm_alloc_pages, which marks all pages as reserved. Reserved
@@ -3489,15 +3489,15 @@


static const im_fglrx_agp_t im_fglrx_agp = {
- &im_agp_free_memory,
- &im_agp_allocate_memory,
- &im_agp_bind_memory,
- &im_agp_unbind_memory,
- &im_agp_enable,
- &im_agp_backend_acquire,
- &im_agp_backend_release,
- &im_agp_copy_info,
- &im_agp_allocate_memory
+ (void *)&im_agp_free_memory,
+ (void *)&im_agp_allocate_memory,
+ (void *)&im_agp_bind_memory,
+ (void *)&im_agp_unbind_memory,
+ (void *)&im_agp_enable,
+ (void *)&im_agp_backend_acquire,
+ (void *)&im_agp_backend_release,
+ (void *)&im_agp_copy_info,
+ (void *)&im_agp_allocate_memory
};

static const im_fglrx_agp_t *im_fglrx_agp_stub = NULL;
@@ -3507,7 +3507,7 @@
*
*/
static
-int ATI_API_CALL test_inter_module_interface()
+int ATI_API_CALL test_inter_module_interface(void)
{
unsigned int found = 0;
__KE_INFO("Testing inter module communication\n");
@@ -3838,7 +3838,7 @@
if (firegl_agp)
return (struct _agp_memory*)FIREGL_agp_allocate_memory_phys_list(pages, type, phys_addr);
if (fglrx_agp)
- return (struct _agp_memory*)(*im_fglrx_agp_stub->allocate_memory_phys_list)(pages, type, phys_addr);
+ return (struct _agp_memory*)(*im_fglrx_agp_stub->allocate_memory_phys_list)(pages, type, (unsigned long)phys_addr);
return NULL;
}
#endif
@@ -3877,7 +3877,7 @@
if (firegl_agp)
return FIREGL_agp_bind_memory((FIREGL_agp_memory*)handle, start);
if (fglrx_agp)
- return (*im_fglrx_agp_stub->bind_memory)((FIREGL_agp_memory*)handle, start);
+ return (*im_fglrx_agp_stub->bind_memory)((struct agp_memory*)handle, start);
return -EINVAL;
}

@@ -3890,7 +3890,7 @@
if (firegl_agp)
return FIREGL_agp_unbind_memory((FIREGL_agp_memory*)handle);
if (fglrx_agp)
- return (*im_fglrx_agp_stub->unbind_memory)((FIREGL_agp_memory*)handle);
+ return (*im_fglrx_agp_stub->unbind_memory)((struct agp_memory*)handle);
return -EINVAL;
}

diff -Naur fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_public.h fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_public.h
--- fglrx-8.20.8-x86_64-kernel-module.orig/build_mod/firegl_public.h 2005-12-07 13:38:03.000000000 +0100
+++ fglrx-8.20.8-x86_64-kernel-module/build_mod/firegl_public.h 2006-01-09 05:42:03.000000000 +0100
@@ -415,6 +415,7 @@
#ifdef __KE_NO_VSPRINTF
extern void ATI_API_CALL __ke_printk(const char* fmt, ...);
#else // !__KE_NO_VSPRINTF
+#define __ke_printk printk
extern void ATI_API_CALL __ke_print_info(const char* fmt, ...);
extern void ATI_API_CALL __ke_print_error(const char* fmt, ...);
extern void ATI_API_CALL __ke_print_debug(const char* fmt, ...);
@@ -654,12 +655,12 @@

#ifdef __x86_64__

-int ATI_API_CALL firegl_get_user_ptr(__ke_u32 *src, void **dst);
+int ATI_API_CALL firegl_get_user_ptr(void **src, void **dst);
int ATI_API_CALL firegl_get_user_u16(__ke_u16 *src, __ke_u16 *dst);
int ATI_API_CALL firegl_get_user_u32(__ke_u32 *src, __ke_u32 *dst);
int ATI_API_CALL firegl_get_user_u64(__ke_u32 *src, __ke_u64 *dst);

-int ATI_API_CALL firegl_put_user_ptr(void *src, __ke_u32 *dst);
+int ATI_API_CALL firegl_put_user_ptr(void *src, void **dst);
int ATI_API_CALL firegl_put_user_u16(__ke_u16 src, __ke_u16 *dst);
int ATI_API_CALL firegl_put_user_u32(__ke_u32 src, __ke_u32 *dst);
int ATI_API_CALL firegl_put_user_u64(__ke_u64 src, __ke_u32 *dst);