1 - get rid of warning when linux/device.h doesnt exist
2 - touch up the Makefile to let the ebuild handle the module details
3 - fix support with io remap stuff in newer kernels
4 - dont include headers that dont exist in 2.4.x kernels
5 - use module_param() for 2.6.x and MODULE_PARM() for all others
6 - dont declare all_devices as static since it is exported
7 - dont include <linux/config.h> as the build system does it for us
8 - in lrmi, map old flag names to new names for versions >= 2.6.26
10 --- src/svgalib-1.9.25/kernel/svgalib_helper/Makefile
11 +++ src/svgalib-1.9.25/kernel/svgalib_helper/Makefile
16 -CLASS_SIMPLE := $(shell grep class_simple_create $(KDIR)/include/linux/device.h)
17 +CLASS_SIMPLE := $(shell grep -s class_simple_create $(KDIR)/include/linux/device.h)
19 ifneq ($(CLASS_SIMPLE),)
20 CLASS_CFLAGS = -DCLASS_SIMPLE=1
21 --- src/svgalib-1.9.25/kernel/svgalib_helper/Makefile.alt
22 +++ src/svgalib-1.9.25/kernel/svgalib_helper/Makefile.alt
24 CFLAGS += -DSVGALIB_HELPER_MAJOR=$(SVGALIB_HELPER_MAJOR)
26 ifeq (1,$(findstring 1,$(MODVER)))
27 - CFLAGS += -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h
28 + CFLAGS += -DMODVERSIONS -DCONFIG_MODVERSIONS=1
31 TARGET = svgalib_helper
40 $(TARGET).o: $(SRC:.c=.o)
43 install: device modules_install
45 modules_install: $(OBJS)
46 - mkdir -p /lib/modules/$(VER)/kernel/misc
47 - install -m 0644 -c $(OBJS) /lib/modules/$(VER)/kernel/misc
48 + mkdir -p $(TOPDIR)/lib/modules/$(VER)/kernel/misc
49 + install -m 0644 -c $(OBJS) $(TOPDIR)/lib/modules/$(VER)/kernel/misc
52 rm -f /dev/svgalib_helper* /dev/svga_helper* /dev/svga /dev/svga?
53 --- src/svgalib-1.9.25/kernel/svgalib_helper/kernel26compat.h
54 +++ src/svgalib-1.9.25/kernel/svgalib_helper/kernel26compat.h
56 # define PCI_GET_CLASS pci_find_class
57 # define PCI_GET_DEVICE pci_find_device
59 -# if defined (PG_chainlock)
60 +# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,3)
61 # define my_io_remap_page_range(vma, start, ofs, len, prot) \
62 io_remap_page_range(vma,start,ofs,len,prot)
66 /* These are also not present in 2.6 kernels ... */
67 #if (!defined _LINUX_DEVFS_FS_KERNEL_H) || (defined KERNEL_2_6)
68 +#include <linux/fs.h>
69 static inline int devfs_register_chrdev (unsigned int major, const char *name,
70 struct file_operations *fops)
74 static inline int devfs_unregister_chrdev (unsigned int major,const char *name)
76 - return unregister_chrdev (major, name);
77 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
78 + return unregister_chrdev (major, name);
80 + unregister_chrdev (major, name);
87 class_device_create(svgalib_helper_class, \
88 MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
89 &sh_pci_devs[_minor]->dev->dev, _name);
90 -#else /* 2.6.15 changed class_device_create */
91 +/* 2.6.15 changed class_device_create */
92 +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
93 # define SLH_SYSFS_ADD_CONTROL \
94 class_device_create(svgalib_helper_class, NULL, \
95 MKDEV(SVGALIB_HELPER_MAJOR, 0), \
97 class_device_create(svgalib_helper_class, NULL, \
98 MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
99 &sh_pci_devs[_minor]->dev->dev, _name);
101 +/* 2.6.26 changed class_device_create to device_create */
102 +#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
103 +# define SLH_SYSFS_ADD_CONTROL \
104 + device_create(svgalib_helper_class, NULL, \
105 + MKDEV(SVGALIB_HELPER_MAJOR, 0), \
108 +# define SLH_SYSFS_ADD_DEVICE(_name, _minor) \
109 + device_create(svgalib_helper_class, &sh_pci_devs[_minor]->dev->dev, \
110 + MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
112 +/* 2.6.27 changed device_create to device_create_drvdata */
114 +# define SLH_SYSFS_ADD_CONTROL \
115 + device_create_drvdata(svgalib_helper_class, NULL, \
116 + MKDEV(SVGALIB_HELPER_MAJOR, 0), \
117 + "%s%d", "svga", 0);
119 +# define SLH_SYSFS_ADD_DEVICE(_name, _minor) \
120 + device_create_drvdata(svgalib_helper_class, \
121 + &sh_pci_devs[_minor]->dev->dev, \
122 + MKDEV(SVGALIB_HELPER_MAJOR, _minor), \
123 + "%s%d", _name, _minor);
126 # define SLH_SYSFS_REMOVE_DEVICE(i) \
127 class_destroy(svgalib_helper_class);
129 #ifndef PCI_VENDOR_ID_RENDITION
130 #define PCI_VENDOR_ID_RENDITION 0x1163
134 +# define IRQF_SHARED SA_SHIRQ
136 --- src/svgalib-1.9.25/kernel/svgalib_helper/main.c
137 +++ src/svgalib-1.9.25/kernel/svgalib_helper/main.c
139 -#include <linux/config.h>
141 #if defined (CONFIG_MODVERSIONS) && !defined (MODVERSIONS)
145 #include <linux/ioport.h>
146 #include <linux/interrupt.h>
147 #include <linux/pci.h>
148 +#include <linux/version.h>
149 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
150 #include <linux/devfs_fs_kernel.h>
152 #include <linux/mm.h>
153 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
154 #include <linux/thread_info.h>
156 #include <linux/smp.h>
157 #include <linux/smp_lock.h>
159 #include <linux/sched.h>
160 #include <linux/wait.h>
161 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
162 #include <linux/syscalls.h>
165 #define __KERNEL_SYSCALLS__
166 #include <linux/unistd.h>
168 #include "displaystart.h"
171 -static int all_devices=0;
175 static char *sdev_id="svgalib_helper";
177 static volatile int vsync=0;
178 static wait_queue_head_t vsync_wait;
180 -static irqreturn_t vsync_interrupt(int irq, void *dev_id, struct pt_regs *regs)
181 +static irqreturn_t vsync_interrupt(int irq, void *dev_id
182 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
183 +, struct pt_regs *regs
187 struct sh_pci_device *dev = (struct sh_pci_device *)dev_id;
193 - request_irq(irqs[i++], vsync_interrupt, SA_SHIRQ, "svgalib_helper", sdev_id);
194 + request_irq(irqs[i++], vsync_interrupt, IRQF_SHARED, "svgalib_helper", sdev_id);
195 vga_enable_vsync((void *)sdev_id);
196 wait_event_interruptible(vsync_wait, !vsync);
199 int i=sh_pci_devs[minor]->dev->irq;
200 sh_pci_devs[minor]->opencount++;
201 if(sh_pci_devs[minor]->opencount==1 && i!=0 && i!=-1 && i!=255)
202 - request_irq(i, vsync_interrupt, SA_SHIRQ, "svgalib_helper", sh_pci_devs[minor]);
203 + request_irq(i, vsync_interrupt, IRQF_SHARED, "svgalib_helper", sh_pci_devs[minor]);
207 @@ -763,10 +772,15 @@
212 +module_param(debug, int, 0);
213 +module_param(all_devices, int, 0);
215 MODULE_PARM(debug, "i");
216 -MODULE_PARM_DESC(debug, "Debug output level.");
218 MODULE_PARM(all_devices, "i");
221 +MODULE_PARM_DESC(debug, "Debug output level.");
222 MODULE_PARM_DESC(all_devices, "Give access to all PCI devices, regardless of class.");
225 --- src/svgalib-1.9.25/src/lrmi.6.c
226 +++ src/svgalib-1.9.25/src/lrmi.6.c
232 +#define TF_MASK X86_EFLAGS_TF
233 +#define IF_MASK X86_EFLAGS_IF
234 +#define IOPL_MASK X86_EFLAGS_IOPL
235 +#define VIF_MASK X86_EFLAGS_VIF
236 +#define VIP_MASK X86_EFLAGS_VIP
239 #define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
240 #define DEFAULT_STACK_SIZE 0x1000
241 --- src/svgalib-1.9.25/src/lrmi.9.c
242 +++ src/svgalib-1.9.25/src/lrmi.9.c
246 #if defined(__linux__)
248 +#define TF_MASK X86_EFLAGS_TF
249 +#define IF_MASK X86_EFLAGS_IF
250 +#define IOPL_MASK X86_EFLAGS_IOPL
251 +#define VIF_MASK X86_EFLAGS_VIF
252 +#define VIP_MASK X86_EFLAGS_VIP
254 #define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
255 #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
256 #define DEFAULT_VM86_FLAGS (PSL_I | PSL_IOPL)
257 --- src/svgalib-1.9.25/lrmi-0.6m/lrmi.c
258 +++ src/svgalib-1.9.25/lrmi-0.6m/lrmi.c
264 +#define TF_MASK X86_EFLAGS_TF
265 +#define IF_MASK X86_EFLAGS_IF
266 +#define IOPL_MASK X86_EFLAGS_IOPL
267 +#define VIF_MASK X86_EFLAGS_VIF
268 +#define VIP_MASK X86_EFLAGS_VIP
271 #define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
272 #define DEFAULT_STACK_SIZE 0x1000
273 #define RETURN_TO_32_INT 255
274 --- src/svgalib-1.9.25/lrmi-0.9/lrmi.c
275 +++ src/svgalib-1.9.25/lrmi-0.9/lrmi.c
279 #if defined(__linux__)
281 +#define TF_MASK X86_EFLAGS_TF
282 +#define IF_MASK X86_EFLAGS_IF
283 +#define IOPL_MASK X86_EFLAGS_IOPL
284 +#define VIF_MASK X86_EFLAGS_VIF
285 +#define VIP_MASK X86_EFLAGS_VIP
287 #define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
288 #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
289 #define DEFAULT_VM86_FLAGS (PSL_I | PSL_IOPL)